From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/ebuilds/
Date: Sat, 5 Sep 2015 21:48:07 +0000 (UTC) [thread overview]
Message-ID: <1441489656.6bd98ee4b60bb581cf535f666dbde4bf1fe6fce5.dolsen@gentoo> (raw)
commit: 6bd98ee4b60bb581cf535f666dbde4bf1fe6fce5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 3 19:20:43 2014 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Sep 5 21:47:36 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6bd98ee4
Repoman: Refactor PkgMetadata and XmlLint classes for variable data passed in
Move all non-consistent data to be passed in via the check functions.
Initialize XmlLint once in the PkgMetadata class __init__().
pym/repoman/_xml.py | 33 ++++++++++++++++++++++---------
pym/repoman/checks/ebuilds/pkgmetadata.py | 12 +++++------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py
index b97c027..d5b5a5e 100644
--- a/pym/repoman/_xml.py
+++ b/pym/repoman/_xml.py
@@ -14,6 +14,8 @@ from repoman._subprocess import repoman_getstatusoutput
class _XMLParser(xml.etree.ElementTree.XMLParser):
+
+
def __init__(self, data, **kwargs):
xml.etree.ElementTree.XMLParser.__init__(self, **kwargs)
self._portage_data = data
@@ -25,11 +27,13 @@ class _XMLParser(xml.etree.ElementTree.XMLParser):
self.parser.StartDoctypeDeclHandler = \
self._portage_StartDoctypeDeclHandler
+
def _portage_XmlDeclHandler(self, version, encoding, standalone):
if self._base_XmlDeclHandler is not None:
self._base_XmlDeclHandler(version, encoding, standalone)
self._portage_data["XML_DECLARATION"] = (version, encoding, standalone)
+
def _portage_StartDoctypeDeclHandler(
self, doctypeName, systemId, publicId, has_internal_subset):
if self._base_StartDoctypeDeclHandler is not None:
@@ -49,33 +53,44 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
class XmlLint(object):
- def __init__(self, options, repolevel, repoman_settings):
+ def __init__(self, options, repoman_settings):
self.metadata_dtd = os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd')
+ self.options = options
+ self.repoman_settings = repoman_settings
self._is_capable = False
self.binary = None
- self._check_capable(options, repolevel, repoman_settings)
+ self._check_capable()
+
- def _check_capable(self, options, repolevel, repoman_settings):
- if options.mode == "manifest":
+ def _check_capable(self):
+ if self.options.mode == "manifest":
return
self.binary = find_binary('xmllint')
if not self.binary:
print(red("!!! xmllint not found. Can't check metadata.xml.\n"))
- if options.xml_parse or repolevel == 3:
- print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
- sys.exit(1)
else:
- if not fetch_metadata_dtd(self.metadata_dtd, repoman_settings):
+ if not fetch_metadata_dtd(self.metadata_dtd, self.repoman_settings):
sys.exit(1)
# this can be problematic if xmllint changes their output
self._is_capable = True
+
@property
def capable(self):
return self._is_capable
- def check(self, checkdir):
+
+ def check(self, checkdir, repolevel):
+ '''Runs checks on the package metadata.xml file
+
+ @param checkdir: string, path
+ @param repolevel: integer
+ @return boolean, False == bad metadata
+ '''
if not self.capable:
+ if self.options.xml_parse or repolevel == 3:
+ print("%s sorry, xmllint is needed. failing\n" % red("!!!"))
+ sys.exit(1)
return True
# xmlint can produce garbage output even on success, so only dump
# the ouput when it fails.
diff --git a/pym/repoman/checks/ebuilds/pkgmetadata.py b/pym/repoman/checks/ebuilds/pkgmetadata.py
index 0778696..674d32f 100644
--- a/pym/repoman/checks/ebuilds/pkgmetadata.py
+++ b/pym/repoman/checks/ebuilds/pkgmetadata.py
@@ -38,27 +38,28 @@ from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint
class PkgMetadata(object):
'''Package metadata.xml checks'''
- def __init__(self, options, qatracker, repolevel, repoman_settings):
+ def __init__(self, options, qatracker, repoman_settings):
'''PkgMetadata init function
@param options: ArgumentParser.parse_known_args(argv[1:]) options
@param qatracker: QATracker instance
- @param repolevel: integer
@param repoman_settings: settings instance
'''
self.options = options
self.qatracker = qatracker
- self.repolevel = repolevel
self.repoman_settings = repoman_settings
self.musedict = {}
+ self.xmllint = XmlLint(self.options, self.repoman_settings)
+
- def check(self, xpkg, checkdir, checkdirlist):
+ def check(self, xpkg, checkdir, checkdirlist, repolevel):
'''Performs the checks on the metadata.xml for the package
@param xpkg: the pacakge being checked
@param checkdir: string, directory path
@param checkdirlist: list of checkdir's
+ @param repolevel: integer
'''
self.musedict = {}
@@ -165,8 +166,7 @@ class PkgMetadata(object):
# Only carry out if in package directory or check forced
if not metadata_bad:
- xmllint = XmlLint(self.options, self.repolevel, self.repoman_settings)
- if not xmllint.check(checkdir):
+ if not self.xmllint.check(checkdir, repolevel):
self.qatracker.add_error("metadata.bad", xpkg + "/metadata.xml")
del metadata_bad
return
next reply other threads:[~2015-09-05 21:48 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-05 21:48 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-09-20 2:06 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/ebuilds/ Brian Dolbec
2015-09-17 4:51 Brian Dolbec
2015-09-17 4:51 Brian Dolbec
2015-09-17 4:51 Brian Dolbec
2015-09-17 3:08 Brian Dolbec
2015-09-17 3:08 Brian Dolbec
2015-09-17 3:08 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-10 14:45 Michał Górny
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2014-11-17 0:55 Brian Dolbec
2014-11-17 0:55 Brian Dolbec
2014-11-17 0:55 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-06-04 14:18 Tom Wijsman
2014-06-04 9:18 Tom Wijsman
2014-06-03 19:33 Brian Dolbec
2014-06-03 11:16 Tom Wijsman
2014-06-02 6:44 Brian Dolbec
2014-06-02 6:05 Brian Dolbec
2014-06-02 3:35 Brian Dolbec
2014-06-02 1:10 Brian Dolbec
2014-05-30 13:03 Brian Dolbec
2014-05-30 13:03 Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441489656.6bd98ee4b60bb581cf535f666dbde4bf1fe6fce5.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox