[WIP]integrated with Virtualcodebase of scancode(First Approach) - #151
[WIP]integrated with Virtualcodebase of scancode(First Approach)#151pratik0316 wants to merge 18 commits into
Conversation
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
969e868 to
17778de
Compare
…re_no_lic_change and test_Delta_one_None Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
d428273 to
d64de2b
Compare
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
76141f6 to
60b3017
Compare
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
0cb65bb to
e40fda3
Compare
| except : | ||
| pass |
There was a problem hiding this comment.
We want to handle the exception properly
There was a problem hiding this comment.
@MaJuRG okay.
The exceptions were raised when we are getting some invalid sacn paths , and when we counter some some attributes like "fiingerprint" which VirtualCodebase is not supporting
| self.new_files_count = 0 #keeps the count of the new file | ||
| self.old_files_count = 0 #keeps the count of old files | ||
| 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},...} |
There was a problem hiding this comment.
What is all this stuff and why is it needed?
There was a problem hiding this comment.
self.new_files_count and self.old_files_count is to keep the track of the new files ,and old files.
I have added this to make the computation of the statistics easier,otherwise we would have to enumerate the virtual codebase objects to get the cont every time.
self.new_files_fingerprint and self.old_files_fingerprint it keeps a mapping of Resource objects files path from codebase1 and codebase2 with respect to the fingerprints which would be used in similarity comparisons.
There was a problem hiding this comment.
@MaJuRG self.new_files and self.old_files it is list of lists comprising of [Resource objects,with their original path] ,Now we need to keep the track of the original path in the align_scans for alignment of the files.
There was a problem hiding this comment.
Its fine to enumerate on the Virtualcodebase. Stats should be calculated in the end anyway, and optionally for the user. I hate having carrying around all these unneeded fields.
There was a problem hiding this comment.
Also, codebase objects have counts already that we can use. There is no need to track this twice.
There was a problem hiding this comment.
@MaJuRG , yes we can get rid of this self.new_files_count and self.old_files_count as they are already present in codebase objects as it is present in the headers of the codebase objects, but for the old files and new files and the fingerprint, I think it is better to have the enumeration done one time and cache those files in an array, else we will again need to enumerate it whenever required.
There was a problem hiding this comment.
@MaJuRG used the counts from the codebase , removed the additional variables for the files_count
…and non similarity matching Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
760640b to
7e78c28
Compare
|
@MaJuRG the test cases like (similarity matching1 and similarity matching2 ,non similarity matching1 ) are passing, the output in json file is appearing as expected. as they are treating the old and new file as File objects and we are using the ScannedResources object for the old and the file.So should I modify test case like this? |
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
be8fc7a to
1b639c6
Compare
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
99a0393 to
03c8d15
Compare
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
ffe2a3e to
c6079d1
Compare
steven-esser
left a comment
There was a problem hiding this comment.
There is a lot to be done here before it can be considered for merging.
| except Exception as exception: | ||
| click.secho(exception.message ,fg = "red") |
There was a problem hiding this comment.
What exact exceptions can occur here?
There was a problem hiding this comment.
@MaJuRG , the error faced here are following two types:
1.When the paths of the json files for the are not valid.
2.When the VirtualCode base gets an unnecessary fields during the scanning .
However the 2nd error could be resolved if we use scancode versionn3 during the scanning of the json files.
| self.new_files_count = 0 #keeps the count of the new file | ||
| self.old_files_count = 0 #keeps the count of old files | ||
| 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},...} |
There was a problem hiding this comment.
Its fine to enumerate on the Virtualcodebase. Stats should be calculated in the end anyway, and optionally for the user. I hate having carrying around all these unneeded fields.
|
|
||
| if self.new.path != '' and self.old.path != '': | ||
|
|
||
| if self.codebase1 != None and self.codebase2 != None: |
There was a problem hiding this comment.
Can we just have a check for the inverse of this so we dont write everything under an unneeded indentation?
There was a problem hiding this comment.
@MaJuRG yeah , trying for it , I think it would be a better approach
| try : | ||
| self.new_files_fingerprint[obj.path] = obj.fingerprint | ||
| except AttributeError: | ||
| self.new_files_fingerprint[obj.path] = None | ||
| if obj.is_file: | ||
| # increment the new files count | ||
| self.new_files_count += 1 |
There was a problem hiding this comment.
Why not use dict.get() method instead of catching exception?
There was a problem hiding this comment.
@MaJuRG , the dict.get() method can not be used here as obj is not a dictionary it is a Virtualcodebase object.
| def enumerate_files_from_codebases(self): | ||
| """ | ||
| An method which call the utility function get_files for generating the codebase | ||
| """ | ||
| self.get_files(self.codebase1,is_new = True) | ||
| self.get_files(self.codebase2,is_new = False) |
There was a problem hiding this comment.
This function's name is unrelated to what it actually does.
There was a problem hiding this comment.
@MaJuRG , I think interchanging the function names get_files and enumerate_files_from_codebases would better match with the situation
There was a problem hiding this comment.
changed the function name
| self.new_files_count = 0 #keeps the count of the new file | ||
| self.old_files_count = 0 #keeps the count of old files | ||
| 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},...} |
There was a problem hiding this comment.
Also, codebase objects have counts already that we can use. There is no need to track this twice.
| all_licenses.append(d) | ||
| return all_licenses | ||
|
|
||
| def new_file_to_dict(self,deltacode): |
There was a problem hiding this comment.
Why is this not a method of the File class?
There was a problem hiding this comment.
@MaJuRG , I will be moving all these methods(license and copyright) to the file class
| ]) | ||
|
|
||
|
|
||
| def old_file_to_dict(self,deltacode): |
There was a problem hiding this comment.
Why are we repeating this function?
There was a problem hiding this comment.
@MaJuRG , I will be truncating this unnecessary functions.
There was a problem hiding this comment.
combined redundant functions def old_file_to_dict(self,deltacode) and def new_file_to_dict(self,deltacode) , to a single function.
|
Thanks @MaJuRG for the review , I will be making the suggested changes ASAP :) |
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
830154f to
709ceee
Compare
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
d8fc89c to
edc0638
Compare
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
|
|
||
|
|
||
| def fetch_files(location): | ||
| codebase = VirtualCodebase(location) |
There was a problem hiding this comment.
This function has been extensively added to test_utils so as to prevent the creation of deltacode object for the test cases when only the Resource files are required
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
…te one Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
|
Closing for now due to stagnation. |
|
I was willing to continue this , due to lack of input I discontinued for a moment , anyway if it's anymore required I will work on it :) |
|
@Pratikrocks Yes this may have fallen through the cracks, sorry about this lack of feedback. The deltacode repo has been updated since this PR was made with a number of configuration changes. If you can, please rebase your branch, or add your changes to a new branch off of the current develop |
In this PR I integrated the virtualcodebases of Scancode to the Deltacode.