"""
Filter stdout or stderr from specific modules
- So far this is just used for pkg_resources
+ So far this is just used for pkg_resources which is quite noisy
"""
def __init__(self, stream, modulenames):
"my_p", default=False, help=
"Specify MY_P")
+ opt_parser.add_option("-l", "--overlay", action='store', dest=
+ 'overlay', metavar='OVERLAY_NAME', default=None, help=
+ 'Specify overy to use by name ($OVERLAY/profiles/repo_name)')
+
opt_parser.add_option("--format", action='store', dest=
"format", default=None, help=
"Format when printing to stdout: ansi, html, bbcode, or none")
from pygments.formatters import TerminalFormatter, HtmlFormatter
from pygments.formatters import BBCodeFormatter
-from g_pypi.portage_utils import make_overlay_dir, find_s_dir, unpack_ebuild
-from g_pypi.portage_utils import get_portdir, get_workdir, find_egg_info_dir
-from g_pypi.portage_utils import valid_cpn, get_installed_ver
+from g_pypi.portage_utils import (make_overlay_dir, find_s_dir, unpack_ebuild,
+ get_portdir, get_workdir, find_egg_info_dir, valid_cpn,
+ get_installed_ver, get_repo_names)
from g_pypi.config import MyConfig
from g_pypi import enamer
from g_pypi.__init__ import __version__ as VERSION
def write_ebuild(self, overwrite=False):
"""Write ebuild file"""
+ #Use command-line overlay if specified, else the one in .g-pyprc
+ if self.options.overlay:
+ overlay_name = self.options.overlay
+ overlays = get_repo_names()
+ if overlays.has_key(overlay_name):
+ overlay_path = overlays[overlay_name]
+ else:
+ self.logger.error("Couldn't find overylay by that name. I know about these:")
+ self.logger.error(overlays)
+ sys.exit(1)
+ else:
+ overlay_path = self.config['overlay']
ebuild_dir = make_overlay_dir(self.options.category, self.vars['pn'], \
- self.config['overlay'])
+ overlay_path)
if not ebuild_dir:
self.logger.error("Couldn't create overylay ebuild directory.")
sys.exit(2)
self.vars['p'])
if os.path.exists(self.ebuild_path) and not overwrite:
#self.logger.error("Ebuild exists. Use -o to overwrite.")
- self.logger.error("Ebuild exists, skipping: %s" % self.ebuild_path)
+ self.logger.warn("Ebuild exists, skipping: %s" % self.ebuild_path)
return
try:
out = open(self.ebuild_path, "w")
Map defined classifier license to Portage license
http://cheeseshop.python.org/pypi?%3Aaction=list_classifiers
+ We should probably check this list with every major list, eh?
"""
my_license = my_license.split(":: ")[-1:][0]
known_licenses = {
import logging
#import fnmatch
-import portage
+from portage import config as portage_config
+from portage import settings as portage_settings
+from portage.const import REPO_NAME_LOC
try:
#portage >= 2.2
__docformat__ = 'restructuredtext'
-ENV = portage.config(clone=portage.settings).environ()
+ENV = portage_config(clone=portage_settings).environ()
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
LOGGER.addHandler(logging.StreamHandler())
+def get_repo_names():
+ """
+ Return a dict of overlay names with their paths
+ e.g.
+ {'reponame': '/path/to/repo', ...}
+
+ @returns: dict with repoman/paths
+
+ """
+ porttrees = [ENV['PORTDIR']] + \
+ [os.path.realpath(t) for t in ENV["PORTDIR_OVERLAY"].split()]
+ treemap = {}
+ for path in porttrees:
+ repo_name_path = os.path.join(path, REPO_NAME_LOC)
+ try:
+ repo_name = open(repo_name_path, 'r').readline().strip()
+ treemap[repo_name] = path
+ except (OSError,IOError):
+ LOGGER.warn("No repo_name in %s" % path)
+ return treemap
+
def get_installed_ver(cpn):
"""
Return PV for installed version of package
# for path, dirs, files in os.walk(os.path.abspath(root)):
# for filename in fnmatch.filter(dirs, pattern):
# yield os.path.join(path, filename)
+if __name__ == '__main__':
+ print get_repo_names()