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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
U
X±du¬ã@sÖdZddlZddlZddlZddlZddlmZddlmZmZddl    m
Z
m Z ddl m Z ddl mZddlmZe e¡Zd    Zd
Zd Ze
je
_e
je
_e
je
_e
je
_e je _e j e _!e je _e j"e _#e j$e _%d d „Z&dd„Z'e&e
_(e'e
_)e&e _(e'e _)Gdd„dƒZ*erej+Z,ne*Z,Gdd„de,ƒZ+Gdd„de-ƒZ.Gdd„de.ƒZ/Gdd„dƒZ0d0dd„Z1dd„Z2dd„Z3d d!„Z4d1d"d#„Z5d2d$d%„Z6d3d&d'„Z7d4d)d*„Z8d+d,„Z9ed-krÒej:d.Z;ej:d/Z<e7e;e<ƒdS)5a@
Create, parse and write MS Windows Manifest files. Find files which are part of an assembly, by searching shared and
private assemblies. Update or add manifest resources in Win32 PE files.
 
Commandline usage:
winmanifest.py <dstpath> <xmlpath>
Updates or adds manifest <xmlpath> as resource in Win32 PE file <dstpath>.
éN)Úglob)ÚNodeÚminidom)ÚDocumentÚElement)Úcompat)Úlog)Ú winresourcezx-wwÚnoneécCs2g}|jD]"}t|tƒr
|j|kr
| |¡q
|S)zB
    Return child elements of type tagName if found, else [].
    )Ú
childNodesÚ
isinstancerÚtagNameÚappend)ÚselfrÚresultÚchild©rúZd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/utils/win32/winmanifest.pyÚgetChildElementsByTagNamebs 
 
 
 rcCs,|jD] }t|tƒr|j|kr|SqdS)zG
    Return the first element of type tagName if found, else None.
    N)r r rr)rrrrrrÚgetFirstChildElementByTagNamens
 
 
 
 
rc@s eZdZdS)Ú_DummyN©Ú__name__Ú
__module__Ú __qualname__rrrrrsrc@s,eZdZdZd
dd„Zd dd„Zdd    „ZdS) ÚFilez=
    A file referenced by an assembly inside a manifest.
    ÚNcCsœtrtj ||¡n||_tj |¡|_|r8| ¡|_    nd|_    tj 
|¡rj|rjt rjt t |  ¡ƒrj| ¡n||_|pvg|_|p€g|_|pŠg|_|p”g|_dS©N)r    rÚ__init__ÚfilenameÚosÚpathÚbasenameÚnameÚupperÚhashalgÚisfileÚhashlibÚhasattrÚlowerÚ    calc_hashÚhashÚ
comClassesÚtypelibsÚcomInterfaceProxyStubsÚ windowClasses)rr r&r,r-r.r/r0rrrrs
 "
 
 
 
z File.__init__c    CsLt|jdƒ}| ¡}W5QRX|r.| ¡|_tt|j ¡ƒ|ƒ ¡|_    dS)zþ
        Calculate the hash of the file.
 
        Will be called automatically from the constructor if the file exists and hashalg is given (and supported),
        but may also be called manually e.g. to update the hash if the file has changed.
        ÚrbN)
Úopenr Úreadr%r&Úgetattrr(r*Ú    hexdigestr,)rr&ÚfdÚbufrrrr+©s
 
zFile.calc_hashcCsNt d|j¡tj ||j¡}tj |¡r:t d|¡|St d|¡dSdS)NzSearching for file %sz Found file %szNo such file %s)ÚloggerÚinfor$r!r"Újoinr'Úwarning)rZ
searchpathÚfnrrrÚfind¶s   z    File.find)rNNNNNN)N)rrrÚ__doc__rr+r=rrrrr‰sø
 
