Mercurial > kallithea
changeset 8201:620c13a373c5
py3: trivial renaming of unicode to str
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Thu, 26 Dec 2019 15:17:51 +0100 |
parents | f9988201a3c4 |
children | 6c381371d106 |
files | kallithea/controllers/api/__init__.py kallithea/lib/celerylib/__init__.py kallithea/lib/helpers.py kallithea/lib/recaptcha.py kallithea/lib/utils2.py kallithea/lib/vcs/backends/base.py kallithea/lib/vcs/backends/hg/repository.py kallithea/lib/vcs/subprocessio.py kallithea/model/db.py kallithea/model/gist.py kallithea/model/notification.py kallithea/tests/vcs/test_git.py kallithea/tests/vcs/test_hg.py kallithea/tests/vcs/test_inmemchangesets.py |
diffstat | 14 files changed, 35 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/api/__init__.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/controllers/api/__init__.py Thu Dec 26 15:17:51 2019 +0100 @@ -226,12 +226,12 @@ if isinstance(raw_response, HTTPError): self._error = str(raw_response) except JSONRPCError as e: - self._error = unicode(e) + self._error = str(e) except Exception as e: log.error('Encountered unhandled exception: %s', traceback.format_exc(),) json_exc = JSONRPCError('Internal server error') - self._error = unicode(json_exc) + self._error = str(json_exc) if self._error is not None: raw_response = None
--- a/kallithea/lib/celerylib/__init__.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/lib/celerylib/__init__.py Thu Dec 26 15:17:51 2019 +0100 @@ -95,7 +95,7 @@ func_name = str(func.__name__) if hasattr(func, '__name__') else str(func) lockkey = 'task_%s.lock' % \ - md5(safe_bytes(func_name + '-' + '-'.join(unicode(x) for x in params))).hexdigest() + md5(safe_bytes(func_name + '-' + '-'.join(str(x) for x in params))).hexdigest() return lockkey
--- a/kallithea/lib/helpers.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/lib/helpers.py Thu Dec 26 15:17:51 2019 +0100 @@ -460,11 +460,11 @@ assert category in ('error', 'success', 'warning'), category if hasattr(message, '__html__'): # render to HTML for storing in cookie - safe_message = unicode(message) + safe_message = str(message) else: # Apply str - the message might be an exception with __str__ # Escape, so we can trust the result without further escaping, without any risk of injection - safe_message = html_escape(unicode(message)) + safe_message = html_escape(str(message)) if logf is None: logf = log.info if category == 'success':
--- a/kallithea/lib/recaptcha.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/lib/recaptcha.py Thu Dec 26 15:17:51 2019 +0100 @@ -26,7 +26,7 @@ return RecaptchaResponse(is_valid=False, error_code='incorrect-captcha-sol') def encode_if_necessary(s): - if isinstance(s, unicode): + if isinstance(s, str): return s.encode('utf-8') return s
--- a/kallithea/lib/utils2.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/lib/utils2.py Thu Dec 26 15:17:51 2019 +0100 @@ -179,8 +179,8 @@ :param prevdate: datetime object :param show_short_version: if it should approximate the date and return a shorter string - :rtype: unicode - :returns: unicode words describing age + :rtype: str + :returns: str words describing age """ now = now or datetime.datetime.now() order = ['year', 'month', 'day', 'hour', 'minute', 'second'] @@ -278,7 +278,7 @@ Removes user:password from given url string :param uri: - :rtype: unicode + :rtype: str :returns: filtered list of strings """ if not uri:
--- a/kallithea/lib/vcs/backends/base.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/lib/vcs/backends/base.py Thu Dec 26 15:17:51 2019 +0100 @@ -342,10 +342,10 @@ combined list of ``Node`` objects ``author`` - author of the changeset, as unicode + author of the changeset, as str ``message`` - message of the changeset, as unicode + message of the changeset, as str ``parents`` list of parent changesets
--- a/kallithea/lib/vcs/backends/hg/repository.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/lib/vcs/backends/hg/repository.py Thu Dec 26 15:17:51 2019 +0100 @@ -428,7 +428,7 @@ if revision in [-1, None]: revision = b'tip' - elif isinstance(revision, unicode): + elif isinstance(revision, str): revision = safe_bytes(revision) try:
--- a/kallithea/lib/vcs/subprocessio.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/lib/vcs/subprocessio.py Thu Dec 26 15:17:51 2019 +0100 @@ -286,7 +286,7 @@ - We are multithreaded. Writing in and reading out, err are all sep threads. - We support concurrent (in and out) stream processing. - - The output is not a stream. It's a queue of read string (bytes, not unicode) + - The output is not a stream. It's a queue of read string (bytes, not str) chunks. The object behaves as an iterable. You can "for chunk in obj:" us. - We are non-blocking in more respects than communicate() (reading from subprocess out pauses when internal buffer is full, but
--- a/kallithea/model/db.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/model/db.py Thu Dec 26 15:17:51 2019 +0100 @@ -205,7 +205,7 @@ @validates('_app_settings_value') def validate_settings_value(self, key, val): - assert isinstance(val, unicode) + assert isinstance(val, str) return val @hybrid_property
--- a/kallithea/model/gist.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/model/gist.py Thu Dec 26 15:17:51 2019 +0100 @@ -125,7 +125,7 @@ Session().flush() # make database assign gist.gist_id if gist_type == Gist.GIST_PUBLIC: # use DB ID for easy to use GIST ID - gist.gist_access_id = unicode(gist.gist_id) + gist.gist_access_id = str(gist.gist_id) log.debug('Creating new %s GIST repo %s', gist_type, gist.gist_access_id) repo = RepoModel()._create_filesystem_repo(
--- a/kallithea/model/notification.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/model/notification.py Thu Dec 26 15:17:51 2019 +0100 @@ -184,7 +184,7 @@ bracket_tags = [] status_change = kwargs.get('status_change') if status_change: - bracket_tags.append(unicode(status_change)) # apply unicode to evaluate LazyString before .join + bracket_tags.append(str(status_change)) # apply str to evaluate LazyString before .join if kwargs.get('closing_pr'): bracket_tags.append(_('Closing')) if bracket_tags:
--- a/kallithea/tests/vcs/test_git.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/tests/vcs/test_git.py Thu Dec 26 15:17:51 2019 +0100 @@ -588,13 +588,13 @@ 'vcs/nodes.py'] assert set(changed) == set([f.path for f in chset.changed]) - def test_commit_message_is_unicode(self): + def test_commit_message_is_str(self): for cs in self.repo: - assert isinstance(cs.message, unicode) + assert isinstance(cs.message, str) - def test_changeset_author_is_unicode(self): + def test_changeset_author_is_str(self): for cs in self.repo: - assert isinstance(cs.author, unicode) + assert isinstance(cs.author, str) def test_repo_files_content_is_bytes(self): changeset = self.repo.get_changeset()
--- a/kallithea/tests/vcs/test_hg.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/tests/vcs/test_hg.py Thu Dec 26 15:17:51 2019 +0100 @@ -535,13 +535,13 @@ # but it would be one of ``removed`` (changeset's attribute) assert path in [rf.path for rf in chset.removed] - def test_commit_message_is_unicode(self): + def test_commit_message_is_str(self): for cm in self.repo: - assert isinstance(cm.message, unicode) + assert isinstance(cm.message, str) - def test_changeset_author_is_unicode(self): + def test_changeset_author_is_str(self): for cm in self.repo: - assert isinstance(cm.author, unicode) + assert isinstance(cm.author, str) def test_repo_files_content_is_bytes(self): test_changeset = self.repo.get_changeset(100)
--- a/kallithea/tests/vcs/test_inmemchangesets.py Sat Dec 21 15:14:08 2019 +0100 +++ b/kallithea/tests/vcs/test_inmemchangesets.py Thu Dec 26 15:17:51 2019 +0100 @@ -37,7 +37,7 @@ for node in to_add: self.imc.add(node) message = u'Added: %s' % ', '.join((node.path for node in self.nodes)) - author = unicode(self.__class__) + author = str(self.__class__) changeset = self.imc.commit(message=message, author=author) newtip = self.repo.get_changeset() @@ -59,7 +59,7 @@ for node in self.nodes] self.imc.add(*to_add) message = u'Added: %s' % ', '.join((node.path for node in self.nodes)) - author = unicode(self.__class__) + author = str(self.__class__) changeset = self.imc.commit(message=message, author=author) newtip = self.repo.get_changeset() @@ -109,7 +109,7 @@ for node in to_add: self.imc.add(node) message = u'Added: %s' % ', '.join((node.path for node in self.nodes)) - author = unicode(self.__class__) + author = str(self.__class__) changeset = self.imc.commit(message=message, author=author) newtip = self.repo.get_changeset() @@ -134,7 +134,7 @@ def test_check_integrity_raise_already_exist(self): node = FileNode('foobar', content='baz') self.imc.add(node) - self.imc.commit(message=u'Added foobar', author=unicode(self)) + self.imc.commit(message=u'Added foobar', author=str(self)) self.imc.add(node) with pytest.raises(NodeAlreadyExistsError): self.imc.commit(message='new message', @@ -189,7 +189,7 @@ def test_check_integrity_change_raise_node_does_not_exist(self): node = FileNode('foobar', content='baz') self.imc.add(node) - self.imc.commit(message=u'Added foobar', author=unicode(self)) + self.imc.commit(message=u'Added foobar', author=str(self)) node = FileNode('not-foobar', content='') self.imc.change(node) with pytest.raises(NodeDoesNotExistError): @@ -198,7 +198,7 @@ def test_change_raise_node_already_changed(self): node = FileNode('foobar', content='baz') self.imc.add(node) - self.imc.commit(message=u'Added foobar', author=unicode(self)) + self.imc.commit(message=u'Added foobar', author=str(self)) node = FileNode('foobar', content='more baz') self.imc.change(node) with pytest.raises(NodeAlreadyChangedError): @@ -212,13 +212,13 @@ with pytest.raises(NodeNotChangedError): self.imc.commit( message=u'Trying to mark node as changed without touching it', - author=unicode(self) + author=str(self), ) def test_change_raise_node_already_removed(self): node = FileNode('foobar', content='baz') self.imc.add(node) - self.imc.commit(message=u'Added foobar', author=unicode(self)) + self.imc.commit(message=u'Added foobar', author=str(self)) self.imc.remove(FileNode('foobar')) with pytest.raises(NodeAlreadyRemovedError): self.imc.change(node) @@ -230,7 +230,7 @@ node = self.nodes[0] assert node.content == tip.get_node(node.path).content self.imc.remove(node) - self.imc.commit(message=u'Removed %s' % node.path, author=unicode(self)) + self.imc.commit(message=u'Removed %s' % node.path, author=str(self)) newtip = self.repo.get_changeset() assert tip != newtip @@ -253,7 +253,7 @@ with pytest.raises(NodeDoesNotExistError): self.imc.commit( message='Trying to remove node at empty repository', - author=str(self) + author=str(self), ) def test_check_integrity_remove_raise_node_does_not_exist(self): @@ -264,7 +264,7 @@ with pytest.raises(NodeDoesNotExistError): self.imc.commit( message=u'Trying to remove not existing node', - author=unicode(self) + author=str(self), ) def test_remove_raise_node_already_removed(self):