since shlex.split() doesn't behave well with unicode strings.
svn path=/main/trunk/; revision=13939
err.flush()
return 2
- import shlex
from portage.util import ConfigProtect
settings = portage.settings
- protect = shlex.split(settings.get("CONFIG_PROTECT", ""))
- protect_mask = shlex.split(settings.get("CONFIG_PROTECT_MASK", ""))
+ protect = portage.util.shlex_split(settings.get("CONFIG_PROTECT", ""))
+ protect_mask = portage.util.shlex_split(
+ settings.get("CONFIG_PROTECT_MASK", ""))
protect_obj = ConfigProtect(root, protect, protect_mask)
if protect_obj.isprotected(f):
except OSError:
pass
- import shlex
from portage.util import ConfigProtect
settings = portage.settings
- protect = shlex.split(settings.get("CONFIG_PROTECT", ""))
- protect_mask = shlex.split(settings.get("CONFIG_PROTECT_MASK", ""))
+ protect = portage.util.shlex_split(settings.get("CONFIG_PROTECT", ""))
+ protect_mask = portage.util.shlex_split(
+ settings.get("CONFIG_PROTECT_MASK", ""))
protect_obj = ConfigProtect(root, protect, protect_mask)
protected = 0
from _emerge.SpawnProcess import SpawnProcess
import urlparse
import sys
-import shlex
+
try:
import portage
except ImportError:
fetch_env = dict(settings.iteritems())
fetch_args = [portage.util.varexpand(x, mydict=fcmd_vars) \
- for x in shlex.split(fcmd)]
+ for x in portage.util.shlex_split(fcmd)]
if self.fd_pipes is None:
self.fd_pipes = {}
import platform
import pwd
import re
-import shlex
import signal
import socket
import stat
# defaults.
portage.writemsg("Using PORTAGE_RSYNC_OPTS instead of hardcoded defaults\n", 1)
- rsync_opts.extend(
- shlex.split(settings.get("PORTAGE_RSYNC_OPTS","")))
+ rsync_opts.extend(portage.util.shlex_split(
+ settings.get("PORTAGE_RSYNC_OPTS", "")))
for opt in ("--recursive", "--times"):
if opt not in rsync_opts:
portage.writemsg(yellow("WARNING:") + " adding required option " + \
user_name=""
updatecache_flg=True
all_rsync_opts = set(rsync_opts)
- extra_rsync_opts = shlex.split(
+ extra_rsync_opts = portage.util.shlex_split(
settings.get("PORTAGE_RSYNC_EXTRA_OPTS",""))
all_rsync_opts.update(extra_rsync_opts)
family = socket.AF_INET
# $Id$
import logging
-import shlex
import signal
import sys
import textwrap
ionice_cmd = settings.get("PORTAGE_IONICE_COMMAND")
if ionice_cmd:
- ionice_cmd = shlex.split(ionice_cmd)
+ ionice_cmd = portage.util.shlex_split(ionice_cmd)
if not ionice_cmd:
return
# no digests because fetch was not called for a specific package
mydigests = {}
- import shlex
ro_distdirs = [x for x in \
- shlex.split(mysettings.get("PORTAGE_RO_DISTDIRS", "")) \
+ util.shlex_split(mysettings.get("PORTAGE_RO_DISTDIRS", "")) \
if os.path.isdir(x)]
fsmirrors = []
"URI": loc,
"FILE": myfile
}
- import shlex
- myfetch = shlex.split(locfetch)
+
+ myfetch = util.shlex_split(locfetch)
myfetch = [varexpand(x, mydict=variables) for x in myfetch]
myret = -1
try:
import codecs
import os, re, shutil, stat, errno, copy, subprocess
import logging
-import shlex
import sys
from itertools import izip
self.myroot=myroot
protect_obj = ConfigProtect(myroot,
- shlex.split(mysettings.get("CONFIG_PROTECT", "")),
- shlex.split(mysettings.get("CONFIG_PROTECT_MASK", "")))
+ portage.util.shlex_split(mysettings.get("CONFIG_PROTECT", "")),
+ portage.util.shlex_split(
+ mysettings.get("CONFIG_PROTECT_MASK", "")))
self.updateprotect = protect_obj.updateprotect
self.isprotected = protect_obj.isprotected
self._installed_instance = None
def _collision_protect(self, srcroot, destroot, mypkglist, mycontents):
collision_ignore = set([normalize_path(myignore) for myignore in \
- shlex.split(self.settings.get("COLLISION_IGNORE", ""))])
+ portage.util.shlex_split(
+ self.settings.get("COLLISION_IGNORE", ""))])
# For collisions with preserved libraries, the current package
# will assume ownership and the libraries will be unregistered.
from portage.output import colorize
from portage.cache.mappings import slot_dict_class
-import portage.xpak
+import portage
import HTMLParser
import sys
import os
"URI": baseurl,
"FILE": os.path.basename(baseurl)
}
- import shlex
+
from portage.util import varexpand
from portage.process import spawn
- myfetch = shlex.split(fcmd)
+ myfetch = portage.util.shlex_split(fcmd)
myfetch = [varexpand(x, mydict=variables) for x in myfetch]
fd_pipes= {
0:sys.stdin.fileno(),
from portage.localization import _
from portage.sets.base import PackageSet
from portage.sets import SetConfigError, get_boolean
+import portage
__all__ = ["CategorySet", "DowngradeSet",
"EverythingSet", "OwnerSet", "VariableSet"]
if not "files" in options:
raise SetConfigError(_("no files given"))
- import shlex
return cls(vardb=trees["vartree"].dbapi,
- files=frozenset(shlex.split(options["files"])))
+ files=frozenset(portage.util.shlex_split(options["files"])))
singleBuilder = classmethod(singleBuilder)
from portage.sets.base import PackageSet
from portage.sets import get_boolean
from portage.versions import catpkgsplit
+import portage
class LibraryConsumerSet(PackageSet):
_operations = ["merge", "unmerge"]
self._setAtoms(self.mapPathsToAtoms(consumers))
def singleBuilder(cls, options, settings, trees):
- import shlex
- files = tuple(shlex.split(options.get("files", "")))
+ files = tuple(portage.util.shlex_split(options.get("files", "")))
if not files:
raise SetConfigError(_("no files given"))
debug = get_boolean(options, "debug", False)
return 0
return 1
+def shlex_split(s):
+ """
+ This is equivalent to shlex.split but it temporarily encodes unicode
+ strings to bytes since shlex.split() doesn't handle unicode strings.
+ """
+ is_unicode = isinstance(s, unicode)
+ if is_unicode:
+ s = s.encode('utf_8', 'replace')
+ rval = shlex.split(s)
+ if is_unicode:
+ rval = [unicode(x, encoding='utf_8', errors='replace') for x in rval]
+ return rval
+
class _tolerant_shlex(shlex.shlex):
def sourcehook(self, newfile):
try:
def editor_is_executable(editor):
"""
Given an EDITOR string, validate that it refers to
- an executable. This uses shlex.split() to split the
+ an executable. This uses shlex_split() to split the
first component and do a PATH lookup if necessary.
@param editor: An EDITOR value from the environment.
@rtype: bool
@returns: True if an executable is found, False otherwise.
"""
- import shlex
- editor_split = shlex.split(editor)
+ editor_split = util.shlex_split(editor)
if not editor_split:
return False
filename = editor_split[0]