pyfemtet 0.6.3__py3-none-any.whl → 0.6.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyfemtet might be problematic. Click here for more details.

pyfemtet/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.6.3"
1
+ __version__ = "0.6.4"
@@ -4,20 +4,31 @@ from typing import Final
4
4
  # レジストリのパスと値の名前
5
5
  _REGISTRY_PATH: Final[str] = r"SOFTWARE\Murata Software\Femtet2014\Femtet"
6
6
  _VALUE_NAME: Final[str] = "AutoSave"
7
+ _DEFAULT_VALUE: Final[bool] = True
7
8
 
8
9
 
9
10
  def _get_autosave_enabled() -> bool:
10
- with winreg.OpenKey(winreg.HKEY_CURRENT_USER, _REGISTRY_PATH) as key:
11
- value, regtype = winreg.QueryValueEx(key, _VALUE_NAME)
12
- if regtype == winreg.REG_DWORD:
13
- return bool(value)
14
- else:
15
- raise ValueError("Unexpected registry value type.")
11
+ try:
12
+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, _REGISTRY_PATH) as key:
13
+ value, regtype = winreg.QueryValueEx(key, _VALUE_NAME)
14
+ if regtype == winreg.REG_DWORD:
15
+ return bool(value)
16
+ else:
17
+ raise ValueError("Unexpected registry value type.")
18
+
19
+ except FileNotFoundError: # [WinError 2] 指定されたファイルが見つかりません。
20
+ __create_registry_key()
21
+ return _get_autosave_enabled()
16
22
 
17
23
 
18
24
  def _set_autosave_enabled(enable: bool) -> None:
19
- with winreg.OpenKey(winreg.HKEY_CURRENT_USER, _REGISTRY_PATH, 0, winreg.KEY_SET_VALUE) as key:
20
- winreg.SetValueEx(key, _VALUE_NAME, 0, winreg.REG_DWORD, int(enable))
25
+ try:
26
+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, _REGISTRY_PATH, 0, winreg.KEY_SET_VALUE) as key:
27
+ winreg.SetValueEx(key, _VALUE_NAME, 0, winreg.REG_DWORD, int(enable))
28
+
29
+ except FileNotFoundError: # [WinError 2] 指定されたファイルが見つかりません。
30
+ __create_registry_key()
31
+ _set_autosave_enabled(enable)
21
32
 
22
33
 
23
34
  def __test_autosave_setting():
@@ -36,3 +47,12 @@ def __test_autosave_setting():
36
47
  print(f"Current AutoSave setting is {'enabled' if after_setting else 'disabled'}.")
37
48
 
38
49
  assert new_setting == after_setting, "レジストリ編集に失敗しました。"
50
+
51
+
52
+ def __create_registry_key():
53
+ with winreg.CreateKey(winreg.HKEY_CURRENT_USER, _REGISTRY_PATH) as key:
54
+ winreg.SetValueEx(key, _VALUE_NAME, 0, winreg.REG_DWORD, int(_DEFAULT_VALUE))
55
+
56
+
57
+ if __name__ == '__main__':
58
+ print(_get_autosave_enabled())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyfemtet
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: Design parameter optimization using Femtet.
5
5
  Home-page: https://github.com/pyfemtet/pyfemtet
6
6
  License: BSD-3-Clause
@@ -1,6 +1,6 @@
1
- pyfemtet/__init__.py,sha256=_SsQ0ZcyZbUqlFFT370nQxs8UER9D0oW_EmCr4Q-hx4,21
1
+ pyfemtet/__init__.py,sha256=ZbrGjsYU2ekVSe1-DcOOl7YsjrwB1bbJTUQlEi8pMjU,21
2
2
  pyfemtet/_femtet_config_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- pyfemtet/_femtet_config_util/autosave.py,sha256=e-_GJdiJ5un7iuTet3bK5vwwq4Aqh7B_YVTANDJfZl8,1383
3
+ pyfemtet/_femtet_config_util/autosave.py,sha256=dNirA9XGuFehas8_Jkj2BW9GOzMbPyhnt1WHcH_ObSU,2070
4
4
  pyfemtet/_femtet_config_util/exit.py,sha256=sx8Wcepgi-lL5qJpJl6WvlzbeVheU9_Dtf1f38mmoTo,1822
5
5
  pyfemtet/_message/1. make_pot.bat,sha256=wrTA0YaL7nUfNB0cS8zljOmwq2qgyG6RMwHQbrwjvY4,476
6
6
  pyfemtet/_message/2. make_mo.bat,sha256=6shJ3Yn4BXjDc0hhv_kiGUtVTq4oSRz8-iS4vW29rNE,155
@@ -116,8 +116,8 @@ pyfemtet/opt/visualization/result_viewer/.gitignore,sha256=ryvb4aqbbsHireHWlPQfx
116
116
  pyfemtet/opt/visualization/result_viewer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
117
117
  pyfemtet/opt/visualization/result_viewer/application.py,sha256=WcHBx_J5eNLKSaprpk9BGifwhO04oN8FiNGYTWorrXA,1691
118
118
  pyfemtet/opt/visualization/result_viewer/pages.py,sha256=laEAKHAtdshCAHxgXo-zMNg3RP6lCxfszO3XwLnF1dU,32156
119
- pyfemtet-0.6.3.dist-info/LICENSE,sha256=sVQBhyoglGJUu65-BP3iR6ujORI6YgEU2Qm-V4fGlOA,1485
120
- pyfemtet-0.6.3.dist-info/METADATA,sha256=l89gTkV_ub72Kqh496W02gf0nmGVwcYC-8w2-Us9zNk,3287
121
- pyfemtet-0.6.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
122
- pyfemtet-0.6.3.dist-info/entry_points.txt,sha256=ZfYqRaoiPtuWqFi2_msccyrVF0LurMn-IHlYamAegZo,104
123
- pyfemtet-0.6.3.dist-info/RECORD,,
119
+ pyfemtet-0.6.4.dist-info/LICENSE,sha256=sVQBhyoglGJUu65-BP3iR6ujORI6YgEU2Qm-V4fGlOA,1485
120
+ pyfemtet-0.6.4.dist-info/METADATA,sha256=nfYqCCLh0gfQqzdjCQ8XNVh8nL9NKpNlbGx_dGoein4,3287
121
+ pyfemtet-0.6.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
122
+ pyfemtet-0.6.4.dist-info/entry_points.txt,sha256=ZfYqRaoiPtuWqFi2_msccyrVF0LurMn-IHlYamAegZo,104
123
+ pyfemtet-0.6.4.dist-info/RECORD,,