当前位置: 首页>>代码示例>>Python>>正文


Python Pkg类代码示例

本文整理汇总了Python中Pkg的典型用法代码示例。如果您正苦于以下问题:Python Pkg类的具体用法?Python Pkg怎么用?Python Pkg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Pkg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_summary

 def check_summary(self, pkg, lang, ignored_words):
     summary = pkg.langtag(rpm.RPMTAG_SUMMARY, lang)
     if use_utf8:
         if not Pkg.is_utf8_bytestr(summary):
             printError(pkg, 'tag-not-utf8', 'Summary', lang)
         summary = Pkg.to_unicode(summary)
     else:
         summary = Pkg.b2s(summary)
     self._unexpanded_macros(pkg, 'Summary(%s)' % lang, summary)
     spell_check(pkg, summary, 'Summary(%s)', lang, ignored_words)
     if '\n' in summary:
         printError(pkg, 'summary-on-multiple-lines', lang)
     if summary[0] != summary[0].upper():
         printWarning(pkg, 'summary-not-capitalized', lang, summary)
     if summary[-1] == '.':
         printWarning(pkg, 'summary-ended-with-dot', lang, summary)
     if len(summary) > max_line_len:
         printError(pkg, 'summary-too-long', lang, summary)
     if leading_space_regex.search(summary):
         printError(pkg, 'summary-has-leading-spaces', lang, summary)
     res = forbidden_words_regex.search(summary)
     if res and Config.getOption('ForbiddenWords'):
         printWarning(pkg, 'summary-use-invalid-word', lang, res.group(1))
     if pkg.name:
         sepchars = '[\s' + punct + ']'
         res = re.search('(?:^|\s)(%s)(?:%s|$)' %
                         (re.escape(pkg.name), sepchars),
                         summary, re.IGNORECASE | re.UNICODE)
         if res:
             printWarning(pkg, 'name-repeated-in-summary', lang,
                          res.group(1))
开发者ID:tomato42,项目名称:rpmlint,代码行数:31,代码来源:TagsCheck.py

示例2: check_syntax_script

def check_syntax_script(prog, commandline, script):
    if not script:
        return False
    # TODO: test that "prog" is available/executable
    tmpfile, tmpname = Pkg.mktemp()
    try:
        tmpfile.write(script)
        tmpfile.close()
        ret = Pkg.getstatusoutput((prog, commandline, tmpname))
    finally:
        tmpfile.close()
        os.remove(tmpname)
    return ret[0]
开发者ID:pvalena,项目名称:rpmlint,代码行数:13,代码来源:PostCheck.py

示例3: check

 def check(self, pkg):
     res = pkg.checkSignature()
     if not res or res[0] != 0:
         if res and res[1]:
             kres = SignatureCheck.unknown_key_regex.search(res[1])
         else:
             kres = None
         if kres:
             printError(pkg, "unknown-key", kres.group(1))
         else:
             Pkg.warn("Error checking signature of %s: %s" %
                      (pkg.filename, res[1]))
     else:
         if not SignatureCheck.pgp_regex.search(res[1]):
             printError(pkg, "no-signature")
开发者ID:jasontibbitts,项目名称:rpmlint,代码行数:15,代码来源:SignatureCheck.py

示例4: check

    def check(self, pkg):

        if pkg.isSource():
            return;

        files = pkg.files()

        for fname, pkgfile in files.items():

            if pkgfile.is_ghost:
                continue

            if fname.startswith('/usr/lib/debug') or \
                    not stat.S_ISREG(pkgfile.mode) or \
                    not pkgfile.magic.startswith('ELF '):
                continue

            ret, output = Pkg.getstatusoutput(['ldd', '-r', '-u',  pkgfile.path])
            for l in output.split('\n'):
                l = l.lstrip()
                if not l.startswith('/'):
                    continue
                lib = l.rsplit('/')[-1]
                if lib in ('libdl.so.2', 'libm.so.6', 'libpthread.so.0'):
                    continue
                printError(pkg, 'elf-binary-unused-dependency', fname, lib)
开发者ID:jsegitz,项目名称:rpmlint-checks,代码行数:26,代码来源:CheckUnusedLibs.py

示例5: check

    def check(self, pkg):

        if pkg.isSource():
            return

        alt_files = set()
        for script in (pkg.header[tag]
                       for tag in (rpm.RPMTAG_POSTIN,
                                   rpm.RPMTAG_PREIN,
                                   rpm.RPMTAG_POSTTRANS)):
            alt_files.update(self.read_ghost_files(Pkg.b2s(script)))

        files = pkg.files()
        ghost_files = pkg.ghostFiles()

        for af in alt_files:
            # /etc/alternatives/$(basename) should be a ghost file
            etc_alt_file = "/etc/alternatives/%s" % os.path.basename(af)

            if etc_alt_file not in files:
                printWarning(pkg,
                             'suse-alternative-link-missing', etc_alt_file)
            elif etc_alt_file not in ghost_files:
                printWarning(pkg,
                             'suse-alternative-link-not-ghost', etc_alt_file)

            # generic-name should be a symlink to /etc/alternatives/$(basename)
            if af not in files:
                printWarning(pkg,
                             'suse-alternative-generic-name-missing', af)
            elif not stat.S_ISLNK(files[af].mode):
                printWarning(pkg,
                             'suse-alternative-generic-name-not-symlink', af)
