summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/elog/__init__.py5
-rw-r--r--pym/portage/elog/messages.py7
-rw-r--r--pym/portage/elog/mod_echo.py12
-rw-r--r--pym/portage/elog/mod_mail.py9
-rw-r--r--pym/portage/elog/mod_mail_summary.py13
-rw-r--r--pym/portage/elog/mod_save_summary.py5
-rw-r--r--pym/portage/env/loaders.py19
-rw-r--r--pym/portage/sets/__init__.py23
-rw-r--r--pym/portage/sets/dbapi.py23
-rw-r--r--pym/portage/sets/files.py15
-rw-r--r--pym/portage/sets/libs.py3
11 files changed, 75 insertions, 59 deletions
diff --git a/pym/portage/elog/__init__.py b/pym/portage/elog/__init__.py
index 5e8b11c8b..ad1ee805f 100644
--- a/pym/portage/elog/__init__.py
+++ b/pym/portage/elog/__init__.py
@@ -13,6 +13,7 @@ from portage.exception import PortageException
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
@@ -157,8 +158,8 @@ def elog_process(cpv, mysettings, phasefilter=None):
_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)
diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py
index 4fa73ba5f..9832f2660 100644
--- a/pym/portage/elog/messages.py
+++ b/pym/portage/elog/messages.py
@@ -10,6 +10,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
)
from portage.const import EBUILD_PHASES
+from portage.localization import _
import os
import sys
@@ -32,7 +33,7 @@ def collect_ebuild_messages(path):
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:
@@ -45,8 +46,8 @@ def collect_ebuild_messages(path):
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:
diff --git a/pym/portage/elog/mod_echo.py b/pym/portage/elog/mod_echo.py
index 30d88f005..fa6577dc6 100644
--- a/pym/portage/elog/mod_echo.py
+++ b/pym/portage/elog/mod_echo.py
@@ -5,6 +5,7 @@
from portage.output import EOutput, colorize
from portage.const import EBUILD_PHASES
+from portage.localization import _
_items = []
def process(mysettings, key, logentries, fulltext):
@@ -18,12 +19,13 @@ def finalize(mysettings=None):
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:
diff --git a/pym/portage/elog/mod_mail.py b/pym/portage/elog/mod_mail.py
index d6383a4eb..841986b96 100644
--- a/pym/portage/elog/mod_mail.py
+++ b/pym/portage/elog/mod_mail.py
@@ -5,6 +5,7 @@
import portage.mail, socket
from portage.exception import PortageException
+from portage.localization import _
from portage.util import writemsg
def process(mysettings, key, logentries, fulltext):
@@ -20,17 +21,17 @@ 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)
diff --git a/pym/portage/elog/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py
index ed5147313..90a6ed2f8 100644
--- a/pym/portage/elog/mod_mail_summary.py
+++ b/pym/portage/elog/mod_mail_summary.py
@@ -5,14 +5,15 @@
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
@@ -30,9 +31,9 @@ def _finalize(mysettings, items):
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:
@@ -44,8 +45,8 @@ def _finalize(mysettings, items):
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
diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py
index 3a062dd12..0e12ac451 100644
--- a/pym/portage/elog/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
@@ -5,6 +5,7 @@
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):
@@ -18,8 +19,8 @@ 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()
diff --git a/pym/portage/env/loaders.py b/pym/portage/env/loaders.py
index 400797c0c..31d3b09aa 100644
--- a/pym/portage/env/loaders.py
+++ b/pym/portage/env/loaders.py
@@ -5,6 +5,7 @@
import os
import stat
+from portage.localization import _
class LoaderError(Exception):
@@ -181,13 +182,13 @@ class ItemFileLoader(FileLoader):
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
@@ -222,19 +223,19 @@ class KeyListFileLoader(FileLoader):
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:
@@ -276,24 +277,24 @@ class KeyValuePairFileLoader(FileLoader):
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:
diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py
index ef7c1d938..80aa608f6 100644
--- a/pym/portage/sets/__init__.py
+++ b/pym/portage/sets/__init__.py
@@ -10,6 +10,7 @@ from ConfigParser import SafeConfigParser, NoOptionError
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 = "@"
@@ -21,7 +22,7 @@ def get_boolean(options, name, default):
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
@@ -56,7 +57,8 @@ class SetConfig(object):
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)
@@ -80,7 +82,8 @@ class SetConfig(object):
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 = {}
@@ -95,18 +98,19 @@ class SetConfig(object):
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:
@@ -114,7 +118,7 @@ class SetConfig(object):
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)
@@ -123,10 +127,11 @@ class SetConfig(object):
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
diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py
index 65d05a2ae..d6e78bfb6 100644
--- a/pym/portage/sets/dbapi.py
+++ b/pym/portage/sets/dbapi.py
@@ -4,6 +4,7 @@
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
@@ -81,7 +82,7 @@ class OwnerSet(PackageSet):
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,
@@ -119,17 +120,17 @@ class VariableSet(EverythingSet):
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,
@@ -198,7 +199,7 @@ class UnavailableSet(EverythingSet):
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,
@@ -234,11 +235,11 @@ class CategorySet(PackageSet):
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)
@@ -252,7 +253,7 @@ class CategorySet(PackageSet):
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
@@ -260,7 +261,7 @@ class CategorySet(PackageSet):
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)
@@ -293,11 +294,11 @@ class AgeSet(EverythingSet):
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)
diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py
index 8abb3481b..9ebff10f2 100644
--- a/pym/portage/sets/files.py
+++ b/pym/portage/sets/files.py
@@ -9,6 +9,7 @@ from itertools import chain
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
@@ -31,7 +32,7 @@ class StaticFileSet(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
@@ -95,7 +96,7 @@ class StaticFileSet(EditablePackageSet):
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
@@ -104,7 +105,7 @@ class StaticFileSet(EditablePackageSet):
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)
@@ -113,7 +114,7 @@ class StaticFileSet(EditablePackageSet):
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)
@@ -121,7 +122,7 @@ class StaticFileSet(EditablePackageSet):
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):
@@ -156,7 +157,7 @@ class ConfigFileSet(PackageSet):
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)
@@ -165,7 +166,7 @@ class ConfigFileSet(PackageSet):
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)
diff --git a/pym/portage/sets/libs.py b/pym/portage/sets/libs.py
index 1c5067ebc..806cb63f6 100644
--- a/pym/portage/sets/libs.py
+++ b/pym/portage/sets/libs.py
@@ -2,6 +2,7 @@
# 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
@@ -49,7 +50,7 @@ class LibraryFileConsumerSet(LibraryConsumerSet):
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)