Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unwanted files dependencies #176

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/deltacode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ def __init__(self, new_path, old_path, options):
self.deltas = []
self.errors = []

self._populate(new_path, old_path)

self.new_scan_options = []
self.old_scan_options = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget where we stand on this, but if the VirtualCodebase objects contain this information, I do not see the value of our DeltaCode object containing it as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VirtualCodebase is actually having all the resources but Delta objects will only contains only the respective deltas

self.determine_delta()
self.options_diff()
self.license_diff()
self.copyright_diff()
self.stats.calculate_stats()
self.similarity()
# Sort deltas by score, descending, i.e., high > low, and then by
# factors, alphabetically. Run the least significant sort first.
self.deltas.sort(key=lambda Delta: Delta.factors, reverse=False)
self.deltas.sort(key=lambda Delta: Delta.score, reverse=True)

def _populate(self, new_path, old_path):
if os.path.isfile(new_path) and os.path.isfile(old_path):
self.codebase1 = VirtualCodebase(new_path)
self.codebase2 = VirtualCodebase(old_path)
Expand All @@ -71,20 +87,6 @@ def __init__(self, new_path, old_path, options):
self.stats = Stat(
self.codebase1.compute_counts()[0], self.codebase2.compute_counts()[0]
)
self.new_scan_options = []
self.old_scan_options = []
self.new_files_errors = []
self.old_files_errors = []
self.determine_delta()
self.options_diff()
self.license_diff()
self.copyright_diff()
self.stats.calculate_stats()
self.similarity()
# Sort deltas by score, descending, i.e., high > low, and then by
# factors, alphabetically. Run the least significant sort first.
self.deltas.sort(key=lambda Delta: Delta.factors, reverse=False)
self.deltas.sort(key=lambda Delta: Delta.score, reverse=True)

def similarity(self):
"""
Expand Down
3 changes: 1 addition & 2 deletions src/deltacode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from deltacode import DeltaCode
from deltacode import __version__
from deltacode.utils import deltas, get_notice, collect_errors
from deltacode.utils import deltas, get_notice


def write_json(deltacode, outfile, all_delta_types=False):
Expand All @@ -48,7 +48,6 @@ def write_json(deltacode, outfile, all_delta_types=False):
# ('old_scan_options', deltacode.old_scan_options),
('deltacode_options', deltacode.options),
('deltacode_version', __version__),
('deltacode_errors', collect_errors(deltacode)),
('deltas_count', len([d for d in deltas(deltacode, all_delta_types)])),
('delta_stats', deltacode.stats.to_dict()),
('deltas', deltas(deltacode, all_delta_types))
Expand Down
314 changes: 0 additions & 314 deletions src/deltacode/models.py

This file was deleted.

1 change: 0 additions & 1 deletion src/deltacode/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,3 @@ def streamline_headers(headers):
"""
headers.pop('deltacode_version', None)
headers.pop('deltacode_options', None)
streamline_errors(headers['deltacode_errors'])
10 changes: 0 additions & 10 deletions src/deltacode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,6 @@ def update_modified_from_copyright_info(delta):
if new_holders != old_holders:
delta.update(5, "copyright change")


def collect_errors(deltacode):
errors = []
errors.extend(deltacode.new_files_errors)
errors.extend(deltacode.old_files_errors)
errors.extend(deltacode.errors)

return errors


def deltas(deltacode, all_delta_types=False):
"""
Return a generator of Delta dictionaries for JSON serialized ouput. Omit
Expand Down
Loading