--- a/VirtualMailManager/common.py Sun Nov 11 16:53:52 2012 +0000
+++ b/VirtualMailManager/common.py Tue Nov 20 13:40:32 2012 +0000
@@ -36,9 +36,9 @@
def get_unicode(string):
"""Converts `string` to `unicode`, if necessary."""
- if isinstance(string, unicode):
+ if isinstance(string, str):
return string
- return unicode(string, ENCODING, 'replace')
+ return str(string, ENCODING, 'replace')
def lisdir(path):
@@ -60,19 +60,19 @@
"""
binary = expand_path(binary)
if not os.path.isfile(binary):
- raise VMMError(_(u"No such file: '%s'") % get_unicode(binary),
+ raise VMMError(_("No such file: '%s'") % get_unicode(binary),
NO_SUCH_BINARY)
if not os.access(binary, os.X_OK):
- raise VMMError(_(u"File is not executable: '%s'") %
+ raise VMMError(_("File is not executable: '%s'") %
get_unicode(binary), NOT_EXECUTABLE)
return binary
def human_size(size):
"""Converts the `size` in bytes in human readable format."""
- if not isinstance(size, (long, int)):
+ if not isinstance(size, int):
try:
- size = long(size)
+ size = int(size)
except ValueError:
raise TypeError("'size' must be a positive long or int.")
if size < 0:
@@ -80,12 +80,12 @@
if size < 1024:
return str(size)
# TP: abbreviations of gibibyte, tebibyte kibibyte and mebibyte
- prefix_multiply = ((_(u'TiB'), 1 << 40), (_(u'GiB'), 1 << 30),
- (_(u'MiB'), 1 << 20), (_(u'KiB'), 1 << 10))
+ prefix_multiply = ((_('TiB'), 1 << 40), (_('GiB'), 1 << 30),
+ (_('MiB'), 1 << 20), (_('KiB'), 1 << 10))
for prefix, multiply in prefix_multiply:
if size >= multiply:
# TP: e.g.: '%(size)s %(prefix)s' -> '118.30 MiB'
- return _(u'%(size)s %(prefix)s') % {
+ return _('%(size)s %(prefix)s') % {
'size': locale.format('%.2f', float(size) / multiply,
True).decode(ENCODING, 'replace'),
'prefix': prefix}
@@ -97,7 +97,7 @@
The string `size` can be suffixed with *b* (bytes), *k* (kilobytes),
*M* (megabytes) or *G* (gigabytes).
"""
- if not isinstance(size, basestring) or not size:
+ if not isinstance(size, str) or not size:
raise TypeError('size must be a non empty string.')
if size[-1].upper() in ('B', 'K', 'M', 'G'):
try:
@@ -108,11 +108,11 @@
if unit == 'B':
return num
elif unit == 'K':
- return num << 10L
+ return num << 10
elif unit == 'M':
- return num << 20L
+ return num << 20
else:
- return num << 30L
+ return num << 30
else:
try:
num = int(size)
@@ -136,8 +136,8 @@
"""
if transport.transport in ('virtual', 'virtual:') and \
not maillocation.postfix:
- raise VMMError(_(u"Invalid transport '%(transport)s' for mailbox "
- u"format '%(mbfmt)s'.") %
+ raise VMMError(_("Invalid transport '%(transport)s' for mailbox "
+ "format '%(mbfmt)s'.") %
{'transport': transport.transport,
'mbfmt': maillocation.mbformat}, INVALID_MAIL_LOCATION)
@@ -189,7 +189,7 @@
global _version_cache
if version in _version_cache:
return _version_cache[version]
- if not isinstance(version, (int, long)):
+ if not isinstance(version, int):
raise TypeError('Argument is not a int/long: %r', version)
major = (version >> 28) & 0xFF
minor = (version >> 20) & 0xFF
@@ -197,7 +197,7 @@
level = (version >> 8) & 0x0F
serial = version & 0xFF
- levels = dict(zip(_version_level.values(), _version_level.keys()))
+ levels = dict(list(zip(list(_version_level.values()), list(_version_level.keys()))))
if level == 0xF and not serial:
version_string = '%u.%u.%u' % (major, minor, patch)
elif level in levels and not patch:
@@ -214,7 +214,7 @@
# TP: [domain default] indicates that a user's setting is the same as
# configured in the user's domain.
# e.g.: [ 0.84%] 42/5,000 [domain default]
- return _(u'%s [domain default]') % domaindata
+ return _('%s [domain default]') % domaindata
def search_addresses(dbh, typelimit=None, lpattern=None, llike=False,