Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added html args #52

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ghlicense/cmd.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"--report", help="The report filename for scan (optional)", action="store")
PARSER.add_argument(
"--origin", help="The origin of the git repo (optional)", action="store")
PARSER.add_argument(
"--html" , help = "Prints the report file into a html file", action="store"
)

PARSER.add_argument('args', nargs=REMAINDER)

ARGS = PARSER.parse_args()
Expand Down Expand Up @@ -322,10 +326,18 @@ def main():
# Update progress based on % of repos scanned
print("|" + "#" * 40 + "| Done 100%")
report_file.write("Statistics: \n")

if ARGS.html is not None:
with open("report.html", "w") as e:
for lines in report_file.readlines():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not working since your reading a file that is not closed yet (tested on python 3.10, may work elsewhere)
You'll have to close the report_file before, then reopen it in read mode and use report_file.read() simply

e.write("<pre>" + lines + "</pre> <br>\n")
print("Report.html has been created")

report_file.write(f"Repos with License: {count_license}\n")
report_file.write(f"Repos without License: {count_no_license}\n")
report_file.write(f"Repos without License and forked: {count_forked}\n")
report_file.write(f"Total Repos: {count_no_license + count_license}\n")

report_file.close()

# If the script was launched in "licenselist" mode
Expand Down