本文整理汇总了Python中Filter.printWarning方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.printWarning方法的具体用法?Python Filter.printWarning怎么用?Python Filter.printWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter.printWarning方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_file
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def check_file(self, pkg, filename):
beam = BeamFile(pkg.files()[filename].path)
if 'debug_info' not in beam.compileinfo['options']:
Filter.printWarning(
pkg, "beam-compiled-without-debug_info", filename)
if not self.source_re.match(Pkg.b2s(beam.compileinfo['source'].value)):
Filter.printWarning(
pkg, "beam-was-not-recompiled", filename,
beam.compileinfo['source'].value)
示例2: check
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def check(self, pkg):
if pkg.isSource():
return
md5s = {}
sizes = {}
files = pkg.files()
configFiles = pkg.configFiles()
for f, pkgfile in files.items():
if f in pkg.ghostFiles():
continue
if not stat.S_ISREG(pkgfile.mode):
continue
md5s.setdefault(pkgfile.md5, set()).add(f)
sizes[pkgfile.md5] = pkgfile.size
sum = 0
for f in md5s:
duplicates = md5s[f]
if len(duplicates) == 1:
continue
one = duplicates.pop()
one_is_config = False
if one in configFiles:
one_is_config = True
partition = get_prefix(one)
st = os.stat(pkg.dirName() + '/' + one)
diff = 1 + len(duplicates) - st[stat.ST_NLINK]
if diff <= 0:
for dupe in duplicates:
if partition != get_prefix(dupe):
Filter.printError(pkg, "hardlink-across-partition",
one, dupe)
if one_is_config and dupe in configFiles:
Filter.printError(pkg, "hardlink-across-config-files",
one, dupe)
continue
for dupe in duplicates:
if partition != get_prefix(dupe):
diff = diff - 1
sum += sizes[f] * diff
if sizes[f] and diff > 0:
Filter.printWarning(pkg, 'files-duplicate', one,
":".join(duplicates))
if sum > 100000:
Filter.printError(pkg, 'files-duplicated-waste', sum)
示例3: grep
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def grep(self, regex, filename):
"""Grep regex from a file, return matching line numbers."""
ret = []
lineno = 0
try:
with open(os.path.join(
self.dirName() or '/', filename.lstrip('/'))) as in_file:
for line in in_file:
lineno += 1
if regex.search(line):
ret.append(str(lineno))
break
except Exception as e:
Filter.printWarning(self, 'read-error', filename, e)
return ret
示例4: check_file
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def check_file(self, pkg, filename):
if filename.startswith('/usr/lib/debug') or pkg.isSource():
return
if not stat.S_ISREG(pkg.files()[filename].mode):
return
grep_date = pkg.grep(self.istoday, filename)
if len(grep_date):
grep_time = pkg.grep(self.looksliketime, filename)
if len(grep_time):
Filter.printError(pkg, "file-contains-date-and-time", filename)
else:
Filter.printWarning(pkg, "file-contains-current-date",
filename)
示例5: check
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def check(self, pkg):
if pkg.isSource():
return
files = pkg.files()
complete_size = 0
lang_size = 0
for f, pkgfile in files.items():
if stat.S_ISREG(pkgfile.mode):
complete_size += pkgfile.size
if pkgfile.lang != '':
lang_size += pkgfile.size
doc_size = 0
for f in pkg.docFiles():
if stat.S_ISREG(files[f].mode):
doc_size += files[f].size
if doc_size * 2 >= complete_size and \
doc_size > 100 * 1024 and \
(complete_size - doc_size) * 20 > complete_size and \
not ignore_pkg(pkg.name):
Filter.printWarning(pkg, "package-with-huge-docs",
("%3d%%" % (doc_size * 100 / complete_size)))
if lang_size * 2 >= complete_size \
and lang_size > 100 * 1024 and \
(complete_size - lang_size) * 20 > complete_size and \
not lang_ignore_pkg(pkg.name):
Filter.printWarning(pkg, "package-with-huge-translation",
("%3d%%" % (lang_size * 100 / complete_size)))
for f in pkg.docFiles():
mode = files[f].mode
if not stat.S_ISREG(mode) or not mode & 0o111:
continue
for ext in ['txt', 'gif', 'jpg', 'html',
'pdf', 'ps', 'pdf.gz', 'ps.gz']:
if f.endswith("." + ext):
Filter.printError(pkg, 'executable-docs', f)
for name in ['README', 'NEWS', 'COPYING', 'AUTHORS']:
if f.endswith("/" + name):
Filter.printError(pkg, 'executable-docs', f)
示例6: grep
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def grep(self, regex, filename):
"""Grep regex from a file, return matching line numbers."""
ret = []
lineno = 0
in_file = None
try:
try:
in_file = open(self.dirName() + '/' + filename)
for line in in_file:
lineno += 1
if regex.search(line):
ret.append(str(lineno))
break
except Exception, e:
Filter.printWarning(self, 'read-error', filename, e)
finally:
if in_file:
in_file.close()
return ret
示例7: grep
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def grep(self, regex, filename):
"""Grep regex from a file, return matching line numbers."""
ret = []
lineno = 0
in_file = None
try:
try:
in_file = open(os.path.join(
self.dirName() or '/', filename.lstrip('/')))
for line in in_file:
lineno += 1
if regex.search(line):
ret.append(str(lineno))
break
except Exception:
Filter.printWarning(self, 'read-error', filename,
sys.exc_info()[1])
finally:
if in_file:
in_file.close()
return ret
示例8: check
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import printWarning [as 别名]
def check(self, pkg):
if pkg.isSource():
return
files = pkg.files()
for f in files:
if f in pkg.ghostFiles():
continue
md5 = files[f].md5
if len(md5) and md5 in (
'c59cbaf0df9bcf35feca0d0f1fc01dae',
'cf8c4d1a5ab88db006c47ae2b51a6b30',
'5d4638159851671944108691f23e4f28',
'0d6be33865b76025c20b48bcac87adb7'):
Filter.printError(pkg, "generic-build-instructions", f)
# bnc 379919
# if len(md5) and md5 in (
# '94d55d512a9ba36caa9b7df079bae19f'):
# printError(pkg, "duplicated-file-gpl-v2", f)
# if len(md5) and md5 in (
# 'd32239bcb673463ab874e80d47fae504'):
# printError(pkg, "duplicated-file-gpl-v3", f)
# bsd causes the false positive COPYING.BSD
if (len(md5) and f.rsplit('/', 1)[1][0].lower() == 'r' and
f.rsplit('.', 1)[-1].lower() in (
'aix', 'bsd', 'dos', 'hpux', 'irix', 'os2', 'mac', 'macos',
'tru64', 'sco', 'vms', 'win32', 'win', 'solaris')):
Filter.printWarning(pkg, "non-linux-readme", f)
if (f.endswith("/Makefile.am") and f[:-3] + ".in" in files and
f in pkg.docFiles()):
if not len(pkg.grep(self.sources_am_re, f)):
Filter.printError(pkg, "makefile-junk", f)
Filter.printError(pkg, "makefile-junk", f[:-3] + ".in")
if f[:-3] in files:
Filter.printError(pkg, "makefile-junk", f[:-3])