a oe @sdZddlZddlZddlZddlZddlZddlmZmZm Z dZ dZ dZ dZ dd Zd d Zd d ZdNddZddZdOddZddZddZddZddZddZd d!ZdPd"d#Zd$d%Zed&krejd'ed(Zej d)d*d+d,d-d.d/ej d0d1d2d3d4ej d0d5d6d7ej d0d8d9d7ej d0d:d;d7ej d0dd?d7ej d0d@dAd7ej d0dBdCd7ej d0dDdEdFdGej d0dHdIdJdGej d0dKdLd7e!\Z"Z#e#se$dMe#D]"Z%ee%D]Z&ee&e"qڐqdS)Qz0 Stamp a Win32 binary with version information. N)BeginUpdateResourceEndUpdateResourceUpdateResourceii?iasciicCs |rdSdS)Nr)debugr r 8C:\Program Files\Certbot\pkgs\win32\lib\win32verstamp.py file_flagssr cCs |rdSdS)Nr )is_dllr r r file_typesrrcCsLtdtt|d>|B|d>|B|d>|B|d>|Btt|tt|dddS)NZ lllllllllllllr)structpackVS_FFI_SIGNATUREVS_FFI_STRUCVERSIONVS_FFI_FILEFLAGSMASKr VOS_NT_WINDOWS32r)majminsubbuildr rr r r VS_FIXEDFILEINFO#s     rcCs:tjdddkr$t|ddSt|ddSdS)Nr )rrzunicode-internalzutf-16le)sys version_infostrencodesr r r nullterm6sr$r cCs,dt||d@}|dkr(|t|S|S)Nr)len null_byte)r#Zextralr r r pad32>s r)cCstdt|d|S)Nhr )rrr&r"r r r addlenFsr+cCsBt|}t|}tdt|dd}||}t||}t|S)Nhhr r)r$rrr&r)r+keyvalueresultr r r StringJs  r1cCsNt|}tddd}||}|D]\}}|t||}t|}q&t|S)Nr,rr)r$rritemsr1r)r+)r.datar0kvr r r StringTableSs r6cCs4tddd}|td}t|td|}t|S)Nr,rrStringFileInfoZ040904E4)rrr$r)r6r+)r3r0r r r r7]s r7cCs2tdt|d}|t|}t||}t|S)Nr,r)rrr&r$r)r+r-r r r Vares  r8cCsJtddd}|td}t|}|D]\}}|t||}q*t|S)Nr,rr VarFileInfo)rrr$r)r2r8r+)r3r0r4r5r r r r9ls  r9c Cs\t||||||}tdt|d} | td} t| |} t| t|t|} t| S)Nr,rVS_VERSION_INFO) rrrr&r$r)r7r9r+) rrrrsdatavdatar rZffir0r r r r:us   r:c Cszt|d}|Wn4tyJ}ztd||fWYd}~n d}~00|j}z$dd|dD}|\}}}} Wn$tttfytd|Yn0|j } | st j |} |j } | durt j |} |j|j|j|| |j|j| |j|d } dtd d d i} |j}|dur0t j |d d v}|j}|durZt j |dd}t| D]\}}|durfd| |<qft|||| | | ||}t|d}t|dd |t |d|j!rtd|dS)Nza+bz)WARNING: File %s could not be opened - %scSsg|] }t|qSr )int).0ir r r zstamp...z1--version must be a.b.c.d (all integers) - got %r) ZCommentsZ CompanyNameZFileDescriptionZ FileVersionZ InternalNameZLegalCopyrightZLegalTrademarksZOriginalFilenameZ ProductNameZProductVersionZ Translationr,i irz .dll .pydrZ_drzStamped:)"opencloseIOErrorprintversionsplit IndexError TypeError ValueErrorZ internal_nameospathbasenameZoriginal_filenameZcommentsZcompany description copyrightZ trademarksproductrrZdllsplitextlowerr endswithlistr2r:rrrverbose)pathnameoptionsfwhyZverbitsZvmajZvminZvsubZvbuildZifnZofnr;r<rZis_debugr4r5Zvsr*r r r stamp~sZ  &         r]__main__z%prog [options] filespec ...)rPz-qz--quiet store_falserWTz%don't print status messages to stdout)actiondestdefaulthelprCz --versionz0.0.0.0zThe version number as m.n.s.b)rbrcz--dllzpStamp the file as a DLL. Default is to look at the file extension for .dll or .pyd.)rcz--debugz!Stamp the file as a debug binary.z --productzThe product name to embed.z --companyzThe company name to embed.z --trademarkszThe trademark string to embed.z --commentszThe comments string to embed.z --copyrightz&The copyright message string to embed.z --descriptionZDESCzThe description to embed.)metavarrcz--internal-nameNAMEzdThe internal filename to embed. If not specified the base filename is used.z--original-filenamezgThe original filename to embed. If not specified the base filename is used.z9You must supply a file to stamp. Use --help for details.)rr)r )rr)'__doc__globZoptparserMrrZwin32apirrrrrrrr!r'r rrr$r)r+r1r6r7r8r9r:r]__name__Z OptionParserparserZ add_option parse_argsrYargserrorgrZr r r r s      ;