Skip to content

Commit

Permalink
Fix bug for not working options(-n, i)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjk7119 committed Oct 24, 2022
1 parent 2950546 commit 32c53bb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ It uses [reuse-tool][ret] to check whether the [source code's copyright and lice
Please see the [**User Guide**](https://fosslight.org/fosslight-guide-en/scanner/1_prechecker.html) for more information on how to install and run it.
Here a short summary:

- `lint` --- Check whether the [source code's copyright and license writing rules][rule] are complied with.
- `lint` --- (Default) Check whether the [source code's copyright and license writing rules][rule] are complied with.

- `convert` --- Convert [sbom-info.yaml](https://github.com/fosslight/fosslight_prechecker/blob/main/tests/convert/sbom-info.yaml) or [oss-pkg-info.yaml](https://github.com/fosslight/fosslight_prechecker/blob/main/tests/convert/oss-pkg-info.yaml) to [fosslight_report.xlsx](https://fosslight.org/fosslight-guide-en/learn/2_fosslight_report.html).

Expand Down
1 change: 1 addition & 0 deletions src/fosslight_prechecker/_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (c) 2022 LG Electronics Inc.
# SPDX-License-Identifier: GPL-3.0-only

PKG_NAME = "fosslight_prechecker"
DEFAULT_EXCLUDE_EXTENSION = ["jar", "png", "exe", "so", "a", "dll", "jpeg", "jpg", "ttf", "lib", "ttc", "pfb",
"pfm", "otf", "afm", "dfont", "json"]
OSS_PKG_INFO_FILES = [r"oss-pkg-info[\s\S]*.ya?ml", r"oss-package[\s\S]*.info", r"sbom-info[\s\S]*.ya?ml",
Expand Down
2 changes: 1 addition & 1 deletion src/fosslight_prechecker/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Parameters:
Mode
lint\t\t Check whether the copyright and license writing rules are complied with
lint\t\t (Default) Check whether the copyright and license writing rules are complied with
convert\t\t Convert sbom_info.yaml -> FOSSLight-Report.xlsx
add\t\t\t Add missing license and copyright
Expand Down
3 changes: 1 addition & 2 deletions src/fosslight_prechecker/_precheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
from reuse.project import Project
from reuse.report import ProjectReport
from fosslight_prechecker._result import write_result_file, create_result_file, result_for_summary, ResultItem
from fosslight_prechecker._constant import DEFAULT_EXCLUDE_EXTENSION, OSS_PKG_INFO_FILES
from fosslight_prechecker._constant import DEFAULT_EXCLUDE_EXTENSION, OSS_PKG_INFO_FILES, PKG_NAME

is_windows = platform.system() == 'Windows'
PKG_NAME = "fosslight_prechecker"
REUSE_CONFIG_FILE = ".reuse/dep5"
DEFAULT_EXCLUDE_EXTENSION_FILES = [] # Exclude files from reuse
_turn_on_default_reuse_config = True
Expand Down
38 changes: 21 additions & 17 deletions src/fosslight_prechecker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
import sys
import os
from fosslight_util.help import print_package_version
from fosslight_prechecker._help import print_help_msg
from fosslight_prechecker._precheck import run_lint, PKG_NAME
from fosslight_oss_pkg._convert import convert_report
from fosslight_prechecker._help import print_help_msg
from fosslight_prechecker._constant import PKG_NAME
from fosslight_prechecker._add import add_content
from fosslight_prechecker._precheck import run_lint


def run_main(mode, path, output, format, no_log, disable, copyright, license):
if mode == "lint":
run_lint(path, disable, output, format, no_log)
elif mode == "add":
add_content(path, license, copyright, output, no_log)
elif mode == "convert":
convert_report(path, output, format, no_log)
else:
print("Not supported mode. Select one of 'lint', 'add', or 'convert'")


def main():
parser = argparse.ArgumentParser(description='FOSSLight Prechecker', prog='fosslight_prechecker', add_help=False)
parser.add_argument('mode', nargs='?', help='lint | convert | add', choices=['lint', 'add', 'convert'])
parser.add_argument('mode', nargs='?', help='lint(default) | convert | add', choices=['lint', 'add', 'convert'], default='lint')
parser.add_argument('-h', '--help', help='Print help message', action='store_true', dest='help')
parser.add_argument('-i', '--ignore', help='Do not write log to file', action='store_false', dest='log')
parser.add_argument('-v', '--version', help='Print FOSSLight Prechecker version', action='store_true', dest='version')
Expand All @@ -29,24 +41,16 @@ def main():
except SystemExit:
sys.exit(0)

if args.help:
print_help_msg()

if args.version:
print_package_version(PKG_NAME, "FOSSLight Prechecker Version")
sys.exit(0)

if not args.path:
args.path = os.getcwd()

if args.mode == "lint":
run_lint(args.path, args.disable, args.output, args.format, args.log)
elif args.mode == "convert":
convert_report(args.path, args.output, args.format, args.log)
elif args.mode == "add":
add_content(args.path, args.license, args.copyright, args.output, args.log)
else:
if args.help:
print_help_msg()
elif args.version:
print_package_version(PKG_NAME, "FOSSLight Prechecker Version")
else:
run_main(args.mode, args.path, args.output, args.format,
args.log, args.disable, args.copyright, args.license)


if __name__ == "__main__":
Expand Down

0 comments on commit 32c53bb

Please sign in to comment.