rc@s eZdZdS)ÚInvalidManifestErrorNrrrrrr?Ásr?c@s eZdZdS)ÚManifestXMLParseErrorNrrrrrr@Åsr@c@seZdZdZd9dd„Zdd„Zd    d
„Zd d „Zd:d d„Zd;dd„Z    e
dd„ƒZ e
dd„ƒZ e
dd„ƒZ d<dd„Zd=dd„Zd>dd„Zd?dd „Zd@d!d"„ZdAd#d$„ZdBd%d&„ZdCd'd(„ZdDd)d*„Zd+d,„Zd-ejd.fd/d0„ZdEd1d2„ZdFd3d4„Zdd-ejd.fd5d6„Zdd-ejd.fd7d8„ZdS)GÚManifesta^
    Manifest constructor.
 
    To build a basic manifest for your application:
      mf = Manifest(type='win32', name='YourAppName', language='*', processorArchitecture='x86', version=[1, 0, 0, 0])
 
    To write the XML to a manifest file:
      mf.writexml("YourAppName.exe.manifest")
    or
      mf.writeprettyxml("YourAppName.exe.manifest")
    ÚassemblyNFcCsd|_d|_||_|pddg|_||_||_||_||_||_||_    |    |_
|
|_ d|_ d|_ | |_| |_|png|_g|_|p~g|_|pˆg|_dS)Nér)r ÚoptionalÚ manifestTypeÚmanifestVersionÚ noInheritableÚ    noInheritÚtyper$ÚlanguageÚprocessorArchitectureÚversionÚpublicKeyTokenÚapplyPublisherPolicyÚ descriptionÚrequestedExecutionLevelÚuiAccessÚdependentAssembliesÚbindingRedirectsÚfilesÚcomInterfaceExternalProxyStubs)rrErFrGrHÚtype_r$rJrKrLrMrOrPrQrRrTrUrrrr×s(
 
zManifest.__init__cCs4t|tƒr| ¡| ¡kSt|tƒr0| ¡|kSdS)NF)r rAÚtoxmlÚstr©rÚotherrrrÚ__eq__s
 
 
 zManifest.__eq__cCs | |¡ Sr)r[rYrrrÚ__ne__
szManifest.__ne__cCs t| ¡ƒSr)ÚreprrW)rrrrÚ__repr__ szManifest.__repr__cCsN|j t|||||||||    |
| | | ||ƒ¡|jrJd |j|f¡|jd_dS)zY
        Shortcut for self.dependentAssemblies.append(Manifest(*args, **kwargs))
        ú:éÿÿÿÿN)rRrrAr r:)rrFrGrHrVr$rJrKrLrMrOrPrQrRrTrUrrrÚadd_dependent_assemblys*ñÿzManifest.add_dependent_assemblyrc
Cs |j t|||||||ƒ¡dS)z4
        Shortcut for manifest.files.append
        N)rTrr)rr$r&r,r-r.r/r0rrrÚadd_file<s zManifest.add_filecCstj t d¡d¡S)NÚ
