home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 116
/
FreelogNo116-JuilletSeptembre2013.iso
/
Bureautique
/
gImageReader
/
gimagereader_0.9-1_win32.exe
/
bin
/
py2exe
/
resources
/
VersionInfo.pyc
(
.txt
)
< prev
Wrap
Python Compiled Bytecode
|
2011-03-24
|
9KB
|
217 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
import struct
VOS_NT_WINDOWS32 = 262148
VFT_APP = 1
RT_VERSION = 16
class VersionError(Exception):
pass
def w32_uc(text):
'''convert a string into unicode, then encode it into UTF-16
little endian, ready to use for win32 apis'''
if type(text) is str:
return unicode(text, 'unicode-escape').encode('utf-16-le')
return None(text).encode('utf-16-le')
class VS_FIXEDFILEINFO:
dwSignature = 0xFEEF04BDL
dwStrucVersion = 65536
dwFileVersionMS = 65536
dwFileVersionLS = 1
dwProductVersionMS = 65536
dwProductVersionLS = 1
dwFileFlagsMask = 63
dwFileFlags = 0
dwFileOS = VOS_NT_WINDOWS32
dwFileType = VFT_APP
dwFileSubtype = 0
dwFileDateMS = 0
dwFileDateLS = 0
fmt = '13L'
def __init__(self, version):
import string as string
version = string.replace(version, ',', '.')
fields = string.split(version + '.0.0.0.0', '.')[:4]
fields = map(string.strip, fields)
try:
self.dwFileVersionMS = int(fields[0]) * 65536 + int(fields[1])
self.dwFileVersionLS = int(fields[2]) * 65536 + int(fields[3])
except ValueError:
raise VersionError, "could not parse version number '%s'" % version
def __str__(self):
return struct.pack(self.fmt, self.dwSignature, self.dwStrucVersion, self.dwFileVersionMS, self.dwFileVersionLS, self.dwProductVersionMS, self.dwProductVersionLS, self.dwFileFlagsMask, self.dwFileFlags, self.dwFileOS, self.dwFileType, self.dwFileSubtype, self.dwFileDateMS, self.dwFileDateLS)
def align(data):
pad = -len(data) % 4
return data + '\x00' * pad
class VS_STRUCT:
items = ()
def __str__(self):
szKey = w32_uc(self.name)
ulen = len(szKey) + 2
value = self.get_value()
data = struct.pack('h%ss0i' % ulen, self.wType, szKey) + value
data = align(data)
for item in self.items:
data = data + str(item)
wLength = len(data) + 4
wValueLength = len(value)
return self.pack('hh', wLength, wValueLength, data)
def pack(self, fmt, len, vlen, data):
return struct.pack(fmt, len, vlen) + data
def get_value(self):
return ''
class String(VS_STRUCT):
wType = 1
items = ()
def __init__(self, .1):
(name, value) = .1
self.name = name
if value:
self.value = value + '\x00'
else:
self.value = value
def pack(self, fmt, len, vlen, data):
return struct.pack(fmt, len, vlen / 2) + data
def get_value(self):
return w32_uc(self.value)
class StringTable(VS_STRUCT):
wType = 1
def __init__(self, name, strings):
self.name = name
self.items = map(String, strings)
class StringFileInfo(VS_STRUCT):
wType = 1
name = 'StringFileInfo'
def __init__(self, name, strings):
self.items = [
StringTable(name, strings)]
class Var(VS_STRUCT):
wType = 0
name = 'Translation'
def __init__(self, value):
self.value = value
def get_value(self):
return struct.pack('l', self.value)
class VarFileInfo(VS_STRUCT):
wType = 1
name = 'VarFileInfo'
def __init__(self, *names):
self.items = map(Var, names)
def get_value(self):
return ''
class VS_VERSIONINFO(VS_STRUCT):
wType = 0
name = 'VS_VERSION_INFO'
def __init__(self, version, items):
self.value = VS_FIXEDFILEINFO(version)
self.items = items
def get_value(self):
return str(self.value)
class Version(object):
def __init__(self, version, comments = None, company_name = None, file_description = None, internal_name = None, legal_copyright = None, legal_trademarks = None, original_filename = None, private_build = None, product_name = None, product_version = None, special_build = None):
self.version = version
strings = []
if comments is not None:
strings.append(('Comments', comments))
if company_name is not None:
strings.append(('CompanyName', company_name))
if file_description is not None:
strings.append(('FileDescription', file_description))
strings.append(('FileVersion', version))
if internal_name is not None:
strings.append(('InternalName', internal_name))
if legal_copyright is not None:
strings.append(('LegalCopyright', legal_copyright))
if legal_trademarks is not None:
strings.append(('LegalTrademarks', legal_trademarks))
if original_filename is not None:
strings.append(('OriginalFilename', original_filename))
if private_build is not None:
strings.append(('PrivateBuild', private_build))
None((strings.append, 'ProductVersion' if product_name is not None else version))
if special_build is not None:
strings.append(('SpecialBuild', special_build))
self.strings = strings
def resource_bytes(self):
vs = VS_VERSIONINFO(self.version, [
StringFileInfo('040904B0', self.strings),
VarFileInfo(78644233)])
return str(vs)
def test():
import sys as sys
sys.path.append('c:/tmp')
hexdump = hexdump
import hexdump
version = Version('1, 0, 0, 1', comments = '\xfcml\xe4ut comments', company_name = 'No Company', file_description = 'silly application', internal_name = 'silly', legal_copyright = u'Copyright \xc2\xa9 2003', original_filename = 'silly.exe', private_build = 'test build', product_name = 'silly product', product_version = None)
hexdump(version.resource_bytes())
if __name__ == '__main__':
import sys
sys.path.append('d:/nbalt/tmp')
from hexdump import hexdump
test()