Fix pep8 failure on py3
pep8 check failed on python3 like ./stackalytics/dashboard/vault.py:48:30: F821 undefined name 'basestring' if not isinstance(o, basestring): ./stackalytics/dashboard/vault.py:51:20: F821 undefined name 'intern' return intern(o) ./stackalytics/dashboard/vault.py:52:26: F821 undefined name 'unicode' if isinstance(o, unicode): ^ This patch fixes it by merging 2 versions of uniintern() into a single method which supports both PY2 and PY3. Change-Id: Ib18fcfffcdcc8628e7bca5b3558667fb371c956d
This commit is contained in:
parent
8534cff698
commit
293a5b5dc6
@ -16,7 +16,6 @@
|
||||
import collections
|
||||
from datetime import timedelta
|
||||
import os
|
||||
import sys
|
||||
|
||||
import flask
|
||||
from oslo_config import cfg
|
||||
@ -42,23 +41,16 @@ RECORD_FIELDS_FOR_AGGREGATE = ['record_id', 'primary_key', 'record_type',
|
||||
CompactRecord = collections.namedtuple('CompactRecord',
|
||||
RECORD_FIELDS_FOR_AGGREGATE)
|
||||
|
||||
_unihash = {}
|
||||
|
||||
if six.PY2:
|
||||
_unihash = {}
|
||||
|
||||
def uniintern(o):
|
||||
if not isinstance(o, basestring):
|
||||
return o
|
||||
if isinstance(o, str):
|
||||
return intern(o)
|
||||
if isinstance(o, unicode):
|
||||
return _unihash.setdefault(o, o)
|
||||
else:
|
||||
def uniintern(o):
|
||||
if isinstance(o, str):
|
||||
return sys.intern(o)
|
||||
else:
|
||||
return o
|
||||
def uniintern(o):
|
||||
if isinstance(o, str):
|
||||
return six.moves.intern(o)
|
||||
if not isinstance(o, six.string_types[0]):
|
||||
return o
|
||||
if isinstance(o, six.text_type):
|
||||
return _unihash.setdefault(o, o)
|
||||
|
||||
|
||||
def compact_records(records):
|
||||
|
Loading…
x
Reference in New Issue
Block a user