zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
U
X±d•%ã@s˜dZddlmZddlmZmZe e¡Z    dZ
dZ dZ dZ dZd    ZGd
d „d ƒZdd d „Zddd„Zddd„Zddd„Zddd„Zddd„Zdd„ZdS) zª
Read and write resources from/to Win32 PE files.
 
Commandline usage:
winresource.py <dstpath> <srcpath>
Updates or adds resources from file <srcpath> in file <dstpath>.
éN)Ú
pywintypesÚwin32apiééÁiiiic@sJeZdZdZdd„Zddd„Zddd„Zdd    d
„Zdd d „Zdd d„Z    dS)ÚFilez
    Win32 PE file class.
    cCs
||_dS©N)Úfilename)Úselfr©r
úZd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/utils/win32/winresource.pyÚ__init__$sz File.__init__NcCst|j|||ƒS)a
        Get resources.
 
        types = a list of resource types to search for (None = all)
        names = a list of resource names to search for (None = all)
        languages = a list of resource languages to search for (None = all)
        Return a dict of the form {type_: {name: {language: data}}}, which might also be empty if no matching resources
        were found.
        )Ú GetResourcesr)r    ÚtypesÚnamesÚ    languagesr
r
r Ú get_resources's
zFile.get_resourcescCst|j||||ƒdS)zß
        Update or add resource data.
 
        type_ = resource type to update
        names = a list of resource names to update (None = all)
        languages = a list of resource languages to update (None = all)
        N)ÚUpdateResourcesr)r    ÚdataÚtype_rrr
r
r Úupdate_resources3szFile.update_resourcescCst|j||||ƒdS)zñ
        Update or add resource data from file srcpath.
 
        type_ = resource type to update
        names = a list of resource names to update (None = all)
        languages = a list of resource languages to update (None = all)
        N)ÚUpdateResourcesFromDataFiler)r    Úsrcpathrrrr
r
r Úupdate_resources_from_datafile=sz#File.update_resources_from_datafilecCst|j||||ƒdS)a
        Update or add resources from resource dict.
 
        types = a list of resource types to update (None = all)
        names = a list of resource names to update (None = all)
        languages = a list of resource languages to update (None = all)
        N)ÚUpdateResourcesFromDictr)r    Úresrrrr
r
r Úupdate_resources_from_dictGszFile.update_resources_from_dictcCst|j||||ƒdS)a 
        Update or add resources from dll/exe file srcpath.
 
        types = a list of resource types to update (None = all)
        names = a list of resource names to update (None = all)
        languages = a list of resource languages to update (None = all)
        N)ÚUpdateResourcesFromResFiler)r    rrrrr
r
r Úupdate_resources_from_resfileQsz"File.update_resources_from_resfile)NNN)NN)NN)NNN)NNN)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__r rrrrrr
r
r
r r s
 
 
 
 
 
 
rc
sZˆr tˆƒ‰ˆrtˆƒ‰ˆr$tˆƒ‰i}zèt |¡}ˆrRdˆkrRt‡fdd„|ƒ}|D]¶}t ||¡}ˆr„dˆkr„t‡fdd„|ƒ}|D]‚}t |||¡}    ˆr¸dˆkr¸t‡fdd„|    ƒ}    |    D]L}
t ||||
¡} ||krài||<|||krøi|||<| ||||
<q¼qˆqVWnDtjk
rT} z"| j    dt
t t t fkr@n| ‚W5d} ~ XYnX|S)ao
    Get resources from hsrc.
 
    types = a list of resource types to search for (None = all)
    names = a list of resource names to search for (None = all)
    languages = a list of resource languages to search for (None = all)
    Return a dict of the form {type_: {name: {language: data}}}, which might also be empty if no matching resources
    were found.
    Ú*cs|ˆkSrr
)r)rr
r Ú<lambda>qóz_GetResources.<locals>.<lambda>cs|ˆkSrr
)Úname)rr
r r#vr$cs|ˆkSrr
)Úlanguage)rr
r r#{r$rN)ÚsetrZEnumResourceTypesÚfilterZEnumResourceNamesZEnumResourceLanguagesZ LoadResourcerÚerrorÚargsÚERROR_RESOURCE_DATA_NOT_FOUNDÚERROR_RESOURCE_TYPE_NOT_FOUNDÚERROR_RESOURCE_NAME_NOT_FOUNDÚERROR_RESOURCE_LANG_NOT_FOUND) ÚhsrcrrrrÚ
enum_typesrZ
enum_namesr%Zenum_languagesr&rÚ    exceptionr
)rrrr Ú _GetResources\sH
 
      ür2cCs*t |dt¡}t||||ƒ}t |¡|S)aw
    Get resources from dll/exe file.
 
    types = a list of resource types to search for (None = all)
    names = a list of resource names to search for (None = all)
    languages = a list of resource languages to search for (None = all)
    Return a dict of the form {type_: {name: {language: data}}}, which might also be empty if no matching resources
    were found.
    r)rZ LoadLibraryExÚLOAD_LIBRARY_AS_DATAFILEr2Ú FreeLibrary)rrrrr/rr
r
r r ‘s
 
r c    
Csöt||g||ƒ}||kr(|dkr(i||<|rŽ|D]\}|||kr0|dkr0g|||<|r0|D].}||||kr\|dkr\||| |¡q\q0t |d¡}|D]F}||D]8}|||D]&}t d|||¡t |||||¡qºqªqžt |d¡dS)zã
    Update or add resource data in dll/exe file dstpath.
 
    type_ = resource type to update
    names = a list of resource names to update (None = all)
    languages = a list of resource languages to update (None = all)
    r"rz-Updating resource type %s name %s language %sN)r ÚappendrÚBeginUpdateResourceÚloggerÚinfoZUpdateResourceÚEndUpdateResource)    Údstpathrrrrrr%r&Zhdstr
r
r r¡s$       rc    Cs2t|dƒ}| ¡}W5QRXt|||||ƒdS)zõ
    Update or add resource data from file srcpath in dll/exe file dstpath.
 
    type_ = resource type to update
    names = a list of resource names to update (None = all)
    languages = a list of resource languages to update (None = all)
    ÚrbN)ÚopenÚreadr)r:rrrrÚsrcrr
r
r rÀs rc    Cs–|r t|ƒ}|rt|ƒ}|r$t|ƒ}|D]h}|r8||kr(||D]N}|rP||kr@|||D]0}|rl||kr\t|||||||g|gƒq\q@q(dS)a
 
    Update or add resources from resource dict in dll/exe file dstpath.
 
    types = a list of resource types to update (None = all)
    names = a list of resource names to update (None = all)
    languages = a list of resource languages to update (None = all)
    N)r'r)r:rrrrrr%r&r
r
r rÍs    rcCst||||ƒ}t||ƒdS)a
    Update or add resources from dll/exe file srcpath in dll/exe file dstpath.
 
    types = a list of resource types to update (None = all)
    names = a list of resource names to update (None = all)
    languages = a list of resource languages to update (None = all)
    N)r r)r:rrrrrr
r
r räsrcCst |d¡}t |d¡dS)z5
    Remove all resources from the dll/exe file.
    TFN)rr6r9)rr/r
r
r ÚRemoveAllResourcesðs r?)NNN)NNN)NN)NN)NNN)NNN)r!ZPyInstaller.logÚlogÚloggingZPyInstaller.compatrrÚ    getLoggerrr7r3ZERROR_BAD_EXE_FORMATr+r,r-r.rr2r rrrrr?r
r
r
r Ú<module> s" 
<
5