From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (unknown [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 060131381FA for ; Tue, 27 May 2014 06:05:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 65534E0893; Tue, 27 May 2014 06:05:01 +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 987F2E088F for ; Tue, 27 May 2014 06:05:00 +0000 (UTC) Received: from spoonbill.gentoo.org (unknown [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 40DD333FB78 for ; Tue, 27 May 2014 06:04:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id E0994181A9 for ; Tue, 27 May 2014 06:04:57 +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: <1401170664.9b19b5835abf159a95a242719400c47fd96f4aa3.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/main.py pym/repoman/scan.py X-VCS-Directories: pym/repoman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 9b19b5835abf159a95a242719400c47fd96f4aa3 X-VCS-Branch: repoman Date: Tue, 27 May 2014 06:04:57 +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: 121adfa8-3b7f-4ac7-83a2-e9f13e2ce57f X-Archives-Hash: 830277c85af9563de2539c1a7c4b0745 commit: 9b19b5835abf159a95a242719400c47fd96f4aa3 Author: Brian Dolbec gentoo org> AuthorDate: Tue May 27 03:54:32 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Tue May 27 06:04:24 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9b19b583 repoman/main/py: Create new scan.py and scan() This moves the main scan code out to a function. Comment out some unused variables. --- pym/repoman/main.py | 45 +++++---------------------------------------- pym/repoman/scan.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 40 deletions(-) diff --git a/pym/repoman/main.py b/pym/repoman/main.py index 8e15e76..2697b1b 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -66,15 +66,16 @@ from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use from repoman.argparser import parse_args from repoman.checks.ebuilds.checks import run_checks, checks_init from repoman.checks.herds.herdbase import make_herd_base -from repoman.errors import caterror, err from repoman.metadata import (fetch_metadata_dtd, metadata_xml_encoding, metadata_doctype_name, metadata_dtd_uri, metadata_xml_declaration) +from repoman.errors import err from repoman.modules import commit from repoman.profile import check_profiles, dev_keywords, setup_profile from repoman.qa_data import (format_qa_output, format_qa_output_column, qahelp, qawarnings, qacats, no_exec, allvars, max_desc_len, missingvars, ruby_deprecated, suspect_virtual, suspect_rdepend, valid_restrict) from repoman.repos import has_global_mask, RepoSettings, repo_metadata +from repoman.scan import scan from repoman._subprocess import repoman_popen, repoman_getstatusoutput from repoman import utilities from repoman.vcs.vcs import (git_supports_gpg_sign, vcs_files_to_cps, @@ -264,47 +265,11 @@ if not uselist: logging.fatal("Couldn't find use.desc?") sys.exit(1) -scanlist = [] -if repolevel == 2: - # we are inside a category directory - catdir = reposplit[-1] - if catdir not in categories: - caterror(catdir, repo_settings.repodir) - mydirlist = os.listdir(startdir) - for x in mydirlist: - if x == "CVS" or x.startswith("."): - continue - if os.path.isdir(startdir + "/" + x): - scanlist.append(catdir + "/" + x) - repo_subdir = catdir + os.sep -elif repolevel == 1: - for x in categories: - if not os.path.isdir(startdir + "/" + x): - continue - for y in os.listdir(startdir + "/" + x): - if y == "CVS" or y.startswith("."): - continue - if os.path.isdir(startdir + "/" + x + "/" + y): - scanlist.append(x + "/" + y) - repo_subdir = "" -elif repolevel == 3: - catdir = reposplit[-2] - if catdir not in categories: - caterror(catdir,repo_settings.repodir) - scanlist.append(catdir + "/" + reposplit[-1]) - repo_subdir = scanlist[-1] + os.sep -else: - msg = 'Repoman is unable to determine PORTDIR or PORTDIR_OVERLAY' + \ - ' from the current working directory' - logging.critical(msg) - sys.exit(1) - -repo_subdir_len = len(repo_subdir) -scanlist.sort() +#################### -logging.debug( - "Found the following packages to scan:\n%s" % '\n'.join(scanlist)) +scanlist = scan(repolevel, reposplit, startdir, categories, repo_settings) +#################### dev_keywords = dev_keywords(profiles) diff --git a/pym/repoman/scan.py b/pym/repoman/scan.py new file mode 100644 index 0000000..575069f --- /dev/null +++ b/pym/repoman/scan.py @@ -0,0 +1,50 @@ + +import logging +import os +import sys + +from repoman.errors import caterror + +def scan(repolevel, reposplit, startdir, categories, repo_settings): + scanlist = [] + if repolevel == 2: + # we are inside a category directory + catdir = reposplit[-1] + if catdir not in categories: + caterror(catdir, repo_settings.repodir) + mydirlist = os.listdir(startdir) + for x in mydirlist: + if x == "CVS" or x.startswith("."): + continue + if os.path.isdir(startdir + "/" + x): + scanlist.append(catdir + "/" + x) + #repo_subdir = catdir + os.sep + elif repolevel == 1: + for x in categories: + if not os.path.isdir(startdir + "/" + x): + continue + for y in os.listdir(startdir + "/" + x): + if y == "CVS" or y.startswith("."): + continue + if os.path.isdir(startdir + "/" + x + "/" + y): + scanlist.append(x + "/" + y) + #repo_subdir = "" + elif repolevel == 3: + catdir = reposplit[-2] + if catdir not in categories: + caterror(catdir,repo_settings.repodir) + scanlist.append(catdir + "/" + reposplit[-1]) + #repo_subdir = scanlist[-1] + os.sep + else: + msg = 'Repoman is unable to determine PORTDIR or PORTDIR_OVERLAY' + \ + ' from the current working directory' + logging.critical(msg) + sys.exit(1) + + #repo_subdir_len = len(repo_subdir) + scanlist.sort() + + logging.debug( + "Found the following packages to scan:\n%s" % '\n'.join(scanlist)) + + return scanlist