changeset 8184:fb4b72c1c0f1

py3: automatic migration with 2to3 -f basestring
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 05 Feb 2020 23:03:55 +0100
parents aa093e05a1c6
children 6e537f0a9961
files kallithea/lib/celerypylons/__init__.py kallithea/lib/helpers.py kallithea/lib/rcmail/message.py kallithea/lib/rcmail/smtp_mailer.py kallithea/lib/utils.py kallithea/lib/utils2.py kallithea/lib/vcs/backends/git/repository.py kallithea/lib/vcs/backends/hg/changeset.py kallithea/lib/vcs/backends/hg/repository.py kallithea/lib/vcs/utils/__init__.py kallithea/model/db.py kallithea/model/scm.py kallithea/model/user_group.py kallithea/tests/scripts/manual_test_crawler.py
diffstat 14 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/celerypylons/__init__.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/celerypylons/__init__.py	Wed Feb 05 23:03:55 2020 +0100
@@ -39,7 +39,7 @@
         celery_key = config_key.replace('.', '_').upper()
         if celery_key.split('_', 1)[0] not in PREFIXES:
             continue
-        if not isinstance(config_value, basestring):
+        if not isinstance(config_value, str):
             continue
         if celery_key in LIST_PARAMS:
             celery_value = config_value.split()
--- a/kallithea/lib/helpers.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/helpers.py	Wed Feb 05 23:03:55 2020 +0100
@@ -166,7 +166,7 @@
         for x in option_list:
             if isinstance(x, tuple) and len(x) == 2:
                 value, label = x
-            elif isinstance(x, basestring):
+            elif isinstance(x, str):
                 value = label = x
             else:
                 log.error('invalid select option %r', x)
@@ -176,7 +176,7 @@
                 for x in value:
                     if isinstance(x, tuple) and len(x) == 2:
                         group_value, group_label = x
-                    elif isinstance(x, basestring):
+                    elif isinstance(x, str):
                         group_value = group_label = x
                     else:
                         log.error('invalid select option %r', x)
--- a/kallithea/lib/rcmail/message.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/rcmail/message.py	Wed Feb 05 23:03:55 2020 +0100
@@ -25,7 +25,7 @@
 
     @property
     def data(self):
-        if isinstance(self._data, basestring):
+        if isinstance(self._data, str):
             return self._data
         self._data = self._data.read()
         return self._data
--- a/kallithea/lib/rcmail/smtp_mailer.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/rcmail/smtp_mailer.py	Wed Feb 05 23:03:55 2020 +0100
@@ -64,7 +64,7 @@
     def send(self, recipients=None, subject='', body='', html='',
              attachment_files=None, headers=None):
         recipients = recipients or []
-        if isinstance(recipients, basestring):
+        if isinstance(recipients, str):
             recipients = [recipients]
         if headers is None:
             headers = {}
--- a/kallithea/lib/utils.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/utils.py	Wed Feb 05 23:03:55 2020 +0100
@@ -132,7 +132,7 @@
 
     if getattr(user, 'user_id', None):
         user_obj = User.get(user.user_id)
-    elif isinstance(user, basestring):
+    elif isinstance(user, str):
         user_obj = User.get_by_username(user)
     else:
         raise Exception('You have to provide a user object or a username')
@@ -140,7 +140,7 @@
     if getattr(repo, 'repo_id', None):
         repo_obj = Repository.get(repo.repo_id)
         repo_name = repo_obj.repo_name
-    elif isinstance(repo, basestring):
+    elif isinstance(repo, str):
         repo_name = repo.lstrip('/')
         repo_obj = Repository.get_by_repo_name(repo_name)
     else:
--- a/kallithea/lib/utils2.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/utils2.py	Wed Feb 05 23:03:55 2020 +0100
@@ -72,7 +72,7 @@
     :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]
@@ -376,7 +376,7 @@
 
 def time_to_datetime(tm):
     if tm:
-        if isinstance(tm, basestring):
+        if isinstance(tm, str):
             try:
                 tm = float(tm)
             except ValueError:
--- a/kallithea/lib/vcs/backends/git/repository.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/vcs/backends/git/repository.py	Wed Feb 05 23:03:55 2020 +0100
@@ -700,7 +700,7 @@
         """
         if config_file is None:
             config_file = []
-        elif isinstance(config_file, basestring):
+        elif isinstance(config_file, str):
             config_file = [config_file]
 
         def gen_configs():
--- a/kallithea/lib/vcs/backends/hg/changeset.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/vcs/backends/hg/changeset.py	Wed Feb 05 23:03:55 2020 +0100
@@ -22,7 +22,7 @@
 
     def __init__(self, repository, revision):
         self.repository = repository
-        assert isinstance(revision, basestring), repr(revision)
+        assert isinstance(revision, str), repr(revision)
         self._ctx = repository._repo[ascii_bytes(revision)]
         self.raw_id = ascii_str(self._ctx.hex())
         self.revision = self._ctx._rev
--- a/kallithea/lib/vcs/backends/hg/repository.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/vcs/backends/hg/repository.py	Wed Feb 05 23:03:55 2020 +0100
@@ -583,7 +583,7 @@
         """
         if config_file is None:
             config_file = []
-        elif isinstance(config_file, basestring):
+        elif isinstance(config_file, str):
             config_file = [config_file]
 
         config = self._repo.ui
--- a/kallithea/lib/vcs/utils/__init__.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/lib/vcs/utils/__init__.py	Wed Feb 05 23:03:55 2020 +0100
@@ -27,7 +27,7 @@
     :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]
--- a/kallithea/model/db.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/model/db.py	Wed Feb 05 23:03:55 2020 +0100
@@ -141,7 +141,7 @@
             return value
         if isinstance(value, int):
             return cls.get(value)
-        if isinstance(value, basestring) and value.isdigit():
+        if isinstance(value, str) and value.isdigit():
             return cls.get(int(value))
         if callback is not None:
             return callback(value)
--- a/kallithea/model/scm.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/model/scm.py	Wed Feb 05 23:03:55 2020 +0100
@@ -141,7 +141,7 @@
             return instance
         elif isinstance(instance, int):
             return cls.get(instance)
-        elif isinstance(instance, basestring):
+        elif isinstance(instance, str):
             if instance.isdigit():
                 return cls.get(int(instance))
             return cls.get_by_repo_name(instance)
@@ -485,7 +485,7 @@
             f_path = safe_str(f_path)
             # decoding here will force that we have proper encoded values
             # in any other case this will throw exceptions and deny commit
-            if isinstance(content, (basestring,)):
+            if isinstance(content, (str,)):
                 content = safe_str(content)
             else:
                 content = content.read()
--- a/kallithea/model/user_group.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/model/user_group.py	Wed Feb 05 23:03:55 2020 +0100
@@ -126,7 +126,7 @@
                 if k == 'users_group_members':
                     members_list = []
                     if v:
-                        v = [v] if isinstance(v, basestring) else v
+                        v = [v] if isinstance(v, str) else v
                         for u_id in set(v):
                             member = UserGroupMember(user_group.users_group_id, u_id)
                             members_list.append(member)
--- a/kallithea/tests/scripts/manual_test_crawler.py	Wed Feb 05 23:03:39 2020 +0100
+++ b/kallithea/tests/scripts/manual_test_crawler.py	Wed Feb 05 23:03:55 2020 +0100
@@ -83,7 +83,7 @@
 
 
 def _get_repo(proj):
-    if isinstance(proj, basestring):
+    if isinstance(proj, str):
         repo = vcs.get_repo(os.path.join(PROJECT_PATH, proj))
         proj = proj
     else: