Skip to content

Commit d5119f6

Browse files
committed
Modify command name #41
* Change '-a/--all' to '-a/--all-delta-types'. * Add default of False to this parameter in 'write_csv()', 'write_json()' and 'utils.deltas()'. Signed-off-by: John M. Horan <johnmhoran@gmail.com>
1 parent 7309796 commit d5119f6

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/deltacode/cli.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040

4141
# FIXME: update the function argument delta to deltacode
42-
def write_csv(delta, result_file, all):
42+
def write_csv(delta, result_file, all_delta_types=False):
4343
"""
4444
Using the DeltaCode object, create a .csv file
4545
containing the primary information from the Delta objects. Omit all Delta
@@ -57,13 +57,13 @@ def write_csv(delta, result_file, all):
5757
f.old_file.size if f.category == 'removed' else f.new_file.size,
5858
f.old_file.path if f.category == 'moved' else '')
5959
for d in delta.deltas for f in delta.deltas.get(d)]:
60-
if all is True:
60+
if all_delta_types is True:
6161
csv_out.writerow(row)
6262
elif row[0] != 'unmodified':
6363
csv_out.writerow(row)
6464

6565

66-
def write_json(deltacode, outfile, all):
66+
def write_json(deltacode, outfile, all_delta_types=False):
6767
"""
6868
Using the DeltaCode object, create a .json file
6969
containing the primary information from the Delta objects. Omit all Delta
@@ -73,7 +73,7 @@ def write_json(deltacode, outfile, all):
7373
results = OrderedDict([
7474
('deltacode_version', __version__),
7575
('deltacode_stats', deltacode.get_stats()),
76-
('deltas', deltas(deltacode, all)),
76+
('deltas', deltas(deltacode, all_delta_types)),
7777
])
7878

7979
# TODO: add toggle for pretty printing
@@ -87,8 +87,8 @@ def write_json(deltacode, outfile, all):
8787
@click.option('-o', '--old', required=True, prompt=False, type=click.Path(exists=True, readable=True), help='Identify the path to the "old" scan file')
8888
@click.option('-c', '--csv-file', prompt=False, type=click.Path(exists=False), help='Identify the path to the .csv output file')
8989
@click.option('-j', '--json-file', prompt=False, default='-', type=click.File(mode='wb', lazy=False), help='Identify the path to the .json output file')
90-
@click.option('-a', '--all', is_flag=True, help="Include unmodified files as well as all changed files in the .json or .csv output. If not selected, only changed files are included.")
91-
def cli(new, old, csv_file, json_file, all):
90+
@click.option('-a', '--all-delta-types', is_flag=True, help="Include unmodified files as well as all changed files in the .json or .csv output. If not selected, only changed files are included.")
91+
def cli(new, old, csv_file, json_file, all_delta_types):
9292
"""
9393
Identify the changes that need to be made to the 'old'
9494
scan file (-o or -old) in order to generate the 'new' scan file (-n or
@@ -101,7 +101,7 @@ def cli(new, old, csv_file, json_file, all):
101101

102102
# output to csv
103103
if csv_file:
104-
write_csv(deltacode, csv_file, all)
104+
write_csv(deltacode, csv_file, all_delta_types)
105105
# generate JSON output
106106
else:
107-
write_json(deltacode, json_file, all)
107+
write_json(deltacode, json_file, all_delta_types)

src/deltacode/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
from commoncode import paths
3232

3333

34-
def deltas(deltacode, all):
34+
def deltas(deltacode, all_delta_types=False):
3535
"""
3636
Return a generator of Delta dictionaries for JSON serialized ouput. Omit
3737
all Delta objects whose 'category' is 'unmodified' unless the user selects
3838
the '-a'/'--all' option.
3939
"""
4040
for category, deltas in deltacode.deltas.iteritems():
4141
for delta in deltas:
42-
if all is True:
42+
if all_delta_types is True:
4343
yield delta.to_dict()
4444
elif delta.category != 'unmodified':
4545
yield delta.to_dict()

0 commit comments

Comments
 (0)