from portage.process import atexit_register
from portage.elog.messages import collect_ebuild_messages, collect_messages
from portage.elog.filtering import filter_loglevels
+from portage.localization import _
import os
_elog_atexit_handlers.append(m.finalize)
atexit_register(m.finalize)
except (ImportError, AttributeError), e:
- writemsg("!!! Error while importing logging modules " + \
- "while loading \"mod_%s\":\n" % str(s))
+ writemsg(_("!!! Error while importing logging modules "
+ "while loading \"mod_%s\":\n") % str(s))
writemsg("%s\n" % str(e), noiselevel=-1)
except PortageException, e:
writemsg("%s\n" % str(e), noiselevel=-1)
)
from portage.const import EBUILD_PHASES
+from portage.localization import _
import os
import sys
for msgfunction in mylogfiles:
filename = os.path.join(path, msgfunction)
if msgfunction not in EBUILD_PHASES:
- writemsg("!!! can't process invalid log file: %s\n" % filename,
+ writemsg(_("!!! can't process invalid log file: %s\n") % filename,
noiselevel=-1)
continue
if not msgfunction in logentries:
try:
msgtype, msg = l.split(" ", 1)
except ValueError:
- writemsg("!!! malformed entry in " + \
- "log file: '%s'\n" % filename, noiselevel=-1)
+ writemsg(_("!!! malformed entry in "
+ "log file: '%s'\n") % filename, noiselevel=-1)
continue
if lastmsgtype is None:
from portage.output import EOutput, colorize
from portage.const import EBUILD_PHASES
+from portage.localization import _
_items = []
def process(mysettings, key, logentries, fulltext):
global _items
printer = EOutput()
for mysettings, key, logentries in _items:
- root_msg = ""
- if mysettings["ROOT"] != "/":
- root_msg = " merged to %s" % mysettings["ROOT"]
print
- printer.einfo("Messages for package %s%s:" % \
- (colorize("INFORM", key), root_msg))
+ if mysettings["ROOT"] == "/":
+ printer.einfo(_("Messages for package %s:") %
+ colorize("INFORM", key))
+ else:
+ printer.einfo(_("Messages for package %(pkg)s merged to %(root)s:") %
+ {"pkg": colorize("INFORM", key), "root": mysettings["ROOT"]})
print
for phase in EBUILD_PHASES:
if phase not in logentries:
import portage.mail, socket
from portage.exception import PortageException
+from portage.localization import _
from portage.util import writemsg
def process(mysettings, key, logentries, fulltext):
mysubject = mysubject.replace("${HOST}", socket.getfqdn())
# look at the phases listed in our logentries to figure out what action was performed
- action = "merged"
+ action = _("merged")
for phase in logentries.keys():
# if we found a *rm phase assume that the package was unmerged
if phase in ["postrm", "prerm"]:
- action = "unmerged"
+ action = _("unmerged")
# if we think that the package was unmerged, make sure there was no unexpected
# phase recorded to avoid misinformation
- if action == "unmerged":
+ if action == _("unmerged"):
for phase in logentries.keys():
if phase not in ["postrm", "prerm", "other"]:
- action = "unknown"
+ action = _("unknown")
mysubject = mysubject.replace("${ACTION}", action)
import portage.mail, socket, os, time
from portage.exception import PortageException
+from portage.localization import _
from portage.util import writemsg
from email.MIMEText import MIMEText as TextMessage
_items = {}
def process(mysettings, key, logentries, fulltext):
global _items
- header = ">>> Messages generated for package %s by process %d on %s:\n\n" % \
- (key, os.getpid(), time.strftime("%Y%m%d-%H%M%S %Z", time.localtime(time.time())))
+ header = _(">>> Messages generated for package %(pkg)s by process %(pid)d on %(time)s:\n\n") % \
+ {"pkg": key, "pid": os.getpid(), "time": time.strftime("%Y%m%d-%H%M%S %Z", time.localtime(time.time()))}
config_root = mysettings["PORTAGE_CONFIGROOT"]
mysettings, items = _items.setdefault(config_root, (mysettings, {}))
items[key] = header + fulltext
if len(items) == 0:
return
elif len(items) == 1:
- count = "one package"
+ count = _("one package")
else:
- count = "multiple packages"
+ count = _("multiple packages")
if "PORTAGE_ELOG_MAILURI" in mysettings:
myrecipient = mysettings["PORTAGE_ELOG_MAILURI"].split()[0]
else:
mysubject = mysubject.replace("${PACKAGE}", count)
mysubject = mysubject.replace("${HOST}", socket.getfqdn())
- mybody = "elog messages for the following packages generated by " + \
- "process %d on host %s:\n" % (os.getpid(), socket.getfqdn())
+ mybody = _("elog messages for the following packages generated by "
+ "process %(pid)d on host %(host)s:\n") % {"pid": os.getpid(), "host": socket.getfqdn()}
for key in items:
mybody += "- %s\n" % key
import os, time
from portage.data import portage_uid, portage_gid
+from portage.localization import _
from portage.util import ensure_dirs, apply_permissions
def process(mysettings, key, logentries, fulltext):
elogfilename = elogdir+"/summary.log"
elogfile = open(elogfilename, "a")
apply_permissions(elogfilename, mode=060, mask=0)
- elogfile.write(">>> Messages generated by process %d on %s for package %s:\n\n" % \
- (os.getpid(), time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime(time.time())), key))
+ elogfile.write(_(">>> Messages generated by process %(pid)d on %(time)s for package %(pkg)s:\n\n") %
+ {"pid": os.getpid(), "time": time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime(time.time())), "pkg": key})
elogfile.write(fulltext)
elogfile.write("\n")
elogfile.close()
import os
import stat
+from portage.localization import _
class LoaderError(Exception):
split = line.split()
if not len(split):
errors.setdefault(self.fname, []).append(
- "Malformed data at line: %s, data: %s"
+ _("Malformed data at line: %s, data: %s")
% (line_num + 1, line))
return
key = split[0]
if not self._validate(key):
errors.setdefault(self.fname, []).append(
- "Validation failed at line: %s, data %s"
+ _("Validation failed at line: %s, data %s")
% (line_num + 1, key))
return
data[key] = None
split = line.split()
if len(split) < 1:
errors.setdefault(self.fname, []).append(
- "Malformed data at line: %s, data: %s"
+ _("Malformed data at line: %s, data: %s")
% (line_num + 1, line))
return
key = split[0]
value = split[1:]
if not self._validate(key):
errors.setdefault(self.fname, []).append(
- "Key validation failed at line: %s, data %s"
+ _("Key validation failed at line: %s, data %s")
% (line_num + 1, key))
return
if not self._valueValidate(value):
errors.setdefault(self.fname, []).append(
- "Value validation failed at line: %s, data %s"
+ _("Value validation failed at line: %s, data %s")
% (line_num + 1, value))
return
if key in data:
split = line.split('=', 1)
if len(split) < 2:
errors.setdefault(self.fname, []).append(
- "Malformed data at line: %s, data %s"
+ _("Malformed data at line: %s, data %s")
% (line_num + 1, line))
return
key = split[0].strip()
value = split[1].strip()
if not key:
errors.setdefault(self.fname, []).append(
- "Malformed key at line: %s, key %s"
+ _("Malformed key at line: %s, key %s")
% (line_num + 1, key))
return
if not self._validate(key):
errors.setdefault(self.fname, []).append(
- "Key validation failed at line: %s, data %s"
+ _("Key validation failed at line: %s, data %s")
% (line_num + 1, key))
return
if not self._valueValidate(value):
errors.setdefault(self.fname, []).append(
- "Value validation failed at line: %s, data %s"
+ _("Value validation failed at line: %s, data %s")
% (line_num + 1, value))
return
if key in data:
from portage import load_mod
from portage.const import USER_CONFIG_PATH, GLOBAL_CONFIG_PATH
from portage.exception import PackageSetNotFound
+from portage.localization import _
SETPREFIX = "@"
elif options[name].lower() in ("0", "no", "off", "false"):
return False
else:
- raise SetConfigError("invalid value '%s' for option '%s'" % (options[name], name))
+ raise SetConfigError(_("invalid value '%(value)s' for option '%(option)s'") % {"value": options[name], "option": name})
class SetConfigError(Exception):
pass
section = self.psets[setname].creator
if parser.has_option(section, "multiset") and \
parser.getboolean(section, "multiset"):
- self.errors.append("Invalid request to reconfigure set '%s' generated by multiset section '%s'" % (setname, section))
+ self.errors.append(_("Invalid request to reconfigure set '%(set)s' generated "
+ "by multiset section '%(section)s'") % {"set": setname, "section": section})
return
for k, v in options.items():
parser.set(section, k, v)
try:
setclass = load_mod("portage.sets."+classname)
except (ImportError, AttributeError):
- self.errors.append("Could not import '%s' for section '%s'" % (classname, sname))
+ self.errors.append(_("Could not import '%(class)s' for section "
+ "'%(section)s'") % {"class": classname, "section": sname})
continue
# prepare option dict for the current section
optdict = {}
try:
newsets = setclass.multiBuilder(optdict, self.settings, self.trees)
except SetConfigError, e:
- self.errors.append("Configuration error in section '%s': %s" % (sname, str(e)))
+ self.errors.append(_("Configuration error in section '%s': %s") % (sname, str(e)))
continue
for x in newsets:
if x in self.psets and not update:
- self.errors.append("Redefinition of set '%s' (sections: '%s', '%s')" % (x, self.psets[x].creator, sname))
+ self.errors.append(_("Redefinition of set '%s' (sections: '%s', '%s')") % (x, self.psets[x].creator, sname))
newsets[x].creator = sname
if parser.has_option(sname, "world-candidate") and \
not parser.getboolean(sname, "world-candidate"):
newsets[x].world_candidate = False
self.psets.update(newsets)
else:
- self.errors.append("Section '%s' is configured as multiset, but '%s' doesn't support that configuration" % (sname, classname))
+ self.errors.append(_("Section '%(section)s' is configured as multiset, but '%(class)s' "
+ "doesn't support that configuration") % {"section": sname, "class": classname})
continue
else:
try:
except NoOptionError:
setname = sname
if setname in self.psets and not update:
- self.errors.append("Redefinition of set '%s' (sections: '%s', '%s')" % (setname, self.psets[setname].creator, sname))
+ self.errors.append(_("Redefinition of set '%s' (sections: '%s', '%s')") % (setname, self.psets[setname].creator, sname))
if hasattr(setclass, "singleBuilder"):
try:
self.psets[setname] = setclass.singleBuilder(optdict, self.settings, self.trees)
not parser.getboolean(sname, "world-candidate"):
self.psets[setname].world_candidate = False
except SetConfigError, e:
- self.errors.append("Configuration error in section '%s': %s" % (sname, str(e)))
+ self.errors.append(_("Configuration error in section '%s': %s") % (sname, str(e)))
continue
else:
- self.errors.append("'%s' does not support individual set creation, section '%s' must be configured as multiset" % (classname, sname))
+ self.errors.append(_("'%(class)s' does not support individual set creation, section '%(section)s' "
+ "must be configured as multiset") % {"class": classname, "section": sname})
continue
self._parsed = True
from portage.versions import catpkgsplit, catsplit, pkgcmp, best
from portage.dep import Atom
+from portage.localization import _
from portage.sets.base import PackageSet
from portage.sets import SetConfigError, get_boolean
def singleBuilder(cls, options, settings, trees):
if not "files" in options:
- raise SetConfigError("no files given")
+ raise SetConfigError(_("no files given"))
import shlex
return cls(vardb=trees["vartree"].dbapi,
variable = options.get("variable")
if variable is None:
- raise SetConfigError("missing required attribute: 'variable'")
+ raise SetConfigError(_("missing required attribute: 'variable'"))
includes = options.get("includes", "")
excludes = options.get("excludes", "")
if not (includes or excludes):
- raise SetConfigError("no includes or excludes given")
+ raise SetConfigError(_("no includes or excludes given"))
metadatadb = options.get("metadata-source", "vartree")
if not metadatadb in trees.keys():
- raise SetConfigError("invalid value '%s' for option metadata-source" % metadatadb)
+ raise SetConfigError(_("invalid value '%s' for option metadata-source") % metadatadb)
return cls(trees["vartree"].dbapi,
metadatadb=trees[metadatadb].dbapi,
metadatadb = options.get("metadata-source", "porttree")
if not metadatadb in trees:
- raise SetConfigError(("invalid value '%s' for option " + \
+ raise SetConfigError(_("invalid value '%s' for option "
"metadata-source") % (metadatadb,))
return cls(trees["vartree"].dbapi,
def singleBuilder(cls, options, settings, trees):
if not "category" in options:
- raise SetConfigError("no category given")
+ raise SetConfigError(_("no category given"))
category = options["category"]
if not category in settings.categories:
- raise SetConfigError("invalid category name '%s'" % category)
+ raise SetConfigError(_("invalid category name '%s'") % category)
visible = cls._builderGetVisible(options)
categories = options["categories"].split()
invalid = set(categories).difference(settings.categories)
if invalid:
- raise SetConfigError("invalid categories: %s" % ", ".join(list(invalid)))
+ raise SetConfigError(_("invalid categories: %s") % ", ".join(list(invalid)))
else:
categories = settings.categories
name_pattern = options.get("name_pattern", "$category/*")
if not "$category" in name_pattern and not "${category}" in name_pattern:
- raise SetConfigError("name_pattern doesn't include $category placeholder")
+ raise SetConfigError(_("name_pattern doesn't include $category placeholder"))
for cat in categories:
myset = CategorySet(cat, trees["porttree"].dbapi, only_visible=visible)
def singleBuilder(cls, options, settings, trees):
mode = options.get("mode", "older")
if str(mode).lower() not in ["newer", "older"]:
- raise SetConfigError("invalid 'mode' value %s (use either 'newer' or 'older')" % mode)
+ raise SetConfigError(_("invalid 'mode' value %s (use either 'newer' or 'older')") % mode)
try:
age = int(options.get("age", "7"))
except ValueError, e:
- raise SetConfigError("value of option 'age' is not an integer")
+ raise SetConfigError(_("value of option 'age' is not an integer"))
return AgeSet(vardb=trees["vartree"].dbapi, mode=mode, age=age)
singleBuilder = classmethod(singleBuilder)
from portage.util import grabfile, write_atomic, ensure_dirs, normalize_path
from portage.const import PRIVATE_PATH, USER_CONFIG_PATH
+from portage.localization import _
from portage.locks import lockfile, unlockfile
from portage import portage_gid
from portage.sets.base import PackageSet, EditablePackageSet
self.description = "Package set loaded from file %s" % self._filename
self.loader = ItemFileLoader(self._filename, self._validate)
if greedy and not dbapi:
- self.errors.append("%s configured as greedy set, but no dbapi instance passed in constructor" % self._filename)
+ self.errors.append(_("%s configured as greedy set, but no dbapi instance passed in constructor") % self._filename)
greedy = False
self.greedy = greedy
self.dbapi = dbapi
def singleBuilder(self, options, settings, trees):
if not "filename" in options:
- raise SetConfigError("no filename specified")
+ raise SetConfigError(_("no filename specified"))
greedy = get_boolean(options, "greedy", False)
filename = options["filename"]
# look for repository path variables
try:
filename = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], filename)
except KeyError:
- raise SetConfigError("Could not find repository '%s'" % match.groupdict()["reponame"])
+ raise SetConfigError(_("Could not find repository '%s'") % match.groupdict()["reponame"])
return StaticFileSet(filename, greedy=greedy, dbapi=trees["vartree"].dbapi)
singleBuilder = classmethod(singleBuilder)
directory = options.get("directory", os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep), "sets"))
name_pattern = options.get("name_pattern", "${name}")
if not "$name" in name_pattern and not "${name}" in name_pattern:
- raise SetConfigError("name_pattern doesn't include ${name} placeholder")
+ raise SetConfigError(_("name_pattern doesn't include ${name} placeholder"))
greedy = get_boolean(options, "greedy", False)
# look for repository path variables
match = self._repopath_match.match(directory)
try:
directory = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], directory)
except KeyError:
- raise SetConfigError("Could not find repository '%s'" % match.groupdict()["reponame"])
+ raise SetConfigError(_("Could not find repository '%s'") % match.groupdict()["reponame"])
if os.path.isdir(directory):
directory = normalize_path(directory)
for parent, dirs, files in os.walk(directory):
def singleBuilder(self, options, settings, trees):
if not "filename" in options:
- raise SetConfigError("no filename specified")
+ raise SetConfigError(_("no filename specified"))
return ConfigFileSet(options["filename"])
singleBuilder = classmethod(singleBuilder)
directory = options.get("directory", os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep)))
name_pattern = options.get("name_pattern", "sets/package_$suffix")
if not "$suffix" in name_pattern and not "${suffix}" in name_pattern:
- raise SetConfigError("name_pattern doesn't include $suffix placeholder")
+ raise SetConfigError(_("name_pattern doesn't include $suffix placeholder"))
for suffix in ["keywords", "use", "mask", "unmask"]:
myname = name_pattern.replace("$suffix", suffix)
myname = myname.replace("${suffix}", suffix)
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage.localization import _
from portage.sets.base import PackageSet
from portage.sets import get_boolean
from portage.versions import catpkgsplit
import shlex
files = tuple(shlex.split(options.get("files", "")))
if not files:
- raise SetConfigError("no files given")
+ raise SetConfigError(_("no files given"))
debug = get_boolean(options, "debug", False)
return LibraryFileConsumerSet(trees["vartree"].dbapi,
files, debug=debug)