From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qf5n3-00083X-9M for garchives@archives.gentoo.org; Fri, 08 Jul 2011 07:47:57 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9612A21C073; Fri, 8 Jul 2011 07:47:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5603621C073 for ; Fri, 8 Jul 2011 07:47:50 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C0EEE2AC001 for ; Fri, 8 Jul 2011 07:47:49 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2087C8003D for ; Fri, 8 Jul 2011 07:47:49 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/checks.py X-VCS-Directories: pym/repoman/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: caf6e68cc5fd175a52610bebdec7d354cc7b714a Date: Fri, 8 Jul 2011 07:47:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 2e3b38560ee25582c3bece28cf29bbc6 commit: caf6e68cc5fd175a52610bebdec7d354cc7b714a Author: Zac Medico gentoo org> AuthorDate: Fri Jul 8 07:47:31 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Jul 8 07:47:31 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dcaf6e68c repoman: centralize code for ignoring comments --- pym/repoman/checks.py | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index fabf0b3..58ac20d 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -16,6 +16,9 @@ class LineCheck(object): """Run a check on a line of an ebuild.""" """A regular expression to determine whether to ignore the line""" ignore_line =3D False + """True if lines containing nothing more than comments with optional + leading whitespace should be ignored""" + ignore_comment =3D True =20 def new(self, pkg): pass @@ -35,7 +38,6 @@ class LineCheck(object): class PhaseCheck(LineCheck): """ basic class for function detection """ =20 - ignore_line =3D re.compile(r'(^\s*#)') func_end_re =3D re.compile(r'^\}$') phases_re =3D re.compile('(%s)' % '|'.join(( 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', @@ -103,6 +105,7 @@ class EbuildWhitespace(LineCheck): repoman_check_name =3D 'ebuild.minorsyn' =20 ignore_line =3D re.compile(r'(^$)|(^(\t)*#)') + ignore_comment =3D False leading_spaces =3D re.compile(r'^[\S\t]') trailing_whitespace =3D re.compile(r'.*([\S]$)')=09 =20 @@ -114,6 +117,7 @@ class EbuildWhitespace(LineCheck): =20 class EbuildBlankLine(LineCheck): repoman_check_name =3D 'ebuild.minorsyn' + ignore_comment =3D False blank_line =3D re.compile(r'^$') =20 def new(self, pkg): @@ -142,6 +146,7 @@ class EbuildQuote(LineCheck): _ignored_commands =3D ["local", "export"] + _message_commands ignore_line =3D re.compile(r'(^$)|(^\s*#.*)|(^\s*\w+=3D.*)' + \ r'|(^\s*(' + "|".join(_ignored_commands) + r')\s+)') + ignore_comment =3D False var_names =3D ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] =20 # EAPI=3D3/Prefix vars @@ -215,6 +220,7 @@ class EbuildAssignment(LineCheck): readonly_assignment =3D re.compile(r'^\s*(export\s+)?(A|CATEGORY|P|PV|P= N|PR|PVR|PF|D|WORKDIR|FILESDIR|FEATURES|USE)=3D') line_continuation =3D re.compile(r'([^#]*\S)(\s+|\t)\\$') ignore_line =3D re.compile(r'(^$)|(^(\t)*#)') + ignore_comment =3D False =20 def __init__(self): self.previous_line =3D None @@ -448,7 +454,6 @@ class InheritAutotools(LineCheck): """ =20 repoman_check_name =3D 'inherit.autotools' - ignore_line =3D re.compile(r'(^|\s*)#') _inherit_autotools_re =3D re.compile(r'^\s*inherit\s(.*\s)?autotools(\s= |$)') _autotools_funcs =3D ( "eaclocal", "eautoconf", "eautoheader", @@ -582,7 +587,6 @@ class SrcUnpackPatches(PhaseCheck): =20 class BuiltWithUse(LineCheck): repoman_check_name =3D 'ebuild.minorsyn' - ignore_line =3D re.compile(r'^\s*#') re =3D re.compile('^.*built_with_use') error =3D errors.BUILT_WITH_USE =20 @@ -601,7 +605,6 @@ class DeprecatedHasq(LineCheck): # EAPI-3 checks class Eapi3DeprecatedFuncs(LineCheck): repoman_check_name =3D 'EAPI.deprecated' - ignore_line =3D re.compile(r'(^\s*#)') deprecated_commands_re =3D re.compile(r'^\s*(check_license)\b') =20 def check_eapi(self, eapi): @@ -616,7 +619,6 @@ class Eapi3DeprecatedFuncs(LineCheck): # EAPI-4 checks class Eapi4IncompatibleFuncs(LineCheck): repoman_check_name =3D 'EAPI.incompatible' - ignore_line =3D re.compile(r'(^\s*#)') banned_commands_re =3D re.compile(r'^\s*(dosed|dohard)') =20 def check_eapi(self, eapi): @@ -630,7 +632,6 @@ class Eapi4IncompatibleFuncs(LineCheck): =20 class Eapi4GoneVars(LineCheck): repoman_check_name =3D 'EAPI.incompatible' - ignore_line =3D re.compile(r'(^\s*#)') undefined_vars_re =3D re.compile(r'.*\$(\{(AA|KV|EMERGE_FROM)\}|(AA|KV|= EMERGE_FROM))') =20 def check_eapi(self, eapi): @@ -667,6 +668,7 @@ _constant_checks =3D tuple((c() for c in ( DeprecatedUseq, DeprecatedHasq))) =20 _here_doc_re =3D re.compile(r'.*\s<<[-]?(\w+)$') +_ignore_comment_re =3D re.compile(r'^\s*#') =20 def run_checks(contents, pkg): checks =3D _constant_checks @@ -687,7 +689,10 @@ def run_checks(contents, pkg): =20 if here_doc_delim is None: # We're not in a here-document. + is_comment =3D _ignore_comment_re.match(line) is not None for lc in checks: + if is_comment and lc.ignore_comment: + continue if lc.check_eapi(pkg.metadata['EAPI']): ignore =3D lc.ignore_line if not ignore or not ignore.match(line):