SystemRootÚWinSxS)r!r"r:rÚgetenv)ÚclsrrrÚget_winsxs_dirKszManifest.get_winsxs_dircCsJ| ¡}tj |¡s t d|¡tj |d¡}tj |¡sFt d|¡|S)NúNo such dir %sZ    Manifests)rgr!r"Úisdirr8r;r:)rfÚwinsxsÚ    manifestsrrrÚget_manifest_dirOs    zManifest.get_manifest_dircCsTtj t d¡d¡}t ¡dkrHtj |d¡}tj |¡sPt     d|¡n| 
¡}|S)Nrcrd©éZPoliciesrh) r!r"r:rreÚsysÚgetwindowsversionrir8r;rl)rfrjÚpcfilesrrrÚget_policy_dirYs  zManifest.get_policy_dirc
Csðd}| ¡}|dkr|j}|dkr(|j}tj |¡rìt d|jd|d¡t     
¡dkrvtj  ||jd|dd¡}ntj  ||jd|dd¡}t |ƒD]>}tj  |¡sºt d|¡qšt d    |¡z t|ƒ}Wn$tk
rötjd
|d d YqšXt d ¡|jD]Ð}| |d¡r|jr&q|jD]¨}    d  dd„|    dDƒ¡}
d  dd„|    d Dƒ¡} t d|
| ¡|    dd|kr–|    ddkr,nn8||    d kr,t dd  dd„|Dƒ¡| ¡|    d }d}q,qqš|sìt d¡|S)NFz,Searching for publisher configuration %s ...T)rJrmz.policyú    .manifestú Not a file %szFound %szCould not parse file %srC©Úexc_infoz/Checking publisher policy for binding redirectsú-cSs g|]}d dd„|Dƒ¡‘qS)Ú.cSsg|] }t|ƒ‘qSr©rX©Ú.0ÚirrrÚ
<listcomp>sz;Manifest.get_policy_redirect.<locals>.<listcomp>.<listcomp>©r:©r{Úpartrrrr}sz0Manifest.get_policy_redirect.<locals>.<listcomp>rrxcSsg|] }t|ƒ‘qSrryrzrrrr}‘sz&Found redirect for version(s) %s -> %sr`zApplying redirect %s -> %scSsg|] }t|ƒ‘qSrryrzrrrr}”sz Publisher configuration not used)rrrLrJr!r"rir8ÚdebugÚ getpolicyidrorpr:rr'r;r9ÚManifestFromXMLFileÚ    ExceptionÚerrorrRÚsame_idrDrS) rrJrLZ
redirectedrqZpoliciesÚ manifestpthÚpolicyrBÚredirectÚoldÚnewrrrÚget_policy_redirectfsF      
 
 
:
zManifest.get_policy_redirectTc Cs6g}g}|jdkrh| | ¡¡d|jkr@| |j d¡d¡|jdkrT| d¡|jdkrh| d¡| | d¡¡| ¡}| ¡}|D]˜}|j}|s¬|r¬| ||¡}g}tj     
|¡râ|  t tj      ||j||dd    ¡ƒ¡|jr°tj     |j¡}    |ttfkrTd
D]F}
|  t tj      |    |j|
¡ƒ¡|  t tj      |    |j|j|
¡ƒ¡q
n\d
D]&}
|  t tj      |    ||j|
¡ƒ¡qXd
D]*}
|  t tj      |    ||j|j|
¡ƒ¡q„t d |j||d¡|D]X} tj     | ¡sît d | ¡qÊtj     tj     | ¡d¡} z>|  d ¡r.t d| ¡t| dgƒ} nt d| ¡t| ƒ} Wn&tk
rjtjd| ddYn°X|  |¡r¸tj      || ¡}tj     
|¡sÄt d|¡t d¡gSn tj     | ¡}| | ¡|j pÚ| j D]<}| !|¡}|rü| |¡nt d¡gSqÜ|SqŒt d¡gS)aÆ
        Search shared and private assemblies and return a list of files.
 
        If any files are not found, return an empty list.
 
        IMPORTANT NOTE: On some Windows systems, the dependency listed in the manifest will not actually be present,
        and finding its files will fail. This is because a newer version of the dependency is installed,
        and the manifest's dependency is being redirected to a newer version. To properly bundle the newer version of
        the assembly, you need to find the newer version by setting ignore_policies=False, and then either create a
        .config file for each bundled assembly, or modify each bundled assembly to point to the newer version.
 
        This is important because Python 2.7's app manifest depends on version 21022 of the VC90 assembly,
        but the Python 2.7.9 installer will install version 30729 of the assembly along with a policy file that
        enacts the version redirect.
        ©NrÚ*Zneutralrwr)úen-usÚenrrrŽ)rJrLz _*.manifest)ú.dllrszSearching for assembly %s ...rtr‘zFound manifest in %srCzFound manifest %szCould not parse manifest %srurhzAssembly incompletezAssembly not found)"rJrÚ getlanguageÚsplitrlrgrLrŒr!r"riÚextendrr:Úgetidr ÚdirnameÚLANGUAGE_NEUTRAL_NT5ÚLANGUAGE_NEUTRAL_NT6r$r8r9r'r;r#ÚsplitextÚendswithÚManifestFromResFilerƒr„r…Ú
startswithrTr=)rZignore_policiesrTÚ    languagesrkrjrJrLÚpathsZdirnmÚextr‡Z
assemblynmÚmanifestZ assemblydirÚfile_r<rrrÚ
find_filesœs‚
 
 
 
 
 
 
 
ÿÿ($(
 
 
 
 
 
zManifest.find_filescCs–|jst d¡dSg}|jr*| |j¡| |j¡|jrH| |j¡|sR|jrr| d dd„|ph|jDƒ¡¡|s~| ¡}|rŒ| |¡d |¡S)aV
        Return an identification string which uniquely names a manifest.
 
        This string is a combination of the manifest's processorArchitecture, name, publicKeyToken, version and
        language.
 
        Arguments:
        version (tuple or list of integers) - If version is given, use it instead of the manifest's version.
        úAssembly metadata incompleterrxcSsg|] }t|ƒ‘qSrryrzrrrr}$sz"Manifest.getid.<locals>.<listcomp>Ú_)    r$r8r;rKrrMrLr:r’)rrJrLÚidrrrr•s 
 
 
 
zManifest.getidcCs.|s
|j}|dkr*ttf|p"t ¡dkS|S)zä
        Get and return the manifest's language as string.
 
        Can be either language-culture e.g. 'en-us' or a string indicating language neutrality, e.g. 'x-ww' on
        Windows XP or 'none' on Vista and later.
        rrm)rJr—r˜rorp)rrJÚwindowsversionrrrr’+s
zManifest.getlanguagecCs^|jst d¡dSg}|jr*| |j¡g}| d¡|jrf| t|jdƒ¡| t|jdƒ¡| |j¡| d |¡¡|jr”| |j¡|jrÖ|p¤t     
¡dkrÖ|rº| d¡n| d d    d
„|jDƒ¡¡|sæ|j |d }|rô| |¡| d¡d  |¡}|jrZ|pt     
¡dkrZ|r:t j  |d¡}n t j  |d d d
„|jDƒ¡¡}|S)a
        Return an identification string which can be used to find a policy.
 
        This string is a combination of the manifest's processorArchitecture, major and minor version, name,
        publicKeyToken and language.
 
        Arguments:
            fuzzy (boolean):
                 If False, insert the full version in the id string. Default is True (omit).
            windowsversion (tuple or list of integers or None):
                If not specified (or None), default to sys.getwindowsversion().
        r£rrˆrrCrxrmrŽcSsg|] }t|ƒ‘qSrryrzrrrr}Ysz(Manifest.getpolicyid.<locals>.<listcomp>)r¦r¤cSsg|] }t|ƒ‘qSrryrzrrrr}es)r$r8r;rKrrLrXr:rMrorpr’r!r")rZfuzzyrJr¦r¥r$rrrr‚8s< 
 
 
 
 
 zManifest.getpolicyidcCsh|jtjkr|j}n |jtjkr&|}ntd|jƒ‚d}|j|krZtd|jd |¡fƒ‚|jdkr”| d¡D] }| d¡D]}|     ||¡q|qnnÐ|r | 
¡|j|_ dd    „|  d
¡pºd   d ¡Dƒ|_t| d ¡ƒ|_t| d¡ƒ|_| d¡D]ˆ}|  d¡pd|_|  d¡pd|_|  d¡p(d|_|  d¡p:d|_|  d¡}|rhtdd„|  d ¡Dƒƒ|_|  d¡pvd|_qò| d¡D] }    |      d¡p˜d ¡dk|_q†| d¡D]}
|
jr²|
jj|_q²| d¡D]b} |  d¡D]P} |  d ¡D]>} |  d!¡D],}|  d"¡|_|  d#¡pd ¡d$k|_ qqòqäqÖ|jdkrN|g}n
| d%¡}|D]t}| d&¡D]b}t!|ƒ}|js‚qj|  d'¡pd ¡dk|_"|j# $|¡|j%rjd( |j%|jf¡|j#d)_%qjq\| d*¡D]R}td+d„|  d,¡  d-¡Dƒƒ}td.d„|  d/¡  d ¡Dƒƒ}|j& $||f¡qÜ| d0¡D](}|j'|  d¡|  d1¡|  d2¡d3q:dS)4zy
        Load manifest from DOM tree.
 
        If initialize is True (default), reset existing attributes first.
        zRInvalid root element node type %s - has to be one of (DOCUMENT_NODE, ELEMENT_NODE))rBÚassemblyBindingÚ configurationÚdependentAssemblyz1Invalid root element <%s> - has to be one of <%s>z>, <r¨Úwindowsr§cSsg|] }t|ƒ‘qSr©Úintrzrrrr}…sz%Manifest.load_dom.<locals>.<listcomp>rFz1.0rxrGrHÚassemblyIdentityrINr$rJrKrLcss|]}t|ƒVqdSrr«rzrrrÚ    <genexpr>sz$Manifest.load_dom.<locals>.<genexpr>rMÚpublisherPolicyÚapplyrÚyesrOÚ    trustInfoÚsecurityÚrequestedPrivilegesrPÚlevelrQÚtrueÚ
dependencyr©rDr_r`ÚbindingRedirectcss&|]}tdd„| d¡DƒƒVqdS)css|]}t|ƒVqdSrr«rzrrrr®®sz.Manifest.load_dom.<locals>.<genexpr>.<genexpr>rxN)Útupler“rrrrr®­sÚ
oldVersionrwcss|]}t|ƒVqdSrr«rzrrrr®°sÚ
newVersionÚfiler&r,©r$r&r,)(ZnodeTyperZ DOCUMENT_NODEÚdocumentElementZ ELEMENT_NODEr?rr:Ú    getCEByTNÚload_domrrEÚgetAr“rFÚboolÚ
getFCEByTNrGrHrIr$rJrKr¹rLrMr*rNZ
firstChildZ    wholeTextrOrPrQÚManifestFromDOMrDrRrr rSrb)rÚdomtreeÚ
initializeZ rootElementZ allowed_namesrªr§r­rLr¯rOr²r³ZreqPrivZ    reqExeLevZ dependenciesr·r©r r¸rºr»r¡rrrrÀhs€  ÿÿ
ÿ
 
 * 
 "ÿzManifest.load_domc
