Skip to content

Improve source files downloading with local package detection#18

Closed
samastek wants to merge 3 commits intosw360:mainfrom
samastek:main
Closed

Improve source files downloading with local package detection#18
samastek wants to merge 3 commits intosw360:mainfrom
samastek:main

Conversation

@samastek
Copy link

The source download process now checks for locally available source packages.
If these are present, it adds a sourceFileComment indicating that the package exists locally.

@gernot-h
Copy link
Collaborator

I've seen you closed this MR, but I quickly reviewed it nevertheless to provide some hints. ;-)

Comment on lines +174 to +175
if os.path.exists(args.output_file):
os.remove(args.output_file)
Copy link
Collaborator

Choose a reason for hiding this comment

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

First of all, this might be a topic for a separate PR or issue. But in general, what's the goal of this change? I don't think silently overwriting an existing file is a good idea. Perhaps we want a better error message here to avoid a Traceback output?

or (MapBom.is_good_match(get_cdx(item, "MapResult"))
and get_cdx(item, "Sw360SourceFileCheck") != "passed")):
map_result = get_cdx(item, "MapResult")
is_missing_from_sw360 = map_result == MapResult.NO_MATCH
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get your idea to make this code more readable, but NO_MATCH doesn't necessarily mean it's missing, but only we didn't find it. So better use something like is_not_found or is_no_match 😉

pattern = f"{package_name}_{version}*"
matches = glob.glob(os.path.join(pkg_dir, pattern))
if matches:
set_cdx(item, "SourceFileComment", "sources locally available")
Copy link
Collaborator

Choose a reason for hiding this comment

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

The SourceFileComment is a description used in SW360 for the uploaded attachment. main() abuses it to understand if the source file exists, but it's not a flag.

@gernot-h
Copy link
Collaborator

In general, we should have some reasoning in the commit messages explaining the idea(s) of the change(s). As you already found out, the code is not really self explaining, neither are changes to it. ;-) But we probably better start with an issue to discuss a possible change and then you already have the necessary reasoning for the commit message when we've agreed. ;-)

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.

2 participants