fedora-python / pyp2rpm

Tool to convert a package from PyPI to RPM SPECFILE or to generate SRPM.
MIT License
125 stars 39 forks source link

Added handling of 'UNKNOWN' URL when package has no sources. #75

Closed frenzymadness closed 7 years ago

hroncok commented 7 years ago

Reference #70 in the commit message?

frenzymadness commented 7 years ago

Yes, I forget to mention related issue in commit message but I can close it manually after merge.

mcyprian commented 7 years ago

The only thing that is changed by this fix is that 'PACKAGE WITHOUT SOURCES' appears at the end of Traceback instead of 'UNKNOWN'. It is not possible to generate the spec file without package sources. I suggest writing error message to stderr instead of log and raising SystemExit in both cases - url is None or set to 'UNKNOWN'.

frenzymadness commented 7 years ago

Ok, I am gonna rearrange this part.

What is preferred way to print to stderr? I prefer to use print("error", file=sys.stderr) but this brings dependency on future module for Python2. Another possibility is to use only sys.stderr.write("error\n").

mcyprian commented 7 years ago

The second option is used in pyp2rpm's sources several times already, so keep it consistent please.

frenzymadness commented 7 years ago

I've made some changes as you suggested. Also, I created new parametrized test for testing exceptions in get_url function.