Browse Source

Py3: Remove unicoder-function

pull/1253/head
Safihre 6 years ago
parent
commit
0d49dbc6e9
  1. 12
      SABnzbd.py
  2. 7
      sabnzbd/api.py
  3. 5
      sabnzbd/database.py
  4. 18
      sabnzbd/encoding.py
  5. 8
      sabnzbd/misc.py
  6. 4
      sabnzbd/newsunpack.py
  7. 4
      sabnzbd/osxmenu.py
  8. 3
      sabnzbd/panic.py
  9. 3
      sabnzbd/sorting.py
  10. 2
      tools/make_mo.py

12
SABnzbd.py

@ -60,7 +60,6 @@ import sabnzbd.scheduler as scheduler
import sabnzbd.config as config
import sabnzbd.cfg
import sabnzbd.downloader
from sabnzbd.encoding import unicoder
import sabnzbd.notifier as notifier
import sabnzbd.zconfig
@ -671,8 +670,6 @@ def evaluate_inipath(path):
but not a leading dot.
foldername is enough, the standard name will be appended.
"""
if sabnzbd.WIN32:
path = unicoder(path)
path = os.path.normpath(os.path.abspath(path))
inipath = os.path.join(path, DEF_INI_FILE)
if os.path.isdir(path):
@ -1570,14 +1567,13 @@ if sabnzbd.WIN32:
win32evtlogutil.ReportEvent(self._svc_display_name_,
state, 0,
servicemanager.EVENTLOG_INFORMATION_TYPE,
(self._svc_name_, unicoder(msg)))
(self._svc_name_, msg))
def ErrLogger(self, msg, text):
win32evtlogutil.ReportEvent(self._svc_display_name_,
servicemanager.PYS_SERVICE_STOPPED, 0,
servicemanager.EVENTLOG_ERROR_TYPE,
(self._svc_name_, unicoder(msg)),
unicoder(text))
(self._svc_name_, msg), text)
def prep_service_parms(args):
@ -1652,9 +1648,7 @@ if __name__ == '__main__':
args = []
for txt in sys.argv:
if ' ' in txt:
txt = '"%s"' % unicoder(txt)
else:
txt = unicoder(txt)
txt = '"%s"' % txt
args.append(txt)
sabnzbd.CMDLINE = ' '.join(args)

7
sabnzbd/api.py

@ -53,7 +53,7 @@ from sabnzbd.misc import loadavg, to_units, int_conv, time_format, \
from sabnzbd.filesystem import diskspace, get_ext, get_filename, globber, \
globber_full, clip_path, remove_all
from sabnzbd.filesystem import same_file
from sabnzbd.encoding import xml_name, unicoder, platform_encode
from sabnzbd.encoding import xml_name, platform_encode
from sabnzbd.postproc import PostProcessor
from sabnzbd.articlecache import ArticleCache
from sabnzbd.utils.servertests import test_nntp_server_dict
@ -601,8 +601,7 @@ def _api_get_cats(name, output, kwargs):
def _api_get_scripts(name, output, kwargs):
""" API: accepts output """
data = [unicoder(val) for val in list_scripts()]
return report(output, keyword="scripts", data=data)
return report(output, keyword="scripts", data=list_scripts())
def _api_version(name, output, kwargs):
@ -1239,7 +1238,7 @@ def build_status(skip_dashboard=False, output=None):
connected += 1
if server.warning and not (connected or server.errormsg):
connected = unicoder(server.warning)
connected = server.warning
if server.request and not server.info:
connected = T(' Resolving address').replace(' ', '')

5
sabnzbd/database.py

@ -30,7 +30,6 @@ import sqlite3
import sabnzbd
import sabnzbd.cfg
from sabnzbd.constants import DB_HISTORY_NAME, STAGES
from sabnzbd.encoding import unicoder
from sabnzbd.bpsmeter import this_week, this_month
from sabnzbd.decorators import synchronized
from sabnzbd.misc import int_conv, caller_name
@ -480,7 +479,7 @@ def unpack_history_info(item):
try:
lines = lst.split('\r\n')
except:
logging.error(T('Invalid stage logging in history for %s') + ' (\\r\\n)', unicoder(item['name']))
logging.error(T('Invalid stage logging in history for %s') + ' (\\r\\n)', item['name'])
logging.debug('Lines: %s', lst)
lines = []
lst = [None for x in STAGES]
@ -497,7 +496,7 @@ def unpack_history_info(item):
try:
logs = logs.split(';')
except:
logging.error(T('Invalid stage logging in history for %s') + ' (;)', unicoder(item['name']))
logging.error(T('Invalid stage logging in history for %s') + ' (;)', item['name'])
logging.debug('Logs: %s', logs)
logs = []
for log in logs:

18
sabnzbd/encoding.py

@ -99,21 +99,3 @@ def platform_encode(p):
return p.decode(codepage, errors='replace').replace('?', '!')
else:
return p
def unicoder(p, force=False):
return p
""" Make sure a Unicode string is returned
When `force` is True, ignore filesystem encoding
"""
if isinstance(p, str):
return p
if isinstance(p, str):
if gUTF or force:
try:
return p.decode('utf-8')
except:
return p.decode(codepage, 'replace')
return p.decode(codepage, 'replace')
else:
return str(str(p))

8
sabnzbd/misc.py

@ -35,7 +35,7 @@ from sabnzbd.constants import DEFAULT_PRIORITY, \
MEBI, DEF_ARTICLE_CACHE_DEFAULT, DEF_ARTICLE_CACHE_MAX
import sabnzbd.config as config
import sabnzbd.cfg as cfg
from sabnzbd.encoding import ubtou, unicoder, platform_btou
from sabnzbd.encoding import ubtou, platform_btou
TAB_UNITS = ('', 'K', 'M', 'G', 'T', 'P')
RE_UNITS = re.compile(r'(\d+\.*\d*)\s*([KMGTP]{0,1})', re.I)
@ -271,13 +271,9 @@ def set_serv_parms(service, args):
""" Set the service command line parameters in Registry """
import winreg
uargs = []
for arg in args:
uargs.append(unicoder(arg))
try:
key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, _SERVICE_KEY + service)
winreg.SetValueEx(key, _SERVICE_PARM, None, winreg.REG_MULTI_SZ, uargs)
winreg.SetValueEx(key, _SERVICE_PARM, None, winreg.REG_MULTI_SZ, args)
winreg.CloseKey(key)
except WindowsError:
return False

4
sabnzbd/newsunpack.py

@ -1927,7 +1927,7 @@ def create_env(nzo=None, extra_env_fields={}):
else:
env['SAB_' + field.upper()] = field_value
except:
# Catch key/unicode errors
# Catch key errors
pass
# Always supply basic info
@ -1947,7 +1947,7 @@ def create_env(nzo=None, extra_env_fields={}):
else:
env['SAB_' + field.upper()] = ''
except:
# Catch key/unicode errors
# Catch key errors
pass
if sabnzbd.DARWIN:

4
sabnzbd/osxmenu.py

@ -45,7 +45,6 @@ import sabnzbd.scheduler as scheduler
import sabnzbd.downloader
import sabnzbd.dirscanner as dirscanner
from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.encoding import unicoder
status_icons = {'idle': '../Resources/sab_idle.tiff', 'pause': '../Resources/sab_pause.tiff', 'clicked': '../Resources/sab_clicked.tiff'}
start_time = NSDate.date()
@ -358,14 +357,13 @@ class SABnzbdDelegate(NSObject):
self.menu_queue.addItem_(NSMenuItem.separatorItem())
for pnfo in pnfo_list:
filename = unicoder(pnfo.filename)
bytesleft = pnfo.bytes_left / MEBI
bytesleftprogess += pnfo.bytes_left
bytes = pnfo.bytes / MEBI
nzo_id = pnfo.nzo_id
timeleft = self.calc_timeleft_(bytesleftprogess, bpsnow)
job = "%s\t(%d/%d MB) %s" % (filename, bytesleft, bytes, timeleft)
job = "%s\t(%d/%d MB) %s" % (pnfo.filename, bytesleft, bytes, timeleft)
menu_queue_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(job, '', '')
self.menu_queue.addItem_(menu_queue_item)

3
sabnzbd/panic.py

@ -30,7 +30,6 @@ except ImportError:
import sabnzbd
import sabnzbd.cfg as cfg
from sabnzbd.encoding import unicoder
PANIC_PORT = 1
PANIC_TEMPL = 2
@ -220,7 +219,7 @@ def show_error_dialog(msg):
Windows-only, otherwise only print to console
"""
if sabnzbd.WIN32:
ctypes.windll.user32.MessageBoxW(0, unicoder(msg), T('Fatal error'), 0)
ctypes.windll.user32.MessageBoxW(0, msg, T('Fatal error'), 0)
print(msg)