开发者ID:jsegitz,项目名称:rpmlint-checks,代码行数:33,代码来源:CheckUpdateAlternatives.py

示例6: check_spec

 def check_spec(self, pkg, spec_file):
     """SCL spec file checks"""
     spec = "\n".join(Pkg.readlines(spec_file))
     if global_scl_definition.search(spec):
         self.check_metapackage(pkg, spec)
     elif scl_package_definition.search(spec):
         self.check_scl_spec(pkg, spec)
     elif scl_use.search(spec):
         printError(pkg, "undeclared-scl")
开发者ID:jasontibbitts,项目名称:rpmlint,代码行数:9,代码来源:SCLCheck.py

示例7: test_parse_deps

 def test_parse_deps(self):
     for (arg, exp) in (
         ("a, b < 1.0 c = 5:2.0-3 d",
          [("a", 0, (None, None, None)),
           ("b", rpm.RPMSENSE_LESS, (None, "1.0", None)),
           ("c", rpm.RPMSENSE_EQUAL, ("5", "2.0", "3")),
           ("d", 0, (None, None, None))]),
     ):
         self.assertEqual(Pkg.parse_deps(arg), exp)
开发者ID:pombreda,项目名称:git-git.code.sf.net-p-rpmlint-code,代码行数:9,代码来源:test.Pkg.py

示例8: check_file

 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)
开发者ID:openSUSE,项目名称:rpmlint-checks,代码行数:9,代码来源:ErlangCheck.py

示例9: check_spec

 def check_spec(self, pkg, spec_file, spec_lines=[]):
     '''SCL spec file checks'''
     spec = '\n'.join(Pkg.readlines(spec_file))
     if global_scl_definition.search(spec):
         self.check_metapackage(pkg, spec)
     elif scl_package_definition.search(spec):
         self.check_scl_spec(pkg, spec)
     elif scl_use.search(spec):
         printError(pkg, 'undeclared-scl')
开发者ID:pombreda,项目名称:git-git.code.sf.net-p-rpmlint-code,代码行数:9,代码来源:SCLCheck.py

示例10: check_description

 def check_description(self, pkg, lang, ignored_words):
     description = pkg.langtag(rpm.RPMTAG_DESCRIPTION, lang)
     self._unexpanded_macros(pkg, '%%description -l %s' % lang, description)
     utf8desc = description
     if use_utf8:
         utf8desc = Pkg.to_utf8(description).decode('utf-8')
     spell_check(pkg, utf8desc, '%%description -l %s', lang, ignored_words)
     for l in utf8desc.splitlines():
         if len(l) > max_line_len:
             printError(pkg, 'description-line-too-long', lang, l)
         res = forbidden_words_regex.search(l)
         if res and Config.getOption('ForbiddenWords'):
             printWarning(pkg, 'description-use-invalid-word', lang,
                          res.group(1))
         res = tag_regex.search(l)
         if res:
             printWarning(pkg, 'tag-in-description', lang, res.group(1))
     if use_utf8 and not Pkg.is_utf8_str(description):
         printError(pkg, 'tag-not-utf8', '%description', lang)
开发者ID:pombreda,项目名称:git-git.code.sf.net-p-rpmlint-code,代码行数:19,代码来源:TagsCheck.py

示例11: check_file

 def check_file(self, pkg, filename):
     try:
         f = open(filename)
     except:
         return
     try:
         first_line = f.read(256).split("\n")[0]
         if self.RE_BIN_SH.match(first_line):
             status, output = Pkg.getstatusoutput(["dash", "-n", filename])
             if status == 2:
                 printWarning(pkg, "bin-sh-syntax-error", filename)
             try:
                 status, output = Pkg.getstatusoutput(["checkbashisms", filename])
                 if status == 1:
                     printInfo(pkg, "potential-bashisms", filename)
             except Exception as x:
                 printError(pkg, 'rpmlint-exception', "%(file)s raised an exception: %(x)s" % {'file':filename, 'x':x})
     finally:
         f.close()
开发者ID:StefanBruens,项目名称:rpmlint-checks,代码行数:19,代码来源:BashismsCheck.py

