# Path: spdx/parsers/builderexceptions.py
# class FileTypeError(BuilderException):
#     def __init__(self,msg):
#         self.msg = msg
# 
# Path: spdx/parsers/parse_anything.py
# def parse_file(fn):
#     buildermodule = jsonyamlxmlbuilders
#     read_data = False
#     if fn.endswith(".rdf") or fn.endswith(".rdf.xml"):
#         parsing_module = rdf
#         buildermodule = rdfbuilders
#     elif fn.endswith(".spdx"):
#         parsing_module = rdf
#         buildermodule = rdfbuilders
#     elif fn.endswith(".tag"):
#         parsing_module = tagvalue
#         buildermodule = tagvaluebuilders
#         read_data = True
#     elif fn.endswith(".json"):
#         parsing_module = jsonparser
#     elif fn.endswith(".xml"):
#         parsing_module = xmlparser
#     elif fn.endswith(".yaml") or fn.endswith(".yml"):
#         parsing_module = yamlparser
#     else:
#         raise FileTypeError("FileType Not Supported" + str(fn))
# 
#     p = parsing_module.Parser(buildermodule.Builder(), StandardLogger())
#     if hasattr(p, "build"):
#         p.build()
#     with open(fn) as f:
#         if read_data:
#             data = f.read()
#             return  p.parse(data)
#         else:
#             return  p.parse(f)
# 
# Path: spdx/writers/write_anything.py
# def write_file(doc, fn):
#     out_mode = "w"
#     if fn.endswith(".rdf") or fn.endswith(".rdf.xml") or fn.endswith(".spdx"):
#         writer_module = rdf
#         out_mode = "wb"
#     elif fn.endswith(".tag"):
#         writer_module = tagvalue
#     elif fn.endswith(".json"):
#         writer_module = json
#     elif fn.endswith(".xml"):
#         writer_module = xml
#     elif fn.endswith(".yaml"):
#         writer_module = yaml
#     else:
#         raise FileTypeError("FileType Not Supported")
# 
#     with open(fn, out_mode) as out:
#         p = writer_module.write_document(doc, out)


import os
import click
from spdx.parsers.builderexceptions import FileTypeError
from spdx.parsers.parse_anything import parse_file
from spdx.writers.write_anything import write_file
#!/usr/bin/env python

# Copyright (c) 2020 Yash Varshney
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#    http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



def print_help_msg(command):
    with click.Context(command) as ctx:
        click.echo(command.get_help(ctx))

@click.command()
@click.argument("src", nargs=-1)

# Path: spdx/parsers/builderexceptions.py
# class FileTypeError(BuilderException):
#     def __init__(self,msg):
#         self.msg = msg
# 
# Path: spdx/parsers/parse_anything.py
# def parse_file(fn):
#     buildermodule = jsonyamlxmlbuilders
#     read_data = False
#     if fn.endswith(".rdf") or fn.endswith(".rdf.xml"):
#         parsing_module = rdf
#         buildermodule = rdfbuilders
#     elif fn.endswith(".spdx"):
#         parsing_module = rdf
#         buildermodule = rdfbuilders
#     elif fn.endswith(".tag"):
#         parsing_module = tagvalue
#         buildermodule = tagvaluebuilders
#         read_data = True
#     elif fn.endswith(".json"):
#         parsing_module = jsonparser
#     elif fn.endswith(".xml"):
#         parsing_module = xmlparser
#     elif fn.endswith(".yaml") or fn.endswith(".yml"):
#         parsing_module = yamlparser
#     else:
#         raise FileTypeError("FileType Not Supported" + str(fn))
# 
#     p = parsing_module.Parser(buildermodule.Builder(), StandardLogger())
#     if hasattr(p, "build"):
#         p.build()
#     with open(fn) as f:
#         if read_data:
#             data = f.read()
#             return  p.parse(data)
#         else:
#             return  p.parse(f)
# 
# Path: spdx/writers/write_anything.py
# def write_file(doc, fn):
#     out_mode = "w"
#     if fn.endswith(".rdf") or fn.endswith(".rdf.xml") or fn.endswith(".spdx"):
#         writer_module = rdf
#         out_mode = "wb"
#     elif fn.endswith(".tag"):
#         writer_module = tagvalue
#     elif fn.endswith(".json"):
#         writer_module = json
#     elif fn.endswith(".xml"):
#         writer_module = xml
#     elif fn.endswith(".yaml"):
#         writer_module = yaml
#     else:
#         raise FileTypeError("FileType Not Supported")
# 
#     with open(fn, out_mode) as out:
#         p = writer_module.write_document(doc, out)


# Path: spdx/cli_tools/convertor.py
import os
import click
from spdx.parsers.builderexceptions import FileTypeError
from spdx.parsers.parse_anything import parse_file
from spdx.writers.write_anything import write_file

#!/usr/bin/env python

# Copyright (c) 2020 Yash Varshney
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#    http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



def print_help_msg(command):
    with click.Context(command) as ctx:
        click.echo(command.get_help(ctx))

@click.command()
@click.argument("src", nargs=-1)

@click.option("--infile", "-i", help="The file to be converted ")