public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/modules/scan/directories/
Date: Sun, 10 Jan 2016 20:17:12 +0000 (UTC)	[thread overview]
Message-ID: <1452456908.afb256c55cadb6c033b3c1721b672bda2b46c46f.dolsen@gentoo> (raw)

commit:     afb256c55cadb6c033b3c1721b672bda2b46c46f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 04:44:05 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 20:15:08 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=afb256c5

repoman: Create new EncodingCheck class plugin

 pym/repoman/modules/scan/directories/__init__.py |  8 +++++
 pym/repoman/modules/scan/directories/encoding.py | 41 ++++++++++++++++++++++++
 pym/repoman/scanner.py                           | 21 +-----------
 3 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/pym/repoman/modules/scan/directories/__init__.py b/pym/repoman/modules/scan/directories/__init__.py
index b9daef0..548d393 100644
--- a/pym/repoman/modules/scan/directories/__init__.py
+++ b/pym/repoman/modules/scan/directories/__init__.py
@@ -26,6 +26,14 @@ module_spec = {
 			'func_kwargs': {
 			},
 		},
+		'encoding-module': {
+			'name': "encoding",
+			'class': "EncodingCheck",
+			'description': doc,
+			'functions': ['check'],
+			'func_kwargs': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/directories/encoding.py b/pym/repoman/modules/scan/directories/encoding.py
new file mode 100644
index 0000000..0985e16
--- /dev/null
+++ b/pym/repoman/modules/scan/directories/encoding.py
@@ -0,0 +1,41 @@
+
+import io
+
+from portage import _encodings
+from portage import _unicode_encode
+
+from repoman.checks.ebuilds.checks import run_checks
+
+
+class EncodingCheck(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		try:
+			# All ebuilds should have utf_8 encoding.
+			f = io.open(
+				_unicode_encode(ebuild.full_path, encoding=_encodings['fs'],
+					errors='strict'),
+				mode='r', encoding=_encodings['repo.content'])
+			try:
+				for check_name, e in run_checks(f, pkg):
+					self.qatracker.add_error(
+						check_name, ebuild.relative_path + ': %s' % e)
+			finally:
+				f.close()
+		except UnicodeDecodeError:
+			# A file.UTF8 failure will have already been recorded.
+			pass
+		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 b00dbd9..ac77d1f 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -3,7 +3,6 @@
 from __future__ import print_function, unicode_literals
 
 import copy
-import io
 import logging
 from itertools import chain
 from pprint import pformat
@@ -13,11 +12,8 @@ from _emerge.Package import Package
 import portage
 from portage import normalize_path
 from portage import os
-from portage import _encodings
-from portage import _unicode_encode
 from portage.dep import Atom
 from portage.output import green
-from repoman.checks.ebuilds.checks import run_checks
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
 from repoman.repos import repo_metadata
@@ -293,7 +289,7 @@ class Scanner(object):
 				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'),
 				('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
-				('mtime', 'MtimeChecks'),
+				('mtime', 'MtimeChecks'), ('encoding', 'EncodingCheck'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -322,21 +318,6 @@ class Scanner(object):
 				continue
 
 			# Syntax Checks
-			try:
-				# All ebuilds should have utf_8 encoding.
-				f = io.open(
-					_unicode_encode(
-						dynamic_data['ebuild'].full_path, encoding=_encodings['fs'], errors='strict'),
-					mode='r', encoding=_encodings['repo.content'])
-				try:
-					for check_name, e in run_checks(f, dynamic_data['pkg']):
-						self.qatracker.add_error(
-							check_name, dynamic_data['ebuild'].relative_path + ': %s' % e)
-				finally:
-					f.close()
-			except UnicodeDecodeError:
-				# A file.UTF8 failure will have already been recorded above.
-				pass
 
 			if self.options.force:
 				# The dep_check() calls are the most expensive QA test. If --force


             reply	other threads:[~2016-01-10 20:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-10 20:17 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-03-07 21:53 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/modules/scan/directories/ Brian Dolbec
2016-01-23  1:42 Brian Dolbec
2016-01-11  8:01 Brian Dolbec
2016-01-11  6:31 Brian Dolbec
2016-01-10 20:17 Brian Dolbec
2016-01-10  3:26 Brian Dolbec
2016-01-06  4:21 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=1452456908.afb256c55cadb6c033b3c1721b672bda2b46c46f.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