Skip to content

Commit 9abfcb4

Browse files
committed
Added the scaned options for the old and the new files
1 parent 6778882 commit 9abfcb4

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/deltacode/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ def __init__(self, new_path, old_path, options):
5151
self.new = Scan(new_path)
5252
self.old = Scan(old_path)
5353
self.options = options
54+
self.scannedOptions = dict({'--new':str(),'--old':str()})
5455
self.deltas = []
5556
self.errors = []
5657
self.stats = Stat(self.new.files_count, self.old.files_count)
5758

5859
if self.new.path != '' and self.old.path != '':
60+
self.scannedOptions['--new'] = self.new.get_scanned_options()
61+
self.scannedOptions['--old'] = self.old.get_scanned_options()
5962
self.determine_delta()
6063
self.determine_moved()
6164
self.license_diff()

src/deltacode/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def write_json(deltacode, outfile, all_delta_types=False):
4646
('deltacode_notice', get_notice()),
4747
('deltacode_options', deltacode.options),
4848
('deltacode_version', __version__),
49+
('scanned_options',deltacode.scannedOptions),
4950
('deltacode_errors', collect_errors(deltacode)),
5051
('deltas_count', len([d for d in deltas(deltacode, all_delta_types)])),
5152
('delta_stats', deltacode.stats.to_dict()),

src/deltacode/models.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, path=''):
4242
path = ''
4343

4444
self.errors = []
45-
45+
4646
if not self.is_valid_scan(path):
4747
self.path = ''
4848
self.files_count = 0
@@ -53,6 +53,30 @@ def __init__(self, path=''):
5353
self.files_count = self.get_files_count(path)
5454
self.files = self.load_files(path)
5555
self.options = self.get_options(path)
56+
57+
def get_scanned_options(self):
58+
try:
59+
scan = json.loads(open(self.path).read())
60+
except IOError:
61+
return
62+
scan = json.loads(open(self.path).read())
63+
scanned_options = []
64+
headers = scan.get('headers')
65+
if headers:
66+
headers = headers[0].get('options')
67+
has_copyright = headers.get('--copyright')
68+
has_license = headers.get('--license')
69+
has_info = headers.get('--info')
70+
has_package = headers.get('--package')
71+
if has_copyright:
72+
scanned_options.append('--copyright')
73+
if has_info:
74+
scanned_options.append('--info')
75+
if has_license:
76+
scanned_options.append('--license')
77+
if has_package:
78+
scanned_options.append('--package')
79+
return ' '.join(scanned_options)
5680

5781
def get_options(self, path):
5882
"""

0 commit comments

Comments
 (0)