From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 30B6058974 for ; Fri, 22 Jan 2016 20:55:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C111021C01B; Fri, 22 Jan 2016 20:55:13 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 463DF21C008 for ; Fri, 22 Jan 2016 20:55:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 51154340ACE for ; Fri, 22 Jan 2016 20:55:12 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D1575CB3 for ; Fri, 22 Jan 2016 20:55:08 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1453488250.009529b32d753e53e43673c53db8004703a53c17.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/metadata/, pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/modules/scan/metadata/__init__.py pym/repoman/modules/scan/metadata/ebuild_metadata.py pym/repoman/scanner.py X-VCS-Directories: pym/repoman/modules/scan/metadata/ pym/repoman/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 009529b32d753e53e43673c53db8004703a53c17 X-VCS-Branch: repoman Date: Fri, 22 Jan 2016 20:55:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d046ade0-c56d-41b8-82d1-a3e4e79faf76 X-Archives-Hash: 0ff5eb57c1073f17edae5d0d5b8e926b commit: 009529b32d753e53e43673c53db8004703a53c17 Author: Brian Dolbec gentoo org> AuthorDate: Sun Jan 3 10:35:49 2016 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Fri Jan 22 18:44:10 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=009529b3 repoman: Migrate code from _scan_ebuilds to a new EbuildMetadata class and check pym/repoman/modules/scan/metadata/__init__.py | 10 +++++- .../modules/scan/metadata/ebuild_metadata.py | 39 ++++++++++++++++++++++ pym/repoman/scanner.py | 27 +-------------- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/pym/repoman/modules/scan/metadata/__init__.py b/pym/repoman/modules/scan/metadata/__init__.py index 7327ec0..eba6565 100644 --- a/pym/repoman/modules/scan/metadata/__init__.py +++ b/pym/repoman/modules/scan/metadata/__init__.py @@ -10,7 +10,7 @@ module_spec = { 'name': 'metadata', 'description': doc, 'provides':{ - 'metadata-module': { + 'pkg-metadata': { 'name': "pkgmetadata", 'class': "PkgMetadata", 'description': doc, @@ -18,6 +18,14 @@ module_spec = { 'func_desc': { }, }, + 'ebuild-metadata': { + 'name': "ebuild_metadata", + 'class': "EbuildMetadata", + 'description': doc, + 'functions': ['check'], + 'func_desc': { + }, + }, } } diff --git a/pym/repoman/modules/scan/metadata/ebuild_metadata.py b/pym/repoman/modules/scan/metadata/ebuild_metadata.py new file mode 100644 index 0000000..143a40e --- /dev/null +++ b/pym/repoman/modules/scan/metadata/ebuild_metadata.py @@ -0,0 +1,39 @@ +# -*- coding:utf-8 -*- + +'''Ebuild Metadata Checks''' + +import re +import sys + +if sys.hexversion >= 0x3000000: + basestring = str + +NON_ASCII_RE = re.compile(r'[^\x00-\x7f]') + + +class EbuildMetadata(object): + + def __init__(self, **kwargs): + self.qatracker = kwargs.get('qatracker') + + def check(self, **kwargs): + ebuild = kwargs.get('ebuild') + for k, v in ebuild.metadata.items(): + if not isinstance(v, basestring): + continue + m = NON_ASCII_RE.search(v) + if m is not None: + self.qatracker.add_error( + "variable.invalidchar", + "%s: %s variable contains non-ASCII " + "character at position %s" % + (ebuild.relative_path, k, m.start() + 1)) + return {'continue': False} + + @property + def runInPkgs(self): + return (False, []) + + @property + def runInEbuilds(self): + return (True, [self.check]) diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py index a8aa2f3..6f3fb53 100644 --- a/pym/repoman/scanner.py +++ b/pym/repoman/scanner.py @@ -5,8 +5,6 @@ from __future__ import print_function, unicode_literals import copy import io import logging -import re -import sys from itertools import chain from pprint import pformat @@ -47,18 +45,10 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan") MODULE_NAMES = MODULE_CONTROLLER.module_names[:] - -if sys.hexversion >= 0x3000000: - basestring = str - -NON_ASCII_RE = re.compile(r'[^\x00-\x7f]') - - def sort_key(item): return item[2].sub_path - class Scanner(object): '''Primary scan class. Operates all the small Q/A tests and checks''' @@ -311,7 +301,7 @@ class Scanner(object): # initialize per ebuild plugin checks here # need to set it up for ==> self.modules_list or some other ordered list for mod in [('ebuild', 'Ebuild'), ('live', 'LiveEclassChecks'), - ('eapi', 'EAPIChecks')]: + ('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata')]: if mod[0]: mod_class = MODULE_CONTROLLER.get_class(mod[0]) logging.debug("Initializing class name: %s", mod_class.__name__) @@ -338,21 +328,6 @@ class Scanner(object): if y_ebuild_continue: continue - - for k, v in dynamic_data['ebuild'].metadata.items(): - if not isinstance(v, basestring): - continue - m = NON_ASCII_RE.search(v) - if m is not None: - self.qatracker.add_error( - "variable.invalidchar", - "%s: %s variable contains non-ASCII " - "character at position %s" % - (dynamic_data['ebuild'].relative_path, k, m.start() + 1)) - - if not dynamic_data['src_uri_error']: - self.thirdparty.check(dynamic_data['ebuild'].metadata, dynamic_data['ebuild'].relative_path) - if dynamic_data['ebuild'].metadata.get("PROVIDE"): self.qatracker.add_error("virtual.oldstyle", dynamic_data['ebuild'].relative_path)