Commit 3effff02 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

py2/py3: maketrans() is different.

parent da6c14eb
...@@ -26,9 +26,13 @@ ...@@ -26,9 +26,13 @@
############################################################################## ##############################################################################
import string, re import string, re
import six
redundant_chars='"\'.:;,-+<>()*~' # chars we need to strip from a word before we see if it matches, and from the searchwords to eliminate boolean mode chars redundant_chars='"\'.:;,-+<>()*~' # chars we need to strip from a word before we see if it matches, and from the searchwords to eliminate boolean mode chars
tr=string.maketrans(redundant_chars,' '*len(redundant_chars)) if six.PY2:
tr=string.maketrans(redundant_chars,' '*len(redundant_chars))
else:
tr = str.maketrans('', '', redundant_chars)
class Done(Exception): class Done(Exception):
pass pass
......
...@@ -103,8 +103,12 @@ class CachedConvertableMixin: ...@@ -103,8 +103,12 @@ class CachedConvertableMixin:
http://pypi.python.org/pypi/uuid/ to generate http://pypi.python.org/pypi/uuid/ to generate
a uuid stored as private property. a uuid stored as private property.
""" """
if six.PY2:
format_cache_id = str(makeSortedTuple(kw)).\ format_cache_id = str(makeSortedTuple(kw)).\
translate(string.maketrans('', ''), '[]()<>\'", ') translate(string.maketrans('', ''), '[]()<>\'", ')
else:
format_cache_id = str(makeSortedTuple(kw)).\
translate(str.maketrans('', '', '[]()<>\'", '))
return '%s:%s:%s' % (aq_base(self).getUid(), self.getRevision(), return '%s:%s:%s' % (aq_base(self).getUid(), self.getRevision(),
format_cache_id) format_cache_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment