22
33from PySide6 import QtCore
44
5+ from ..Constants .packaging_constants import *
56from .subprocess_tool import SubProcessTool
67
7- pyinstaller_args : list = [
8- "script_path" ,
9- "icon_path" ,
10- "FD" ,
11- "console" ,
12- "out_name" ,
13- ]
14-
158
169class Packaging (QtCore .QObject ):
1710 """
@@ -28,7 +21,7 @@ def __init__(self, parent: Optional[QtCore.QObject] = None) -> None:
2821
2922 super (Packaging , self ).__init__ (parent )
3023
31- self .args_dict : dict = dict .fromkeys (pyinstaller_args , "" )
24+ self .args_dict : dict = dict .fromkeys (pyinstaller_args_list , "" )
3225 self ._args : List [str ] = []
3326 self .subprocess : SubProcessTool = SubProcessTool (self , program = "pyinstaller" )
3427
@@ -40,8 +33,8 @@ def set_pyinstaller_args(self, arg: tuple[str, str]) -> None:
4033 """
4134
4235 arg_key , arg_value = arg
43- if arg_key in self . args_dict . keys () :
44- self .args_dict [arg_key ] = arg_value
36+ # if arg_key in pyinstaller_args_list :
37+ self .args_dict [arg_key ] = arg_value
4538 self ._add_pyinstaller_args ()
4639
4740 def _add_pyinstaller_args (self ) -> None :
@@ -50,21 +43,21 @@ def _add_pyinstaller_args(self) -> None:
5043 """
5144
5245 self ._args = [] # 避免重复添加
53- self ._args .extend ([self .args_dict [" script_path" ]])
54- if self .args_dict [" icon_path" ]:
55- self ._args .extend (["--icon" , self .args_dict [" icon_path" ]])
56- if self .args_dict ["FD" ]:
57- if self .args_dict ["FD" ] == "One Dir" :
46+ self ._args .extend ([self .args_dict [PyinstallerArgs . script_path ]])
47+ if self .args_dict [PyinstallerArgs . icon_path ]:
48+ self ._args .extend (["--icon" , self .args_dict [PyinstallerArgs . icon_path ]])
49+ if self .args_dict [PyinstallerArgs . FD ]:
50+ if self .args_dict [PyinstallerArgs . FD ] == "One Dir" :
5851 self ._args .extend (["--onedir" ])
59- elif self .args_dict ["FD" ] == "One File" :
52+ elif self .args_dict [PyinstallerArgs . FD ] == "One File" :
6053 self ._args .extend (["--onefile" ])
61- if self .args_dict [" console" ]:
62- if self .args_dict [" console" ] == "console" :
54+ if self .args_dict [PyinstallerArgs . console ]:
55+ if self .args_dict [PyinstallerArgs . console ] == "console" :
6356 self ._args .extend (["--console" ])
64- elif self .args_dict [" console" ] == "windowed" :
57+ elif self .args_dict [PyinstallerArgs . console ] == "windowed" :
6558 self ._args .extend (["--windowed" ])
66- if self .args_dict [" out_name" ]:
67- self ._args .extend (["--name" , self .args_dict [" out_name" ]])
59+ if self .args_dict [PyinstallerArgs . out_name ]:
60+ self ._args .extend (["--name" , self .args_dict [PyinstallerArgs . out_name ]])
6861
6962 self .args_settled .emit (self ._args )
7063
0 commit comments