Yash-Varshney / tools-python

A Python library to parse, validate and create SPDX documents.
http://spdx.org
Apache License 2.0
0 stars 0 forks source link

convertor: allow user to specify formats #8

Open zvr opened 4 years ago

zvr commented 4 years ago

besides automatic format discovery based on filename extensions, the user should be able to specify in and out formats with command-line options t, --to=, -f, --from

This would allow to call it like:

convert -from=yaml    oldyacmlfile.backup newfile.rdf

Refer to my previous email for more invocation examples.

Yash-Varshney commented 4 years ago

@zvr pls check the -f/-t use, I've just added in.

Yash-Varshney commented 4 years ago

also, I need an advice.. How to use from as an argument in a function because it is predefined in python. in the code, I need to replace frome to from

goneall commented 4 years ago

also, I need an advice.. How to use from as an argument in a function because it is predefined in python. in the code, I need to replace frome to from

@pombredanne - as a Python Person - could you help out Yash on his question related to reserved words?

pombredanne commented 4 years ago

also, I need an advice.. How to use from as an argument in a function because it is predefined in python. in the code, I need to replace frome to from

@Yash-Varshney can you elaborate with specifics and either a code snippet or a link?

pombredanne commented 4 years ago

Note that you cannot use keyword reserved names except as keywords. That's an axiom :) ... so no from and no for, if else, etc.

Yash-Varshney commented 4 years ago

@pombredanne the code snippet was something like this:

@click.option("--frome", "-f", type=click.Choice(["tag", "rdf"], case_sensitive=False))
def main(infile, outfile, src, frome, to):

I am using click module but was not able to use the term from. Thanks for helping and pointing out the axiom 👍

zvr commented 4 years ago
zvr commented 4 years ago

Actually I just checked and the click documentation has exactly the way to use --from in the option manual, under the comment

How to use a Python reserved word such as from as a parameter

https://click.palletsprojects.com/en/7.x/options/

Yash-Varshney commented 4 years ago

thanks @zvr. I think the motive of this issue is achieved, please look out the code.