Skip to content

Commit

Permalink
Remove direct dependency on six #295
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne committed Dec 4, 2020
1 parent 2517e26 commit 11165a4
Show file tree
Hide file tree
Showing 46 changed files with 66 additions and 120 deletions.
6 changes: 2 additions & 4 deletions etc/scripts/sch2js/sch2js.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
"""

if __name__ == '__main__':

from six import iteritems

from schematics.types.base import BaseType
from schematics.types.compound import ListType
Expand Down Expand Up @@ -84,7 +82,7 @@ def jsonschema_for_single_field(field_instance):
field_schema['title'] = field_instance.metadata.get('label', '')
field_schema['description'] = field_instance.metadata.get('description', '')

for js_key, schematic_key in iteritems(schema_kwargs_to_schematics):
for js_key, schematic_key in schema_kwargs_to_schematics.items():
value = getattr(field_instance, schematic_key, None)
if value is not None:
field_schema[js_key] = value
Expand All @@ -98,7 +96,7 @@ def jsonschema_for_fields(model):
"""
properties = {}
required = []
for field_name, field_instance in iteritems(model.fields):
for field_name, field_instance in model.fields.items():
serialized_name = getattr(field_instance, 'serialized_name', None) or field_name

if isinstance(field_instance, ModelType):
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def read(*names, **kwargs):
# textcode
'Beautifulsoup4 >= 4.0.0, <5.0.0',
'html5lib',
'six',
'pdfminer.six >= 20170720',
'pycryptodome >= 3.4',
'chardet >= 3.0.0, <4.0.0',
Expand Down
4 changes: 1 addition & 3 deletions src/cluecode/copyrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import sys
from time import time

from six import string_types

from cluecode import copyrights_hint
from commoncode.text import toascii
from commoncode.text import unixlinesep
Expand Down Expand Up @@ -60,7 +58,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))


"""
Expand Down
3 changes: 1 addition & 2 deletions src/cluecode/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import re

import ipaddress
from six import string_types
import urlpy

from commoncode.text import toascii
Expand Down Expand Up @@ -55,7 +54,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))


"""
Expand Down
3 changes: 1 addition & 2 deletions src/cluecode/plugin_filter_clues.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from itertools import chain

import attr
from six import string_types

from commoncode.cliutils import PluggableCommandLineOption
from commoncode.cliutils import POST_SCAN_GROUP
Expand All @@ -49,7 +48,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))


@post_scan_impl
Expand Down
3 changes: 1 addition & 2 deletions src/cluecode/plugin_ignore_copyrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import re

from six import string_types

from commoncode.cliutils import PluggableCommandLineOption
from commoncode.cliutils import OUTPUT_FILTER_GROUP
Expand All @@ -48,7 +47,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))


@output_filter_impl
Expand Down
5 changes: 2 additions & 3 deletions src/formattedcode/output_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


import saneyaml
from six import string_types
import unicodecsv

from formattedcode import FileOptionType
Expand All @@ -52,7 +51,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types)
return logger.debug(' '.join(isinstance(a, str)
and a or repr(a) for a in args))


Expand Down Expand Up @@ -229,7 +228,7 @@ def pretty(data):
maptypes = dict, dict
coltypes = seqtypes + maptypes
if isinstance(data, seqtypes):
if len(data) == 1 and isinstance(data[0], string_types):
if len(data) == 1 and isinstance(data[0], str):
return data[0].strip()
if isinstance(data, coltypes):
return saneyaml.dump(
Expand Down
5 changes: 2 additions & 3 deletions src/formattedcode/output_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


import jsonstreams
from six import string_types

from formattedcode import FileOptionType
from commoncode.cliutils import PluggableCommandLineOption
Expand Down Expand Up @@ -55,7 +54,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types)
return logger.debug(' '.join(isinstance(a, str)
and a or repr(a) for a in args))


Expand Down Expand Up @@ -113,7 +112,7 @@ def write_results(codebase, output_file, pretty=False, **kwargs):

# If `output_file` is a path string, open the file at path `output_file` and use it as `output_file`
close_fd = False
if isinstance(output_file, string_types):
if isinstance(output_file, str):
output_file = open(output_file, 'w')
close_fd = True

Expand Down
3 changes: 1 addition & 2 deletions src/formattedcode/output_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
except ImportError:
from io import StringIO

from six import string_types
from spdx.checksum import Algorithm
from spdx.creationinfo import Tool
from spdx.document import Document
Expand Down Expand Up @@ -71,7 +70,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types)
return logger.debug(' '.join(isinstance(a, str)
and a or repr(a) for a in args))

