diff --git a/cwr/grammar/factory/adapter.py b/cwr/grammar/factory/adapter.py index 8fef85e..9870e66 100644 --- a/cwr/grammar/factory/adapter.py +++ b/cwr/grammar/factory/adapter.py @@ -25,7 +25,7 @@ __status__ = 'Development' -class FieldAdapter(object): +class FieldAdapter(object, metaclass=ABCMeta): """ Interface for adapting field rules creation to the parser factory requirements. @@ -34,7 +34,6 @@ class FieldAdapter(object): and then generate a specific field rule from them. """ - __metaclass__ = ABCMeta def __init__(self): pass diff --git a/cwr/grammar/factory/decorator.py b/cwr/grammar/factory/decorator.py index eefc4ff..d7b339c 100644 --- a/cwr/grammar/factory/decorator.py +++ b/cwr/grammar/factory/decorator.py @@ -21,9 +21,7 @@ __status__ = 'Development' -class RuleDecorator(object): - __metaclass__ = ABCMeta - +class RuleDecorator(object, metaclass=ABCMeta): def __init__(self): pass diff --git a/cwr/grammar/factory/rule.py b/cwr/grammar/factory/rule.py index ba6a7ea..8b65d30 100644 --- a/cwr/grammar/factory/rule.py +++ b/cwr/grammar/factory/rule.py @@ -15,9 +15,7 @@ __status__ = 'Development' -class RuleFactory(object): - __metaclass__ = ABCMeta - +class RuleFactory(object, metaclass=ABCMeta): def __init__(self): pass diff --git a/cwr/interested_party.py b/cwr/interested_party.py index a3a61d2..bea1e84 100644 --- a/cwr/interested_party.py +++ b/cwr/interested_party.py @@ -12,11 +12,10 @@ __status__ = 'Development' -class InterestedParty(object): +class InterestedParty(object, metaclass=ABCMeta): """ Represents a CWR interested party. """ - __metaclass__ = ABCMeta def __init__(self, ip_n='', @@ -105,13 +104,12 @@ def tax_id(self, value): self._tax_id = value -class InterestedPartyRecord(TransactionRecord): +class InterestedPartyRecord(TransactionRecord, metaclass=ABCMeta): """ Represents a CWR Interested Party Record. This is meant to be used for Publisher and Writer records. """ - __metaclass__ = ABCMeta def __init__(self, record_type='', diff --git a/cwr/non_roman_alphabet.py b/cwr/non_roman_alphabet.py index 1a333fa..3953fd3 100644 --- a/cwr/non_roman_alphabet.py +++ b/cwr/non_roman_alphabet.py @@ -12,13 +12,12 @@ __status__ = 'Development' -class NonRomanAlphabetRecord(TransactionRecord): +class NonRomanAlphabetRecord(TransactionRecord, metaclass=ABCMeta): """ Represents a CWR Non-Roman Alphabet record. These are the records to represent alternate names out of the ASCII table. """ - __metaclass__ = ABCMeta def __init__(self, record_type='', diff --git a/cwr/parser/decoder/common.py b/cwr/parser/decoder/common.py index 5657bb2..2b04f34 100644 --- a/cwr/parser/decoder/common.py +++ b/cwr/parser/decoder/common.py @@ -28,12 +28,11 @@ __status__ = 'Development' -class Decoder(object): +class Decoder(object, metaclass=ABCMeta): """ Interface for implementing decoder parsers. These parser receive a data structure and return an instance of a class from the domain model. """ - __metaclass__ = ABCMeta def __init__(self): pass diff --git a/cwr/parser/decoder/file.py b/cwr/parser/decoder/file.py index f2903e7..daa2535 100644 --- a/cwr/parser/decoder/file.py +++ b/cwr/parser/decoder/file.py @@ -170,7 +170,7 @@ def default_grammar_factory(): field_values = CWRTables() - for entry in data.values(): + for entry in list(data.values()): if 'source' in entry: values_id = entry['source'] entry['values'] = field_values.get_data(values_id) @@ -206,7 +206,7 @@ def default_filename_grammar_factory(): data = config.load_field_config('filename') field_values = CWRTables() - for entry in data.values(): + for entry in list(data.values()): if 'source' in entry: values_id = entry['source'] entry['values'] = field_values.get_data(values_id) diff --git a/cwr/parser/encoder/common.py b/cwr/parser/encoder/common.py index 1cfbe82..0c789e5 100644 --- a/cwr/parser/encoder/common.py +++ b/cwr/parser/encoder/common.py @@ -20,12 +20,11 @@ __status__ = 'Development' -class Encoder(object): +class Encoder(object, metaclass=ABCMeta): """ Interface for implementing encoder parsers. These parser receive a class from the domain model and return a data structure. """ - __metaclass__ = ABCMeta def __init__(self): pass diff --git a/cwr/record.py b/cwr/record.py index 4d0dcbb..418d175 100644 --- a/cwr/record.py +++ b/cwr/record.py @@ -66,7 +66,7 @@ def record_type(self, value): self._record_type = value -class TransactionRecord(Record): +class TransactionRecord(Record, metaclass=ABCMeta): """ Represents a CWR Transaction Record. @@ -89,7 +89,6 @@ class TransactionRecord(Record): the one of the previous paragraph), and that it is the 3th (starting with 1) detail on the file. """ - __metaclass__ = ABCMeta def __init__(self, record_type='', diff --git a/cwr/work.py b/cwr/work.py index 377a88f..e9b89ea 100644 --- a/cwr/work.py +++ b/cwr/work.py @@ -51,7 +51,7 @@ __status__ = 'Development' -class BaseWorkRecord(TransactionRecord): +class BaseWorkRecord(TransactionRecord, metaclass=ABCMeta): """ Abstract class representing a Work's basic information. @@ -62,7 +62,6 @@ class BaseWorkRecord(TransactionRecord): This is meant to store the data which identifies a work in a generic way, which are the title, the language and the ISWC. """ - __metaclass__ = ABCMeta def __init__(self, record_type='', diff --git a/tests/grammar/factory/test_default_rule_factory_stress.py b/tests/grammar/factory/test_default_rule_factory_stress.py index 5949475..730844b 100644 --- a/tests/grammar/factory/test_default_rule_factory_stress.py +++ b/tests/grammar/factory/test_default_rule_factory_stress.py @@ -23,7 +23,7 @@ def test_10(self): record = '' if sys.version_info[0] == 2: - for x in xrange(35): + for x in range(35): if len(record) == 0: record = _agreement_full() elif len(record) > 0: diff --git a/tests/grammar/factory/test_default_rule_factory_times.py b/tests/grammar/factory/test_default_rule_factory_times.py index 443702e..c07bfe1 100644 --- a/tests/grammar/factory/test_default_rule_factory_times.py +++ b/tests/grammar/factory/test_default_rule_factory_times.py @@ -21,7 +21,7 @@ def setUp(self): def test_10000(self): start = time.clock() if sys.version_info[0] == 2: - for x in xrange(10000): + for x in range(10000): self._factory.get_rule('transmission') else: for x in range(10000): diff --git a/tests/grammar/factory/test_field_factory_times.py b/tests/grammar/factory/test_field_factory_times.py index 2ef6235..9b526bf 100644 --- a/tests/grammar/factory/test_field_factory_times.py +++ b/tests/grammar/factory/test_field_factory_times.py @@ -32,7 +32,7 @@ def setUp(self): def test_10000(self): start = time.clock() if sys.version_info[0] == 2: - for x in xrange(10000): + for x in range(10000): self._factory.get_rule('test_field') else: for x in range(10000): diff --git a/tests/visual/file_contents.py b/tests/visual/file_contents.py index 48525db..5160b92 100644 --- a/tests/visual/file_contents.py +++ b/tests/visual/file_contents.py @@ -21,11 +21,11 @@ if __name__ == '__main__': print('File contents parsing test') - path = raw_input( + path = input( 'Please enter the full path to a CWR file (e.g. c:/documents/file.cwr): ') - output = raw_input( + output = input( 'Please enter the full path to the file where the results will be stored: ') - log = raw_input( + log = input( 'Please enter the full path to the file where parsing log will be saved: ') print('\n') print('Reading file %s' % path) diff --git a/tests/visual/file_json.py b/tests/visual/file_json.py index 584731c..f9f44c8 100644 --- a/tests/visual/file_json.py +++ b/tests/visual/file_json.py @@ -20,9 +20,9 @@ if __name__ == '__main__': print('File to JSON test') - path = raw_input( + path = input( 'Please enter the full path to a CWR file (e.g. c:/documents/file.cwr): ') - output = raw_input( + output = input( 'Please enter the full path to the file where the results will be stored: ') print('\n') print('Reading file %s' % path)