commit:     2ceec91cec02b94cad84fddaf29bbe884baa1b6d
Author:     Louis Sautier <sautier.louis <AT> gmail <DOT> com>
AuthorDate: Mon Jun 19 12:31:50 2017 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Jun 27 21:29:30 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=2ceec91c

Repoman: detect inconsistent metadata.xml indentation

 repoman/pym/repoman/modules/scan/metadata/pkgmetadata.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/repoman/pym/repoman/modules/scan/metadata/pkgmetadata.py 
b/repoman/pym/repoman/modules/scan/metadata/pkgmetadata.py
index 92c74e6f8..6a0f501ec 100644
--- a/repoman/pym/repoman/modules/scan/metadata/pkgmetadata.py
+++ b/repoman/pym/repoman/modules/scan/metadata/pkgmetadata.py
@@ -3,8 +3,10 @@
 '''Package Metadata Checks operations'''
 
 import sys
+import re
 
 from itertools import chain
+from collections import Counter
 
 try:
        from lxml import etree
@@ -96,6 +98,14 @@ class PkgMetadata(ScanBase, USEFlagChecks):
                        self.muselist = frozenset(self.musedict)
                        return False
 
+               indentation_chars = Counter()
+               for l in etree.tostring(_metadata_xml).splitlines():
+                       indentation_chars.update(re.match(b"\s*", l).group(0))
+               if len(indentation_chars) > 1:
+                       self.qatracker.add_error("metadata.warning", 
"%s/metadata.xml: %s" %
+                               (xpkg, "inconsistent use of tabs and spaces in 
indentation")
+                       )
+
                xml_encoding = _metadata_xml.docinfo.encoding
                if xml_encoding.upper() != metadata_xml_encoding:
                        self.qatracker.add_error(

Reply via email to