1 |
commit: c26a6f10faed17ba08bbed946e50b8492ed975e0 |
2 |
Author: Dirkjan Ochtman <dirkjan <AT> ochtman <DOT> nl> |
3 |
AuthorDate: Mon Jan 25 20:37:13 2016 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 3 09:15:26 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c26a6f10 |
7 |
|
8 |
repoman: Remove No longer used repoman._xml module |
9 |
|
10 |
pym/repoman/_xml.py | 105 ---------------------------------------------------- |
11 |
1 file changed, 105 deletions(-) |
12 |
|
13 |
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py |
14 |
deleted file mode 100644 |
15 |
index 33a536a..0000000 |
16 |
--- a/pym/repoman/_xml.py |
17 |
+++ /dev/null |
18 |
@@ -1,105 +0,0 @@ |
19 |
-# -*- coding:utf-8 -*- |
20 |
- |
21 |
-from __future__ import print_function, unicode_literals |
22 |
- |
23 |
-import sys |
24 |
-import xml |
25 |
- |
26 |
-# import our initialized portage instance |
27 |
-from repoman._portage import portage |
28 |
- |
29 |
-from portage import os |
30 |
-from portage.output import red |
31 |
-from portage.process import find_binary |
32 |
- |
33 |
-from repoman.metadata import fetch_metadata_xsd |
34 |
-from repoman._subprocess import repoman_getstatusoutput |
35 |
- |
36 |
- |
37 |
-class _XMLParser(xml.etree.ElementTree.XMLParser): |
38 |
- |
39 |
- def __init__(self, data, **kwargs): |
40 |
- xml.etree.ElementTree.XMLParser.__init__(self, **kwargs) |
41 |
- self._portage_data = data |
42 |
- if hasattr(self, 'parser'): |
43 |
- self._base_XmlDeclHandler = self.parser.XmlDeclHandler |
44 |
- self.parser.XmlDeclHandler = self._portage_XmlDeclHandler |
45 |
- self._base_StartDoctypeDeclHandler = \ |
46 |
- self.parser.StartDoctypeDeclHandler |
47 |
- self.parser.StartDoctypeDeclHandler = \ |
48 |
- self._portage_StartDoctypeDeclHandler |
49 |
- |
50 |
- def _portage_XmlDeclHandler(self, version, encoding, standalone): |
51 |
- if self._base_XmlDeclHandler is not None: |
52 |
- self._base_XmlDeclHandler(version, encoding, standalone) |
53 |
- self._portage_data["XML_DECLARATION"] = (version, encoding, standalone) |
54 |
- |
55 |
- def _portage_StartDoctypeDeclHandler( |
56 |
- self, doctypeName, systemId, publicId, has_internal_subset): |
57 |
- if self._base_StartDoctypeDeclHandler is not None: |
58 |
- self._base_StartDoctypeDeclHandler( |
59 |
- doctypeName, systemId, publicId, has_internal_subset) |
60 |
- self._portage_data["DOCTYPE"] = (doctypeName, systemId, publicId) |
61 |
- |
62 |
- |
63 |
-class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder): |
64 |
- """ |
65 |
- Implements doctype() as required to avoid deprecation warnings with |
66 |
- >=python-2.7. |
67 |
- """ |
68 |
- def doctype(self, name, pubid, system): |
69 |
- pass |
70 |
- |
71 |
- |
72 |
-class XmlLint(object): |
73 |
- |
74 |
- def __init__(self, options, repoman_settings, metadata_xsd=None): |
75 |
- self.metadata_xsd = (metadata_xsd or |
76 |
- os.path.join(repoman_settings["DISTDIR"], 'metadata.xsd')) |
77 |
- self.options = options |
78 |
- self.repoman_settings = repoman_settings |
79 |
- self._is_capable = metadata_xsd is not None |
80 |
- self.binary = None |
81 |
- self._check_capable() |
82 |
- |
83 |
- def _check_capable(self): |
84 |
- if self.options.mode == "manifest": |
85 |
- return |
86 |
- self.binary = find_binary('xmllint') |
87 |
- if not self.binary: |
88 |
- print(red("!!! xmllint not found. Can't check metadata.xml.\n")) |
89 |
- elif not self._is_capable: |
90 |
- if not fetch_metadata_xsd(self.metadata_xsd, self.repoman_settings): |
91 |
- sys.exit(1) |
92 |
- # this can be problematic if xmllint changes their output |
93 |
- self._is_capable = True |
94 |
- |
95 |
- @property |
96 |
- def capable(self): |
97 |
- return self._is_capable |
98 |
- |
99 |
- def check(self, checkdir, repolevel): |
100 |
- '''Runs checks on the package metadata.xml file |
101 |
- |
102 |
- @param checkdir: string, path |
103 |
- @param repolevel: integer |
104 |
- @return boolean, False == bad metadata |
105 |
- ''' |
106 |
- if not self.capable: |
107 |
- if self.options.xml_parse or repolevel == 3: |
108 |
- print("%s sorry, xmllint is needed. failing\n" % red("!!!")) |
109 |
- sys.exit(1) |
110 |
- return True |
111 |
- # xmlint can produce garbage output even on success, so only dump |
112 |
- # the ouput when it fails. |
113 |
- st, out = repoman_getstatusoutput( |
114 |
- self.binary + " --nonet --noout --schema %s %s" % ( |
115 |
- portage._shell_quote(self.metadata_xsd), |
116 |
- portage._shell_quote( |
117 |
- os.path.join(checkdir, "metadata.xml")))) |
118 |
- if st != os.EX_OK: |
119 |
- print(red("!!!") + " metadata.xml is invalid:") |
120 |
- for z in out.splitlines(): |
121 |
- print(red("!!! ") + z) |
122 |
- return False |
123 |
- return True |