Cs–t|tƒr|}n|j}zt |¡}WnNtjjjk
rr}z*d|t|j    dƒg}t
d  |¡ƒ|‚W5d}~XYnX|r€|  ¡||_ | |d¡dS)z9
        Load manifest from file or file object.
        z
  File "%r"
   rú NF)r rXr$rÚparseÚxmlÚparsersÚexpatÚ
ExpatErrorÚargsr@r:rr rÀ)rÚfilename_or_filerÆr rÅÚerÍrrrrȵs
"zManifest.parsec
CsRzt |¡}Wn2tjjjk
r@}zt|ƒ|‚W5d}~XYnX| ||¡dS)z0
        Load manifest from XML string.
        N)rÚ parseStringrÉrÊrËrÌr@rÀ)rÚxmlstrrÆrÅrÏrrrÚ parse_stringÇs
zManifest.parse_stringcCsV|r
d}n |j|jk}|j|jkoT|j|jkoT|j|jkoT|j|jkoT|j|jkoT|S)zÂ
        Return a bool indicating if another manifest has the same identitiy.
 
        This is done by comparing language, name, processorArchitecture, publicKeyToken, type and version.
        T)rLrJr$rKrMrI)rr Zskip_version_checkZ version_checkrrrr†Ñs 
ÿ
þ
þýzManifest.same_idc     CsÞtƒ}| |j¡}|jdkrP| d¡}| d¡}| |¡| |¡| |¡n
| |¡|jdkr˜| dd¡|jdkr˜| dd d    d
„|jDƒ¡¡|jr®| | d ¡¡|jrÄ| | d ¡¡| d ¡}|j    râ| 
d|j    ¡|j rö| 
d|j ¡|j r | 
d|j ¡|j r"| 
d|j ¡|jrH| 
dd dd
„|jDƒ¡¡|jr^| 
d|j¡| ¡rt| |¡n| ¡|jdk    r¾| d¡}|jr¨| dd¡n | dd¡| |¡|jrì| d¡}| | |j¡¡| |¡|jdkr„| d¡}| dd¡| d¡}    | d¡}
| d ¡} |  d!|j¡|jrP|  d"d#¡n |  d"d$¡|
 | ¡|     |
¡| |    ¡| |¡|jr*|jD]–} |jdkrÀ| d%¡} | jrÀ|  
d&d¡| d¡}|  ¡}|jjD]}| | d'¡¡qÚ| ¡|jdkr|  |¡| | ¡n
| |¡q’|jr”|jD]Z}| d(¡}| 
d)d* d+d
„|d,Dƒ¡¡| 
d-d d.d
„|d/Dƒ¡¡| |¡q8|jræ|jD]B}| d0¡}d1D]"}t||ƒ}|r´| ||¡q´| |¡q¢|jd2krf| d3¡}| 
dd4¡| d5¡}d6d7d8d9d:d;œ}|  ¡D]&}| d<¡}| 
d=|¡| |¡q*| |¡| |¡|jd2krÚ| d5¡}| 
dd¡| d>¡}| d?¡}| 
dd@¡| d#¡}| |¡| |¡| |¡| |¡|S)Az2
        Return the manifest as DOM tree.
        r§r¨rªr©Úxmlnsz urn:schemas-microsoft-com:asm.v1rFrxcSsg|] }t|ƒ‘qSrryrzrrrr}òsz"Manifest.todom.<locals>.<listcomp>rGrHr­rIr$rJrKrLcSsg|] }t|ƒ‘qSrryrzrrrr}srMNr¯r°r±ÚnorO)Ú    asInvokerZhighestAvailableÚrequireAdministratorr²z urn:schemas-microsoft-com:asm.v3r³r´rPrµrQr¶Úfalser·rDFr¸rºrwcSs g|]}d dd„|Dƒ¡‘qS)rxcSsg|] }t|ƒ‘qSrryrzrrrr}6sz-Manifest.todom.<locals>.<listcomp>.<listcomp>r~rrrrr}6srr»cSsg|] }t|ƒ‘qSrryrzrrrr}8srCr¼r½rBZ compatibilityz*urn:schemas-microsoft-com:compatibility.v1Z applicationz&{e2011457-1546-43c5-a5fe-008deee3d3f0}z&{35138b9a-5d96-4fbd-8e2d-a2440225f93a}z&{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}z&{1f676c76-80e1-4239-95bb-83d0f6d0da78}z&{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a})ÚVistaÚ7Ú8z8.1Ú10Z supportedOSZIdZwindowsSettingsZ longPathAwarez5http://schemas.microsoft.com/SMI/2016/WindowsSettings)!rÚcErEÚaChildÚsetAr:rFrGrHrIÚ setAttributer$rJrKrLrMZ hasAttributesÚunlinkrNrOÚcTrPrQrRrDÚtodomr¾r Ú    cloneNoderSrTr4Úvalues) rÚdocZdocEÚcfgÚwinZaIdZppEZdescEZtEZsEZrpEZrelErBZdEZdaEZadomrr¸ZbrEr¡ZfEÚattrÚvalrÜZcaEZsupportedOS_guidsZguidZsosEZaEZwsEZlpaEZlpaTrrrrâásê 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ÿ 
 
 
 
 
