diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py +++ b/kallithea/lib/utils2.py @@ -27,25 +27,37 @@ Original author and date, and relevant c :license: GPLv3, see LICENSE.md for more details. """ -from __future__ import print_function - import binascii import datetime +import json import os -import pwd import re import time -import urllib +import urllib.parse import urlobject from tg.i18n import ugettext as _ from tg.i18n import ungettext from webhelpers2.text import collapse, remove_formatting, strip_tags -from kallithea.lib.compat import json +from kallithea.lib.vcs.utils import ascii_bytes, ascii_str, safe_bytes, safe_str # re-export from kallithea.lib.vcs.utils.lazy import LazyProperty +try: + import pwd +except ImportError: + pass + + +# mute pyflakes "imported but unused" +assert ascii_bytes +assert ascii_str +assert safe_bytes +assert safe_str +assert LazyProperty + + def str2bool(_str): """ returns True/False value from given string, it tries to translate the @@ -71,7 +83,7 @@ def aslist(obj, sep=None, strip=True): :param sep: :param strip: """ - if isinstance(obj, (basestring)): + if isinstance(obj, (str)): lst = obj.split(sep) if strip: lst = [v.strip() for v in lst] @@ -98,14 +110,12 @@ def convert_line_endings(line, mode): :rtype: str :return: converted line according to mode """ - from string import replace - if mode == 0: - line = replace(line, '\r\n', '\n') - line = replace(line, '\r', '\n') + line = line.replace('\r\n', '\n') + line = line.replace('\r', '\n') elif mode == 1: - line = replace(line, '\r\n', '\r') - line = replace(line, '\n', '\r') + line = line.replace('\r\n', '\r') + line = line.replace('\n', '\r') elif mode == 2: line = re.sub("\r(?!\n)|(?