3
sabnzbd/sorting.py

@ -30,7 +30,6 @@ import sabnzbd
from sabnzbd.filesystem import move_to_path, cleanup_empty_directories, get_unique_path, \
get_unique_filename, get_ext, renamer, sanitize_foldername, clip_path
from sabnzbd.constants import series_match, date_match, year_match, sample_match
from sabnzbd.encoding import unicoder
import sabnzbd.cfg as cfg
RE_SAMPLE = re.compile(sample_match, re.I)
@ -899,7 +898,7 @@ def path_subst(path, mapping):
break
newpath.append(result)
n += 1
return ''.join([unicoder(x) for x in newpath])
return ''.join(newpath)
def get_titles(nzo, match, name, titleing=False):

2
tools/make_mo.py

@ -206,7 +206,6 @@ def make_templates():
if lng != 'en' and os.path.exists(os.path.join(POE_DIR,lng+'.po')):
print(('Create email template for %s' % lng))
trans = gettext.translation(DOMAIN_E, MO_DIR, [lng], fallback=False, codeset='latin-1')
# The unicode flag will make _() return Unicode
trans.install(names=['lgettext'])
translate_tmpl('email', lng)
@ -246,7 +245,6 @@ def patch_nsis():
trans = lcode
else:
trans = gettext.translation(DOMAIN_N, MO_DIR, [lcode], fallback=False, codeset='latin-1')
# The unicode flag will make _() return Unicode
trans.install(names=['lgettext'])
trans = trans.replace('\r', '').replace('\n', '\\r\\n')
trans = trans.replace('\\', '$\\').replace('"', '$\\"')

Loading…
Cancel
Save