Skip to content

Commit

Permalink
Use Pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
willend committed Jul 31, 2024
1 parent 810f1f6 commit 3a851c6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tools/Python/mcdoc/mcdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
import re
import subprocess
from os.path import join, basename
import pathlib

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from mccodelib import utils, mccode_config

def get_html_filepath(filepath):
''' transform from .anything to .html '''
h = os.path.splitext(filepath)[0] + '.html'
h = re.sub(mccode_config.directories['resourcedir'], mccode_config.directories['docdir'],h)
h = pathlib.Path(os.path.splitext(filepath)[0] + '.html')
h = pathlib.Path(str(h).replace(mccode_config.directories['resourcedir'], mccode_config.directories['docdir']))
return h

class OverviewDocWriter:
Expand Down Expand Up @@ -904,8 +905,8 @@ def write_doc_files_or_continue(comp_infos, instr_infos, comp_files, instr_files
f = comp_files[i]
doc = CompDocWriter(p)
text = doc.create()
h = os.path.splitext(f)[0] + '.html'
h = re.sub(mccode_config.directories['resourcedir'], mccode_config.directories['docdir'],h)
h = pathlib.Path(os.path.splitext(f)[0] + '.html')
h = pathlib.Path(str(h).replace(mccode_config.directories['resourcedir'], mccode_config.directories['docdir']))
if printlog:
print("writing doc file... %s" % h)
write_file(h, text, failsilent=True)
Expand All @@ -915,8 +916,8 @@ def write_doc_files_or_continue(comp_infos, instr_infos, comp_files, instr_files
f = instr_files[i]
doc = InstrDocWriter(p)
text = doc.create()
h = os.path.splitext(f)[0] + '.html'
h = re.sub(mccode_config.directories['resourcedir'], mccode_config.directories['docdir'],h)
h = pathlib.Path(os.path.splitext(f)[0] + '.html')
h = pathlib.Path(str(h).replace(mccode_config.directories['resourcedir'], mccode_config.directories['docdir']))
if printlog:
print("writing doc file... %s" % h)
write_file(h, text, failsilent=True)
Expand Down

0 comments on commit 3a851c6

Please sign in to comment.