本文整理汇总了Python中waflib.Utils.md5方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.md5方法的具体用法?Python Utils.md5怎么用?Python Utils.md5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Utils
的用法示例。
在下文中一共展示了Utils.md5方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signature
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def signature(self):
# compute the result one time, and suppose the scan_signature will give the good result
try: return self.cache_sig
except AttributeError: pass
self.m = Utils.md5()
self.m.update(self.hcode)
id_sig = self.m.digest()
# explicit deps
self.m = Utils.md5()
self.sig_explicit_deps()
exp_sig = self.m.digest()
# env vars
self.m = Utils.md5()
self.sig_vars()
var_sig = self.m.digest()
# implicit deps / scanner results
self.m = Utils.md5()
if self.scan:
try:
self.sig_implicit_deps()
except Errors.TaskRescan:
return self.signature()
impl_sig = self.m.digest()
ret = self.cache_sig = impl_sig + id_sig + exp_sig + var_sig
return ret
示例2: h_file
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def h_file(filename):
"""now folders can have a signature too"""
st = os.stat(filename)
if stat.S_ISDIR(st[stat.ST_MODE]):
return Utils.md5(filename).digest()
m = Utils.md5()
m.update(str(st.st_mtime))
m.update(str(st.st_size))
m.update(filename)
return m.digest()
示例3: h_file
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def h_file(filename):
st = os.stat(filename)
if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
if filename in Build.hashes_md5_tstamp:
if Build.hashes_md5_tstamp[filename][0] == str(st.st_mtime):
return Build.hashes_md5_tstamp[filename][1]
m = Utils.md5()
if STRONGEST:
f = open(filename, 'rb')
read = 1
try:
while read:
read = f.read(100000)
m.update(read)
finally:
f.close()
else:
m.update(str(st.st_mtime))
m.update(str(st.st_size))
m.update(filename)
# ensure that the cache is overwritten
Build.hashes_md5_tstamp[filename] = (str(st.st_mtime), m.digest())
return m.digest()
示例4: hash_env_vars
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def hash_env_vars(self, env, vars_lst):
if not env.table:
env = env.parent
if not env:
return Utils.SIG_NIL
idx = str(id(env)) + str(vars_lst)
try:
cache = self.cache_env
except AttributeError:
cache = self.cache_env = {}
else:
try:
return self.cache_env[idx]
except KeyError:
pass
v = str([env[a] for a in vars_lst])
v = v.replace(self.srcnode.abspath().__repr__()[:-1], '')
m = Utils.md5()
m.update(v.encode())
ret = m.digest()
Logs.debug('envhash: %r %r', ret, v)
cache[idx] = ret
return ret
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:30,代码来源:netcache_client.py
示例5: hash_env_vars
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def hash_env_vars(self, env, vars_lst):
# reimplement so that the resulting hash does not depend on local paths
if not env.table:
env = env.parent
if not env:
return Utils.SIG_NIL
idx = str(id(env)) + str(vars_lst)
try:
cache = self.cache_env
except AttributeError:
cache = self.cache_env = {}
else:
try:
return self.cache_env[idx]
except KeyError:
pass
v = str([env[a] for a in vars_lst])
v = v.replace(self.srcnode.abspath().__repr__()[:-1], "")
m = Utils.md5()
m.update(v.encode())
ret = m.digest()
Logs.debug("envhash: %r %r", ret, v)
cache[idx] = ret
return ret
示例6: uid
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def uid(self):
"""
Returns an identifier used to determine if tasks are up-to-date. Since the
identifier will be stored between executions, it must be:
- unique for a task: no two tasks return the same value (for a given build context)
- the same for a given task instance
By default, the node paths, the class name, and the function are used
as inputs to compute a hash.
The pointer to the object (python built-in 'id') will change between build executions,
and must be avoided in such hashes.
:return: hash value
:rtype: string
"""
try:
return self.uid_
except AttributeError:
m = Utils.md5(self.__class__.__name__)
up = m.update
for x in self.inputs + self.outputs:
up(x.abspath())
self.uid_ = m.digest()
return self.uid_
示例7: signature
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def signature(self):
"""
Task signatures are stored between build executions, they are use to track the changes
made to the input nodes (not to the outputs!). The signature hashes data from various sources:
* files listed in the inputs (list of node objects)
* list of nodes returned by scanner methods (when present)
* variables/values read from task.__class__.vars/task.env
if the signature is expected to give a different result, clear the result stored in self.cache_sig
"""
try: return self.cache_sig
except AttributeError: pass
self.m = Utils.md5()
self.m.update(self.hcode.encode())
# explicit deps
self.sig_explicit_deps()
# env vars
self.sig_vars()
# implicit deps / scanner results
if self.scan:
try:
imp_sig = self.sig_implicit_deps()
except Errors.TaskRescan:
return self.signature()
ret = self.cache_sig = self.m.digest()
return ret
示例8: cached_hash_file
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def cached_hash_file(self):
try:
cache = self.ctx.cache_listdir_cache_hash_file
except AttributeError:
cache = self.ctx.cache_listdir_cache_hash_file = {}
if id(self.parent) in cache:
try:
t = cache[id(self.parent)][self.name]
except KeyError:
raise IOError('Not a file')
else:
# an opportunity to list the files and the timestamps at once
findData = ctypes.wintypes.WIN32_FIND_DATAW()
find = FindFirstFile(TP % self.parent.abspath(), ctypes.byref(findData))
if find == INVALID_HANDLE_VALUE:
cache[id(self.parent)] = {}
raise IOError('Not a file')
cache[id(self.parent)] = lst_files = {}
try:
while True:
if findData.cFileName not in UPPER_FOLDERS:
thatsadir = findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
if not thatsadir:
ts = findData.ftLastWriteTime
d = (ts.dwLowDateTime << 32) | ts.dwHighDateTime
lst_files[str(findData.cFileName)] = d
if not FindNextFile(find, ctypes.byref(findData)):
break
except Exception:
cache[id(self.parent)] = {}
raise IOError('Not a file')
finally:
FindClose(find)
t = lst_files[self.name]
fname = self.abspath()
if fname in Build.hashes_md5_tstamp:
if Build.hashes_md5_tstamp[fname][0] == t:
return Build.hashes_md5_tstamp[fname][1]
try:
fd = os.open(fname, os.O_BINARY | os.O_RDONLY | os.O_NOINHERIT)
except OSError:
raise IOError('Cannot read from %r' % fname)
f = os.fdopen(fd, 'rb')
m = Utils.md5()
rb = 1
try:
while rb:
rb = f.read(200000)
m.update(rb)
finally:
f.close()
# ensure that the cache is overwritten
Build.hashes_md5_tstamp[fname] = (t, m.digest())
return m.digest()
示例9: uid
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def uid(self):
if not hasattr(self, 'uid_'):
m = Utils.md5()
m.update(self.__class__.__name__)
m.update(self.env.get_flat('SUBMODULE_PATH'))
self.uid_ = m.digest()
return self.uid_
示例10: uid
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def uid(self):
try:
return self.uid_
except AttributeError:
m=Utils.md5(self.__class__.__name__)
up=m.update
for x in self.inputs+self.outputs:
up(x.abspath())
self.uid_=m.digest()
return self.uid_
示例11: uid
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def uid(self):
if not hasattr(self, 'uid_'):
m = Utils.md5()
def u(s):
m.update(s.encode('utf-8'))
u(self.__class__.__name__)
u(self.env.get_flat('CMAKE_BLD_DIR'))
u(self.env.get_flat('CMAKE_TARGET'))
self.uid_ = m.digest()
return self.uid_
示例12: config_sig
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def config_sig(self):
m = Utils.md5()
def u(s):
m.update(s.encode('utf-8'))
u(self.srcnode.abspath())
u(self.bldnode.abspath())
keys = self.vars_keys()
for k in keys:
u(k)
u(self.vars[k])
return m.digest()
示例13: uid
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def uid(self):
try:
return self.uid_
except AttributeError:
m=Utils.md5()
up=m.update
up(self.__class__.__name__.encode('iso8859-1'))
for x in self.inputs+self.outputs:
up(x.abspath().encode('iso8859-1'))
self.uid_=m.digest()
return self.uid_
示例14: uid
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def uid(self):
try:
return self.uid_
except AttributeError:
m = Utils.md5()
src = self.generator.bld.srcnode
up = m.update
up(self.__class__.__name__.encode())
for x in self.inputs + self.outputs:
up(x.path_from(src).encode())
self.uid_ = m.digest()
return self.uid_
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:14,代码来源:netcache_client.py
示例15: uid
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import md5 [as 别名]
def uid(self):
try:
return self.uid_
except AttributeError:
# this is not a real hot zone, but we want to avoid surprises here
m = Utils.md5()
up = m.update
up(self.__class__.__name__.encode())
for x in self.inputs + self.outputs:
up(x.path_from(x.ctx.srcnode).encode())
self.uid_ = m.digest()
return self.uid_