û 
 
 
 
 
 
 
 
 
 
 
zManifest.todomz  úUTF-8cCsD| ¡}| |||¡}| |¡ tj¡ d|d|¡}| ¡|S)z<
        Return the manifest as pretty-printed XML.
        ú#<?xml version="1.0" encoding="%s"?>ú4<?xml version="1.0" encoding="%s" standalone="yes"?>)râÚ toprettyxmlÚdecodeÚstripr!ÚlinesepÚreplacerà)rÚindentÚnewlÚencodingrÅrÑrrrrífsþzManifest.toprettyxmlcCs2| ¡}| |¡ ¡ d|d|¡}| ¡|S)z-
        Return the manifest as XML.
        rërì)rârWrîrñrà)rrôrÅrÑrrrrWusþzManifest.toxmlcCst|| ¡ d¡||ƒdS)zJ
        Update or add manifest resource in dll/exe file dstpath.
        rêN)ÚUpdateManifestResourcesFromXMLríÚencode)rÚdstpathÚnamesrrrrÚupdate_resourcesƒszManifest.update_resourcesc    CsN|s
|j}t|tƒrt|dƒ}| |||¡}|| | ¡¡W5QRXdS©zE
        Write the manifest as XML to a file or file object.
        ÚwbN)r r rXr2ríÚwriterö©rrÎròrórôrÑrrrÚwriteprettyxml‰s
 
zManifest.writeprettyxmlc    CsJ|s
|j}t|tƒrt|dƒ}| |¡}|| | ¡¡W5QRXdSrú)r r rXr2rWrürörýrrrÚwritexml•s
 
 
zManifest.writexml)rBNFFNNNNNNNNNNNN)NFFNNNNNNNNNNNN)rrrNNNN)NN)T)NN)NN)TNN)T)T)T)F)rê)NN)rrrr>rr[r\r^rarbÚ classmethodrgrlrrrŒr¢r•r’r‚rÀrÈrÒr†râr!rðrírWrùrþrÿrrrrrAÉs† ï
,ð
.ø
 
 
    
 
6
t
 
 
0
M
 
 
 

 
 rAcCst|||ƒ}g}|rR|trRt|tƒrR| ¡rRtt| ¡ƒƒ\}}| t    |ƒ¡qt|tƒrht
