_unicode_encode() and _unicode_decode() where appropriate.
svn path=/main/trunk/; revision=14002
import cPickle as pickle
except ImportError:
import pickle
-import os
+from portage import _unicode_encode
+from portage import os
import sys
from portage.cache import fs_template
from portage.cache import cache_errors
self._db_path = os.path.join(self.location, fs_template.gen_label(self.location, self.label)+default_db)
self.__db = None
try:
- self.__db = anydbm_module.open(self._db_path, "w", self._perms)
-
+ self.__db = anydbm_module.open(
+ _unicode_encode(self._db_path), 'w', self._perms)
except anydbm_module.error:
# XXX handle this at some point
try:
# try again if failed
try:
if self.__db == None:
- self.__db = anydbm_module.open(self._db_path, "c", self._perms)
+ self.__db = anydbm_module.open(
+ _unicode_encode(self._db_path), 'c', self._perms)
except anydbm_module.error, e:
raise cache_errors.InitializationError(self.__class__, e)
self._ensure_access(self._db_path)
from portage.cache import fs_template
from portage.versions import catsplit
from portage import cpv_getkey
-from portage.util import writemsg
-import os
+from portage import os
+from portage import _unicode_decode
import xattr
from errno import ENODATA,ENOSPC,E2BIG
def __iter__(self):
- portdir = self.portdir
- if isinstance(portdir, unicode):
- # Avoid UnicodeDecodeError raised from
- # os.path.join when called by os.walk.
- portdir = portdir.encode('utf_8', 'replace')
-
- for root, dirs, files in os.walk(portdir):
+ for root, dirs, files in os.walk(self.portdir):
for file in files:
+ file = _unicode_decode(file)
if file[-7:] == '.ebuild':
cat = os.path.basename(os.path.dirname(root))
pn_pv = file[:-7]
import codecs
from portage.cache import fs_template
from portage.cache import cache_errors
-import errno, os, stat
-from portage.cache.template import reconstruct_eclasses
-# store the current key order *here*.
+import errno
+import stat
+from portage import os
+from portage import _unicode_encode
+
class database(fs_template.FsBased):
autocommits = True
def _getitem(self, cpv):
fp = os.path.join(self.location, cpv)
try:
- myf = codecs.open(fp, mode='r', encoding='utf_8', errors='replace')
+ myf = codecs.open(_unicode_encode(fp),
+ mode='r', encoding='utf_8', errors='replace')
try:
d = self._parse_data(myf.readlines(), cpv)
if '_mtime_' not in d:
s = cpv.rfind("/")
fp = os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
try:
- myf = codecs.open(fp, mode='w',
+ myf = codecs.open(_unicode_encode(fp), mode='w',
encoding='utf_8', errors='replace')
except (IOError, OSError), e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
- myf = codecs.open(fp, mode='w',
+ myf = codecs.open(_unicode_encode(fp), mode='w',
encoding='utf_8', errors='replace')
except (OSError, IOError),e:
raise cache_errors.CacheCorruption(cpv, e)
from portage.cache import fs_template
from portage.cache import cache_errors
-import errno, os, stat
+from portage import os
+from portage import _unicode_encode
+import codecs
+import errno
+import stat
# store the current key order *here*.
class database(fs_template.FsBased):
def _getitem(self, cpv):
d = {}
try:
- myf = open(os.path.join(self._base, cpv),"r")
+ myf = codecs.open(_unicode_encode(os.path.join(self._base, cpv)),
+ mode='r', encoding='utf_8', errors='replace')
for k,v in zip(self.auxdbkey_order, myf):
d[k] = v.rstrip("\n")
except (OSError, IOError),e:
s = cpv.rfind("/")
fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
try:
- myf = open(fp, "w")
+ myf = codecs.open(_unicode_encode(fp), mode='w',
+ encoding='utf_8', errors='replace')
except (OSError, IOError), e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
- myf=open(fp,"w")
+ myf = codecs.open(_unicode_encode(fp), mode='w',
+ encoding='utf_8', errors='replace')
except (OSError, IOError),e:
raise cache_errors.CacheCorruption(cpv, e)
else:
# License: GPL2
# $Id$
-import os
from portage.cache import template
+from portage import os
-import portage.proxy.lazyimport
-import portage.proxy as proxy
-proxy.lazyimport.lazyimport(globals(),
+from portage.proxy.lazyimport import lazyimport
+lazyimport(globals(),
'portage.data:portage_gid',
'portage.exception:PortageException',
'portage.util:apply_permissions',
)
+del lazyimport
class FsBased(template.database):
"""template wrapping fs needed options, and providing _ensure_access as a way to
# License: GPL2
# $Id$
-import errno, os, re, sys
+import errno
+import re
+from portage import os
+from portage import _unicode_encode
from portage.cache import cache_errors, flat_hash
import portage.eclass_cache
from portage.cache.template import reconstruct_eclasses
for i in xrange(magic_line_count - len(self.auxdbkey_order)):
new_content.append(u'\n')
new_content = u''.join(new_content)
- new_content = new_content.encode('utf_8', 'replace')
+ new_content = _unicode_encode(new_content)
new_fp = os.path.join(self.location, cpv)
try:
- f = open(new_fp, 'rb')
+ f = open(_unicode_encode(new_fp), 'rb')
except EnvironmentError:
pass
else:
fp = os.path.join(self.location,cpv[:s],
".update.%i.%s" % (os.getpid(), cpv[s+1:]))
try:
- myf = open(fp, 'wb')
+ myf = open(_unicode_encode(fp), 'wb')
except EnvironmentError, e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
- myf = open(fp, 'wb')
+ myf = open(_unicode_encode(fp), 'wb')
except EnvironmentError, e:
raise cache_errors.CacheCorruption(cpv, e)
else:
from portage.cache import fs_template
from portage.cache import cache_errors
-import os
+from portage import os
+from portage import _unicode_encode
from portage.cache.template import reconstruct_eclasses
-from portage.util import writemsg, apply_secpass_permissions
-from portage.data import portage_gid
+from portage.util import writemsg
from portage.localization import _
try:
import sqlite3 as db_module # sqlite3 is optional with >=python-2.5
try:
self._ensure_dirs()
self._db_connection = self._db_module.connect(
- database=self._dbpath, **connection_kwargs)
+ database=_unicode_encode(self._dbpath), **connection_kwargs)
self._db_cursor = self._db_connection.cursor()
self._db_cursor.execute("PRAGMA encoding = %s" % self._db_escape_string("UTF-8"))
if not self._ensure_access(self._dbpath):