Skip to content

Commit

Permalink
Refactored packaging to make the project more pythonic
Browse files Browse the repository at this point in the history
  • Loading branch information
klittlepage committed Feb 23, 2018
1 parent ec58a97 commit c90708d
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 43 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include schema/base_schema.json
include fire/schema/base_schema.json
7 changes: 7 additions & 0 deletions bin/fire-1099
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Main entrypoint
"""

from fire.translator import cli

cli()
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions entities/end_of_payer.py → fire/entities/end_of_payer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"""
from itertools import chain

from translator.util import rjust_zero
from translator.util import factor_transforms, xform_entity, fire_entity
from fire.translator.util import rjust_zero
from fire.translator.util import factor_transforms, xform_entity, fire_entity

"""
_END_OF_PAYER_TRANSFORMS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Representation of an "end_of_transmission" record, including transformation
functions and support functions for conversion into different formats.
"""
from translator.util import rjust_zero
from translator.util import factor_transforms, xform_entity, fire_entity
from fire.translator.util import rjust_zero
from fire.translator.util import factor_transforms, xform_entity, fire_entity

"""
_END_OF_TRANSMISSION_TRANSFORMS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Representation of a "extension_of_time" record, including transformation
functions and support functions for conversion into different formats.
"""
from translator.util import digits_only, uppercase
from translator.util import factor_transforms, xform_entity, fire_entity
from fire.translator.util import digits_only, uppercase
from fire.translator.util import factor_transforms, xform_entity, fire_entity

"""
EXTENSION_OF_TIME_TRANSFORMS
Expand Down
4 changes: 2 additions & 2 deletions entities/payees.py → fire/entities/payees.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"""
from itertools import chain

from translator.util import digits_only, uppercase, rjust_zero
from translator.util import factor_transforms, xform_entity, fire_entity
from fire.translator.util import digits_only, uppercase, rjust_zero
from fire.translator.util import factor_transforms, xform_entity, fire_entity
"""
_PAYEE_TRANSFORMS
-----------------------
Expand Down
4 changes: 2 additions & 2 deletions entities/payer.py → fire/entities/payer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Representation of a "payer" record, including transformation functions
and support functions for conversion into different formats.
"""
from translator.util import digits_only, uppercase, rjust_zero
from translator.util import factor_transforms, xform_entity, fire_entity
from fire.translator.util import digits_only, uppercase, rjust_zero
from fire.translator.util import factor_transforms, xform_entity, fire_entity

"""
_PAYER_TRANSFORMS
Expand Down
4 changes: 2 additions & 2 deletions entities/transmitter.py → fire/entities/transmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Representation of a "transmitter" record, including transformation functions
and support functions for conversion into different formats.
"""
from translator.util import digits_only, uppercase, rjust_zero
from translator.util import factor_transforms, xform_entity, fire_entity
from fire.translator.util import digits_only, uppercase, rjust_zero
from fire.translator.util import factor_transforms, xform_entity, fire_entity

"""
_TRANSMITTER_TRANSFORMS
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions fire/translator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Module entrypoint
"""

from .translator import cli
21 changes: 8 additions & 13 deletions translator/translator.py → fire/translator/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@
from jsonschema import validate
import click

from translator.util import SequenceGenerator
from entities import transmitter, payer, payees, end_of_payer, \
end_of_transmission
from fire.entities import transmitter, payer, payees, end_of_payer, \
end_of_transmission
from .util import SequenceGenerator

@click.command()
@click.argument('input_path', type=click.Path(exists=True))
@click.option('--output', type=click.Path())

@click.option('--output', type=click.Path(),
help='system path for the output to be generated')
def cli(input_path, output):
"""
Wrapper and entry point for command line interface.
Parameters
----------
input_path : str
system path for file containing the user input JSON data
output : str
optional system path for the output to be generated
Convert a JSON input file into the format required by IRS Publication 1220
\b
input_path: system path for file containing the user input JSON data
"""
run(input_path, output)

Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
packages=find_packages(exclude=['contrib', 'docs', 'tests*', 'spec*']),
include_package_data=True,
install_requires=['click', 'jsonschema'],
entry_points = '''
[console_scripts]
fire-1099 = translator.translator:cli
''',
scripts=['bin/fire-1099'],

classifiers=[
'Development Status :: 4 - Alpha',
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from jsonschema import validate
from nose.tools import raises

SCHEMA = json.load(open("./schema/base_schema.json"))
SCHEMA = json.load(open("./fire/schema/base_schema.json"))
VALID_ALL_PATH = "./spec/data/valid_all.json"
INVALID_PHONE_NUMS = ["+1 555 666 7777", "555 A44 B777", "123ABC5678",
"123 45 67", "555 666 777788", "555 666 7777 #"]
Expand Down
2 changes: 1 addition & 1 deletion spec/test_entity_payee.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
VALID_TINS, INVALID_TINS, VALID_ZIPS, INVALID_ZIPS, \
PAYEE_BLANK_MAP, VALID_DOLLAR_AMOUNTS, \
INVALID_DOLLAR_AMOUNTS
from entities import payees
from fire.entities import payees

VALID_PAYEE = []
VALID_PAYEE = VALID_ALL_DATA["payees"]
Expand Down
2 changes: 1 addition & 1 deletion spec/test_entity_payer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SCHEMA, PAYER_BLANK_MAP, VALID_ALL_DATA, \
VALID_PHONE_NUMS, VALID_ZIPS, INVALID_ZIPS, \
INVALID_PHONE_NUMS, VALID_TINS, INVALID_TINS
from entities import payer
from fire.entities import payer

VALID_PAYER = {}
VALID_PAYER["payer"] = VALID_ALL_DATA["payer"]
Expand Down
2 changes: 1 addition & 1 deletion spec/test_entity_transmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
VALID_PHONE_NUMS, VALID_ZIPS, INVALID_ZIPS, \
VALID_EMAILS, INVALID_EMAILS, INVALID_PHONE_NUMS, \
VALID_TINS, INVALID_TINS
from entities import transmitter
from fire.entities import transmitter

VALID_TRANSMITTER = {}
VALID_TRANSMITTER["transmitter"] = VALID_ALL_DATA["transmitter"]
Expand Down
2 changes: 1 addition & 1 deletion spec/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
END_OF_PAYER_BLANK_MAP, END_OF_TRANSMISSION_BLANK_MAP, \
TRANSMITTER_BLANK_MAP, VALID_ALL_DATA, \
VALID_ALL_PATH
from translator import translator
from fire.translator import translator

# Tests whether a correct input file generates a correct output file
# Tests whether an output file is defaulted if no path is given
Expand Down
8 changes: 0 additions & 8 deletions translator/__main__.py

This file was deleted.

0 comments on commit c90708d

Please sign in to comment.