Skip to content

Commit

Permalink
Merge pull request #143 from nokia/fix-none-warning
Browse files Browse the repository at this point in the history
Fixing bugs
  • Loading branch information
vargenau authored Jan 8, 2025
2 parents d3f79ae + d55f66a commit 50ac30d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,47 @@
logger.propagate = True

def main():
args = parseArguments()

logLevel = ""
if args.debug:
logLevel = logging.DEBUG
logger.debug("Debug logging is ON")
else:
logLevel = logging.INFO

logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(message)s',
level=logLevel,
handlers=[
logging.FileHandler("log.log"), # Write logs to a file
logging.StreamHandler()
])

if args.version:
reportVersion()
sys.exit(0)

logger.debug("Start parsing.")

filePath = str(args.input)
validator = Validator()
try:
args = parseArguments()

reference_logic = args.reference_logic
if None == reference_logic:
reference_logic = "none"
result, problems = validator.validate(filePath,
args.strict_purl_check,
args.strict_url_check,
referringLogic=args.reference_logic)

exitCode = reportCli(result, problems, args.nr_of_errors, args.input)
sys.exit(exitCode)
logLevel = ""
if args.debug:
logLevel = logging.DEBUG
logger.debug("Debug logging is ON")
else:
logLevel = logging.INFO

logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(message)s',
level=logLevel,
handlers=[
logging.FileHandler("log.log"), # Write logs to a file
logging.StreamHandler()
])

if args.version:
reportVersion()
sys.exit(0)

logger.debug("Start parsing.")

filePath = str(args.input)
validator = Validator()

reference_logic = args.reference_logic
if None == args.reference_logic:
reference_logic = "none"

result, problems = validator.validate(filePath,
args.strict_purl_check,
args.strict_url_check,
referringLogic=reference_logic)

exitCode = reportCli(result, problems, args.nr_of_errors, args.input)
sys.exit(exitCode)
except KeyboardInterrupt:
print(" Ctrl-C pressed. Terminating...")
sys.exit(2)

class Argument:
def __init__(self, argument, action, help):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def validate(self,
problems.append("File error", "General", "General", f"JSON syntax error at line {e.lineno} column {e.colno}", file)
return False, problems
except SPDXParsingError as e:
logger.error("ERROR! The file is not an SPDX file")
logger.error(f"ERROR! The file ({filePath}) is not an SPDX file")
all_messages = ""
for message in e.messages:
logger.error(message)
Expand All @@ -211,7 +211,7 @@ def validate(self,

errors = validate_full_spdx_document(doc)
if errors:
logger.error("ERROR! The file is not a valid SPDX file")
logger.error(f"ERROR! The file ({filePath}) is not a valid SPDX file")
for error in errors:
logger.debug(f"Validation error: {error.context.parent_id} - {error.context.full_element} - {error.validation_message}")
spdxId = "General"
Expand Down

0 comments on commit 50ac30d

Please sign in to comment.