Skip to content

Commit

Permalink
Merge pull request #173 from Python3pkg/master
Browse files Browse the repository at this point in the history
Convert to Python3
  • Loading branch information
Bernardo-MG authored May 21, 2017
2 parents f759e88 + a0dc831 commit c21b8a2
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 32 deletions.
3 changes: 1 addition & 2 deletions cwr/grammar/factory/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -34,7 +34,6 @@ class FieldAdapter(object):
and then generate a specific field rule
from them.
"""
__metaclass__ = ABCMeta

def __init__(self):
pass
Expand Down
4 changes: 1 addition & 3 deletions cwr/grammar/factory/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
__status__ = 'Development'


class RuleDecorator(object):
__metaclass__ = ABCMeta

class RuleDecorator(object, metaclass=ABCMeta):
def __init__(self):
pass

Expand Down
4 changes: 1 addition & 3 deletions cwr/grammar/factory/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
__status__ = 'Development'


class RuleFactory(object):
__metaclass__ = ABCMeta

class RuleFactory(object, metaclass=ABCMeta):
def __init__(self):
pass

Expand Down
6 changes: 2 additions & 4 deletions cwr/interested_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='',
Expand Down Expand Up @@ -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='',
Expand Down
3 changes: 1 addition & 2 deletions cwr/non_roman_alphabet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='',
Expand Down
3 changes: 1 addition & 2 deletions cwr/parser/decoder/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cwr/parser/decoder/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cwr/parser/encoder/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cwr/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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='',
Expand Down
3 changes: 1 addition & 2 deletions cwr/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
__status__ = 'Development'


class BaseWorkRecord(TransactionRecord):
class BaseWorkRecord(TransactionRecord, metaclass=ABCMeta):
"""
Abstract class representing a Work's basic information.
Expand All @@ -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='',
Expand Down
2 changes: 1 addition & 1 deletion tests/grammar/factory/test_default_rule_factory_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/grammar/factory/test_default_rule_factory_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/grammar/factory/test_field_factory_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/visual/file_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/visual/file_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c21b8a2

Please sign in to comment.