@@ -172,7 +172,7 @@ def process_codebase(self, codebase, classify, **kwargs):
172172 has_package_data = hasattr (codebase .root , 'package_data' )
173173 if not has_package_data :
174174 # FIXME: this is not correct... we may still have cases where this
175- # is wrong: e.g. a META-INF directory and we may not have a package
175+ # is wrong: e.g. a META-INF directory and we may not have a package
176176 return
177177
178178
@@ -286,7 +286,7 @@ def process_codebase(self, codebase, classify, **kwargs):
286286 '/setup.cfg' : 'pypi' ,
287287 '/setup.py' : 'pypi' ,
288288 '/PKG-INFO' : 'pypi' ,
289- '/pyproject.toml' : 'pypi' ,
289+ '/pyproject.toml' : 'pypi' ,
290290 '.spec' : 'rpm' ,
291291 '/cargo.toml' : 'rust' ,
292292 '.spdx' : 'spdx' ,
@@ -310,18 +310,32 @@ def process_codebase(self, codebase, classify, **kwargs):
310310)
311311
312312
313+ def check_resource_name_start_and_end (resource , STARTS_ENDS ):
314+ """
315+ Return True if `resource.name` or `resource.base_name` begins or ends with
316+ an element of `STARTS_ENDS`
317+ """
318+ name = resource .name .lower ()
319+ base_name = resource .base_name .lower ()
320+ return (
321+ name .startswith (STARTS_ENDS )
322+ or name .endswith (STARTS_ENDS )
323+ or base_name .startswith (STARTS_ENDS )
324+ or base_name .endswith (STARTS_ENDS )
325+ )
326+
327+
313328def set_classification_flags (resource ,
314329 _LEGAL = LEGAL_STARTS_ENDS ,
315330 _MANIF = MANIFEST_ENDS ,
316331 _README = README_STARTS_ENDS ):
317332 """
318333 Set classification flags on the `resource` Resource
319334 """
320- name = resource .name .lower ()
321335 path = resource .path .lower ()
322336
323- resource .is_legal = is_legal = name . startswith ( _LEGAL ) or name . endswith ( _LEGAL )
324- resource .is_readme = is_readme = name . startswith ( _README ) or name . endswith ( _README )
337+ resource .is_legal = is_legal = check_resource_name_start_and_end ( resource , _LEGAL )
338+ resource .is_readme = is_readme = check_resource_name_start_and_end ( resource , _README )
325339 resource .is_manifest = is_manifest = path .endswith (_MANIF )
326340 resource .is_key_file = (resource .is_top_level
327341 and (is_readme or is_legal or is_manifest ))
0 commit comments