@@ -10,24 +10,21 @@ def __init__(self, src_entry):
1010 self .src_entry = src_entry
1111 self .path = src_entry ['commentPath' ]
1212 elements = re .split (r"!|#|" + os .sep , self .path )
13- # self.elements = self.path.replace("!", os.sep).replace("#", os.sep).split(os.sep)
1413 self .elements = list (filter (None , elements ))
1514
1615 except KeyError :
1716 return
1817
1918 def search_component (self , compname_arr , compver ):
20- # logging.debug("")
21- # logging.debug(f"search_component() Checking Comp '{compname}/{compver}' - {self.path}:")
2219 # If component_version_reqd:
2320 # - folder matches compname and compver
2421 # - folder1 matches compname and folder2 matches compver
2522 # Else:
2623 # - folder matches compname
2724 # Returns:
28- # Bool1 - compname found
29- # Bool2 - version found
30- # Match_value - search result against both
25+ # - Bool1 - compname found
26+ # - Bool2 - version found
27+ # - Match_value - search result against both
3128
3229
3330 best_match_name = 0
@@ -39,96 +36,48 @@ def search_component(self, compname_arr, compver):
3936 # compstring = f"{cname} {compver}"
4037
4138 # test of path search
42- # newpath = self.path.replace(os.sep, " ")
4339 rep = f"[{ os .sep } !#]"
4440 newpath = re .sub (rep , ' ' , self .path ).lower ()
45- # comp_in_path = fuzz.token_set_ratio(compstring, newpath)
4641 compname_setratio = fuzz .token_set_ratio (cname , newpath )
47- compname_sortratio = fuzz .token_sort_ratio (cname , newpath )
48- compname_partialratio = fuzz .partial_ratio (cname , newpath )
49- compver_setratio = fuzz .token_set_ratio (compver , newpath )
50- compver_sortratio = fuzz .token_sort_ratio (compver , newpath )
42+ # compname_sortratio = fuzz.token_sort_ratio(cname, newpath)
43+ # compname_partialratio = fuzz.partial_ratio(cname, newpath)
44+ # compver_setratio = fuzz.token_set_ratio(compver, newpath)
45+ # compver_sortratio = fuzz.token_sort_ratio(compver, newpath)
5146 compver_partialratio = fuzz .partial_ratio (compver , newpath )
5247
5348 if compname_setratio + compver_partialratio > best_match_name + best_match_ver :
5449 best_match_name = compname_setratio
5550 best_match_ver = compver_partialratio
56- # match_path = self.path
5751 logging .debug (f"search_component(): TEST '{ cname } /{ compver } ' - { compname_setratio ,compver_partialratio } : path='{ self .path } " )
5852
5953 if best_match_name > 45 :
6054 name_bool = True
6155 if best_match_ver > 80 :
6256 ver_bool = True
6357 return name_bool , ver_bool , best_match_name + best_match_ver
64- # compstring = f"{compname} {compver}"
65- # element_in_compname = 0
66- # compver_in_element = 0
67- # found_compname_only = False
68- # for element in self.elements:
69- # pos = re.search(r"\.dll|\.obj|\.o|\.a|\.lib|\.iso|\.qcow2|\.vmdk|\.vdi|\.ova|\.nbi|\.vib|\.exe|\.img|"
70- # "\.bin|\.apk|\.aac|\.ipa|\.msi|\.zip|\.gz|\.tar|\.xz|\.lz|\.bz2|\.7z|\.rar|"
71- # "\.cpio|\.Z|\.lz4|\.lha|\.arj|\.jar|\.ear|\.war|\.rpm|\.deb|\.dmg|\.pki", element)
72- # if pos is not None:
73- # element = element[:pos.start()]
74- # # How much of the element string is from the compname and version?
75- # # - for example acl-1.3.0.jar
76- # # - Value of 100 indicates either compname or version exists in element
77- # element_in_compstring = fuzz.token_set_ratio(element, compstring)
78- # element_in_compname = fuzz.token_set_ratio(element, compname)
79- # compver_in_element = fuzz.token_set_ratio(compver, element)
80- #
81- # if element_in_compstring > 80:
82- # if compver_in_element > 50:
83- # # element has both compname and version
84- # logging.debug(f"search_component() - MATCHED component name & version ({compstring}) in '{element}'")
85- # return True, True, element_in_compname + compver_in_element
86- # elif element_in_compname > 50 and len(element) > 2:
87- # found_compname_only = True
88- # logging.debug(f"search_component() - FOUND component name ONLY ({compname}) in '{element}'")
89- # elif found_compname_only:
90- # if compver_in_element > 50:
91- # logging.debug(f"search_component() - MATCHED component version ({compver}) in '{element}'")
92- # return True, True, element_in_compname + compver_in_element
93- # else:
94- # test = 1
95- #
96- # if found_compname_only:
97- # logging.debug("search_component() - MATCHED Compname only")
98- # return True, False, element_in_compname + compver_in_element
99- #
100- # logging.debug(f"search_component() - NOT MATCHED")
10158
10259
10360 def filter_folders (self ):
10461 # Return True if path should be ignored + reason
10562 if not global_values .no_ignore_synopsys :
106- # syn_folders = ['.synopsys', 'synopsys-detect', '.coverity', 'synopsys-detect.jar',
107- # 'scan.cli.impl-standalone.jar', 'seeker-agent.tgz', 'seeker-agent.zip',
108- # 'Black_Duck_Scan_Installation']
109-
11063 syn_folders_re = (f"\\ { os .sep } (\.synopsys|synopsys-detect|\.coverity|synopsys-detect.*\.jar|scan\.cli\.impl-standalone\.jar|"
11164 f"seeker-agent.*|Black_Duck_Scan_Installation)\\ { os .sep } " )
11265 res = re .search (syn_folders_re , os .sep + self .path + os .sep )
11366 if res :
11467 return True , f"Found { res .group ()} folder in Signature match path '{ self .path } '"
11568
11669 if not global_values .no_ignore_defaults :
117- # def_folders = ['.cache', '.m2', '.local', '.cache','.config', '.docker', '.npm', '.npmrc', '.pyenv',
118- # '.Trash', '.git', 'node_modules']
11970 def_folders_re = (f"\\ { os .sep } (\.cache|\.m2|\.local|\.config|\.docker|\.npm|\.npmrc|"
12071 f"\.pyenv|\.Trash|\.git|node_modules)\\ { os .sep } " )
12172 res = re .search (def_folders_re , os .sep + self .path + os .sep )
12273 if res :
12374 return True , f"Found { res .group ()} folder in Signature match path '{ self .path } '"
12475
12576 if not global_values .no_ignore_test :
126- test_folders = f"\\ { os .sep } (test|tests|testsuite)\\ { os .sep } "
77+ test_folders = f"\\ { os .sep } (test|tests|testsuite|testsuites )\\ { os .sep } "
12778 res = re .search (test_folders , os .sep + self .path + os .sep , flags = re .IGNORECASE )
12879 if res :
12980 return True , f"Found { res .group ()} in Signature match path '{ self .path } '"
130- # if e in test_folders:
131- # return True, f"Found '{e}' in Signature match path '{self.path}'"
13281
13382 return False , ''
13483
0 commit comments