summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-08-15 18:13:18 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-08-15 18:13:18 +0000
commit74ecc5568944b42e38cd99a4c07a6249bc9a56ed (patch)
tree4afdd58d9462b0d2efe71edfa43810e42766b5d2 /pym
parent6a454b2769795983b0f91d341632782b2596ef0b (diff)
downloadportage-74ecc5568944b42e38cd99a4c07a6249bc9a56ed.tar.gz
portage-74ecc5568944b42e38cd99a4c07a6249bc9a56ed.tar.bz2
portage-74ecc5568944b42e38cd99a4c07a6249bc9a56ed.zip
Prepare 308 messages to localization.
svn path=/main/trunk/; revision=14067
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/__init__.py650
-rw-r--r--pym/portage/_selinux.py16
-rw-r--r--pym/portage/checksum.py5
-rw-r--r--pym/portage/data.py15
-rw-r--r--pym/portage/dep.py57
-rw-r--r--pym/portage/dispatch_conf.py23
-rw-r--r--pym/portage/exception.py9
-rw-r--r--pym/portage/getbinpkg.py53
-rw-r--r--pym/portage/glsa.py39
-rw-r--r--pym/portage/locks.py36
-rw-r--r--pym/portage/mail.py13
-rw-r--r--pym/portage/manifest.py11
-rw-r--r--pym/portage/news.py9
-rw-r--r--pym/portage/output.py20
-rw-r--r--pym/portage/update.py15
-rw-r--r--pym/portage/util.py33
-rw-r--r--pym/portage/versions.py9
17 files changed, 511 insertions, 502 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d38d2c3f7..4815cc074 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1109,14 +1109,14 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
# an older package installed ON TOP of a newer version will cause ldconfig
# to overwrite the symlinks we just made. -X means no links. After 'clean'
# we can safely create links.
- writemsg_level(">>> Regenerating %setc/ld.so.cache...\n" % \
+ writemsg_level(_(">>> Regenerating %setc/ld.so.cache...\n") % \
(target_root,))
if makelinks:
os.system("cd / ; %s -r '%s'" % (ldconfig, target_root))
else:
os.system("cd / ; %s -X -r '%s'" % (ldconfig, target_root))
elif ostype in ("FreeBSD","DragonFly"):
- writemsg_level(">>> Regenerating %svar/run/ld-elf.so.hints...\n" % \
+ writemsg_level(_(">>> Regenerating %svar/run/ld-elf.so.hints...\n") % \
target_root)
os.system(("cd / ; %s -elf -i " + \
"-f '%svar/run/ld-elf.so.hints' '%setc/ld.so.conf'") % \
@@ -1563,7 +1563,7 @@ class config(object):
def check_var_directory(varname, var):
if not os.path.isdir(var):
- writemsg(("!!! Error: %s='%s' is not a directory. " + \
+ writemsg(_("!!! Error: %s='%s' is not a directory. "
"Please correct this.\n") % (varname, var),
noiselevel=-1)
raise portage.exception.DirectoryNotFound(var)
@@ -1633,15 +1633,15 @@ class config(object):
pass
else:
if not eapi_is_supported(eapi):
- raise portage.exception.ParseError(
- "Profile contains unsupported " + \
- "EAPI '%s': '%s'" % \
+ raise portage.exception.ParseError(_(
+ "Profile contains unsupported "
+ "EAPI '%s': '%s'") % \
(eapi, os.path.realpath(eapi_file),))
if os.path.exists(parentsFile):
parents = grabfile(parentsFile)
if not parents:
raise portage.exception.ParseError(
- "Empty parent file: '%s'" % parentsFile)
+ _("Empty parent file: '%s'") % parentsFile)
for parentPath in parents:
parentPath = normalize_path(os.path.join(
currentPath, parentPath))
@@ -1649,13 +1649,13 @@ class config(object):
addProfile(parentPath)
else:
raise portage.exception.ParseError(
- "Parent '%s' not found: '%s'" % \
+ _("Parent '%s' not found: '%s'") % \
(parentPath, parentsFile))
self.profiles.append(currentPath)
try:
addProfile(os.path.realpath(self.profile_path))
except portage.exception.ParseError, e:
- writemsg("!!! Unable to parse profile: '%s'\n" % \
+ writemsg(_("!!! Unable to parse profile: '%s'\n") % \
self.profile_path, noiselevel=-1)
writemsg("!!! ParseError: %s\n" % str(e), noiselevel=-1)
del e
@@ -1979,7 +1979,7 @@ class config(object):
del e
except ParsingError, e:
portage.util.writemsg_level(
- "!!! Error parsing '%s': %s\n" % \
+ _("!!! Error parsing '%s': %s\n") % \
(self._local_repo_conf_path, e),
level=logging.ERROR, noiselevel=-1)
del e
@@ -2038,26 +2038,26 @@ class config(object):
for x in range(len(pkgprovidedlines)-1, -1, -1):
myline = pkgprovidedlines[x]
if not isvalidatom("=" + myline):
- writemsg("Invalid package name in package.provided:" + \
- " %s\n" % myline, noiselevel=-1)
+ writemsg(_("Invalid package name in package.provided: %s\n") % \
+ myline, noiselevel=-1)
has_invalid_data = True
del pkgprovidedlines[x]
continue
cpvr = catpkgsplit(pkgprovidedlines[x])
if not cpvr or cpvr[0] == "null":
- writemsg("Invalid package name in package.provided: "+pkgprovidedlines[x]+"\n",
+ writemsg(_("Invalid package name in package.provided: ")+pkgprovidedlines[x]+"\n",
noiselevel=-1)
has_invalid_data = True
del pkgprovidedlines[x]
continue
if cpvr[0] == "virtual":
- writemsg("Virtual package in package.provided: %s\n" % \
+ writemsg(_("Virtual package in package.provided: %s\n") % \
myline, noiselevel=-1)
has_invalid_data = True
del pkgprovidedlines[x]
continue
if has_invalid_data:
- writemsg("See portage(5) for correct package.provided usage.\n",
+ writemsg(_("See portage(5) for correct package.provided usage.\n"),
noiselevel=-1)
self.pprovideddict = {}
for x in pkgprovidedlines:
@@ -2096,8 +2096,8 @@ class config(object):
if os.path.isdir(ov):
new_ov.append(ov)
else:
- writemsg("!!! Invalid PORTDIR_OVERLAY" + \
- " (not a dir): '%s'\n" % ov, noiselevel=-1)
+ writemsg(_("!!! Invalid PORTDIR_OVERLAY"
+ " (not a dir): '%s'\n") % ov, noiselevel=-1)
self["PORTDIR_OVERLAY"] = " ".join(new_ov)
self.backup_changes("PORTDIR_OVERLAY")
@@ -2114,7 +2114,7 @@ class config(object):
try:
self[var] = str(int(self.get(var, "0")))
except ValueError:
- writemsg(("!!! %s='%s' is not a valid integer. " + \
+ writemsg(_("!!! %s='%s' is not a valid integer. "
"Falling back to '0'.\n") % (var, self[var]),
noiselevel=-1)
self[var] = "0"
@@ -2131,8 +2131,8 @@ class config(object):
""" Don't show this warning when running repoman and the
sandbox feature came from a profile that doesn't belong to
the user."""
- writemsg(colorize("BAD", "!!! Problem with sandbox" + \
- " binary. Disabling...\n\n"), noiselevel=-1)
+ writemsg(colorize("BAD", _("!!! Problem with sandbox"
+ " binary. Disabling...\n\n")), noiselevel=-1)
if "sandbox" in self.features:
self.features.remove("sandbox")
if "usersandbox" in self.features:
@@ -2181,7 +2181,7 @@ class config(object):
try:
portage.util.ensure_dirs(mydir, gid=gid, mode=mode, mask=modemask)
except portage.exception.PortageException, e:
- writemsg("!!! Directory initialization failed: '%s'\n" % mydir,
+ writemsg(_("!!! Directory initialization failed: '%s'\n") % mydir,
noiselevel=-1)
writemsg("!!! %s\n" % str(e),
noiselevel=-1)
@@ -2211,20 +2211,20 @@ class config(object):
traversed_groups = set()
license_group = self._license_groups.get(group_name)
if group_name in traversed_groups:
- writemsg(("Circular license group reference" + \
+ writemsg(_("Circular license group reference"
" detected in '%s'\n") % group_name, noiselevel=-1)
rValue.append("@"+group_name)
elif license_group:
traversed_groups.add(group_name)
for l in license_group:
if l.startswith("-"):
- writemsg(("Skipping invalid element %s" + \
+ writemsg(_("Skipping invalid element %s"
" in license group '%s'\n") % (l, group_name),
noiselevel=-1)
else:
rValue.extend(self._expandLicenseToken(l, traversed_groups))
else:
- writemsg("Undefined license group '%s'\n" % group_name,
+ writemsg(_("Undefined license group '%s'\n") % group_name,
noiselevel=-1)
rValue.append("@"+group_name)
if negate:
@@ -2238,14 +2238,14 @@ class config(object):
groups = self["ACCEPT_KEYWORDS"].split()
archlist = self.archlist()
if not archlist:
- writemsg("--- 'profiles/arch.list' is empty or " + \
- "not available. Empty portage tree?\n", noiselevel=1)
+ writemsg(_("--- 'profiles/arch.list' is empty or "
+ "not available. Empty portage tree?\n"), noiselevel=1)
else:
for group in groups:
if group not in archlist and \
not (group.startswith("-") and group[1:] in archlist) and \
group not in ("*", "~*", "**"):
- writemsg("!!! INVALID ACCEPT_KEYWORDS: %s\n" % str(group),
+ writemsg(_("!!! INVALID ACCEPT_KEYWORDS: %s\n") % str(group),
noiselevel=-1)
abs_profile_path = os.path.join(self["PORTAGE_CONFIGROOT"],
@@ -2253,10 +2253,10 @@ class config(object):
if not self.profile_path or (not os.path.islink(abs_profile_path) and \
not os.path.exists(os.path.join(abs_profile_path, "parent")) and \
os.path.exists(os.path.join(self["PORTDIR"], "profiles"))):
- writemsg("\a\n\n!!! %s is not a symlink and will probably prevent most merges.\n" % abs_profile_path,
+ writemsg(_("\a\n\n!!! %s is not a symlink and will probably prevent most merges.\n") % abs_profile_path,
noiselevel=-1)
- writemsg("!!! It should point into a profile within %s/profiles/\n" % self["PORTDIR"])
- writemsg("!!! (You can safely ignore this message when syncing. It's harmless.)\n\n\n")
+ writemsg(_("!!! It should point into a profile within %s/profiles/\n") % self["PORTDIR"])
+ writemsg(_("!!! (You can safely ignore this message when syncing. It's harmless.)\n\n\n"))
abs_user_virtuals = os.path.join(self["PORTAGE_CONFIGROOT"],
USER_VIRTUALS_FILE)
@@ -2267,8 +2267,8 @@ class config(object):
if "fakeroot" in self.features and \
not portage.process.fakeroot_capable:
- writemsg("!!! FEATURES=fakeroot is enabled, but the " + \
- "fakeroot binary is not installed.\n", noiselevel=-1)
+ writemsg(_("!!! FEATURES=fakeroot is enabled, but the "
+ "fakeroot binary is not installed.\n"), noiselevel=-1)
def loadVirtuals(self,root):
"""Not currently used by portage."""
@@ -2299,14 +2299,14 @@ class config(object):
def modifying(self):
if self.locked:
- raise Exception("Configuration is locked.")
+ raise Exception(_("Configuration is locked."))
def backup_changes(self,key=None):
self.modifying()
if key and key in self.configdict["env"]:
self.backupenv[key] = copy.deepcopy(self.configdict["env"][key])
else:
- raise KeyError("No such key defined in environment: %s" % key)
+ raise KeyError(_("No such key defined in environment: %s") % key)
def reset(self,keeping_pkg=0,use_cache=1):
"""
@@ -2655,7 +2655,7 @@ class config(object):
if ebuild_force_test and \
not hasattr(self, "_ebuild_force_test_msg_shown"):
self._ebuild_force_test_msg_shown = True
- writemsg("Forcing test.\n", noiselevel=-1)
+ writemsg(_("Forcing test.\n"), noiselevel=-1)
if "test" in self.features and "test" in iuse_implicit:
if "test" in self.usemask and not ebuild_force_test:
# "test" is in IUSE and USE=test is masked, so execution
@@ -2917,8 +2917,8 @@ class config(object):
hastesting = False
for gp in mygroups:
if gp == "*" or (gp == "-*" and len(mygroups) == 1):
- writemsg(("--- WARNING: Package '%s' uses" + \
- " '%s' keyword.\n") % (cpv, gp), noiselevel=-1)
+ writemsg(_("--- WARNING: Package '%(cpv)s' uses"
+ " '%(keyword)s' keyword.\n") % {"cpv": cpv, "keyword": gp}, noiselevel=-1)
if gp == "*":
match = 1
break
@@ -3121,7 +3121,7 @@ class config(object):
try:
self._accept_chost_re = re.compile(r'^%s$' % accept_chost[0])
except re.error, e:
- writemsg("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n" % \
+ writemsg(_("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n") % \
(accept_chost[0], e), noiselevel=-1)
self._accept_chost_re = re.compile("^$")
else:
@@ -3129,7 +3129,7 @@ class config(object):
self._accept_chost_re = re.compile(
r'^(%s)$' % "|".join(accept_chost))
except re.error, e:
- writemsg("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n" % \
+ writemsg(_("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n") % \
(" ".join(accept_chost), e), noiselevel=-1)
self._accept_chost_re = re.compile("^$")
@@ -3284,7 +3284,7 @@ class config(object):
if x[0]=="+":
# Not legal. People assume too much. Complain.
writemsg(colorize("BAD",
- "USE flags should not start with a '+': %s" % x) \
+ _("USE flags should not start with a '+': %s") % x) \
+ "\n", noiselevel=-1)
x=x[1:]
if not x:
@@ -3343,8 +3343,8 @@ class config(object):
continue
if x[0] == "+":
- writemsg(colorize("BAD", "USE flags should not start " + \
- "with a '+': %s\n" % x), noiselevel=-1)
+ writemsg(colorize("BAD", _("USE flags should not start "
+ "with a '+': %s\n") % x), noiselevel=-1)
x = x[1:]
if not x:
continue
@@ -3367,20 +3367,20 @@ class config(object):
for x in curdb[var].split():
if x[0] == "+":
if is_not_incremental:
- writemsg(colorize("BAD", "Invalid '+' " + \
- "operator in non-incremental variable " + \
- "'%s': '%s'\n" % (var, x)), noiselevel=-1)
+ writemsg(colorize("BAD", _("Invalid '+' "
+ "operator in non-incremental variable "
+ "'%s': '%s'\n") % (var, x)), noiselevel=-1)
continue
else:
- writemsg(colorize("BAD", "Invalid '+' " + \
- "operator in incremental variable " + \
- "'%s': '%s'\n" % (var, x)), noiselevel=-1)
+ writemsg(colorize("BAD", _("Invalid '+' "
+ "operator in incremental variable "
+ "'%s': '%s'\n") % (var, x)), noiselevel=-1)
x = x[1:]
if x[0] == "-":
if is_not_incremental:
- writemsg(colorize("BAD", "Invalid '-' " + \
- "operator in non-incremental variable " + \
- "'%s': '%s'\n" % (var, x)), noiselevel=-1)
+ writemsg(colorize("BAD", _("Invalid '-' "
+ "operator in non-incremental variable "
+ "'%s': '%s'\n") % (var, x)), noiselevel=-1)
continue
myflags.discard(var_lower + "_" + x[1:])
continue
@@ -3427,7 +3427,7 @@ class config(object):
virtuals_dict = grabdict(virtuals_file)
for k in virtuals_dict.keys():
if not isvalidatom(k) or dep_getkey(k) != k:
- writemsg("--- Invalid virtuals atom in %s: %s\n" % \
+ writemsg(_("--- Invalid virtuals atom in %s: %s\n") % \
(virtuals_file, k), noiselevel=-1)
del virtuals_dict[k]
continue
@@ -3438,7 +3438,7 @@ class config(object):
# allow incrementals
myatom = x[1:]
if not isvalidatom(myatom):
- writemsg("--- Invalid atom in %s: %s\n" % \
+ writemsg(_("--- Invalid atom in %s: %s\n") % \
(virtuals_file, x), noiselevel=-1)
myvalues.remove(x)
if not myvalues:
@@ -3594,7 +3594,7 @@ class config(object):
continue
myvalue = self[x]
if not isinstance(myvalue, basestring):
- writemsg("!!! Non-string value in config: %s=%s\n" % \
+ writemsg(_("!!! Non-string value in config: %s=%s\n") % \
(x, myvalue), noiselevel=-1)
continue
if filter_calling_env and \
@@ -3654,7 +3654,7 @@ class config(object):
else:
self._selinux_enabled = 0
else:
- writemsg("!!! SELinux module not found. Please verify that it was installed.\n",
+ writemsg(_("!!! SELinux module not found. Please verify that it was installed.\n"),
noiselevel=-1)
self._selinux_enabled = 0
@@ -4019,11 +4019,11 @@ def _check_digests(filename, digests, show_errors=1):
verified_ok, reason = portage.checksum.verify_all(filename, digests)
if not verified_ok:
if show_errors:
- writemsg("!!! Previously fetched" + \
- " file: '%s'\n" % filename, noiselevel=-1)
- writemsg("!!! Reason: %s\n" % reason[0],
+ writemsg(_("!!! Previously fetched"
+ " file: '%s'\n") % filename, noiselevel=-1)
+ writemsg(_("!!! Reason: %s\n") % reason[0],
noiselevel=-1)
- writemsg(("!!! Got: %s\n" + \
+ writemsg(_("!!! Got: %s\n"
"!!! Expected: %s\n") % \
(reason[1], reason[2]), noiselevel=-1)
return False
@@ -4049,7 +4049,7 @@ def _check_distfile(filename, digests, eout, show_errors=1):
return (False, st)
if not digests:
if size is not None:
- eout.ebegin("%s %s ;-)" % (os.path.basename(filename), "size"))
+ eout.ebegin(_("%s size ;-)") % os.path.basename(filename))
eout.eend(0)
elif st.st_size == 0:
# Zero-byte distfiles are always invalid.
@@ -4096,7 +4096,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
if ("mirror" in features) and ("lmirror" not in features):
# lmirror should allow you to bypass mirror restrictions.
# XXX: This is not a good thing, and is temporary at best.
- print ">>> \"mirror\" mode desired and \"mirror\" restriction found; skipping fetch."
+ print _(">>> \"mirror\" mode desired and \"mirror\" restriction found; skipping fetch.")
return 1
# Generally, downloading the same file repeatedly from
@@ -4108,18 +4108,18 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
v = int(mysettings.get("PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS",
checksum_failure_max_tries))
except (ValueError, OverflowError):
- writemsg("!!! Variable PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS" + \
- " contains non-integer value: '%s'\n" % \
+ writemsg(_("!!! Variable PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"
+ " contains non-integer value: '%s'\n") % \
mysettings["PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"], noiselevel=-1)
- writemsg("!!! Using PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS " + \
- "default value: %s\n" % checksum_failure_max_tries,
+ writemsg(_("!!! Using PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS "
+ "default value: %s\n") % checksum_failure_max_tries,
noiselevel=-1)
v = checksum_failure_max_tries
if v < 1:
- writemsg("!!! Variable PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS" + \
- " contains value less than 1: '%s'\n" % v, noiselevel=-1)
- writemsg("!!! Using PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS " + \
- "default value: %s\n" % checksum_failure_max_tries,
+ writemsg(_("!!! Variable PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"
+ " contains value less than 1: '%s'\n") % v, noiselevel=-1)
+ writemsg(_("!!! Using PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS "
+ "default value: %s\n") % checksum_failure_max_tries,
noiselevel=-1)
v = checksum_failure_max_tries
checksum_failure_max_tries = v
@@ -4135,11 +4135,11 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
match = _fetch_resume_size_re.match(fetch_resume_size)
if match is None or \
(match.group(2).upper() not in _size_suffix_map):
- writemsg("!!! Variable PORTAGE_FETCH_RESUME_MIN_SIZE" + \
- " contains an unrecognized format: '%s'\n" % \
+ writemsg(_("!!! Variable PORTAGE_FETCH_RESUME_MIN_SIZE"
+ " contains an unrecognized format: '%s'\n") % \
mysettings["PORTAGE_FETCH_RESUME_MIN_SIZE"], noiselevel=-1)
- writemsg("!!! Using PORTAGE_FETCH_RESUME_MIN_SIZE " + \
- "default value: %s\n" % fetch_resume_size_default,
+ writemsg(_("!!! Using PORTAGE_FETCH_RESUME_MIN_SIZE "
+ "default value: %s\n") % fetch_resume_size_default,
noiselevel=-1)
fetch_resume_size = None
if fetch_resume_size is None:
@@ -4180,10 +4180,10 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
if not os.access(mysettings["DISTDIR"],os.W_OK) and fetch_to_ro:
if use_locks:
writemsg(colorize("BAD",
- "!!! For fetching to a read-only filesystem, " + \
- "locking should be turned off.\n"), noiselevel=-1)
- writemsg("!!! This can be done by adding -distlocks to " + \
- "FEATURES in /etc/make.conf\n", noiselevel=-1)
+ _("!!! For fetching to a read-only filesystem, "
+ "locking should be turned off.\n")), noiselevel=-1)
+ writemsg(_("!!! This can be done by adding -distlocks to "
+ "FEATURES in /etc/make.conf\n"), noiselevel=-1)
# use_locks = 0
# local mirrors are always added
@@ -4268,9 +4268,9 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
thirdpartymirror_uris.setdefault(myfile, []).extend(uris)
if not filedict[myfile]:
- writemsg("No known mirror by the name: %s\n" % (mirrorname))
+ writemsg(_("No known mirror by the name: %s\n") % (mirrorname))
else:
- writemsg("Invalid mirror definition in SRC_URI:\n", noiselevel=-1)
+ writemsg(_("Invalid mirror definition in SRC_URI:\n"), noiselevel=-1)
writemsg(" %s\n" % (myuri), noiselevel=-1)
else:
if restrict_fetch:
@@ -4340,7 +4340,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
# The directory has just been created
# and therefore it must be empty.
continue
- writemsg("Adjusting permissions recursively: '%s'\n" % mydir,
+ writemsg(_("Adjusting permissions recursively: '%s'\n") % mydir,
noiselevel=-1)
def onerror(e):
raise # bail out on the first error that occurs during recursion
@@ -4348,24 +4348,24 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
gid=dir_gid, dirmode=dirmode, dirmask=modemask,
filemode=filemode, filemask=modemask, onerror=onerror):
raise portage.exception.OperationNotPermitted(
- "Failed to apply recursive permissions for the portage group.")
+ _("Failed to apply recursive permissions for the portage group."))
except portage.exception.PortageException, e:
if not os.path.isdir(mysettings["DISTDIR"]):
writemsg("!!! %s\n" % str(e), noiselevel=-1)
- writemsg("!!! Directory Not Found: DISTDIR='%s'\n" % mysettings["DISTDIR"], noiselevel=-1)
- writemsg("!!! Fetching will fail!\n", noiselevel=-1)
+ writemsg(_("!!! Directory Not Found: DISTDIR='%s'\n") % mysettings["DISTDIR"], noiselevel=-1)
+ writemsg(_("!!! Fetching will fail!\n"), noiselevel=-1)
if can_fetch and \
not fetch_to_ro and \
not os.access(mysettings["DISTDIR"], os.W_OK):
- writemsg("!!! No write access to '%s'\n" % mysettings["DISTDIR"],
+ writemsg(_("!!! No write access to '%s'\n") % mysettings["DISTDIR"],
noiselevel=-1)
can_fetch = False
if can_fetch and use_locks and locks_in_subdir:
distlocks_subdir = os.path.join(mysettings["DISTDIR"], locks_in_subdir)
if not os.access(distlocks_subdir, os.W_OK):
- writemsg("!!! No write access to write to %s. Aborting.\n" % distlocks_subdir,
+ writemsg(_("!!! No write access to write to %s. Aborting.\n") % distlocks_subdir,
noiselevel=-1)
return 0
del distlocks_subdir
@@ -4429,16 +4429,16 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
has_space = False
if not has_space:
- writemsg("!!! Insufficient space to store %s in %s\n" % \
+ writemsg(_("!!! Insufficient space to store %s in %s\n") % \
(myfile, mysettings["DISTDIR"]), noiselevel=-1)
if has_space_superuser:
- writemsg("!!! Insufficient privileges to use " + \
- "remaining space.\n", noiselevel=-1)
+ writemsg(_("!!! Insufficient privileges to use "
+ "remaining space.\n"), noiselevel=-1)
if userfetch:
- writemsg("!!! You may set FEATURES=\"-userfetch\"" + \
- " in /etc/make.conf in order to fetch with\n" + \
- "!!! superuser privileges.\n", noiselevel=-1)
+ writemsg(_("!!! You may set FEATURES=\"-userfetch\""
+ " in /etc/make.conf in order to fetch with\n"
+ "!!! superuser privileges.\n"), noiselevel=-1)
if distdir_writable and use_locks:
@@ -4456,7 +4456,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
file_lock = portage.locks.lockfile(myfile_path,
wantnewlockfile=1, **lock_kwargs)
except portage.exception.TryAgain:
- writemsg((">>> File '%s' is already locked by " + \
+ writemsg(_(">>> File '%s' is already locked by "
"another fetcher. Continuing...\n") % myfile,
noiselevel=-1)
continue
@@ -4475,8 +4475,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
stat_cached=mystat)
except portage.exception.PortageException, e:
if not os.access(myfile_path, os.R_OK):
- writemsg("!!! Failed to adjust permissions:" + \
- " %s\n" % str(e), noiselevel=-1)
+ writemsg(_("!!! Failed to adjust permissions:"
+ " %s\n") % str(e), noiselevel=-1)
del e
continue
@@ -4490,8 +4490,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
if mystat is not None:
if stat.S_ISDIR(mystat.st_mode):
portage.util.writemsg_level(
- ("!!! Unable to fetch file since " + \
- "a directory is in the way: \n" + \
+ _("!!! Unable to fetch file since "
+ "a directory is in the way: \n"
"!!! %s\n") % myfile_path,
level=logging.ERROR, noiselevel=-1)
return 0
@@ -4513,21 +4513,21 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
# in order to force the old digests to be replaced.
# Since the user may want to keep this file, rename
# it instead of deleting it.
- writemsg((">>> Renaming distfile with size " + \
- "%d (smaller than " "PORTAGE_FETCH_RESU" + \
+ writemsg(_(">>> Renaming distfile with size "
+ "%d (smaller than " "PORTAGE_FETCH_RESU"
"ME_MIN_SIZE)\n") % mystat.st_size)
temp_filename = \
_checksum_failure_temp_file(
mysettings["DISTDIR"], myfile)
- writemsg_stdout("Refetching... " + \
- "File renamed to '%s'\n\n" % \
+ writemsg_stdout(_("Refetching... "
+ "File renamed to '%s'\n\n") % \
temp_filename, noiselevel=-1)
elif mystat.st_size >= size:
temp_filename = \
_checksum_failure_temp_file(
mysettings["DISTDIR"], myfile)
- writemsg_stdout("Refetching... " + \
- "File renamed to '%s'\n\n" % \
+ writemsg_stdout(_("Refetching... "
+ "File renamed to '%s'\n\n") % \
temp_filename, noiselevel=-1)
if distdir_writable and ro_distdirs:
@@ -4554,8 +4554,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
mirror_file = os.path.join(mydir, myfile)
try:
shutil.copyfile(mirror_file, myfile_path)
- writemsg(_("Local mirror has file:" + \
- " %(file)s\n" % {"file":myfile}))
+ writemsg(_("Local mirror has file: %s\n") % myfile)
break
except (IOError, OSError), e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
@@ -4575,8 +4574,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
stat_cached=mystat)
except portage.exception.PortageException, e:
if not os.access(myfile_path, os.R_OK):
- writemsg("!!! Failed to adjust permissions:" + \
- " %s\n" % str(e), noiselevel=-1)
+ writemsg(_("!!! Failed to adjust permissions:"
+ " %s\n") % str(e), noiselevel=-1)
# If the file is empty then it's obviously invalid. Remove
# the empty file and try to download if possible.
@@ -4607,21 +4606,21 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
verified_ok, reason = portage.checksum.verify_all(
myfile_path, mydigests[myfile])
if not verified_ok:
- writemsg("!!! Previously fetched" + \
- " file: '%s'\n" % myfile, noiselevel=-1)
- writemsg("!!! Reason: %s\n" % reason[0],
+ writemsg(_("!!! Previously fetched"
+ " file: '%s'\n") % myfile, noiselevel=-1)
+ writemsg(_("!!! Reason: %s\n") % reason[0],
noiselevel=-1)
- writemsg(("!!! Got: %s\n" + \
+ writemsg(_("!!! Got: %s\n"
"!!! Expected: %s\n") % \
(reason[1], reason[2]), noiselevel=-1)
- if reason[0] == "Insufficient data for checksum verification":
+ if reason[0] == _("Insufficient data for checksum verification"):
return 0
if distdir_writable:
temp_filename = \
_checksum_failure_temp_file(
mysettings["DISTDIR"], myfile)
- writemsg_stdout("Refetching... " + \
- "File renamed to '%s'\n\n" % \
+ writemsg_stdout(_("Refetching... "
+ "File renamed to '%s'\n\n") % \
temp_filename, noiselevel=-1)
else:
eout = portage.output.EOutput()
@@ -4662,7 +4661,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
fetchcommand = mysettings.get(fetchcommand_var)
if fetchcommand is None:
portage.util.writemsg_level(
- ("!!! %s is unset. It should " + \
+ _("!!! %s is unset. It should "
"have been defined in\n!!! %s/make.globals.\n") \
% (fetchcommand_var,
portage.const.GLOBAL_CONFIG_PATH),
@@ -4670,7 +4669,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
return 0
if "${FILE}" not in fetchcommand:
portage.util.writemsg_level(
- ("!!! %s does not contain the required ${FILE}" + \
+ _("!!! %s does not contain the required ${FILE}"
" parameter.\n") % fetchcommand_var,
level=logging.ERROR, noiselevel=-1)
missing_file_param = True
@@ -4682,7 +4681,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
resumecommand = mysettings.get(resumecommand_var)
if resumecommand is None:
portage.util.writemsg_level(
- ("!!! %s is unset. It should " + \
+ _("!!! %s is unset. It should "
"have been defined in\n!!! %s/make.globals.\n") \
% (resumecommand_var,
portage.const.GLOBAL_CONFIG_PATH),
@@ -4690,16 +4689,16 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
return 0
if "${FILE}" not in resumecommand:
portage.util.writemsg_level(
- ("!!! %s does not contain the required ${FILE}" + \
+ _("!!! %s does not contain the required ${FILE}"
" parameter.\n") % resumecommand_var,
level=logging.ERROR, noiselevel=-1)
missing_file_param = True
if missing_file_param:
portage.util.writemsg_level(
- "!!! Refer to the make.conf(5) man page for " + \
- "information about how to\n!!! correctly specify " + \
- "FETCHCOMMAND and RESUMECOMMAND.\n",
+ _("!!! Refer to the make.conf(5) man page for "
+ "information about how to\n!!! correctly specify "
+ "FETCHCOMMAND and RESUMECOMMAND.\n"),
level=logging.ERROR, noiselevel=-1)
if myfile != os.path.basename(loc):
return 0
@@ -4715,13 +4714,13 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
mysize = 0
if mysize == 0:
- writemsg("!!! File %s isn't fetched but unable to get it.\n" % myfile,
+ writemsg(_("!!! File %s isn't fetched but unable to get it.\n") % myfile,
noiselevel=-1)
elif size is None or size > mysize:
- writemsg("!!! File %s isn't fully fetched, but unable to complete it\n" % myfile,
+ writemsg(_("!!! File %s isn't fully fetched, but unable to complete it\n") % myfile,
noiselevel=-1)
else:
- writemsg(("!!! File %s is incorrect size, " + \
+ writemsg(_("!!! File %s is incorrect size, "
"but unable to retry.\n") % myfile, noiselevel=-1)
return 0
else:
@@ -4739,8 +4738,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
fetched = 0
else:
if mystat.st_size < fetch_resume_size:
- writemsg((">>> Deleting distfile with size " + \
- "%d (smaller than " "PORTAGE_FETCH_RESU" + \
+ writemsg(_(">>> Deleting distfile with size "
+ "%d (smaller than " "PORTAGE_FETCH_RESU"
"ME_MIN_SIZE)\n") % mystat.st_size)
try:
os.unlink(myfile_path)
@@ -4752,14 +4751,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
fetched = 0
if fetched == 1:
#resume mode:
- writemsg(">>> Resuming download...\n")
+ writemsg(_(">>> Resuming download...\n"))
locfetch=resumecommand
command_var = resumecommand_var
else:
#normal mode:
locfetch=fetchcommand
command_var = fetchcommand_var
- writemsg_stdout(">>> Downloading '%s'\n" % \
+ writemsg_stdout(_(">>> Downloading '%s'\n") % \
re.sub(r'//(.+):.+@(.+)/',r'//\1:*password*@\2/', loc))
variables = {
"DISTDIR": mysettings["DISTDIR"],
@@ -4782,8 +4781,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
pass
except portage.exception.PortageException, e:
if not os.access(myfile_path, os.R_OK):
- writemsg("!!! Failed to adjust permissions:" + \
- " %s\n" % str(e), noiselevel=-1)
+ writemsg(_("!!! Failed to adjust permissions:"
+ " %s\n") % str(e), noiselevel=-1)
# If the file is empty then it's obviously invalid. Don't
# trust the return value from the fetcher. Remove the
@@ -4811,16 +4810,16 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
# contains wget's -P option where it should
# instead have -O.
portage.util.writemsg_level(
- ("!!! The command specified in the " + \
- "%s variable appears to have\n!!! " + \
- "created a directory instead of a " + \
+ _("!!! The command specified in the "
+ "%s variable appears to have\n!!! "
+ "created a directory instead of a "
"normal file.\n") % command_var,
level=logging.ERROR, noiselevel=-1)
portage.util.writemsg_level(
- "!!! Refer to the make.conf(5) " + \
- "man page for information about how " + \
- "to\n!!! correctly specify " + \
- "FETCHCOMMAND and RESUMECOMMAND.\n",
+ _("!!! Refer to the make.conf(5) "
+ "man page for information about how "
+ "to\n!!! correctly specify "
+ "FETCHCOMMAND and RESUMECOMMAND.\n"),
level=logging.ERROR, noiselevel=-1)
return 0
@@ -4844,7 +4843,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
).read()):
try:
os.unlink(mysettings["DISTDIR"]+"/"+myfile)
- writemsg(">>> Deleting invalid distfile. (Improper 404 redirect from server.)\n")
+ writemsg(_(">>> Deleting invalid distfile. (Improper 404 redirect from server.)\n"))
fetched = 0
continue
except (IOError, OSError):
@@ -4859,19 +4858,19 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
verified_ok,reason = portage.checksum.verify_all(mysettings["DISTDIR"]+"/"+myfile, mydigests[myfile])
if not verified_ok:
print reason
- writemsg("!!! Fetched file: "+str(myfile)+" VERIFY FAILED!\n",
+ writemsg(_("!!! Fetched file: %s VERIFY FAILED!\n") % myfile,
noiselevel=-1)
- writemsg("!!! Reason: "+reason[0]+"\n",
+ writemsg(_("!!! Reason: %s\n") % reason[0],
noiselevel=-1)
- writemsg("!!! Got: %s\n!!! Expected: %s\n" % \
+ writemsg(_("!!! Got: %s\n!!! Expected: %s\n") % \
(reason[1], reason[2]), noiselevel=-1)
- if reason[0] == "Insufficient data for checksum verification":
+ if reason[0] == _("Insufficient data for checksum verification"):
return 0
temp_filename = \
_checksum_failure_temp_file(
mysettings["DISTDIR"], myfile)
- writemsg_stdout("Refetching... " + \
- "File renamed to '%s'\n\n" % \
+ writemsg_stdout(_("Refetching... "
+ "File renamed to '%s'\n\n") % \
temp_filename, noiselevel=-1)
fetched=0
checksum_failure_count += 1
@@ -4903,7 +4902,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
fetched=2
break
elif mydigests!=None:
- writemsg("No digest file available and download failed.\n\n",
+ writemsg(_("No digest file available and download failed.\n\n"),
noiselevel=-1)
finally:
if use_locks and file_lock:
@@ -4914,11 +4913,11 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
if fetched != 2:
if restrict_fetch and not restrict_fetch_msg:
restrict_fetch_msg = True
- msg = ("\n!!! %s/%s" + \
- " has fetch restriction turned on.\n" + \
- "!!! This probably means that this " + \
- "ebuild's files must be downloaded\n" + \
- "!!! manually. See the comments in" + \
+ msg = _("\n!!! %s/%s"
+ " has fetch restriction turned on.\n"
+ "!!! This probably means that this "
+ "ebuild's files must be downloaded\n"
+ "!!! manually. See the comments in"
" the ebuild for more information.\n\n") % \
(mysettings["CATEGORY"], mysettings["PF"])
portage.util.writemsg_level(msg,
@@ -4984,10 +4983,10 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
elif listonly:
pass
elif not filedict[myfile]:
- writemsg("Warning: No mirrors available for file" + \
- " '%s'\n" % (myfile), noiselevel=-1)
+ writemsg(_("Warning: No mirrors available for file"
+ " '%s'\n") % (myfile), noiselevel=-1)
else:
- writemsg("!!! Couldn't download '%s'. Aborting.\n" % myfile,
+ writemsg(_("!!! Couldn't download '%s'. Aborting.\n") % myfile,
noiselevel=-1)
if listonly:
@@ -5100,30 +5099,30 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
st = None
if not fetch({myfile : uris}, fetch_settings):
- writemsg(("!!! Fetch failed for %s, can't update " + \
+ writemsg(_("!!! Fetch failed for %s, can't update "
"Manifest\n") % myfile, noiselevel=-1)
if myfile in dist_hashes and \
st is not None and st.st_size > 0:
# stat result is obtained before calling fetch(),
# since fetch may rename the existing file if the
# digest does not match.
- writemsg("!!! If you would like to " + \
- "forcefully replace the existing " + \
- "Manifest entry\n!!! for %s, use the " % \
- myfile + "following command:\n" + \
+ writemsg(_("!!! If you would like to "
+ "forcefully replace the existing "
+ "Manifest entry\n!!! for %s, use "
+ "the following command:\n") % myfile + \
"!!! " + colorize("INFORM",
"ebuild --force %s manifest" % \
os.path.basename(myebuild)) + "\n",
noiselevel=-1)
return 0
- writemsg_stdout(">>> Creating Manifest for %s\n" % mysettings["O"])
+ writemsg_stdout(_(">>> Creating Manifest for %s\n") % mysettings["O"])
try:
mf.create(requiredDistfiles=myarchives,
assumeDistHashesSometimes=True,
assumeDistHashesAlways=(
"assume-digests" in mysettings.features))
except portage.exception.FileNotFound, e:
- writemsg(("!!! File %s doesn't exist, can't update " + \
+ writemsg(_("!!! File %s doesn't exist, can't update "
"Manifest\n") % e, noiselevel=-1)
return 0
except portage.exception.PortagePackageException, e:
@@ -5132,7 +5131,7 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
try:
mf.write(sign=False)
except portage.exception.PermissionDenied, e:
- writemsg("!!! Permission Denied: %s\n" % (e,), noiselevel=-1)
+ writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
return 0
if "assume-digests" not in mysettings.features:
distlist = mf.fhashdict.get("DIST", {}).keys()
@@ -5191,7 +5190,7 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
pkgdir = mysettings["O"]
manifest_path = os.path.join(pkgdir, "Manifest")
if not os.path.exists(manifest_path):
- writemsg("!!! Manifest file not found: '%s'\n" % manifest_path,
+ writemsg(_("!!! Manifest file not found: '%s'\n") % manifest_path,
noiselevel=-1)
if strict:
return 0
@@ -5204,7 +5203,7 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
manifest_empty = False
break
if manifest_empty:
- writemsg("!!! Manifest is empty: '%s'\n" % manifest_path,
+ writemsg(_("!!! Manifest is empty: '%s'\n") % manifest_path,
noiselevel=-1)
if strict:
return 0
@@ -5214,17 +5213,17 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1"
try:
if strict and "PORTAGE_PARALLEL_FETCHONLY" not in mysettings:
- eout.ebegin("checking ebuild checksums ;-)")
+ eout.ebegin(_("checking ebuild checksums ;-)"))
mf.checkTypeHashes("EBUILD")
eout.eend(0)
- eout.ebegin("checking auxfile checksums ;-)")
+ eout.ebegin(_("checking auxfile checksums ;-)"))
mf.checkTypeHashes("AUX")
eout.eend(0)
- eout.ebegin("checking miscfile checksums ;-)")
+ eout.ebegin(_("checking miscfile checksums ;-)"))
mf.checkTypeHashes("MISC", ignoreMissingFiles=True)
eout.eend(0)
for f in myfiles:
- eout.ebegin("checking %s ;-)" % f)
+ eout.ebegin(_("checking %s ;-)") % f)
ftype = mf.findFile(f)
if ftype is None:
raise KeyError(f)
@@ -5232,20 +5231,20 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
eout.eend(0)
except KeyError, e:
eout.eend(1)
- writemsg("\n!!! Missing digest for %s\n" % str(e), noiselevel=-1)
+ writemsg(_("\n!!! Missing digest for %s\n") % str(e), noiselevel=-1)
return 0
except portage.exception.FileNotFound, e:
eout.eend(1)
- writemsg("\n!!! A file listed in the Manifest could not be found: %s\n" % str(e),
+ writemsg(_("\n!!! A file listed in the Manifest could not be found: %s\n") % str(e),
noiselevel=-1)
return 0
except portage.exception.DigestException, e:
eout.eend(1)
- writemsg("\n!!! Digest verification failed:\n", noiselevel=-1)
+ writemsg(_("\n!!! Digest verification failed:\n"), noiselevel=-1)
writemsg("!!! %s\n" % e.value[0], noiselevel=-1)
- writemsg("!!! Reason: %s\n" % e.value[1], noiselevel=-1)
- writemsg("!!! Got: %s\n" % e.value[2], noiselevel=-1)
- writemsg("!!! Expected: %s\n" % e.value[3], noiselevel=-1)
+ writemsg(_("!!! Reason: %s\n") % e.value[1], noiselevel=-1)
+ writemsg(_("!!! Got: %s\n") % e.value[2], noiselevel=-1)
+ writemsg(_("!!! Expected: %s\n") % e.value[3], noiselevel=-1)
return 0
# Make sure that all of the ebuilds are actually listed in the Manifest.
glep55 = 'parse-eapi-glep-55' in mysettings.features
@@ -5256,7 +5255,7 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
elif f[-7:] == '.ebuild':
pf = f[:-7]
if pf is not None and not mf.hasFile("EBUILD", f):
- writemsg("!!! A file is not listed in the Manifest: '%s'\n" % \
+ writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \
os.path.join(pkgdir, f), noiselevel=-1)
if strict:
return 0
@@ -5271,8 +5270,8 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
except UnicodeDecodeError:
parent = _unicode_decode(parent,
encoding=_fs_encoding, errors='replace')
- writemsg("!!! Path contains invalid " + \
- "character(s) for encoding '%s': '%s'" \
+ writemsg(_("!!! Path contains invalid "
+ "character(s) for encoding '%s': '%s'") \
% (_fs_encoding, parent), noiselevel=-1)
if strict:
return 0
@@ -5290,8 +5289,8 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
if f.startswith("."):
continue
f = os.path.join(parent, f)[len(filesdir) + 1:]
- writemsg("!!! File name contains invalid " + \
- "character(s) for encoding '%s': '%s'" \
+ writemsg(_("!!! File name contains invalid "
+ "character(s) for encoding '%s': '%s'") \
% (_fs_encoding, f), noiselevel=-1)
if strict:
return 0
@@ -5301,7 +5300,7 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
f = os.path.join(parent, f)[len(filesdir) + 1:]
file_type = mf.findFile(f)
if file_type != "AUX" and not f.startswith("digest-"):
- writemsg("!!! A file is not listed in the Manifest: '%s'\n" % \
+ writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \
os.path.join(filesdir, f), noiselevel=-1)
if strict:
return 0
@@ -5398,7 +5397,7 @@ def _post_src_install_checks(mysettings):
global _post_phase_cmds
retval = _spawn_misc_sh(mysettings, _post_phase_cmds["install"])
if retval != os.EX_OK:
- writemsg("!!! install_qa_check failed; exiting.\n",
+ writemsg(_("!!! install_qa_check failed; exiting.\n"),
noiselevel=-1)
return retval
@@ -5475,43 +5474,43 @@ def _check_build_log(mysettings, out=None):
wrap_width = 70
if am_maintainer_mode:
- msg = ["QA Notice: Automake \"maintainer mode\" detected:"]
+ msg = [_("QA Notice: Automake \"maintainer mode\" detected:")]
msg.append("")
msg.extend("\t" + line for line in am_maintainer_mode)
msg.append("")
- msg.extend(wrap(
- "If you patch Makefile.am, " + \
- "configure.in, or configure.ac then you " + \
- "should use autotools.eclass and " + \
- "eautomake or eautoreconf. Exceptions " + \
- "are limited to system packages " + \
- "for which it is impossible to run " + \
- "autotools during stage building. " + \
- "See http://www.gentoo.org/p" + \
- "roj/en/qa/autofailure.xml for more information.",
+ msg.extend(wrap(_(
+ "If you patch Makefile.am, "
+ "configure.in, or configure.ac then you "
+ "should use autotools.eclass and "
+ "eautomake or eautoreconf. Exceptions "
+ "are limited to system packages "
+ "for which it is impossible to run "
+ "autotools during stage building. "
+ "See http://www.gentoo.org/p"
+ "roj/en/qa/autofailure.xml for more information."),
wrap_width))
_eqawarn(msg)
if bash_command_not_found:
- msg = ["QA Notice: command not found:"]
+ msg = [_("QA Notice: command not found:")]
msg.append("")
msg.extend("\t" + line for line in bash_command_not_found)
_eqawarn(msg)
if helper_missing_file:
- msg = ["QA Notice: file does not exist:"]
+ msg = [_("QA Notice: file does not exist:")]
msg.append("")
msg.extend("\t" + line[4:] for line in helper_missing_file)
_eqawarn(msg)
if configure_opts_warn:
- msg = ["QA Notice: Unrecognized configure options:"]
+ msg = [_("QA Notice: Unrecognized configure options:")]
msg.append("")
msg.extend("\t" + line for line in configure_opts_warn)
_eqawarn(msg)
if make_jobserver:
- msg = ["QA Notice: make jobserver unavailable:"]
+ msg = [_("QA Notice: make jobserver unavailable:")]
msg.append("")
msg.extend("\t" + line for line in make_jobserver)
_eqawarn(msg)
@@ -5642,9 +5641,9 @@ def _merge_unicode_error(errors):
from textwrap import wrap
lines = []
- msg = "This package installs one or more file names containing " + \
- "characters that do not match your current locale " + \
- "settings. The current setting for filesystem encoding is '%s'." \
+ msg = _("This package installs one or more file names containing "
+ "characters that do not match your current locale "
+ "settings. The current setting for filesystem encoding is '%s'.") \
% _merge_encoding
lines.extend(wrap(msg, 72))
@@ -5654,9 +5653,9 @@ def _merge_unicode_error(errors):
lines.append("")
if _merge_encoding.lower().replace('_', '').replace('-', '') != 'utf8':
- msg = "For best results, UTF-8 encoding is recommended. See " + \
- "the Gentoo Linux Localization Guide for instructions " + \
- "about how to configure your locale for UTF-8 encoding:"
+ msg = _("For best results, UTF-8 encoding is recommended. See "
+ "the Gentoo Linux Localization Guide for instructions "
+ "about how to configure your locale for UTF-8 encoding:")
lines.extend(wrap(msg, 72))
lines.append("")
lines.append("\t" + \
@@ -5820,7 +5819,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
mysplit=pkgsplit(mypv,silent=0)
if mysplit is None:
raise portage.exception.IncorrectParameter(
- "Invalid ebuild path: '%s'" % myebuild)
+ _("Invalid ebuild path: '%s'") % myebuild)
# Make a backup of PORTAGE_TMPDIR prior to calling config.reset()
# so that the caller can override it.
@@ -5991,7 +5990,7 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
pass
elif errno.EPERM == oe.errno:
writemsg("%s\n" % oe, noiselevel=-1)
- writemsg("Operation Not Permitted: rmtree('%s')\n" % \
+ writemsg(_("Operation Not Permitted: rmtree('%s')\n") % \
clean_dir, noiselevel=-1)
return 1
else:
@@ -6005,7 +6004,7 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
pass
elif errno.EPERM == oe.errno:
writemsg("%s\n" % oe, noiselevel=-1)
- writemsg("Operation Not Permitted: makedirs('%s')\n" % \
+ writemsg(_("Operation Not Permitted: makedirs('%s')\n") % \
dir_path, noiselevel=-1)
return False
else:
@@ -6032,13 +6031,13 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
portage.util.apply_secpass_permissions(mysettings[dir_key],
uid=portage_uid, gid=portage_gid)
except portage.exception.PermissionDenied, e:
- writemsg("Permission Denied: %s\n" % str(e), noiselevel=-1)
+ writemsg(_("Permission Denied: %s\n") % str(e), noiselevel=-1)
return 1
except portage.exception.OperationNotPermitted, e:
- writemsg("Operation Not Permitted: %s\n" % str(e), noiselevel=-1)
+ writemsg(_("Operation Not Permitted: %s\n") % str(e), noiselevel=-1)
return 1
except portage.exception.FileNotFound, e:
- writemsg("File Not Found: '%s'\n" % str(e), noiselevel=-1)
+ writemsg(_("File Not Found: '%s'\n") % str(e), noiselevel=-1)
return 1
_prepare_workdir(mysettings)
@@ -6141,13 +6140,13 @@ def _prepare_features_dirs(mysettings):
if droppriv_fix:
_adjust_perms_msg(mysettings,
colorize("WARN", " * ") + \
- "Adjusting permissions " + \
- "for FEATURES=userpriv: '%s'\n" % mydir)
+ _("Adjusting permissions "
+ "for FEATURES=userpriv: '%s'\n") % mydir)
elif modified:
_adjust_perms_msg(mysettings,
colorize("WARN", " * ") + \
- "Adjusting permissions " + \
- "for FEATURES=%s: '%s'\n" % (myfeature, mydir))
+ _("Adjusting permissions "
+ "for FEATURES=%s: '%s'\n") % (myfeature, mydir))
if modified or kwargs["always_recurse"] or droppriv_fix:
def onerror(e):
@@ -6157,21 +6156,21 @@ def _prepare_features_dirs(mysettings):
gid=portage_gid, dirmode=dirmode, dirmask=modemask,
filemode=filemode, filemask=modemask, onerror=onerror):
raise portage.exception.OperationNotPermitted(
- "Failed to apply recursive permissions for the portage group.")
+ _("Failed to apply recursive permissions for the portage group."))
except portage.exception.DirectoryNotFound, e:
failure = True
- writemsg("\n!!! Directory does not exist: '%s'\n" % \
+ writemsg(_("\n!!! Directory does not exist: '%s'\n") % \
(e,), noiselevel=-1)
- writemsg("!!! Disabled FEATURES='%s'\n" % myfeature,
+ writemsg(_("!!! Disabled FEATURES='%s'\n") % myfeature,
noiselevel=-1)
except portage.exception.PortageException, e:
failure = True
writemsg("\n!!! %s\n" % str(e), noiselevel=-1)
- writemsg("!!! Failed resetting perms on %s='%s'\n" % \
+ writemsg(_("!!! Failed resetting perms on %s='%s'\n") % \
(kwargs["basedir_var"], basedir), noiselevel=-1)
- writemsg("!!! Disabled FEATURES='%s'\n" % myfeature,
+ writemsg(_("!!! Disabled FEATURES='%s'\n") % myfeature,
noiselevel=-1)
if failure:
@@ -6194,11 +6193,11 @@ def _prepare_workdir(mysettings):
else:
workdir_mode = parsed_mode
except KeyError, e:
- writemsg("!!! PORTAGE_WORKDIR_MODE is unset, using %s.\n" % oct(workdir_mode))
+ writemsg(_("!!! PORTAGE_WORKDIR_MODE is unset, using %s.\n") % oct(workdir_mode))
except ValueError, e:
if len(str(e)) > 0:
writemsg("%s\n" % e)
- writemsg("!!! Unable to parse PORTAGE_WORKDIR_MODE='%s', using %s.\n" % \
+ writemsg(_("!!! Unable to parse PORTAGE_WORKDIR_MODE='%s', using %s.\n") % \
(mysettings["PORTAGE_WORKDIR_MODE"], oct(workdir_mode)))
mysettings["PORTAGE_WORKDIR_MODE"] = oct(workdir_mode)
try:
@@ -6218,9 +6217,9 @@ def _prepare_workdir(mysettings):
uid=portage_uid, gid=portage_gid, mode=02770)
except portage.exception.PortageException, e:
writemsg("!!! %s\n" % str(e), noiselevel=-1)
- writemsg("!!! Permission issues with PORT_LOGDIR='%s'\n" % \
+ writemsg(_("!!! Permission issues with PORT_LOGDIR='%s'\n") % \
mysettings["PORT_LOGDIR"], noiselevel=-1)
- writemsg("!!! Disabling logging.\n", noiselevel=-1)
+ writemsg(_("!!! Disabling logging.\n"), noiselevel=-1)
while "PORT_LOGDIR" in mysettings:
del mysettings["PORT_LOGDIR"]
if "PORT_LOGDIR" in mysettings and \
@@ -6251,25 +6250,25 @@ def _doebuild_exit_status_check(mydo, settings):
if not exit_status_file or \
os.path.exists(exit_status_file):
return None
- msg = ("The ebuild phase '%s' has exited " % mydo) + \
- "unexpectedly. This type of behavior " + \
- "is known to be triggered " + \
- "by things such as failed variable " + \
- "assignments (bug #190128) or bad substitution " + \
- "errors (bug #200313). Normally, before exiting, bash should " + \
- "have displayed an error message above. If bash did not " + \
- "produce an error message above, it's possible " + \
- "that the ebuild has called `exit` when it " + \
- "should have called `die` instead. This behavior may also " + \
- "be triggered by a corrupt bash binary or a hardware " + \
- "problem such as memory or cpu malfunction. If the problem is not " + \
- "reproducible or it appears to occur randomly, then it is likely " + \
- "to be triggered by a hardware problem. " + \
- "If you suspect a hardware problem then you should " + \
- "try some basic hardware diagnostics such as memtest. " + \
- "Please do not report this as a bug unless it is consistently " + \
- "reproducible and you are sure that your bash binary and hardware " + \
- "are functioning properly."
+ msg = _("The ebuild phase '%s' has exited "
+ "unexpectedly. This type of behavior "
+ "is known to be triggered "
+ "by things such as failed variable "
+ "assignments (bug #190128) or bad substitution "
+ "errors (bug #200313). Normally, before exiting, bash should "
+ "have displayed an error message above. If bash did not "
+ "produce an error message above, it's possible "
+ "that the ebuild has called `exit` when it "
+ "should have called `die` instead. This behavior may also "
+ "be triggered by a corrupt bash binary or a hardware "
+ "problem such as memory or cpu malfunction. If the problem is not "
+ "reproducible or it appears to occur randomly, then it is likely "
+ "to be triggered by a hardware problem. "
+ "If you suspect a hardware problem then you should "
+ "try some basic hardware diagnostics such as memtest. "
+ "Please do not report this as a bug unless it is consistently "
+ "reproducible and you are sure that your bash binary and hardware "
+ "are functioning properly.") % mydo
return msg
def _doebuild_exit_status_check_and_log(settings, mydo, retval):
@@ -6446,7 +6445,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
_doebuild_manifest_cache = None
if not os.path.exists(manifest_path):
out = portage.output.EOutput()
- out.eerror("Manifest not found for '%s'" % (myebuild,))
+ out.eerror(_("Manifest not found for '%s'") % (myebuild,))
_doebuild_broken_ebuilds.add(myebuild)
return 1
mf = Manifest(pkgdir, mysettings["DISTDIR"])
@@ -6458,22 +6457,22 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
mf.checkFileHashes("EBUILD", os.path.basename(myebuild))
except KeyError:
out = portage.output.EOutput()
- out.eerror("Missing digest for '%s'" % (myebuild,))
+ out.eerror(_("Missing digest for '%s'") % (myebuild,))
_doebuild_broken_ebuilds.add(myebuild)
return 1
except portage.exception.FileNotFound:
out = portage.output.EOutput()
- out.eerror("A file listed in the Manifest " + \
- "could not be found: '%s'" % (myebuild,))
+ out.eerror(_("A file listed in the Manifest "
+ "could not be found: '%s'") % (myebuild,))
_doebuild_broken_ebuilds.add(myebuild)
return 1
except portage.exception.DigestException, e:
out = portage.output.EOutput()
- out.eerror("Digest verification failed:")
+ out.eerror(_("Digest verification failed:"))
out.eerror("%s" % e.value[0])
- out.eerror("Reason: %s" % e.value[1])
- out.eerror("Got: %s" % e.value[2])
- out.eerror("Expected: %s" % e.value[3])
+ out.eerror(_("Reason: %s") % e.value[1])
+ out.eerror(_("Got: %s") % e.value[2])
+ out.eerror(_("Expected: %s") % e.value[3])
_doebuild_broken_ebuilds.add(myebuild)
return 1
@@ -6495,8 +6494,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
f = os.path.join(pkgdir, f)
if f not in _doebuild_broken_ebuilds:
out = portage.output.EOutput()
- out.eerror("A file is not listed in the " + \
- "Manifest: '%s'" % (f,))
+ out.eerror(_("A file is not listed in the "
+ "Manifest: '%s'") % (f,))
_doebuild_broken_manifests.add(manifest_path)
return 1
@@ -6615,11 +6614,10 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
if "PORTAGE_TMPDIR" not in mysettings or \
not os.path.isdir(mysettings["PORTAGE_TMPDIR"]):
- writemsg("The directory specified in your " + \
- "PORTAGE_TMPDIR variable, '%s',\n" % \
- mysettings.get("PORTAGE_TMPDIR", ""), noiselevel=-1)
- writemsg("does not exist. Please create this directory or " + \
- "correct your PORTAGE_TMPDIR setting.\n", noiselevel=-1)
+ writemsg(_("The directory specified in your "
+ "PORTAGE_TMPDIR variable, '%s',\n"
+ "does not exist. Please create this directory or "
+ "correct your PORTAGE_TMPDIR setting.\n") % mysettings.get("PORTAGE_TMPDIR", ""), noiselevel=-1)
return 1
# as some people use a separate PORTAGE_TMPDIR mount
@@ -6631,20 +6629,20 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
checkdir = mysettings["PORTAGE_TMPDIR"]
if not os.access(checkdir, os.W_OK):
- writemsg("%s is not writable.\n" % checkdir + \
- "Likely cause is that you've mounted it as readonly.\n" \
- , noiselevel=-1)
+ writemsg(_("%s is not writable.\n"
+ "Likely cause is that you've mounted it as readonly.\n") % checkdir,
+ noiselevel=-1)
return 1
else:
from tempfile import NamedTemporaryFile
fd = NamedTemporaryFile(prefix="exectest-", dir=checkdir)
os.chmod(fd.name, 0755)
if not os.access(fd.name, os.X_OK):
- writemsg("Can not execute files in %s\n" % checkdir + \
- "Likely cause is that you've mounted it with one of the\n" + \
- "following mount options: 'noexec', 'user', 'users'\n\n" + \
- "Please make sure that portage can execute files in this directory.\n" \
- , noiselevel=-1)
+ writemsg(_("Can not execute files in %s\n"
+ "Likely cause is that you've mounted it with one of the\n"
+ "following mount options: 'noexec', 'user', 'users'\n\n"
+ "Please make sure that portage can execute files in this directory.\n") % checkdir,
+ noiselevel=-1)
fd.close()
return 1
fd.close()
@@ -6707,7 +6705,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
# would be preserved between normal phases.
open(_unicode_encode(env_file + '.raw'), 'w')
else:
- writemsg(("!!! Error extracting saved " + \
+ writemsg(_("!!! Error extracting saved "
"environment: '%s'\n") % \
saved_env, noiselevel=-1)
try:
@@ -6724,11 +6722,11 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
value = mysettings.get(var)
if value and value.strip():
continue
- msg = ("%s is not set... " % var) + \
- ("Are you missing the '%setc/make.profile' symlink? " % \
- mysettings["PORTAGE_CONFIGROOT"]) + \
- "Is the symlink correct? " + \
- "Is your portage tree complete?"
+ msg = _("%(var)s is not set... "
+ "Are you missing the '%(configroot)setc/make.profile' symlink? "
+ "Is the symlink correct? "
+ "Is your portage tree complete?") % \
+ {"var": var, "configroot": mysettings["PORTAGE_CONFIGROOT"]}
from portage.elog.messages import eerror
from textwrap import wrap
for line in wrap(msg, 70):
@@ -6781,7 +6779,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
mysettings, debug=debug, free=1, logfile=logfile)
phase_retval = exit_status_check(phase_retval)
if phase_retval != os.EX_OK:
- writemsg("!!! post preinst failed; exiting.\n",
+ writemsg(_("!!! post preinst failed; exiting.\n"),
noiselevel=-1)
return phase_retval
elif mydo == "postinst":
@@ -6802,7 +6800,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
mysettings, debug=debug, free=1, logfile=logfile)
phase_retval = exit_status_check(phase_retval)
if phase_retval != os.EX_OK:
- writemsg("!!! post postinst failed; exiting.\n",
+ writemsg(_("!!! post postinst failed; exiting.\n"),
noiselevel=-1)
return phase_retval
elif mydo in ("prerm", "postrm", "config", "info"):
@@ -6840,7 +6838,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
aalist = mydbapi.getFetchMap(mycpv, mytree=mytree)
except portage.exception.InvalidDependString, e:
writemsg("!!! %s\n" % str(e), noiselevel=-1)
- writemsg("!!! Invalid SRC_URI for '%s'.\n" % mycpv,
+ writemsg(_("!!! Invalid SRC_URI for '%s'.\n") % mycpv,
noiselevel=-1)
del e
return 1
@@ -6884,7 +6882,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
# and it can interfere with parallel tasks.
digestgen(aalist, mysettings, overwrite=0, myportdb=mydbapi)
except portage.exception.PermissionDenied, e:
- writemsg("!!! Permission Denied: %s\n" % (e,), noiselevel=-1)
+ writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
if mydo in ("digest", "manifest"):
return 1
@@ -6992,7 +6990,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
# forget it and are using ebuild
if not os.path.exists(
os.path.join(mysettings["PORTAGE_BUILDDIR"], ".installed")):
- writemsg("!!! mydo=qmerge, but the install phase has not been run\n",
+ writemsg(_("!!! mydo=qmerge, but the install phase has not been run\n"),
noiselevel=-1)
return 1
# qmerge is a special phase that implies noclean.
@@ -7022,7 +7020,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
myebuild=mysettings["EBUILD"], mytree=tree, mydbapi=mydbapi,
vartree=vartree, prev_mtimes=prev_mtimes)
else:
- print "!!! Unknown mydo:",mydo
+ print _("!!! Unknown mydo: %s") % mydo
return 1
return retval
@@ -7087,10 +7085,10 @@ def _validate_deps(mysettings, myroot, mydo, mydbapi):
k, metadata[k], str(e)))
if not metadata["SLOT"]:
- msgs.append(" SLOT is undefined\n")
+ msgs.append(_(" SLOT is undefined\n"))
if msgs:
- portage.util.writemsg_level("Error(s) in metadata for '%s':\n" % \
+ portage.util.writemsg_level(_("Error(s) in metadata for '%s':\n") % \
(mysettings.mycpv,), level=logging.ERROR, noiselevel=-1)
for x in msgs:
portage.util.writemsg_level(x,
@@ -7135,7 +7133,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
except SystemExit, e:
raise
except Exception, e:
- print "!!! Stating source file failed... movefile()"
+ print _("!!! Stating source file failed... movefile()")
print "!!!",e
return None
@@ -7184,7 +7182,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
except SystemExit, e:
raise
except Exception, e:
- print "!!! failed to properly create symlink:"
+ print _("!!! failed to properly create symlink:")
print "!!!",dest,"->",target
print "!!!",e
return None
@@ -7202,7 +7200,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
os.unlink(hardlink_tmp)
except OSError, e:
if e.errno != errno.ENOENT:
- writemsg("!!! Failed to remove hardlink temp file: %s\n" % \
+ writemsg(_("!!! Failed to remove hardlink temp file: %s\n") % \
(hardlink_tmp,), noiselevel=-1)
writemsg("!!! %s\n" % (e,), noiselevel=-1)
return None
@@ -7216,7 +7214,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
try:
os.rename(hardlink_tmp, dest)
except OSError, e:
- writemsg("!!! Failed to rename %s to %s\n" % \
+ writemsg(_("!!! Failed to rename %s to %s\n") % \
(hardlink_tmp, dest), noiselevel=-1)
writemsg("!!! %s\n" % (e,), noiselevel=-1)
return None
@@ -7238,7 +7236,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
except Exception, e:
if e[0]!=errno.EXDEV:
# Some random error.
- print "!!! Failed to move",src,"to",dest
+ print _("!!! Failed to move %(src)s to %(dest)s") % {"src": src, "dest": dest}
print "!!!",e
return None
# Invalid cross-device-link 'bind' mounted or actually Cross-Device
@@ -7256,17 +7254,17 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
except SystemExit, e:
raise
except Exception, e:
- print '!!! copy',src,'->',dest,'failed.'
+ print _('!!! copy %(src)s -> %(dest)s failed.') % {"src": src, "dest": dest}
print "!!!",e
return None
else:
#we don't yet handle special, so we need to fall back to /bin/mv
a = process.spawn([MOVE_BINARY, '-f', src, dest], env=os.environ)
if a != os.EX_OK:
- writemsg("!!! Failed to move special file:\n", noiselevel=-1)
- writemsg("!!! '%s' to '%s'\n" % \
- (_unicode_decode(src, encoding=encoding),
- _unicode_decode(dest, encoding=encoding)), noiselevel=-1)
+ writemsg(_("!!! Failed to move special file:\n"), noiselevel=-1)
+ writemsg(_("!!! '%(src)s' to '%(dest)s'\n") % \
+ {"src": _unicode_decode(src, encoding=encoding),
+ "dest": _unicode_decode(dest, encoding=encoding)}, noiselevel=-1)
writemsg("!!! %s\n" % a, noiselevel=-1)
return None # failure
try:
@@ -7280,7 +7278,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
except SystemExit, e:
raise
except Exception, e:
- print "!!! Failed to chown/chmod/unlink in movefile()"
+ print _("!!! Failed to chown/chmod/unlink in movefile()")
print "!!!",dest
print "!!!",e
return None
@@ -7300,7 +7298,7 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
try:
newmtime = long(os.stat(dest).st_mtime)
except OSError, e:
- writemsg("!!! Failed to stat in movefile()\n", noiselevel=-1)
+ writemsg(_("!!! Failed to stat in movefile()\n"), noiselevel=-1)
writemsg("!!! %s\n" % dest, noiselevel=-1)
writemsg("!!! %s\n" % str(e), noiselevel=-1)
return None
@@ -7316,7 +7314,7 @@ def merge(mycat, mypkg, pkgloc, infloc, myroot, mysettings, myebuild=None,
mytree=None, mydbapi=None, vartree=None, prev_mtimes=None, blockers=None,
scheduler=None):
if not os.access(myroot, os.W_OK):
- writemsg("Permission denied: access('%s', W_OK)\n" % myroot,
+ writemsg(_("Permission denied: access('%s', W_OK)\n") % myroot,
noiselevel=-1)
return errno.EACCES
mylink = dblink(mycat, mypkg, myroot, mysettings, treetype=mytree,
@@ -7416,16 +7414,16 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
except portage.exception.InvalidAtom:
if portage.dep._dep_check_strict:
raise portage.exception.ParseError(
- "invalid atom: '%s'" % x)
+ _("invalid atom: '%s'") % x)
else:
if x.blocker and x.blocker.overlap.forbid and \
eapi in ("0", "1") and portage.dep._dep_check_strict:
raise portage.exception.ParseError(
- "invalid atom: '%s'" % (x,))
+ _("invalid atom: '%s'") % (x,))
if x.use and eapi in ("0", "1") and \
portage.dep._dep_check_strict:
raise portage.exception.ParseError(
- "invalid atom: '%s'" % (x,))
+ _("invalid atom: '%s'") % (x,))
if repoman and x.use and x.use.conditional:
evaluated_atom = portage.dep.remove_slot(x)
@@ -7486,8 +7484,8 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
use_split = db.aux_get(cpv, ["USE"])[0].split()
pkg_kwargs["myuse"] = use_split
if edebug:
- print "Virtual Parent: ", y[0]
- print "Virtual Depstring:", depstring
+ print _("Virtual Parent: "), y[0]
+ print _("Virtual Depstring:"), depstring
# Set EAPI used for validation in dep_check() recursion.
virtual_eapi, = db.aux_get(cpv, ["EAPI"])
@@ -7823,7 +7821,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
mysplit2=mysplit[:]
mysplit2=dep_wordreduce(mysplit2,mysettings,mydbapi,mode,use_cache=use_cache)
if mysplit2 is None:
- return [0,"Invalid token"]
+ return [0, _("Invalid token")]
writemsg("\n\n\n", 1)
writemsg("mysplit: %s\n" % (mysplit), 1)
@@ -7837,7 +7835,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
raise # This shouldn't happen.
# dbapi.match() failed due to an invalid atom in
# the dependencies of an installed package.
- return [0, "Invalid atom: '%s'" % (e,)]
+ return [0, _("Invalid atom: '%s'") % (e,)]
mylist = flatten(myzaps)
writemsg("myzaps: %s\n" % (myzaps), 1)
@@ -7958,11 +7956,11 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
# dbapi.cp_list().
if mydb.cp_list(dep_getkey(vkey), use_cache=use_cache):
mykey = vkey
- writemsg("virts chosen: %s\n" % (mykey), 1)
+ writemsg(_("virts chosen: %s\n") % (mykey), 1)
break
if mykey == mykey_orig:
mykey=virts[mykey][0]
- writemsg("virts defaulted: %s\n" % (mykey), 1)
+ writemsg(_("virts defaulted: %s\n") % (mykey), 1)
#we only perform virtual expansion if we are passed a dbapi
else:
#specific cpv, no category, ie. "foo-1.0"
@@ -8019,7 +8017,7 @@ def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_lo
portdb = globals()["portdb"]
mysplit = catpkgsplit(mycpv)
if not mysplit:
- raise ValueError("invalid CPV: %s" % mycpv)
+ raise ValueError(_("invalid CPV: %s") % mycpv)
if metadata is None:
db_keys = list(portdb._aux_cache_keys)
try:
@@ -8095,7 +8093,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
mysplit = catpkgsplit(mycpv)
if not mysplit:
- raise ValueError("invalid CPV: %s" % mycpv)
+ raise ValueError(_("invalid CPV: %s") % mycpv)
if metadata is None:
db_keys = list(portdb._aux_cache_keys)
try:
@@ -8282,7 +8280,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
if vartree is None:
vartree = db[myroot]["vartree"]
if mytbz2[-5:]!=".tbz2":
- print "!!! Not a .tbz2 file"
+ print _("!!! Not a .tbz2 file")
return 1
tbz2_lock = None
@@ -8299,7 +8297,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
xptbz2 = portage.xpak.tbz2(mytbz2)
mycat = xptbz2.getfile("CATEGORY")
if not mycat:
- writemsg("!!! CATEGORY info missing from info chunk, aborting...\n",
+ writemsg(_("!!! CATEGORY info missing from info chunk, aborting...\n"),
noiselevel=-1)
return 1
mycat = mycat.strip()
@@ -8326,7 +8324,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
for mydir in (builddir, pkgloc, infloc):
portage.util.ensure_dirs(mydir, uid=portage_uid,
gid=portage_gid, mode=0755)
- writemsg_stdout(">>> Extracting info\n")
+ writemsg_stdout(_(">>> Extracting info\n"))
xptbz2.unpackinfo(infloc)
mysettings.setcpv(mycat + "/" + mypkg, mydb=mydbapi)
# Store the md5sum in the vdb.
@@ -8344,15 +8342,15 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
retval = doebuild(myebuild, "setup", myroot, mysettings, debug=debug,
tree="bintree", mydbapi=mydbapi, vartree=vartree)
if retval != os.EX_OK:
- writemsg("!!! Setup failed: %s\n" % retval, noiselevel=-1)
+ writemsg(_("!!! Setup failed: %s\n") % retval, noiselevel=-1)
return retval
- writemsg_stdout(">>> Extracting %s\n" % mypkg)
+ writemsg_stdout(_(">>> Extracting %s\n") % mypkg)
retval = portage.process.spawn_bash(
"bzip2 -dqc -- '%s' | tar -xp -C '%s' -f -" % (mytbz2, pkgloc),
env=mysettings.environ())
if retval != os.EX_OK:
- writemsg("!!! Error Extracting '%s'\n" % mytbz2, noiselevel=-1)
+ writemsg(_("!!! Error Extracting '%s'\n") % mytbz2, noiselevel=-1)
return retval
#portage.locks.unlockfile(tbz2_lock)
#tbz2_lock = None
@@ -8393,18 +8391,18 @@ def deprecated_profile_check(settings=None):
return False
dcontent = codecs.open(_unicode_encode(deprecated_profile_file),
mode='r', encoding='utf_8', errors='replace').readlines()
- writemsg(colorize("BAD", "\n!!! Your current profile is " + \
- "deprecated and not supported anymore.") + "\n", noiselevel=-1)
+ writemsg(colorize("BAD", _("\n!!! Your current profile is "
+ "deprecated and not supported anymore.")) + "\n", noiselevel=-1)
if not dcontent:
- writemsg(colorize("BAD","!!! Please refer to the " + \
- "Gentoo Upgrading Guide.") + "\n", noiselevel=-1)
+ writemsg(colorize("BAD", _("!!! Please refer to the "
+ "Gentoo Upgrading Guide.")) + "\n", noiselevel=-1)
return True
newprofile = dcontent[0]
- writemsg(colorize("BAD", "!!! Please upgrade to the " + \
- "following profile if possible:") + "\n", noiselevel=-1)
+ writemsg(colorize("BAD", _("!!! Please upgrade to the "
+ "following profile if possible:")) + "\n", noiselevel=-1)
writemsg(8*" " + colorize("GOOD", newprofile) + "\n", noiselevel=-1)
if len(dcontent) > 1:
- writemsg("To upgrade do the following steps:\n", noiselevel=-1)
+ writemsg(_("To upgrade do the following steps:\n"), noiselevel=-1)
for myline in dcontent[1:]:
writemsg(myline, noiselevel=-1)
writemsg("\n\n", noiselevel=-1)
@@ -8473,8 +8471,8 @@ def _global_updates(trees, prev_mtimes):
else:
update_data = grab_updates(updpath, prev_mtimes)
except portage.exception.DirectoryNotFound:
- writemsg("--- 'profiles/updates' is empty or " + \
- "not available. Empty portage tree?\n", noiselevel=1)
+ writemsg(_("--- 'profiles/updates' is empty or "
+ "not available. Empty portage tree?\n"), noiselevel=1)
return
myupd = None
if len(update_data) > 0:
@@ -8484,15 +8482,13 @@ def _global_updates(trees, prev_mtimes):
for mykey, mystat, mycontent in update_data:
writemsg_stdout("\n\n")
writemsg_stdout(colorize("GOOD",
- "Performing Global Updates: ")+bold(mykey)+"\n")
- writemsg_stdout("(Could take a couple of minutes if you have a lot of binary packages.)\n")
- writemsg_stdout(" " + bold(".") + "='update pass' " + \
- bold("*") + "='binary update' " + bold("#") + \
- "='/var/db update' " + bold("@") + "='/var/db move'\n" + \
- " " + bold("s") + "='/var/db SLOT move' " + \
- bold("%") + "='binary move' " + bold("S") + \
- "='binary SLOT move'\n " + \
- bold("p") + "='update /etc/portage/package.*'\n")
+ _("Performing Global Updates: "))+bold(mykey)+"\n")
+ writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n"))
+ writemsg_stdout(_(" %s='update pass' %s='binary update' "
+ "%s='/var/db update' %s='/var/db move'\n"
+ " %s='/var/db SLOT move' %s='binary move' "
+ "%s='binary SLOT move'\n %s='update /etc/portage/package.*'\n") % \
+ (bold("."), bold("*"), bold("#"), bold("@"), bold("s"), bold("%"), bold("S"), bold("p")))
valid_updates, errors = parse_updates(mycontent)
myupd.extend(valid_updates)
writemsg_stdout(len(valid_updates) * "." + "\n")
@@ -8580,8 +8576,8 @@ def _global_updates(trees, prev_mtimes):
if do_upgrade_packagesmessage and bindb and \
bindb.cpv_all():
- writemsg_stdout(" ** Skipping packages. Run 'fixpackages' or set it in FEATURES to fix the")
- writemsg_stdout("\n tbz2's in the packages directory. "+bold("Note: This can take a very long time."))
+ writemsg_stdout(_(" ** Skipping packages. Run 'fixpackages' or set it in FEATURES to fix the tbz2's in the packages directory.\n"))
+ writemsg_stdout(bold(_("Note: This can take a very long time.")))
writemsg_stdout("\n")
if myupd:
return myupd
@@ -8608,7 +8604,7 @@ class MtimeDB(dict):
del f
except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError), e:
if isinstance(e, pickle.UnpicklingError):
- writemsg("!!! Error loading '%s': %s\n" % \
+ writemsg(_("!!! Error loading '%s': %s\n") % \
(filename, str(e)), noiselevel=-1)
del e
d = {}
@@ -8629,7 +8625,7 @@ class MtimeDB(dict):
for k in d.keys():
if k not in mtimedbkeys:
- writemsg("Deleting invalid mtimedb key: %s\n" % str(k))
+ writemsg(_("Deleting invalid mtimedb key: %s\n") % str(k))
del d[k]
self.update(d)
self._clean_data = copy.deepcopy(d)
diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py
index e92c21fc9..71ec0a46e 100644
--- a/pym/portage/_selinux.py
+++ b/pym/portage/_selinux.py
@@ -8,6 +8,8 @@ import os
import shutil
import portage
+from portage.localization import _
+
import selinux
from selinux import is_selinux_enabled, getfilecon, lgetfilecon
@@ -16,7 +18,7 @@ def copyfile(src, dest):
dest = portage._unicode_encode(dest)
(rc, ctx) = selinux.lgetfilecon(src)
if rc < 0:
- raise OSError("copyfile: Failed getting context of \"%s\"." % src)
+ raise OSError(_("copyfile: Failed getting context of \"%s\".") % src)
setfscreate(ctx)
try:
@@ -27,7 +29,7 @@ def copyfile(src, dest):
def getcontext():
(rc, ctx) = selinux.getcon()
if rc < 0:
- raise OSError("getcontext: Failed getting current process context.")
+ raise OSError(_("getcontext: Failed getting current process context."))
return ctx
@@ -37,7 +39,7 @@ def mkdir(target, refdir):
(rc, ctx) = selinux.getfilecon(refdir)
if rc < 0:
raise OSError(
- "mkdir: Failed getting context of reference directory \"%s\"." \
+ _("mkdir: Failed getting context of reference directory \"%s\".") \
% refdir)
setfscreatecon(ctx)
@@ -51,7 +53,7 @@ def rename(src, dest):
dest = portage._unicode_encode(dest)
(rc, ctx) = selinux.lgetfilecon(src)
if rc < 0:
- raise OSError("rename: Failed getting context of \"%s\"." % src)
+ raise OSError(_("rename: Failed getting context of \"%s\".") % src)
setfscreate(ctx)
try:
@@ -68,13 +70,13 @@ def setexec(ctx="\n"):
if isinstance(ctx, unicode):
ctx = ctx.encode('utf_8', 'replace')
if selinux.setexeccon(ctx) < 0:
- raise OSError("setexec: Failed setting exec() context \"%s\"." % ctx)
+ raise OSError(_("setexec: Failed setting exec() context \"%s\".") % ctx)
def setfscreate(ctx="\n"):
ctx = portage._unicode_encode(ctx)
if selinux.setfscreatecon(ctx) < 0:
raise OSError(
- "setfscreate: Failed setting fs create context \"%s\"." % ctx)
+ _("setfscreate: Failed setting fs create context \"%s\".") % ctx)
def spawn_wrapper(spawn_func, selinux_type):
@@ -96,7 +98,7 @@ def symlink(target, link, reflnk):
(rc, ctx) = selinux.lgetfilecon(reflnk)
if rc < 0:
raise OSError(
- "symlink: Failed getting context of reference symlink \"%s\"." \
+ _("symlink: Failed getting context of reference symlink \"%s\".") \
% reflnk)
setfscreate(ctx)
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 330d85dfb..f871c49ae 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -5,6 +5,7 @@
import portage
from portage.const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE
+from portage.localization import _
from portage import os
from portage import _fs_encoding
from portage import _merge_encoding
@@ -162,7 +163,7 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
try:
mysize = os.stat(filename)[stat.ST_SIZE]
if mydict["size"] != mysize:
- return False,("Filesize does not match recorded size", mysize, mydict["size"])
+ return False,(_("Filesize does not match recorded size"), mysize, mydict["size"])
except OSError, e:
if e.errno == errno.ENOENT:
raise portage.exception.FileNotFound(filename)
@@ -181,7 +182,7 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
got = list(got)
got.sort()
got = " ".join(got)
- return False, ("Insufficient data for checksum verification", got, expected)
+ return False, (_("Insufficient data for checksum verification"), got, expected)
for x in mydict:
if x == "size":
diff --git a/pym/portage/data.py b/pym/portage/data.py
index 5d5219be9..0ce760a92 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -10,6 +10,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.output:colorize',
'portage.util:writemsg',
)
+from portage.localization import _
ostype=platform.system()
userland = None
@@ -30,9 +31,9 @@ if not lchown:
lchown = missingos.lchown
except ImportError:
def lchown(*pos_args, **key_args):
- writemsg(colorize("BAD", "!!!") + \
- " It seems that os.lchown does not" + \
- " exist. Please rebuild python.\n", noiselevel=-1)
+ writemsg(colorize("BAD", "!!!") + _(
+ " It seems that os.lchown does not"
+ " exist. Please rebuild python.\n"), noiselevel=-1)
lchown()
lchown = portage._unicode_func_wrapper(lchown)
@@ -84,10 +85,10 @@ except KeyError:
portage_uid=0
portage_gid=0
writemsg(colorize("BAD",
- "portage: 'portage' user or group missing.") + "\n", noiselevel=-1)
- writemsg(
- " For the defaults, line 1 goes into passwd, " + \
- "and 2 into group.\n", noiselevel=-1)
+ _("portage: 'portage' user or group missing.")) + "\n", noiselevel=-1)
+ writemsg(_(
+ " For the defaults, line 1 goes into passwd, "
+ "and 2 into group.\n"), noiselevel=-1)
writemsg(colorize("GOOD",
" portage:x:250:250:portage:/var/tmp/portage:/bin/false") \
+ "\n", noiselevel=-1)
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index f36f78256..71dc758a5 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -23,6 +23,7 @@ import weakref
from itertools import chain
import portage.exception
from portage.exception import InvalidData, InvalidAtom
+from portage.localization import _
from portage.versions import catpkgsplit, catsplit, pkgcmp, pkgsplit, ververify
import portage.cache.mappings
@@ -50,7 +51,7 @@ def cpvequal(cpv1, cpv2):
split2 = catpkgsplit(cpv2)
if not split1 or not split2:
- raise portage.exception.PortageException("Invalid data '%s, %s', parameter was not a CPV" % (cpv1, cpv2))
+ raise portage.exception.PortageException(_("Invalid data '%s, %s', parameter was not a CPV") % (cpv1, cpv2))
if split1[0] != split2[0]:
return False
@@ -93,7 +94,7 @@ def paren_reduce(mystr,tokenize=1):
m = _paren_whitespace_re.search(mystr)
if m is not None:
raise portage.exception.InvalidDependString(
- "missing space by parenthesis: '%s'" % m.group(0))
+ _("missing space by parenthesis: '%s'") % m.group(0))
mylist = []
while mystr:
left_paren = mystr.find("(")
@@ -108,13 +109,13 @@ def paren_reduce(mystr,tokenize=1):
return [mylist,mystr[1:]]
elif has_left_paren and not has_right_paren:
raise portage.exception.InvalidDependString(
- "missing right parenthesis: '%s'" % mystr)
+ _("missing right parenthesis: '%s'") % mystr)
elif has_left_paren and left_paren < right_paren:
freesec,subsec = mystr.split("(",1)
sublist = paren_reduce(subsec, tokenize=tokenize)
if len(sublist) != 2:
raise portage.exception.InvalidDependString(
- "malformed syntax: '%s'" % mystr)
+ _("malformed syntax: '%s'") % mystr)
subsec, tail = sublist
else:
subsec,tail = mystr.split(")",1)
@@ -124,7 +125,7 @@ def paren_reduce(mystr,tokenize=1):
return mylist+[subsec],tail
if not isinstance(tail, basestring):
raise portage.exception.InvalidDependString(
- "malformed syntax: '%s'" % mystr)
+ _("malformed syntax: '%s'") % mystr)
mystr = tail
if freesec:
if tokenize:
@@ -219,9 +220,9 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
for x, y in enumerate(deparray):
if y == '||':
if len(deparray) - 1 == x or not isinstance(deparray[x+1], list):
- raise portage.exception.InvalidDependString(deparray[x]+" missing atom list in \""+paren_enclose(deparray)+"\"")
+ raise portage.exception.InvalidDependString(_('%(dep)s missing atom list in "%(deparray)s"') % {"dep": deparray[x], "deparray": paren_enclose(deparray)})
if deparray and deparray[-1] and deparray[-1][-1] == "?":
- raise portage.exception.InvalidDependString("Conditional without target in \""+paren_enclose(deparray)+"\"")
+ raise portage.exception.InvalidDependString(_('Conditional without target in "%s"') % paren_enclose(deparray))
global _dep_check_strict
@@ -248,15 +249,15 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
if mydeparray:
newdeparray.append(mydeparray.pop(0))
else:
- raise ValueError("Conditional with no target.")
+ raise ValueError(_("Conditional with no target."))
# Deprecation checks
warned = 0
if len(newdeparray[-1]) == 0:
- sys.stderr.write("Note: Empty target in string. (Deprecated)\n")
+ sys.stderr.write(_("Note: Empty target in string. (Deprecated)\n"))
warned = 1
if len(newdeparray) != 2:
- sys.stderr.write("Note: Nested use flags without parenthesis (Deprecated)\n")
+ sys.stderr.write(_("Note: Nested use flags without parenthesis (Deprecated)\n"))
warned = 1
if warned:
sys.stderr.write(" --> "+" ".join(map(str,[head]+newdeparray))+"\n")
@@ -286,7 +287,7 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
ismatch = False
if missing_flag:
raise portage.exception.InvalidDependString(
- "Conditional without flag: \"" + \
+ _('Conditional without flag: "') + \
paren_enclose([head+"?", newdeparray[-1]])+"\"")
# If they all match, process the target
@@ -301,7 +302,7 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
rlist.append(target)
else:
raise portage.exception.InvalidDependString(
- "Conditional without parenthesis: '%s?'" % head)
+ _("Conditional without parenthesis: '%s?'") % head)
else:
rlist += [head]
@@ -406,7 +407,7 @@ class _use_dep(object):
def _validate_flag(self, token, flag):
if self._valid_use_re.match(flag) is None:
- raise InvalidAtom("Invalid use dep: '%s'" % (token,))
+ raise InvalidAtom(_("Invalid use dep: '%s'") % (token,))
return flag
def __nonzero__(self):
@@ -802,30 +803,30 @@ def dep_getusedeps( depend ):
while( open_bracket != -1 ):
bracket_count += 1
if bracket_count > 1:
- raise InvalidAtom("USE Dependency with more " + \
- "than one set of brackets: %s" % (depend,))
+ raise InvalidAtom(_("USE Dependency with more "
+ "than one set of brackets: %s") % (depend,))
close_bracket = depend.find(']', open_bracket )
if close_bracket == -1:
- raise InvalidAtom("USE Dependency with no closing bracket: %s" % depend )
+ raise InvalidAtom(_("USE Dependency with no closing bracket: %s") % depend )
use = depend[open_bracket + 1: close_bracket]
# foo[1:1] may return '' instead of None, we don't want '' in the result
if not use:
- raise InvalidAtom("USE Dependency with " + \
- "no use flag ([]): %s" % depend )
+ raise InvalidAtom(_("USE Dependency with "
+ "no use flag ([]): %s") % depend )
if not comma_separated:
comma_separated = "," in use
if comma_separated and bracket_count > 1:
- raise InvalidAtom("USE Dependency contains a mixture of " + \
- "comma and bracket separators: %s" % depend )
+ raise InvalidAtom(_("USE Dependency contains a mixture of "
+ "comma and bracket separators: %s") % depend )
if comma_separated:
for x in use.split(","):
if x:
use_list.append(x)
else:
- raise InvalidAtom("USE Dependency with no use " + \
- "flag next to comma: %s" % depend )
+ raise InvalidAtom(_("USE Dependency with no use "
+ "flag next to comma: %s") % depend )
else:
use_list.append(use)
@@ -1088,13 +1089,13 @@ def match_from_list(mydep, candidate_list):
else:
cat, pkg, ver, rev = mycpv_cps
if mydep == mycpv:
- raise KeyError("Specific key requires an operator" + \
- " (%s) (try adding an '=')" % (mydep))
+ raise KeyError(_("Specific key requires an operator"
+ " (%s) (try adding an '=')") % (mydep))
if ver and rev:
operator = get_operator(mydep)
if not operator:
- writemsg("!!! Invalid atom: %s\n" % mydep, noiselevel=-1)
+ writemsg(_("!!! Invalid atom: %s\n") % mydep, noiselevel=-1)
return []
else:
operator = None
@@ -1163,7 +1164,7 @@ def match_from_list(mydep, candidate_list):
try:
result = pkgcmp(xs, mysplit)
except ValueError: # pkgcmp may return ValueError during int() conversion
- writemsg("\nInvalid package name: %s\n" % x, noiselevel=-1)
+ writemsg(_("\nInvalid package name: %s\n") % x, noiselevel=-1)
raise
if result is None:
continue
@@ -1180,9 +1181,9 @@ def match_from_list(mydep, candidate_list):
if result <= 0:
mylist.append(x)
else:
- raise KeyError("Unknown operator: %s" % mydep)
+ raise KeyError(_("Unknown operator: %s") % mydep)
else:
- raise KeyError("Unknown operator: %s" % mydep)
+ raise KeyError(_("Unknown operator: %s") % mydep)
if slot is not None:
candidate_list = mylist
diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index 487065a84..f9d551ff6 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -11,6 +11,7 @@ from stat import *
import os, sys, commands, shutil
import portage
+from portage.localization import _
RCS_BRANCH = '1.1.1'
RCS_LOCK = 'rcs -ko -M -l'
@@ -27,7 +28,7 @@ def read_config(mandatory_opts):
opts = None
if not opts:
- print >> sys.stderr, 'dispatch-conf: Error reading /etc/dispatch-conf.conf; fatal'
+ print >> sys.stderr, _('dispatch-conf: Error reading /etc/dispatch-conf.conf; fatal')
sys.exit(1)
for key in mandatory_opts:
@@ -35,12 +36,12 @@ def read_config(mandatory_opts):
if key == "merge":
opts["merge"] = "sdiff --suppress-common-lines --output='%s' '%s' '%s'"
else:
- print >> sys.stderr, 'dispatch-conf: Missing option "%s" in /etc/dispatch-conf.conf; fatal' % (key,)
+ print >> sys.stderr, _('dispatch-conf: Missing option "%s" in /etc/dispatch-conf.conf; fatal') % (key,)
if not os.path.exists(opts['archive-dir']):
os.mkdir(opts['archive-dir'])
elif not os.path.isdir(opts['archive-dir']):
- print >> sys.stderr, 'dispatch-conf: Config archive dir [%s] must exist; fatal' % (opts['archive-dir'],)
+ print >> sys.stderr, _('dispatch-conf: Config archive dir [%s] must exist; fatal') % (opts['archive-dir'],)
sys.exit(1)
return opts
@@ -61,8 +62,8 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
try:
shutil.copy2(curconf, archive)
except(IOError, os.error), why:
- print >> sys.stderr, 'dispatch-conf: Error copying %s to %s: %s; fatal' % \
- (curconf, archive, str(why))
+ print >> sys.stderr, _('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
+ {"curconf": curconf, "archive": archive, "reason": str(why)}
if os.path.exists(archive + ',v'):
os.system(RCS_LOCK + ' ' + archive)
os.system(RCS_PUT + ' ' + archive)
@@ -77,8 +78,8 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
try:
shutil.copy2(newconf, archive)
except(IOError, os.error), why:
- print >> sys.stderr, 'dispatch-conf: Error copying %s to %s: %s; fatal' % \
- (newconf, archive, str(why))
+ print >> sys.stderr, _('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
+ {"newconf": newconf, "archive": archive, "reason": str(why)}
if has_branch:
if mrgconf != '':
@@ -120,16 +121,16 @@ def file_archive(archive, curconf, newconf, mrgconf):
try:
shutil.copy2(curconf, archive)
except(IOError, os.error), why:
- print >> sys.stderr, 'dispatch-conf: Error copying %s to %s: %s; fatal' % \
- (curconf, archive, str(why))
+ print >> sys.stderr, _('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
+ {"curconf": curconf, "archive": archive, "reason": str(why)}
if newconf != '':
# Save off new config file in the archive dir with .dist.new suffix
try:
shutil.copy2(newconf, archive + '.dist.new')
except(IOError, os.error), why:
- print >> sys.stderr, 'dispatch-conf: Error copying %s to %s: %s; fatal' % \
- (newconf, archive + '.dist.new', str(why))
+ print >> sys.stderr, _('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
+ {"newconf": newconf, "archive": archive + '.dist.new', "reason": str(why)}
ret = 0
if mrgconf != '' and os.path.exists(archive + '.dist'):
diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 6626fa3bf..f47937115 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage.localization import _
class PortageException(Exception):
"""General superclass for portage exceptions"""
@@ -95,10 +96,10 @@ class UnsupportedAPIException(PortagePackageException):
def __init__(self, cpv, eapi):
self.cpv, self.eapi = cpv, eapi
def __str__(self):
- msg = ("Unable to do any operations on '%s', since " + \
- "it's EAPI is higher than this portage version's. Please upgrade" + \
- " to a portage version that supports EAPI '%s'.") % \
- (self.cpv, str(self.eapi).lstrip("-"))
+ msg = _("Unable to do any operations on '%(cpv)s', since "
+ "it's EAPI is higher than this portage version's. Please upgrade"
+ " to a portage version that supports EAPI '%(eapi)s'.") % \
+ {"cpv": self.cpv, "eapi": str(self.eapi).lstrip("-")}
return msg
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 75d997e54..ac8deae0b 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -5,6 +5,7 @@
from portage.output import colorize
from portage.cache.mappings import slot_dict_class
+from portage.localization import _
import portage
import HTMLParser
import sys
@@ -83,8 +84,8 @@ def create_conn(baseurl,conn=None):
parts = baseurl.split("://",1)
if len(parts) != 2:
- raise ValueError("Provided URL does not " + \
- "contain protocol identifier. '%s'" % baseurl)
+ raise ValueError(_("Provided URL does not "
+ "contain protocol identifier. '%s'") % baseurl)
protocol,url_parts = parts
del parts
@@ -106,7 +107,7 @@ def create_conn(baseurl,conn=None):
del userpass_host
if len(userpass) > 2:
- raise ValueError("Unable to interpret username/password provided.")
+ raise ValueError(_("Unable to interpret username/password provided."))
elif len(userpass) == 2:
username = userpass[0]
password = userpass[1]
@@ -141,7 +142,7 @@ def create_conn(baseurl,conn=None):
conn.login(username,password)
else:
sys.stderr.write(colorize("WARN",
- " * No password provided for username")+" '%s'" % \
+ _(" * No password provided for username"))+" '%s'" % \
(username,) + "\n\n")
conn.login(username)
conn.set_pasv(passive)
@@ -151,12 +152,12 @@ def create_conn(baseurl,conn=None):
import paramiko
except ImportError:
raise NotImplementedError(
- "paramiko must be installed for sftp support")
+ _("paramiko must be installed for sftp support"))
t = paramiko.Transport(host)
t.connect(username=username, password=password)
conn = paramiko.SFTPClient.from_transport(t)
else:
- raise NotImplementedError, "%s is not a supported protocol." % protocol
+ raise NotImplementedError, _("%s is not a supported protocol.") % protocol
return (conn,protocol,address, http_params, http_headers)
@@ -235,10 +236,10 @@ def make_http_request(conn, address, params={}, headers={}, dest=None):
if parts[0] == "Location":
if (rc == 301):
sys.stderr.write(colorize("BAD",
- "Location has moved: ") + str(parts[1]) + "\n")
+ _("Location has moved: ")) + str(parts[1]) + "\n")
if (rc == 302):
sys.stderr.write(colorize("BAD",
- "Location has temporarily moved: ") + \
+ _("Location has temporarily moved: ")) + \
str(parts[1]) + "\n")
address = parts[1]
break
@@ -317,7 +318,7 @@ def dir_get_list(baseurl,conn=None):
else:
import portage.exception
raise portage.exception.PortageException(
- "Unable to get listing: %s %s" % (rc,msg))
+ _("Unable to get listing: %s %s") % (rc,msg))
elif protocol in ["ftp"]:
if address[-1] == '/':
olddir = conn.pwd()
@@ -330,7 +331,7 @@ def dir_get_list(baseurl,conn=None):
elif protocol == "sftp":
listing = conn.listdir(address)
else:
- raise TypeError("Unknown protocol. '%s'" % protocol)
+ raise TypeError(_("Unknown protocol. '%s'") % protocol)
if not keepconnection:
conn.close()
@@ -362,7 +363,7 @@ def file_get_metadata(baseurl,conn=None, chunk_size=3000):
finally:
f.close()
else:
- raise TypeError("Unknown protocol. '%s'" % protocol)
+ raise TypeError(_("Unknown protocol. '%s'") % protocol)
if data:
xpaksize = portage.xpak.decodeint(data[-8:-4])
@@ -412,7 +413,7 @@ def file_get(baseurl,dest,conn=None,fcmd=None):
}
retval = spawn(myfetch, env=os.environ.copy(), fd_pipes=fd_pipes)
if retval != os.EX_OK:
- sys.stderr.write("Fetcher exited with a failure condition.\n")
+ sys.stderr.write(_("Fetcher exited with a failure condition.\n"))
return 0
return 1
@@ -453,7 +454,7 @@ def file_get_lib(baseurl,dest,conn=None):
finally:
f.close()
else:
- raise TypeError("Unknown protocol. '%s'" % protocol)
+ raise TypeError(_("Unknown protocol. '%s'") % protocol)
if not keepconnection:
conn.close()
@@ -493,7 +494,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
# TODO: If py3k, override Unpickler.find_class().
pass
metadata = mypickle.load()
- out.write("Loaded metadata pickle.\n")
+ out.write(_("Loaded metadata pickle.\n"))
out.flush()
metadatafile.close()
except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError):
@@ -510,15 +511,15 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
metadata[baseurl]["data"]={}
if not os.access(cache_path, os.W_OK):
- sys.stderr.write("!!! Unable to write binary metadata to disk!\n")
- sys.stderr.write("!!! Permission denied: '%s'\n" % cache_path)
+ sys.stderr.write(_("!!! Unable to write binary metadata to disk!\n"))
+ sys.stderr.write(_("!!! Permission denied: '%s'\n") % cache_path)
return metadata[baseurl]["data"]
import portage.exception
try:
filelist = dir_get_list(baseurl, conn)
except portage.exception.PortageException, e:
- sys.stderr.write("!!! Error connecting to '%s'.\n" % baseurl)
+ sys.stderr.write(_("!!! Error connecting to '%s'.\n") % baseurl)
sys.stderr.write("!!! %s\n" % str(e))
del e
return metadata[baseurl]["data"]
@@ -545,7 +546,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
except ValueError, e:
sys.stderr.write("--- "+str(e)+"\n")
if trynum < 3:
- sys.stderr.write("Retrying...\n")
+ sys.stderr.write(_("Retrying...\n"))
sys.stderr.flush()
mytempfile.close()
continue
@@ -561,7 +562,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
raise
except Exception, e:
mytempfile.close()
- sys.stderr.write("!!! Failed to use gzip: "+str(e)+"\n")
+ sys.stderr.write(_("!!! Failed to use gzip: ")+str(e)+"\n")
sys.stderr.flush()
mytempfile.close()
try:
@@ -570,13 +571,13 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
metadata[baseurl]["indexname"] = mfile
metadata[baseurl]["timestamp"] = int(time.time())
metadata[baseurl]["modified"] = 0 # It's not, right after download.
- out.write("Pickle loaded.\n")
+ out.write(_("Pickle loaded.\n"))
out.flush()
break
except SystemExit, e:
raise
except Exception, e:
- sys.stderr.write("!!! Failed to read data from index: "+str(mfile)+"\n")
+ sys.stderr.write(_("!!! Failed to read data from index: ")+str(mfile)+"\n")
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
try:
@@ -586,7 +587,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
except SystemExit, e:
raise
except Exception, e:
- sys.stderr.write("!!! Failed to write binary metadata to disk!\n")
+ sys.stderr.write(_("!!! Failed to write binary metadata to disk!\n"))
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
break
@@ -607,8 +608,8 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
self.display()
def display(self):
self.out.write("\r"+colorize("WARN",
- "cache miss: '"+str(self.misses)+"'") + \
- " --- "+colorize("GOOD","cache hit: '"+str(self.hits)+"'"))
+ _("cache miss: '")+str(self.misses)+"'") + \
+ " --- "+colorize("GOOD", _("cache hit: '")+str(self.hits)+"'"))
self.out.flush()
cache_stats = CacheStats(out)
@@ -651,7 +652,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
metadata[baseurl]["data"][x] = make_metadata_dict(myid)
elif verbose:
sys.stderr.write(colorize("BAD",
- "!!! Failed to retrieve metadata on: ")+str(x)+"\n")
+ _("!!! Failed to retrieve metadata on: "))+str(x)+"\n")
sys.stderr.flush()
else:
cache_stats.hits += 1
@@ -682,7 +683,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
except SystemExit, e:
raise
except Exception, e:
- sys.stderr.write("!!! Failed to write binary metadata to disk!\n")
+ sys.stderr.write(_("!!! Failed to write binary metadata to disk!\n"))
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index a16b98c2c..008cb86dc 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -11,6 +11,7 @@ import xml.dom.minidom
from portage.versions import pkgsplit, catpkgsplit, pkgcmp, best
from portage.util import grabfile
from portage.const import CACHE_PATH
+from portage.localization import _
# Note: the space for rgt and rlt is important !!
# FIXME: use slot deps instead, requires GLSA format versioning
@@ -185,7 +186,7 @@ def getText(node, format):
elif subnode.nodeName == "#text":
rValue += subnode.data
else:
- raise GlsaFormatException("Invalid Tag found: ", subnode.nodeName)
+ raise GlsaFormatException(_("Invalid Tag found: "), subnode.nodeName)
if format == "strip":
rValue = rValue.strip(" \n\t")
rValue = re.sub("[\s]{2,}", " ", rValue)
@@ -439,7 +440,7 @@ class Glsa:
elif os.path.exists(myid):
self.type = "file"
else:
- raise GlsaArgumentException("Given ID "+myid+" isn't a valid GLSA ID or filename.")
+ raise GlsaArgumentException(_("Given ID %s isn't a valid GLSA ID or filename.") % myid)
self.nr = myid
self.config = myconfig
self.vardbapi = vardbapi
@@ -487,7 +488,7 @@ class Glsa:
raise GlsaTypeException(self.DOM.doctype.systemId)
myroot = self.DOM.getElementsByTagName("glsa")[0]
if self.type == "id" and myroot.getAttribute("id") != self.nr:
- raise GlsaFormatException("filename and internal id don't match:" + myroot.getAttribute("id") + " != " + self.nr)
+ raise GlsaFormatException(_("filename and internal id don't match:") + myroot.getAttribute("id") + " != " + self.nr)
# the simple (single, required, top-level, #PCDATA) tags first
self.title = getText(myroot.getElementsByTagName("title")[0], format="strip")
@@ -510,7 +511,7 @@ class Glsa:
try:
self.count = int(count)
except ValueError:
- # TODO should this rais a GlsaFormatException?
+ # TODO should this raise a GlsaFormatException?
self.count = 1
# now the optional and 0-n toplevel, #PCDATA tags and references
@@ -566,27 +567,27 @@ class Glsa:
width = 76
outstream.write(("GLSA %s: \n%s" % (self.nr, self.title)).center(width)+"\n")
outstream.write((width*"=")+"\n")
- outstream.write(wrap(self.synopsis, width, caption="Synopsis: ")+"\n")
- outstream.write("Announced on: %s\n" % self.announced)
- outstream.write("Last revised on: %s : %02d\n\n" % (self.revised, self.count))
+ outstream.write(wrap(self.synopsis, width, caption=_("Synopsis: "))+"\n")
+ outstream.write(_("Announced on: %s\n") % self.announced)
+ outstream.write(_("Last revised on: %s : %02d\n\n") % (self.revised, self.count))
if self.glsatype == "ebuild":
for k in self.packages.keys():
pkg = self.packages[k]
for path in pkg:
vul_vers = "".join(path["vul_vers"])
unaff_vers = "".join(path["unaff_vers"])
- outstream.write("Affected package: %s\n" % k)
- outstream.write("Affected archs: ")
+ outstream.write(_("Affected package: %s\n") % k)
+ outstream.write(_("Affected archs: "))
if path["arch"] == "*":
- outstream.write("All\n")
+ outstream.write(_("All\n"))
else:
outstream.write("%s\n" % path["arch"])
- outstream.write("Vulnerable: %s\n" % vul_vers)
- outstream.write("Unaffected: %s\n\n" % unaff_vers)
+ outstream.write(_("Vulnerable: %s\n") % vul_vers)
+ outstream.write(_("Unaffected: %s\n\n") % unaff_vers)
elif self.glsatype == "infrastructure":
pass
if len(self.bugs) > 0:
- outstream.write("\nRelated bugs: ")
+ outstream.write(_("\nRelated bugs: "))
for i in range(0, len(self.bugs)):
outstream.write(self.bugs[i])
if i < len(self.bugs)-1:
@@ -594,15 +595,15 @@ class Glsa:
else:
outstream.write("\n")
if self.background:
- outstream.write("\n"+wrap(self.background, width, caption="Background: "))
- outstream.write("\n"+wrap(self.description, width, caption="Description: "))
- outstream.write("\n"+wrap(self.impact_text, width, caption="Impact: "))
- outstream.write("\n"+wrap(self.workaround, width, caption="Workaround: "))
- outstream.write("\n"+wrap(self.resolution, width, caption="Resolution: "))
+ outstream.write("\n"+wrap(self.background, width, caption=_("Background: ")))
+ outstream.write("\n"+wrap(self.description, width, caption=_("Description: ")))
+ outstream.write("\n"+wrap(self.impact_text, width, caption=_("Impact: ")))
+ outstream.write("\n"+wrap(self.workaround, width, caption=_("Workaround: ")))
+ outstream.write("\n"+wrap(self.resolution, width, caption=_("Resolution: ")))
myreferences = ""
for r in self.references:
myreferences += (r.replace(" ", SPACE_ESCAPE)+NEWLINE_ESCAPE+" ")
- outstream.write("\n"+wrap(myreferences, width, caption="References: "))
+ outstream.write("\n"+wrap(myreferences, width, caption=_("References: ")))
outstream.write("\n")
def isVulnerable(self):
diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index c256a5ada..c41b4aae7 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -35,7 +35,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
import fcntl
if not mypath:
- raise InvalidData("Empty path given")
+ raise InvalidData(_("Empty path given"))
if isinstance(mypath, basestring) and mypath[-1] == '/':
mypath = mypath[:-1]
@@ -82,8 +82,8 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
unlinkfile=unlinkfile, waiting_msg=waiting_msg,
flags=flags)
else:
- writemsg("Cannot chown a lockfile. This could " + \
- "cause inconvenience later.\n")
+ writemsg(_("Cannot chown a lockfile. This could "
+ "cause inconvenience later.\n"))
finally:
os.umask(old_mask)
@@ -92,7 +92,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
myfd = mypath
else:
- raise ValueError("Unknown type passed in '%s': '%s'" % \
+ raise ValueError(_("Unknown type passed in '%s': '%s'") % \
(type(mypath), mypath))
# try for a non-blocking lock, if it's held, throw a message
@@ -113,9 +113,9 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
out.quiet = _quiet
if waiting_msg is None:
if isinstance(mypath, int):
- waiting_msg = "waiting for lock on fd %i" % myfd
+ waiting_msg = _("waiting for lock on fd %i") % myfd
else:
- waiting_msg = "waiting for lock on %s\n" % lockfilename
+ waiting_msg = _("waiting for lock on %s\n") % lockfilename
out.ebegin(waiting_msg)
# try for the exclusive lock now.
try:
@@ -148,7 +148,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
myfd != HARDLINK_FD and _fstat_nlink(myfd) == 0:
# The file was deleted on us... Keep trying to make one...
os.close(myfd)
- writemsg("lockfile recurse\n",1)
+ writemsg(_("lockfile recurse\n"), 1)
lockfilename, myfd, unlinkfile, locking_method = lockfile(
mypath, wantnewlockfile=wantnewlockfile, unlinkfile=unlinkfile,
waiting_msg=waiting_msg, flags=flags)
@@ -191,7 +191,7 @@ def unlockfile(mytuple):
# myfd may be None here due to myfd = mypath in lockfile()
if isinstance(lockfilename, basestring) and \
not os.path.exists(lockfilename):
- writemsg("lockfile does not exist '%s'\n" % lockfilename,1)
+ writemsg(_("lockfile does not exist '%s'\n") % lockfilename,1)
if myfd is not None:
os.close(myfd)
return False
@@ -204,7 +204,7 @@ def unlockfile(mytuple):
except OSError:
if isinstance(lockfilename, basestring):
os.close(myfd)
- raise IOError("Failed to unlock file '%s'\n" % lockfilename)
+ raise IOError(_("Failed to unlock file '%s'\n") % lockfilename)
try:
# This sleep call was added to allow other processes that are
@@ -217,17 +217,17 @@ def unlockfile(mytuple):
locking_method(myfd,fcntl.LOCK_EX|fcntl.LOCK_NB)
# We won the lock, so there isn't competition for it.
# We can safely delete the file.
- writemsg("Got the lockfile...\n",1)
+ writemsg(_("Got the lockfile...\n"), 1)
if _fstat_nlink(myfd) == 1:
os.unlink(lockfilename)
- writemsg("Unlinked lockfile...\n",1)
+ writemsg(_("Unlinked lockfile...\n"), 1)
locking_method(myfd,fcntl.LOCK_UN)
else:
- writemsg("lockfile does not exist '%s'\n" % lockfilename,1)
+ writemsg(_("lockfile does not exist '%s'\n") % lockfilename, 1)
os.close(myfd)
return False
except Exception, e:
- writemsg("Failed to get lock... someone took it.\n",1)
+ writemsg(_("Failed to get lock... someone took it.\n"), 1)
writemsg(str(e)+"\n",1)
# why test lockfilename? because we may have been handed an
@@ -289,10 +289,10 @@ def hardlink_lockfile(lockfilename, max_wait=14400):
else:
reported_waiting = True
from portage.const import PORTAGE_BIN_PATH
- msg = "\nWaiting on (hardlink) lockfile:" + \
- " (one '.' per 3 seconds)\n" + \
- "%s/clean_locks can fix stuck locks.\n" % PORTAGE_BIN_PATH + \
- "Lockfile: %s\n" % lockfilename
+ msg = _("\nWaiting on (hardlink) lockfile: (one '.' per 3 seconds)\n"
+ "%(bin_path)s/clean_locks can fix stuck locks.\n"
+ "Lockfile: %(lockfilename)s\n") % \
+ {"bin_path": PORTAGE_BIN_PATH, "lockfilename": lockfilename}
writemsg(msg, noiselevel=-1)
time.sleep(3)
@@ -339,7 +339,7 @@ def hardlock_cleanup(path, remove_all_locks=False):
mycount += 1
- results.append("Found %(count)s locks" % {"count":mycount})
+ results.append(_("Found %(count)s locks") % {"count":mycount})
for x in mylist:
if myhost in mylist[x] or remove_all_locks:
diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index 9779fac86..767c66b3f 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -8,6 +8,7 @@ from email.MIMEText import MIMEText as TextMessage
from email.MIMEMultipart import MIMEMultipart as MultipartMessage
from email.MIMEBase import MIMEBase as BaseMessage
from email.header import Header
+from portage.localization import _
def create_message(sender, recipient, subject, body, attachments=None):
@@ -34,7 +35,7 @@ def create_message(sender, recipient, subject, body, attachments=None):
x = x.encode('utf_8', 'replace')
mymessage.attach(TextMessage(x))
else:
- raise portage.exception.PortageException("Can't handle type of attachment: %s" % type(x))
+ raise portage.exception.PortageException(_("Can't handle type of attachment: %s") % type(x))
mymessage.set_unixfrom(sender)
mymessage["To"] = recipient
@@ -68,7 +69,7 @@ def send_mail(mysettings, message):
try:
mymailuser,mymailpasswd = myauthdata.split(":")
except ValueError:
- print "!!! invalid SMTP AUTH configuration, trying unauthenticated ..."
+ print _("!!! invalid SMTP AUTH configuration, trying unauthenticated ...")
else:
myconndata = mymailuri
if ":" in myconndata:
@@ -99,14 +100,14 @@ def send_mail(mysettings, message):
fd = os.popen(mymailhost+" -f "+myfrom+" "+myrecipient, "w")
fd.write(message.as_string())
if fd.close() != None:
- sys.stderr.write("!!! %s returned with a non-zero exit code. This generally indicates an error.\n" % mymailhost)
+ sys.stderr.write(_("!!! %s returned with a non-zero exit code. This generally indicates an error.\n") % mymailhost)
else:
try:
if int(mymailport) > 100000:
myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000)
myconn.ehlo()
if not myconn.has_extn("STARTTLS"):
- raise portage.exception.PortageException("!!! TLS support requested for logmail but not suported by server")
+ raise portage.exception.PortageException(_("!!! TLS support requested for logmail but not suported by server"))
myconn.starttls()
myconn.ehlo()
else:
@@ -116,8 +117,8 @@ def send_mail(mysettings, message):
myconn.sendmail(myfrom, myrecipient, message.as_string())
myconn.quit()
except smtplib.SMTPException, e:
- raise portage.exception.PortageException("!!! An error occured while trying to send logmail:\n"+str(e))
+ raise portage.exception.PortageException(_("!!! An error occured while trying to send logmail:\n")+str(e))
except socket.error, e:
- raise portage.exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?")
+ raise portage.exception.PortageException(_("!!! A network error occured while trying to send logmail:\n%s\nSure you configured PORTAGE_ELOG_MAILURI correctly?") % str(e))
return
diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index cc02ddfcc..4c4cb60b3 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -19,6 +19,7 @@ from portage import _unicode_encode
from portage.exception import DigestException, FileNotFound, \
InvalidDataType, MissingParameter, PermissionDenied, \
PortageException, PortagePackageException
+from portage.localization import _
class FileNotInManifestException(PortageException):
pass
@@ -221,7 +222,7 @@ class Manifest(object):
for t in self.fhashdict:
for f in self.fhashdict[t]:
if portage.const.MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
- raise MissingParameter("Missing %s checksum: %s %s" % (portage.const.MANIFEST2_REQUIRED_HASH, t, f))
+ raise MissingParameter(_("Missing %s checksum: %s %s") % (portage.const.MANIFEST2_REQUIRED_HASH, t, f))
def write(self, sign=False, force=False):
""" Write Manifest instance to disk, optionally signing it """
@@ -342,11 +343,11 @@ class Manifest(object):
cpv = "%s/%s" % (cat, pf)
if not ps:
raise PortagePackageException(
- "Invalid package name: '%s'" % cpv)
+ _("Invalid package name: '%s'") % cpv)
if ps[0] != pn:
raise PortagePackageException(
- "Package name does not " + \
- "match directory name: '%s'" % cpv)
+ _("Package name does not "
+ "match directory name: '%s'") % cpv)
cpvlist.append(cpv)
elif manifest2MiscfileFilter(f):
mytype = "MISC"
@@ -437,7 +438,7 @@ class Manifest(object):
except FileNotFound, e:
if not ignoreMissing:
raise
- return False, "File Not Found: '%s'" % str(e)
+ return False, _("File Not Found: '%s'") % str(e)
def checkCpvHashes(self, cpv, checkDistfiles=True, onlyDistfiles=False, checkMiscfiles=False):
""" check the hashes for all files associated to the given cpv, include all
diff --git a/pym/portage/news.py b/pym/portage/news.py
index c6bd9eafa..36d4603f7 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -15,6 +15,7 @@ from portage.util import apply_secpass_permissions, ensure_dirs, \
grabfile, normalize_path, write_atomic, writemsg_level
from portage.data import portage_gid
from portage.dep import isvalidatom
+from portage.localization import _
from portage.locks import lockfile, unlockfile
from portage.exception import InvalidLocation, OperationNotPermitted, \
PermissionDenied
@@ -70,7 +71,7 @@ class NewsManager(object):
def _news_dir(self, repoid):
repo_path = self.portdb.getRepositoryPath(repoid)
if repo_path is None:
- raise AssertionError("Invalid repoID: %s" % repoid)
+ raise AssertionError(_("Invalid repoID: %s") % repoid)
return os.path.join(repo_path, self.news_path)
def updateItems(self, repoid):
@@ -249,9 +250,9 @@ class NewsItem(object):
if invalids:
self._valid = False
msg = []
- msg.append("Invalid news item: %s" % (self.path,))
+ msg.append(_("Invalid news item: %s") % (self.path,))
for lineno, line in invalids:
- msg.append(" line %d: %s" % (lineno, line))
+ msg.append(_(" line %d: %s") % (lineno, line))
writemsg_level("".join("!!! %s\n" % x for x in msg),
level=logging.ERROR, noiselevel=-1)
@@ -270,7 +271,7 @@ class DisplayRestriction(object):
return True
def checkRestriction(self, **kwargs):
- raise NotImplementedError('Derived class should over-ride this method')
+ raise NotImplementedError('Derived class should override this method')
class DisplayProfileRestriction(DisplayRestriction):
"""
diff --git a/pym/portage/output.py b/pym/portage/output.py
index 8c6eb2ce0..fbf6c01e4 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -21,6 +21,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
from portage.const import COLOR_MAP_FILE
from portage.exception import CommandNotFound, FileNotFound, \
ParseError, PermissionDenied, PortageException
+from portage.localization import _
havecolor=1
dotitles=1
@@ -177,9 +178,8 @@ def _parse_color_map(onerror=None):
split_line = line.split("=")
if len(split_line) != 2:
- e = ParseError("'%s', line %s: %s" % (
- myfile, lineno,
- "expected exactly one occurence of '=' operator"))
+ e = ParseError(_("'%s', line %s: expected exactly one occurence of '=' operator") % \
+ (myfile, lineno))
raise e
if onerror:
onerror(e)
@@ -190,9 +190,8 @@ def _parse_color_map(onerror=None):
k = strip_quotes(split_line[0].strip())
v = strip_quotes(split_line[1].strip())
if not k in _styles and not k in codes:
- e = ParseError("'%s', line %s: %s'%s'" % (
- myfile, lineno,
- "Unknown variable: ", k))
+ e = ParseError(_("'%s', line %s: Unknown variable: '%s'") % \
+ (myfile, lineno, k))
if onerror:
onerror(e)
else:
@@ -212,9 +211,8 @@ def _parse_color_map(onerror=None):
elif k in codes:
code_list.append(codes[x])
else:
- e = ParseError("'%s', line %s: %s'%s'" % (
- myfile, lineno,
- "Undefined: ", x))
+ e = ParseError(_("'%s', line %s: Undefined: '%s'") % \
+ (myfile, lineno, x))
if onerror:
onerror(e)
else:
@@ -427,7 +425,7 @@ def set_term_size(lines, columns, fd):
try:
spawn(cmd, env=os.environ, fd_pipes={0:fd})
except CommandNotFound:
- writemsg("portage: stty: command not found\n", noiselevel=-1)
+ writemsg(_("portage: stty: command not found\n"), noiselevel=-1)
class EOutput(object):
"""
@@ -730,7 +728,7 @@ try:
except FileNotFound:
pass
except PermissionDenied, e:
- writemsg("Permission denied: '%s'\n" % str(e), noiselevel=-1)
+ writemsg(_("Permission denied: '%s'\n") % str(e), noiselevel=-1)
del e
except PortageException, e:
writemsg("%s\n" % str(e), noiselevel=-1)
diff --git a/pym/portage/update.py b/pym/portage/update.py
index 4e309e401..412956591 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -12,8 +12,9 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.versions:ververify'
)
-from portage.exception import DirectoryNotFound, PortageException
from portage.const import USER_CONFIG_PATH, WORLD_FILE
+from portage.exception import DirectoryNotFound, PortageException
+from portage.localization import _
ignored_dbentries = ("CONTENTS", "environment.bz2")
@@ -115,25 +116,25 @@ def parse_updates(mycontent):
if len(mysplit) == 0:
continue
if mysplit[0] not in ("move", "slotmove"):
- errors.append("ERROR: Update type not recognized '%s'" % myline)
+ errors.append(_("ERROR: Update type not recognized '%s'") % myline)
continue
if mysplit[0] == "move":
if len(mysplit) != 3:
- errors.append("ERROR: Update command invalid '%s'" % myline)
+ errors.append(_("ERROR: Update command invalid '%s'") % myline)
continue
orig_value, new_value = mysplit[1], mysplit[2]
for cp in (orig_value, new_value):
if not (isvalidatom(cp) and isjustname(cp)):
errors.append(
- "ERROR: Malformed update entry '%s'" % myline)
+ _("ERROR: Malformed update entry '%s'") % myline)
continue
if mysplit[0] == "slotmove":
if len(mysplit)!=4:
- errors.append("ERROR: Update command invalid '%s'" % myline)
+ errors.append(_("ERROR: Update command invalid '%s'") % myline)
continue
pkg, origslot, newslot = mysplit[1], mysplit[2], mysplit[3]
if not isvalidatom(pkg):
- errors.append("ERROR: Malformed update entry '%s'" % myline)
+ errors.append(_("ERROR: Malformed update entry '%s'") % myline)
continue
# The list of valid updates is filtered by continue statements above.
@@ -215,7 +216,7 @@ def update_config_files(config_root, protect, protect_mask, update_iter):
write_atomic(updating_file, "".join(file_contents[x]))
except PortageException, e:
writemsg("\n!!! %s\n" % str(e), noiselevel=-1)
- writemsg("!!! An error occured while updating a config file:" + \
+ writemsg(_("!!! An error occured while updating a config file:") + \
" '%s'\n" % updating_file, noiselevel=-1)
continue
diff --git a/pym/portage/util.py b/pym/portage/util.py
index 94f3b52c5..67e502df8 100644
--- a/pym/portage/util.py
+++ b/pym/portage/util.py
@@ -31,6 +31,7 @@ from portage import _unicode_decode
from portage.exception import PortageException, FileNotFound, \
OperationNotPermitted, PermissionDenied, ReadOnlyFileSystem
from portage.dep import isvalidatom
+from portage.localization import _
from portage.proxy.objectproxy import ObjectProxy
from portage.cache.mappings import UserDict
@@ -294,7 +295,7 @@ def grabdict_package(myfilename, juststrings=0, recursive=0):
for x in pkgs.keys():
if not isvalidatom(x):
del(pkgs[x])
- writemsg("--- Invalid atom in %s: %s\n" % (myfilename, x),
+ writemsg(_("--- Invalid atom in %s: %s\n") % (myfilename, x),
noiselevel=-1)
return pkgs
@@ -308,7 +309,7 @@ def grabfile_package(myfilename, compatlevel=0, recursive=0):
if pkg[:1] == "*":
pkg = pkg[1:]
if not isvalidatom(pkg):
- writemsg("--- Invalid atom in %s: %s\n" % (myfilename, pkgs[x]),
+ writemsg(_("--- Invalid atom in %s: %s\n") % (myfilename, pkgs[x]),
noiselevel=-1)
del(pkgs[x])
return pkgs
@@ -373,7 +374,7 @@ class _tolerant_shlex(shlex.shlex):
try:
return shlex.shlex.sourcehook(self, newfile)
except EnvironmentError, e:
- writemsg("!!! Parse error in '%s': source command failed: %s\n" % \
+ writemsg(_("!!! Parse error in '%s': source command failed: %s\n") % \
(self.infile, str(e)), noiselevel=-1)
return (newfile, StringIO())
@@ -390,7 +391,7 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
# Workaround for avoiding a silent error in shlex that
# is triggered by a source statement at the end of the file without a
# trailing newline after the source statement
- # NOTE: shex doesn't seem to supported unicode objects
+ # NOTE: shex doesn't seem to support unicode objects
# (produces spurious \0 characters with python-2.6.2)
if sys.hexversion < 0x3000000:
content = open(_unicode_encode(mycfg), 'rb').read()
@@ -432,17 +433,17 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
#unexpected end of file
#lex.error_leader(self.filename,lex.lineno)
if not tolerant:
- writemsg("!!! Unexpected end of config file: variable "+str(key)+"\n",
+ writemsg(_("!!! Unexpected end of config file: variable %s\n") % key,
noiselevel=-1)
- raise Exception("ParseError: Unexpected EOF: "+str(mycfg)+": on/before line "+str(lex.lineno))
+ raise Exception(_("ParseError: Unexpected EOF: %s: on/before line %s") % (mycfg, lex.lineno))
else:
return mykeys
elif (equ!='='):
#invalid token
#lex.error_leader(self.filename,lex.lineno)
if not tolerant:
- raise Exception("ParseError: Invalid token " + \
- "'%s' (not '='): %s: line %s" % \
+ raise Exception(_("ParseError: Invalid token "
+ "'%s' (not '='): %s: line %s") % \
(equ, mycfg, lex.lineno))
else:
return mykeys
@@ -451,9 +452,9 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
#unexpected end of file
#lex.error_leader(self.filename,lex.lineno)
if not tolerant:
- writemsg("!!! Unexpected end of config file: variable "+str(key)+"\n",
+ writemsg(_("!!! Unexpected end of config file: variable %s\n") % key,
noiselevel=-1)
- raise portage.exception.CorruptionError("ParseError: Unexpected EOF: "+str(mycfg)+": line "+str(lex.lineno))
+ raise portage.exception.CorruptionError(_("ParseError: Unexpected EOF: %s: line %s") % (mycfg, lex.lineno))
else:
return mykeys
key = _unicode_decode(key)
@@ -584,7 +585,7 @@ pickle_write = None
def pickle_read(filename,default=None,debug=0):
import os
if not os.access(filename, os.R_OK):
- writemsg("pickle_read(): File not readable. '"+filename+"'\n",1)
+ writemsg(_("pickle_read(): File not readable. '")+filename+"'\n",1)
return default
data = None
try:
@@ -593,11 +594,11 @@ def pickle_read(filename,default=None,debug=0):
data = mypickle.load()
myf.close()
del mypickle,myf
- writemsg("pickle_read(): Loaded pickle. '"+filename+"'\n",1)
+ writemsg(_("pickle_read(): Loaded pickle. '")+filename+"'\n",1)
except SystemExit, e:
raise
except Exception, e:
- writemsg("!!! Failed to load pickle: "+str(e)+"\n",1)
+ writemsg(_("!!! Failed to load pickle: ")+str(e)+"\n",1)
data = default
return data
@@ -809,10 +810,10 @@ def apply_recursive_permissions(top, uid=-1, gid=-1,
# go unnoticed. Callers can pass in a quiet instance.
def onerror(e):
if isinstance(e, OperationNotPermitted):
- writemsg("Operation Not Permitted: %s\n" % str(e),
+ writemsg(_("Operation Not Permitted: %s\n") % str(e),
noiselevel=-1)
elif isinstance(e, FileNotFound):
- writemsg("File Not Found: '%s'\n" % str(e), noiselevel=-1)
+ writemsg(_("File Not Found: '%s'\n") % str(e), noiselevel=-1)
else:
raise
@@ -917,7 +918,7 @@ class atomic_ofstream(ObjectProxy):
except IOError, e:
if canonical_path == filename:
raise
- writemsg("!!! Failed to open file: '%s'\n" % tmp_name,
+ writemsg(_("!!! Failed to open file: '%s'\n") % tmp_name,
noiselevel=-1)
writemsg("!!! %s\n" % str(e), noiselevel=-1)
diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 299988061..82cf998dc 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -11,13 +11,14 @@ suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
from portage.exception import InvalidData
+from portage.localization import _
def ververify(myver, silent=1):
if ver_regexp.match(myver):
return 1
else:
if not silent:
- print "!!! syntax error in version: %s" % myver
+ print _("!!! syntax error in version: %s") % myver
return 0
vercmp_cache = {}
@@ -58,11 +59,11 @@ def vercmp(ver1, ver2, silent=1):
# checking that the versions are valid
if not match1 or not match1.groups():
if not silent:
- print "!!! syntax error in version: %s" % ver1
+ print _("!!! syntax error in version: %s") % ver1
return None
if not match2 or not match2.groups():
if not silent:
- print "!!! syntax error in version: %s" % ver2
+ print _("!!! syntax error in version: %s") % ver2
return None
# shortcut for cvs ebuilds (new style)
@@ -218,7 +219,7 @@ def pkgsplit(mypkg,silent=1):
if len(myparts)<2:
if not silent:
- print "!!! Name error in",mypkg+": missing a version or name part."
+ print _("!!! Name error in %s: missing a version or name part.") % mypkg
pkgcache[mypkg]=None
return None