Skip to content

Commit

Permalink
chore: cleanup using lint
Browse files Browse the repository at this point in the history
  • Loading branch information
matinnuhamunada committed May 8, 2024
1 parent 90159f3 commit 702cc90
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/bgcflow/mkdocs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import logging
import os
import shutil
import signal
import subprocess
Expand Down Expand Up @@ -34,6 +33,7 @@ class Dict2Class(object):
print_references():
Returns a formatted string of the `references` attribute of the object.
"""

def __init__(self, my_dict):
"""
Initializes the object with attributes from the dictionary.
Expand Down Expand Up @@ -82,6 +82,7 @@ def load_project_metadata(path_to_metadata):
p = Dict2Class(p)
return p


def write_mkdocs_file(data_input, output_file, action):
"""
Writes data to a file in either YAML or plain text format.
Expand All @@ -100,7 +101,9 @@ def write_mkdocs_file(data_input, output_file, action):
None
"""
if output_file.exists():
overwrite = input(f"WARNING: {output_file} already exists. Do you want to overwrite it? (y/n) ")
overwrite = input(
f"WARNING: {output_file} already exists. Do you want to overwrite it? (y/n) "
)
if overwrite.lower() != "y":
print("Skipping file write.")
else:
Expand All @@ -114,16 +117,17 @@ def write_mkdocs_file(data_input, output_file, action):
# continue with writing the file
with open(output_file, "w", encoding="utf-8") as f:
if action == "yaml":
yaml.dump(data_input, f)
yaml.dump(data_input, f)
elif action == "write":
f.write(data_input)


def generate_mkdocs_report(
bgcflow_dir: str,
project_name: str,
port: int = 8001,
fileserver: str = "http://localhost:8002",
ipynb: bool = True
ipynb: bool = True,
) -> None:
"""
Generates an MkDocs report for a BGCFlow project.
Expand Down Expand Up @@ -223,7 +227,9 @@ def generate_mkdocs_report(
mkdocs_py = report_dir / "main.py"
logging.info(f"Generating python macros at: {mkdocs_py}")
j2_template = Template(macros_template)
write_mkdocs_file(j2_template.render({"file_server": fileserver}), mkdocs_py, "write")
write_mkdocs_file(
j2_template.render({"file_server": fileserver}), mkdocs_py, "write"
)

# generate custom javascripts
# script_dir = docs_dir / "scripts"
Expand Down

0 comments on commit 702cc90

Please sign in to comment.