Skip to content
Merged
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
12 changes: 7 additions & 5 deletions src/deltacode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def determine_delta(self):
delta_old_files = old_index[path]
except KeyError:
delta = Delta(100, new_file, None)
delta.factors.append('added')
delta.status = 'added'
self.deltas.append(delta)
continue

Expand All @@ -116,12 +116,12 @@ def determine_delta(self):
# TODO: make sure sha1 is NOT empty
if new_file.sha1 == f.sha1:
delta = Delta(0, new_file, f)
delta.factors.append('unmodified')
delta.status = 'unmodified'
self.deltas.append(delta)
continue
else:
delta = Delta(20, new_file, f)
delta.factors.append('modified')
delta.status = 'modified'
self.deltas.append(delta)

# now time to find the added.
Expand All @@ -137,7 +137,7 @@ def determine_delta(self):
new_index[path]
except KeyError:
delta = Delta(0, None, old_file)
delta.factors.append('removed')
delta.status = 'removed'
self.deltas.append(delta)
continue

Expand Down Expand Up @@ -180,7 +180,7 @@ def update_deltas(self, added, removed):
creation -- and delete the 'added' and 'removed' objects.
"""
delta = Delta(0, added.new_file, removed.old_file)
delta.factors.append('moved')
delta.status = 'moved'
self.deltas.append(delta)
self.deltas.remove(added)
self.deltas.remove(removed)
Expand Down Expand Up @@ -252,6 +252,7 @@ def __init__(self, score=0, new_file=None, old_file=None):
self.old_file = old_file if old_file else None
self.factors = []
self.score = score
self.status = ''

def update(self, score=0, factor=''):
"""
Expand Down Expand Up @@ -305,6 +306,7 @@ def to_dict(self):
old_file = None

return OrderedDict([
('status', self.status),
('factors', self.factors),
('score', self.score),
('new', new_file),
Expand Down
186 changes: 5 additions & 181 deletions tests/data/deltacode/scan_sorted01_new.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"--license": true,
"--package": true
},
"files_count": 6,
"files_count": 5,
"files": [
{
"path": "sorted01_new",
Expand Down Expand Up @@ -38,33 +38,6 @@
"size_count": 1230,
"scan_errors": []
},
{
"path": "sorted01_new/a",
"type": "directory",
"name": "a",
"base_name": "a",
"extension": "",
"size": 0,
"date": null,
"sha1": null,
"md5": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
"is_binary": false,
"is_text": false,
"is_archive": false,
"is_media": false,
"is_source": false,
"is_script": false,
"licenses": [],
"copyrights": [],
"packages": [],
"files_count": 2,
"dirs_count": 0,
"size_count": 430,
"scan_errors": []
},
{
"path": "sorted01_new/a/a2.py",
"type": "file",
Expand All @@ -86,7 +59,7 @@
"is_script": false,
"licenses": [
{
"key": "apache-2.0",
"key": "apache-3.0",
Comment thread
steven-esser marked this conversation as resolved.
"score": 40.0,
"short_name": "Apache 2.0",
"category": "Permissive",
Expand Down Expand Up @@ -187,104 +160,16 @@
"size_count": 0,
"scan_errors": []
},
{
"path": "sorted01_new/b",
"type": "directory",
"name": "b",
"base_name": "b",
"extension": "",
"size": 0,
"date": null,
"sha1": null,
"md5": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
"is_binary": false,
"is_text": false,
"is_archive": false,
"is_media": false,
"is_source": false,
"is_script": false,
"licenses": [],
"copyrights": [],
"packages": [],
"files_count": 4,
"dirs_count": 0,
"size_count": 800,
"scan_errors": []
},
{
"path": "sorted01_new/b/a1.py",
"type": "file",
"name": "a1.py",
"base_name": "a1",
"extension": ".py",
"size": 200,
"date": "2017-09-26",
"sha1": "84b647771481d39dd3a53f6dc210c26abac37748",
"md5": "3cb56efa7140478458dbaa2b30239845",
"mime_type": "text/plain",
"file_type": "ASCII text, with CRLF line terminators",
"programming_language": "Python",
"is_binary": false,
"is_text": true,
"is_archive": false,
"is_media": false,
"is_source": true,
"is_script": false,
"licenses": [
{
"key": "apache-2.0",
"score": 40.0,
"short_name": "Apache 2.0",
"category": "Permissive",
"owner": "Apache Software Foundation",
"homepage_url": "http://www.apache.org/licenses/",
"text_url": "http://www.apache.org/licenses/LICENSE-2.0",
"reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0",
"spdx_license_key": "Apache-2.0",
"spdx_url": "https://spdx.org/licenses/Apache-2.0",
"start_line": 3,
"end_line": 3,
"matched_rule": {
"identifier": "apache-2.0_57.RULE",
"license_choice": false,
"licenses": [
"apache-2.0"
]
}
}
],
"copyrights": [
{
"statements": [
"Copyright (c) 2017 Acme Software Inc. and others."
],
"holders": [
"Acme Software Inc. and others."
],
"authors": [],
"start_line": 2,
"end_line": 2
}
],
"packages": [],
"files_count": 0,
"dirs_count": 0,
"size_count": 0,
"scan_errors": []
},
{
"path": "sorted01_new/b/b1.py",
"type": "file",
"name": "b1.py",
"base_name": "b1",
"extension": ".py",
"size": 200,
"size": 240,
"date": "2017-09-26",
"sha1": "70f6ce80985578b5104db0abc578cf5a05e78f4b",
"md5": "af9e9420c6c5b2b0ca74e96bf7c1a2f4",
"sha1": "70f6ce80843278b5104db0abc578cf5a05e78f4b",
"md5": "af9e9420c6c5b2c9ac74e96bf7c1a2f4",
"mime_type": "text/plain",
"file_type": "ASCII text, with CRLF line terminators",
"programming_language": "Python",
Expand Down Expand Up @@ -396,67 +281,6 @@
"dirs_count": 0,
"size_count": 0,
"scan_errors": []
},
{
"path": "sorted01_new/b/b3.py",
"type": "file",
"name": "b3.py",
"base_name": "b3",
"extension": ".py",
"size": 200,
"date": "2017-09-26",
"sha1": "e49d4463662414bee5ad2d2e5c1fbd704f33b84e",
"md5": "8d458f54d32959b03dff37ef485b29c6",
"mime_type": "text/plain",
"file_type": "ASCII text, with CRLF line terminators",
"programming_language": "Python",
"is_binary": false,
"is_text": true,
"is_archive": false,
"is_media": false,
"is_source": true,
"is_script": false,
"licenses": [
{
"key": "apache-2.0",
"score": 40.0,
"short_name": "Apache 2.0",
"category": "Permissive",
"owner": "Apache Software Foundation",
"homepage_url": "http://www.apache.org/licenses/",
"text_url": "http://www.apache.org/licenses/LICENSE-2.0",
"reference_url": "https://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0",
"spdx_license_key": "Apache-2.0",
"spdx_url": "https://spdx.org/licenses/Apache-2.0",
"start_line": 3,
"end_line": 3,
"matched_rule": {
"identifier": "apache-2.0_57.RULE",
"license_choice": false,
"licenses": [
"apache-2.0"
]
}
}
],
"copyrights": [
{
"statements": [
"Copyright (c) 2017 Acme Software Inc. and others."
],
"holders": [
"Acme Software Inc. and others."
],
"authors": [],
"start_line": 2,
"end_line": 2
}
],
"packages": [],
"files_count": 0,
"dirs_count": 0,
"size_count": 0,
"scan_errors": []
}
]
}
Loading