本文整理汇总了Python中daklib.config.Config.find_i方法的典型用法代码示例。如果您正苦于以下问题:Python Config.find_i方法的具体用法?Python Config.find_i怎么用?Python Config.find_i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类daklib.config.Config
的用法示例。
在下文中一共展示了Config.find_i方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: from daklib.config import Config [as 别名]
# 或者: from daklib.config.Config import find_i [as 别名]
def check(self, upload):
cnf = Config()
future_cutoff = time.time() + cnf.find_i('Dinstall::FutureTimeTravelGrace', 24*3600)
past_cutoff = time.mktime(time.strptime(cnf.find('Dinstall::PastCutoffYear', '1975'), '%Y'))
class TarTime(object):
def __init__(self):
self.future_files = dict()
self.past_files = dict()
def callback(self, member, data):
if member.mtime > future_cutoff:
self.future_files[member.name] = member.mtime
elif member.mtime < past_cutoff:
self.past_files[member.name] = member.mtime
def format_reason(filename, direction, files):
reason = "{0}: has {1} file(s) with a timestamp too far in the {2}:\n".format(filename, len(files), direction)
for fn, ts in files.iteritems():
reason += " {0} ({1})".format(fn, time.ctime(ts))
return reason
for binary in upload.changes.binaries:
filename = binary.hashed_file.filename
path = os.path.join(upload.directory, filename)
deb = apt_inst.DebFile(path)
tar = TarTime()
deb.control.go(tar.callback)
if tar.future_files:
raise Reject(format_reason(filename, 'future', tar.future_files))
if tar.past_files:
raise Reject(format_reason(filename, 'past', tar.past_files))