changeset 8200:f9988201a3c4

py3: some not-entirely-trivial removing of "unicode"
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 21 Dec 2019 15:14:08 +0100
parents 1112e440b921
children 620c13a373c5
files kallithea/controllers/admin/admin.py kallithea/controllers/search.py kallithea/lib/vcs/backends/git/repository.py kallithea/lib/vcs/backends/hg/inmemory.py kallithea/model/db.py scripts/update-copyrights.py
diffstat 6 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/admin/admin.py	Sat Dec 28 19:59:15 2019 +0100
+++ b/kallithea/controllers/admin/admin.py	Sat Dec 21 15:14:08 2019 +0100
@@ -60,7 +60,7 @@
     if search_term:
         qp = QueryParser('repository', schema=JOURNAL_SCHEMA)
         qp.add_plugin(DateParserPlugin())
-        qry = qp.parse(unicode(search_term))
+        qry = qp.parse(search_term)
         log.debug('Filtering using parsed query %r', qry)
 
     def wildcard_handler(col, wc_term):
--- a/kallithea/controllers/search.py	Sat Dec 28 19:59:15 2019 +0100
+++ b/kallithea/controllers/search.py	Sat Dec 21 15:14:08 2019 +0100
@@ -96,7 +96,7 @@
                     # for case-sensitive matching
                     cur_query = u'repository_rawname:%s %s' % (c.repo_name, cur_query)
                 try:
-                    query = qp.parse(unicode(cur_query))
+                    query = qp.parse(cur_query)
                     # extract words for highlight
                     if isinstance(query, Phrase):
                         highlight_items.update(query.words)
--- a/kallithea/lib/vcs/backends/git/repository.py	Sat Dec 28 19:59:15 2019 +0100
+++ b/kallithea/lib/vcs/backends/git/repository.py	Sat Dec 21 15:14:08 2019 +0100
@@ -274,7 +274,7 @@
                 msg = "Revision %r does not exist for %s" % (revision, self.name)
                 raise ChangesetDoesNotExistError(msg)
 
-        if isinstance(revision, (str, unicode)):
+        if isinstance(revision, str):
             if revision.isdigit() and (len(revision) < 12 or len(revision) == revision.count('0')):
                 try:
                     return self.revisions[int(revision)]
--- a/kallithea/lib/vcs/backends/hg/inmemory.py	Sat Dec 28 19:59:15 2019 +0100
+++ b/kallithea/lib/vcs/backends/hg/inmemory.py	Sat Dec 21 15:14:08 2019 +0100
@@ -30,12 +30,12 @@
         """
         self.check_integrity(parents)
 
+        if not isinstance(message, str):
+            raise RepositoryError('message must be a str - got %r' % type(message))
+        if not isinstance(author, str):
+            raise RepositoryError('author must be a str - got %r' % type(author))
+
         from .repository import MercurialRepository
-        if not isinstance(message, unicode) or not isinstance(author, unicode):
-            raise RepositoryError('Given message and author needs to be '
-                                  'an <unicode> instance got %r & %r instead'
-                                  % (type(message), type(author)))
-
         if branch is None:
             branch = MercurialRepository.DEFAULT_BRANCH_NAME
         kwargs[b'branch'] = safe_bytes(branch)
--- a/kallithea/model/db.py	Sat Dec 28 19:59:15 2019 +0100
+++ b/kallithea/model/db.py	Sat Dec 21 15:14:08 2019 +0100
@@ -218,9 +218,7 @@
     @app_settings_value.setter
     def app_settings_value(self, val):
         """
-        Setter that will always make sure we use unicode in app_settings_value
-
-        :param val:
+        Setter that will always make sure we use str in app_settings_value
         """
         self._app_settings_value = safe_str(val)
 
--- a/scripts/update-copyrights.py	Sat Dec 28 19:59:15 2019 +0100
+++ b/scripts/update-copyrights.py	Sat Dec 21 15:14:08 2019 +0100
@@ -51,7 +51,7 @@
     * first contribution
     * number of contribution years
     * name (with some unicode normalization)
-    The entries must be 2-tuples of a list of string years and the unicode name"""
+    The entries must be 2-tuples of a list of string years and the name"""
     return (x[0] and -int(x[0][-1]),
             x[0] and int(x[0][0]),
             -len(x[0]),