commit: 2fb6926a6a78b5f78408989faba4c7c04547db16
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue May 27 03:54:32 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue May 27 05:03:49 2014 +0000
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2fb6926a
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..d7cd1be
--- /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