Skip to content

[Test]VirtualCodebase - #166

Closed
pratik0316 wants to merge 9 commits into
aboutcode-org:developfrom
pratik0316:VC
Closed

[Test]VirtualCodebase#166
pratik0316 wants to merge 9 commits into
aboutcode-org:developfrom
pratik0316:VC

Conversation

@pratik0316

Copy link
Copy Markdown
Collaborator

Signed-off-by: Pratik Dey pratikrocks.dey11@gmail.com

Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
…ths asserts

Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Comment thread src/deltacode/__init__.py
self.new_files = [] # a list of [[new file1:Original path],[new file2:Original Path],...]
self.old_files = [] # a list of [[old file1:Original path],[old file2:Original Path],...]
self.new_files_fingerprint = dict() # map of { {new_file1:fingerprint},{new_file2:fingerprint},...} it will be needed when we need the fingerprints
self.old_files_fingerprint = dict() # map of { {old_file1:fingerprint},{old_file2:fingerprint},...}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

used for preserving the fingerprints in a way such that <file_location : figerprint> it is a dictionary

Comment thread src/deltacode/__init__.py
self.old_files_fingerprint = dict() # map of { {old_file1:fingerprint},{old_file2:fingerprint},...}
self.new_files_original_path = dict() #this keeps a map of the path of file with respect to original path
self.old_files_original_path = dict()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

dictionary
to preserve the it is used later.

Comment thread src/deltacode/__init__.py

if self.codebase1 is not None and self.codebase2 is not None:
self.fetch_files(self.codebase1,self.new_files, self.new_files_fingerprint)
self.fetch_files(self.codebase2,self.old_files, self.old_files_fingerprint)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fetches old and new files

Comment thread src/deltacode/__init__.py
for i,obj in enumerate(resources):
files.append([obj,''])
try :
fingerprint[obj.path] = obj.fingerprint

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

stores the fingerprint which is used for similarity matchings

Comment thread src/deltacode/__init__.py
f[1] = f[0].path
for f in self.old_files:
f[1] = f[0].path

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fix the path as the second value in self.new_files

Comment thread src/deltacode/__init__.py

def to_dict(self):
def copyrights_to_dict(self,file):
"""

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copyright comparisons

Comment thread src/deltacode/utils.py
else:
delta.update(0, category.lower() + ' added')
return

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

changes as per the new design

Comment thread src/deltacode/utils.py
elif category not in unique_categories:
delta.update(0, category.lower() + ' added')

try:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

chages as per the new desing

Comment thread src/deltacode/utils.py
ratio = (value / total) * 100
return round(ratio, 2)
except ZeroDivisionError:
return 0

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We need to handle this exception as total may be zero in cases where the codebase is not generated in case of invalid paths.

Comment thread tests/test_cli.py

test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

# TODO: need to fix in scancode

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

cli/scan_1_file_moved_new.json is having fingerprint attribute so this test will fail as VirtualCodebase do not support fingerprint attribute

Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>

fixed tests for test_deltacode.py

Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
…ense_changes

Signed-off-by: Pratik Dey <pratikrocks.dey11@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant