pyfemtet 0.6.1__py3-none-any.whl → 0.6.3__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 +1 -1
- pyfemtet/_femtet_config_util/__init__.py +0 -0
- pyfemtet/_femtet_config_util/autosave.py +38 -0
- pyfemtet/_femtet_config_util/exit.py +58 -0
- pyfemtet/_message/1. make_pot.bat +2 -3
- pyfemtet/_message/2. make_mo.bat +1 -1
- pyfemtet/_message/babel.cfg +1 -1
- pyfemtet/_message/locales/ja/LC_MESSAGES/messages.po +136 -124
- pyfemtet/_message/locales/messages.pot +136 -124
- pyfemtet/_message/messages.py +3 -0
- pyfemtet/_warning.py +59 -3
- pyfemtet/opt/_femopt.py +62 -42
- pyfemtet/opt/_test_utils/record_history.py +50 -0
- pyfemtet/opt/interface/_base.py +10 -1
- pyfemtet/opt/interface/_excel_interface.py +437 -0
- pyfemtet/opt/interface/_femtet.py +4 -75
- pyfemtet/opt/interface/_femtet_with_sldworks.py +1 -1
- pyfemtet/opt/optimizer/_base.py +11 -9
- pyfemtet/opt/visualization/_complex_components/main_figure_creator.py +82 -21
- {pyfemtet-0.6.1.dist-info → pyfemtet-0.6.3.dist-info}/METADATA +1 -1
- {pyfemtet-0.6.1.dist-info → pyfemtet-0.6.3.dist-info}/RECORD +24 -20
- {pyfemtet-0.6.1.dist-info → pyfemtet-0.6.3.dist-info}/LICENSE +0 -0
- {pyfemtet-0.6.1.dist-info → pyfemtet-0.6.3.dist-info}/WHEEL +0 -0
- {pyfemtet-0.6.1.dist-info → pyfemtet-0.6.3.dist-info}/entry_points.txt +0 -0
pyfemtet/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.6.
|
|
1
|
+
__version__ = "0.6.3"
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import winreg
|
|
2
|
+
from typing import Final
|
|
3
|
+
|
|
4
|
+
# レジストリのパスと値の名前
|
|
5
|
+
_REGISTRY_PATH: Final[str] = r"SOFTWARE\Murata Software\Femtet2014\Femtet"
|
|
6
|
+
_VALUE_NAME: Final[str] = "AutoSave"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
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.")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
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))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def __test_autosave_setting():
|
|
24
|
+
|
|
25
|
+
# 使用例
|
|
26
|
+
current_setting = _get_autosave_enabled()
|
|
27
|
+
print(f"Current AutoSave setting is {'enabled' if current_setting else 'disabled'}.")
|
|
28
|
+
|
|
29
|
+
# 設定を変更する例
|
|
30
|
+
new_setting = not current_setting
|
|
31
|
+
_set_autosave_enabled(new_setting)
|
|
32
|
+
print(f"AutoSave setting has been {'enabled' if new_setting else 'disabled'}.")
|
|
33
|
+
|
|
34
|
+
# 再度設定を確認する
|
|
35
|
+
after_setting = _get_autosave_enabled()
|
|
36
|
+
print(f"Current AutoSave setting is {'enabled' if after_setting else 'disabled'}.")
|
|
37
|
+
|
|
38
|
+
assert new_setting == after_setting, "レジストリ編集に失敗しました。"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from time import time, sleep
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from win32com.client import CDispatch
|
|
5
|
+
from femtetutils import util
|
|
6
|
+
import psutil
|
|
7
|
+
|
|
8
|
+
from pyfemtet.dispatch_extensions._impl import _get_pid
|
|
9
|
+
from pyfemtet.core import _version
|
|
10
|
+
from pyfemtet._message import Msg
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger('fem')
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _exit_or_force_terminate(timeout, Femtet: CDispatch, force=True):
|
|
16
|
+
|
|
17
|
+
# Femtet がすでに終了しているかどうかを判断する
|
|
18
|
+
hwnd = Femtet.hWnd
|
|
19
|
+
pid = _get_pid(hwnd)
|
|
20
|
+
|
|
21
|
+
# pid が 0 ならすでに終了しているものと見做して何もしない
|
|
22
|
+
if pid == 0:
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
# Exit() メソッドを定義している最小の Femtet バージョン
|
|
26
|
+
minimum_version = _version(2024, 0, 1)
|
|
27
|
+
|
|
28
|
+
# 現在の Femtet のバージョン
|
|
29
|
+
current_version = _version(Femtet=Femtet)
|
|
30
|
+
|
|
31
|
+
# 現在のバージョン >= minimum version なら Exit を実行
|
|
32
|
+
if current_version >= minimum_version:
|
|
33
|
+
# gracefully termination method without save project available from 2024.0.1
|
|
34
|
+
try:
|
|
35
|
+
Femtet.Exit(force)
|
|
36
|
+
|
|
37
|
+
except AttributeError as e:
|
|
38
|
+
raise AttributeError('Macro version is not consistent to the one of Femtet.exe. '
|
|
39
|
+
'Please consider ``Enable Macros`` to fix it.')
|
|
40
|
+
|
|
41
|
+
# そうでなければ強制終了する
|
|
42
|
+
else:
|
|
43
|
+
# terminate
|
|
44
|
+
util.close_femtet(Femtet.hWnd, timeout, force)
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
pid = _get_pid(hwnd)
|
|
48
|
+
start = time()
|
|
49
|
+
while psutil.pid_exists(pid):
|
|
50
|
+
if time() - start > 30: # 30 秒経っても存在するのは何かおかしい
|
|
51
|
+
logger.error(Msg.ERR_CLOSE_FEMTET_FAILED)
|
|
52
|
+
break
|
|
53
|
+
sleep(1)
|
|
54
|
+
sleep(1)
|
|
55
|
+
|
|
56
|
+
# dead
|
|
57
|
+
except (AttributeError, OSError):
|
|
58
|
+
pass
|
|
@@ -4,9 +4,8 @@ rem .pot file defines the target of string to translate.
|
|
|
4
4
|
rem .po file is the implementation of translation.
|
|
5
5
|
|
|
6
6
|
cd %~dp0\..\..
|
|
7
|
-
poetry run pybabel extract -F ./pyfemtet/
|
|
8
|
-
|
|
9
|
-
poetry run pybabel update -i ./pyfemtet/message/locales/messages.pot --no-wrap -d ./pyfemtet/message/locales -l ja
|
|
7
|
+
poetry run pybabel extract -F ./pyfemtet/_message/babel.cfg --no-wrap --ignore-dirs=".*" -o ./pyfemtet/_message/locales/messages.pot .
|
|
8
|
+
poetry run pybabel update -i ./pyfemtet/_message/locales/messages.pot --no-wrap -d ./pyfemtet/_message/locales -l ja
|
|
10
9
|
|
|
11
10
|
echo "�������ꂽ .po �t�@�C����|�Ă��������B"
|
|
12
11
|
pause
|
pyfemtet/_message/2. make_mo.bat
CHANGED
pyfemtet/_message/babel.cfg
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[python: ./pyfemtet/
|
|
1
|
+
[python: ./pyfemtet/_message/messages.py]
|
|
2
2
|
# [html: **/templates/**.html]
|