d|ƒ‚t ƒ}d  |g|¡|_ | |d¡|S)zL
    Create and return manifest instance from resource in dll/exe file.
    z+No matching manifest resource found in '%s'r_F)ÚGetManifestResourcesÚ RT_MANIFESTr ÚdictÚkeysÚnextÚiterÚitemsrrXr?rAr:r rÒ)r rørÚresÚpthÚkeyr rrrr›¢s  
  r›cCstƒ}| |¡|S)z<
    Create and return manifest instance from DOM tree.
    )rArÀ)rÅr rrrrÄ´s
rÄcCstƒ}| |¡|S)z7
    Create and return manifest instance from XML.
    )rArÒ)rÑr rrrÚManifestFromXML½s
r cCstƒ}| |¡|S)z8
    Create and return manifest instance from file.
    )rArÈ)rÎr rrrrƒÆs
rƒcCst |tg||¡S)z+
    Get manifest resources from file.
    )r    Z GetResourcesr)r rørrrrrÏsrcCsHt d|¡| ¡ d¡r d}nd}t ||t|p6|g|p@ddg¡dS)z<
    Update or add manifest XML as resource in dstpath.
    zUpdating manifest in %sú.exerCérrŽN)r8r9r*ršr    ZUpdateResourcesr)r÷rÑrørr$rrrrõÖs
 rõcCsJt d||¡| ¡ d¡r"d}nd}t ||t|p8|g|pBddg¡dS)zI
    Update or add manifest XML from srcpath as resource in dstpath.
    zUpdating manifest from %s in %sr rCr rrŽN)r8r9r*ršr    ZUpdateResourcesFromDataFiler)r÷Úsrcpathrørr$rrrÚ"UpdateManifestResourcesFromXMLFileâs
rFc CsR|s8t|ƒ}tj |¡}tj tj |¡d¡d|_n.t|tƒrTd|krTt|ƒ}nt|t    ƒsft|ƒ}t
dd„|j Dƒƒ}|j |krºt|ƒ}|j D]&}|j|kr’|j   |¡| |j¡q’d|krâ|j   t    ddddtƒd    d
d ¡|rîd |_nd |_|rþd|_tj |¡ }    |    s>t|ƒ ¡ dd¡}
| ¡ dd¡} |
| k}    |    rN| |¡|S)z#
    Create assembly manifest.
    rú<cSsg|]
}|j‘qSr)r$)r{Údeprrrr}ýsz#create_manifest.<locals>.<listcomp>z!Microsoft.Windows.Common-Controlsr©Úwin32rŽ)rnrrrZ6595b64144ccf1df)rErVr$rJrKrLrMrÖrÕTú r)rƒr!r"r#r™r$r rXr rAÚsetrRr rÚaddÚprocessor_architecturerPrQÚexistsrírñrþ) r r ÚconsoleZ    uac_adminZ uac_uiaccessr$Z    dep_namesZ depmanifestrBZneed_newZold_xmlZnew_xmlrrrÚcreate_manifestîsP  
 
 
 
 
 ùÿ 
rcCstjdkrdSdSdS)a
    Detect processor architecture for assembly manifest.
 
    According to:
    http://msdn.microsoft.com/en-us/library/windows/desktop/aa374219(v=vs.85).aspx
    item processorArchitecture in assembly manifest is
 
    'x86' - 32bit Windows
    'amd64' - 64bit Windows
    Ú32bitÚx86Úamd64N)rÚ architecturerrrrr's
rÚ__main__rCr )NN)NN)NN)NN)FF)=r>r(r!rorÉrÚxml.domrrZxml.dom.minidomrrZ PyInstallerrrÚloggingZPyInstaller.utils.win32r    Ú    getLoggerrr8r—r˜rÚ appendChildrÝÚ createElementrÜZcreateTextNoderáZgetElementsByTagNameZgetEByTNÚ getAttributerÁZremoveAttributeZremArßrÞrrr¿rÃrrZ_Filer„r?r@rAr›rÄr rƒrrõrrrÚargvr÷rrrrrÚ<module><sn        
  8^
            
 
 
 
9