"""
Expand Down
1 change: 0 additions & 1 deletion src/licensedcode/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from os.path import join
import sys

import six
import yg.lockfile # NOQA

from commoncode.fileutils import resource_iter
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from time import time

from intbitset import intbitset
from six import string_types

from commoncode.dict_utils import sparsify
from licensedcode import MAX_DIST
Expand Down Expand Up @@ -91,7 +90,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a)
return logger.debug(' '.join(isinstance(a, str) and a or repr(a)
for a in args))


Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from itertools import groupby

import attr
from six import string_types

from licensedcode import MAX_DIST
from licensedcode import query
Expand Down Expand Up @@ -86,7 +85,7 @@ def logger_debug(*args): pass
logger = logging.getLogger(__name__)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))

logging.basicConfig(stream=sys.stdout)
logger.setLevel(logging.DEBUG)
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/match_aho.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from itertools import groupby

import ahocorasick
from six import string_types

from licensedcode import SMALL_RULE
from licensedcode.match import LicenseMatch
Expand All @@ -48,7 +47,7 @@
logger = logging.getLogger(__name__)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))

logging.basicConfig(stream=sys.stdout)
logger.setLevel(logging.DEBUG)
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/match_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from array import array
from hashlib import md5

from six import string_types

from licensedcode.match import LicenseMatch
from licensedcode.spans import Span
Expand All @@ -45,7 +44,7 @@
logger = logging.getLogger(__name__)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))

# logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
logging.basicConfig(stream=sys.stdout)
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/match_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from time import time
import sys

from six import string_types

from licensedcode.match import LicenseMatch
from licensedcode.spans import Span
Expand All @@ -46,7 +45,7 @@ def logger_debug(*args): pass
logger = logging.getLogger(__name__)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))

logging.basicConfig(stream=sys.stdout)
logger.setLevel(logging.DEBUG)
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/match_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from itertools import groupby

from intbitset import intbitset
from six import string_types

from commoncode.dict_utils import sparsify
from licensedcode.tokenize import ngrams
Expand Down Expand Up @@ -122,7 +121,7 @@ def logger_debug(*args): pass
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))


def tids_sets_intersector(qset, iset):
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/match_spdx_lid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from license_expression import LicenseSymbol
from license_expression import LicenseWithExceptionSymbol
from license_expression import Licensing
from six import string_types

from licensedcode.match import LicenseMatch
from licensedcode.models import SpdxRule
Expand Down Expand Up @@ -70,7 +69,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))


MATCH_SPDX_ID = '1-spdx-id'
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/plugin_license_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


import attr
from six import string_types

from plugincode.post_scan import PostScanPlugin
from plugincode.post_scan import post_scan_impl
Expand All @@ -42,7 +41,7 @@
logger = logging.getLogger(__name__)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))

logging.basicConfig(stream=sys.stdout)
logger.setLevel(logging.DEBUG)
Expand Down
3 changes: 1 addition & 2 deletions src/licensedcode/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import re

from intbitset import intbitset
from six import string_types

from commoncode.text import toascii
from licensedcode.spans import Span
Expand Down Expand Up @@ -102,7 +101,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))

# for the cases of very long lines, we break in abritrary pseudo lines at 25
# tokens to avoid getting huge query runs for texts on a single line (e.g.
Expand Down
3 changes: 1 addition & 2 deletions src/packagedcode/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import attr
import saneyaml
from six import string_types

from commoncode import filetype
from packagedcode import models
Expand Down Expand Up @@ -102,7 +101,7 @@ def build_package(package_data):
copyright_statement = package_data.get('copyright')

owner = package_data.get('owner')
if not isinstance(owner, string_types):
if not isinstance(owner, str):
owner = repr(owner)
parties = [models.Party(type=models.party_person, name=owner, role='owner')]

Expand Down
5 changes: 2 additions & 3 deletions src/packagedcode/bower.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import attr
from packageurl import PackageURL
from six import string_types

from commoncode import filetype
from commoncode import ignore
Expand Down Expand Up @@ -96,7 +95,7 @@ def build_package(package_data):
version = package_data.get('version')
declared_license = package_data.get('license')
if declared_license:
if isinstance(declared_license, string_types):
if isinstance(declared_license, str):
declared_license = [declared_license]
elif isinstance(declared_license, (list, tuple)):
declared_license = [l for l in declared_license if l and l.strip()]
Expand All @@ -115,7 +114,7 @@ def build_package(package_data):
url = author.get('homepage')
party = models.Party(name=name, role='author', email=email, url=url)
parties.append(party)
elif isinstance(author, string_types):
elif isinstance(author, str):
parties.append(models.Party(name=author, role='author'))
else:
parties.append(models.Party(name=repr(author), role='author'))
Expand Down
3 changes: 1 addition & 2 deletions src/packagedcode/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import sys

import attr
from six import string_types

from commoncode import filetype
from commoncode import fileutils
Expand Down Expand Up @@ -57,7 +56,7 @@ def logger_debug(*args):
logger.setLevel(logging.DEBUG)

def logger_debug(*args):
return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))


@attr.s()
Expand Down
Loading

0 comments on commit 11165a4

Please sign in to comment.