示例12: check

    def check(self, pkg):
        # Check only binary package
        if pkg.isSource():
            return

        initscript_list = []
        for fname, pkgfile in pkg.files().items():

            if not fname.startswith('/etc/init.d/') and \
                    not fname.startswith('/etc/rc.d/init.d/'):
                continue

            basename = os.path.basename(fname)
            initscript_list.append(basename)
            if pkgfile.mode & 0500 != 0500:
                printError(pkg, 'init-script-non-executable', fname)

            if "." in basename:
                printError(pkg, 'init-script-name-with-dot', fname)

            # check chkconfig call in %post and %preun
            postin = pkg[rpm.RPMTAG_POSTIN] or \
                pkg.scriptprog(rpm.RPMTAG_POSTINPROG)
            if not postin:
                printError(pkg, 'init-script-without-chkconfig-postin', fname)
            elif not chkconfig_regex.search(postin):
                printError(pkg, 'postin-without-chkconfig', fname)

            preun = pkg[rpm.RPMTAG_PREUN] or \
                pkg.scriptprog(rpm.RPMTAG_PREUNPROG)
            if not preun:
                printError(pkg, 'init-script-without-chkconfig-preun', fname)
            elif not chkconfig_regex.search(preun):
                printError(pkg, 'preun-without-chkconfig', fname)

            status_found = False
            reload_found = False
            chkconfig_content_found = False
            subsys_regex_found = False
            in_lsb_tag = False
            in_lsb_description = False
            lastline = ''
            lsb_tags = {}
            # check common error in file content
            content = None
            try:
                content = Pkg.readlines(pkgfile.path)
            except Exception, e:
                printWarning(pkg, 'read-error', e)
                continue
开发者ID:matwey,项目名称:rpmlint,代码行数:50,代码来源:InitScriptCheck.py

示例13: check_syntax_script

def check_syntax_script(prog, commandline, script):
    if not script:
        return False
    # TODO: test that "prog" is available/executable
    tmpfd, tmpname = tempfile.mkstemp(prefix='rpmlint.')
    tmpfile = os.fdopen(tmpfd, 'wb')
    try:
        tmpfile.write(script)
        tmpfile.close()
        ret = Pkg.getstatusoutput((prog, commandline, tmpname))
    finally:
        tmpfile.close()
        os.remove(tmpname)
    return ret[0]
开发者ID:c72578,项目名称:rpmlint,代码行数:14,代码来源:PostCheck.py

示例14: check

    def check(self, pkg):
        for fname, pkgfile in pkg.files().items():
            path = pkgfile.path
            if zip_regex.search(fname) and os.path.exists(path) and \
               stat.S_ISREG(os.lstat(path)[stat.ST_MODE]) and \
               zipfile.is_zipfile(path):
                z = None  # TODO ZipFile is context manager in 2.7+
                try:
                    z = zipfile.ZipFile(path, 'r')
                    badcrc = z.testzip()
                    if badcrc:
                        printError(pkg, 'bad-crc-in-zip', badcrc, fname)
                except zipfile.error:
                    printWarning(pkg, 'unable-to-read-zip', '%s: %s' %
                                 (fname, sys.exc_info()[1]))
                else:
                    compressed = False
                    for zinfo in z.infolist():
                        if zinfo.compress_type != zipfile.ZIP_STORED:
                            compressed = True
                            break
                    if not compressed:
                        printWarning(pkg, 'uncompressed-zip', fname)

                    # additional jar checks
                    if jar_regex.search(fname):
                        try:
                            mf = Pkg.b2s(z.read('META-INF/MANIFEST.MF'))
                            if classpath_regex.search(mf):
                                printWarning(pkg,
                                             'class-path-in-manifest', fname)
                        except KeyError:
                            # META-INF/* are optional:
                            # http://java.sun.com/j2se/1.4/docs/guide/jar/jar.html
                            pass
                        try:
                            zinfo = z.getinfo('META-INF/INDEX.LIST')
                            if not want_indexed_jars:
                                printWarning(pkg, 'jar-indexed', fname)
                        except KeyError:
                            if want_indexed_jars:
                                printWarning(pkg, 'jar-not-indexed', fname)
                            pass

                z and z.close()
开发者ID:c72578,项目名称:rpmlint,代码行数:45,代码来源:ZipCheck.py

示例15: ExecutableMenuFile

             if mode & 0111 != 0:
                 yield ExecutableMenuFile(pkg, f)
             menus.append(f)
     else:
         # Check old menus from KDE and GNOME
         res=old_menu_file_regex.search(f)
         if res:
             mode=files[f][0]
             if stat.S_ISREG(mode):
                 yield OldMenuEntry(pkg, f)
         else:
             # Check non transparent xpm files
             res=xpm_ext_regex.search(f)
             if res:
                 mode=files[f][0]
                 if stat.S_ISREG(mode) and not Pkg.grep('None",', dirname + '/' + f):
                     yield NonTransparentXpm(pkg, f)
 if len(menus) > 0:
     dir=pkg.dirName()
     if menus != []:
         postin=pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
         if not postin:
             yield MenuWithoutPostin(pkg)
         else:
             if not update_menus_regex.search(postin):
                 yield PostinWithoutUpdateMenus(pkg)                    
             
         postun=pkg[rpm.RPMTAG_POSTUN] or pkg[rpm.RPMTAG_POSTUNPROG]
         if not postun:
             yield MenuWithoutPostun(pkg)
         else:
开发者ID:bhdn,项目名称:scrutiny,代码行数:31,代码来源:MenuCheck.py


注:本文中的Pkg类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。