Skip to content

Commit a1f944a

Browse files
committed
Transform/DDG: Support the script running outside the repository tree
1 parent 8974514 commit a1f944a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

index2ddg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ def main():
462462
parser = argparse.ArgumentParser(prog='index2ddg.py')
463463
parser.add_argument('index', type=str,
464464
help='The path to the XML index containing identifier data')
465+
parser.add_argument('reference', type=str,
466+
help=('The path to the downloaded reference (reference '
467+
'directory in the downloaded archive)'))
465468
parser.add_argument('output', type=str,
466469
help='The path to destination output.txt file')
467470
parser.add_argument('--split_code_snippets', action='store_true', default=False,
@@ -503,11 +506,11 @@ def main():
503506
tr.transform(index_file)
504507

505508
# get a list of existing pages
506-
html_files = get_html_files('reference')
509+
html_files = get_html_files(args.reference)
507510

508511
# get a mapping between titles and pages
509512
# linkmap = dict { title -> filename }
510-
link_map = build_link_map('reference')
513+
link_map = build_link_map(args.reference)
511514

512515
# create a list of processing instructions for each page
513516
proc_ins = get_processing_instructions(ident_map, link_map)
@@ -538,7 +541,7 @@ def main():
538541
#print(str(i) + '/' + str(len(proc_ins)) + ': ' + link)
539542
#i+=1
540543

541-
root = e.parse('reference/'+fn, parser=html.HTMLParser())
544+
root = e.parse(os.path.join(args.reference, fn), parser=html.HTMLParser())
542545

543546
for ident in idents:
544547

0 commit comments

Comments
 (0)