From 3ffc96453e3eb57ce1277dc71b28b8d2c38a6b6b Mon Sep 17 00:00:00 2001 From: gabe Date: Sun, 26 Sep 2021 12:32:22 -0500 Subject: [PATCH] implemented importing exclude globs from a file. --- ASCIIsite.py | 11 +++++- tests/globignore | 1 + tests/result/include/include.txt | 65 ++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/globignore create mode 100644 tests/result/include/include.txt diff --git a/ASCIIsite.py b/ASCIIsite.py index 8d5b212..50c9479 100755 --- a/ASCIIsite.py +++ b/ASCIIsite.py @@ -11,8 +11,9 @@ def parse_arguments(): parser=argparse.ArgumentParser(description='create a website directory structure by converting .adoc files in a directory strucutre to .html files.') parser.add_argument('inputDir', type=Path, help='The directory of adoc files to be copied and converted.') parser.add_argument('-o', '--output', type=Path, help='What to name the generated directory or tar file') - parser.add_argument('-z', '--compress', action='store_true', help='whether to compress the resulting directory to a tar.gz file. can be usefull for scripting to transfer the site to a remote server.') + parser.add_argument('--exclude-file', type=Path, help='A text file containing glob patterns to exclude, 1 per line.') parser.add_argument('--exclude', nargs='+', help='A list of glob patterns to ignore. Remember to quote them so your shell doesnt escape them!') + parser.add_argument('-z', '--compress', action='store_true', help='whether to compress the resulting directory to a tar.gz file. can be usefull for scripting to transfer the site to a remote server.') args=parser.parse_args() #set compress flag @@ -44,7 +45,13 @@ def parse_arguments(): logging.info(f'outputting to {outFile.resolve()}') logging.debug(f'compress is {compress}') - return args.inputDir.resolve(), outFile, compress, args.exclude + with open(args.exclude_file, 'r') as file: + exclude=[glob.strip() for glob in file] + + if args.exclude != None: + exclude.extend(args.exclude) + + return args.inputDir.resolve(), outFile, compress, exclude #Doing it in a tmpDir first, as some distrubutions put temp files on a ramdisk. this should speed up the operation sigificantly. class TmpDir: diff --git a/tests/globignore b/tests/globignore new file mode 100644 index 0000000..0eddfc6 --- /dev/null +++ b/tests/globignore @@ -0,0 +1 @@ +include* diff --git a/tests/result/include/include.txt b/tests/result/include/include.txt new file mode 100644 index 0000000..a7151a2 --- /dev/null +++ b/tests/result/include/include.txt @@ -0,0 +1,65 @@ +== included section + +Fusce maximus nec magna eu ultricies. +Fusce quis tellus vitae arcu facilisis lobortis. +Donec id erat at enim porta placerat in vitae sapien. +Duis justo arcu, hendrerit nec nulla eu, dictum dapibus ipsum. +Sed fermentum id elit eget fringilla. +Suspendisse volutpat imperdiet justo, ut efficitur odio maximus et. +Nunc interdum sollicitudin eros sit amet convallis. +Praesent volutpat tempus metus id tincidunt. +Proin aliquet justo a fermentum consectetur. +Nunc scelerisque, nisi id scelerisque dictum, nibh lectus ultrices nunc, quis ultricies erat velit sit amet urna. +Maecenas orci felis, volutpat at bibendum ut, mattis eu justo. + +=== blocks + +.listing block +---- +example of _listing block_ +with verbatim line break +---- + +.example block +==== +example block +with line break +==== + +.literal block +.... +_literal_ block +with line break +.... + +.pass block +++++ +pass block +with underlined text +++++ + +.quote block +____ +quote block +with line break +____ + +.sidebar block +**** +sidebar block +with line break +**** + +[NOTE] +==== +This is an example of an admonition block. + +Unlike an admonition paragraph, it may contain any AsciiDoc content. +The style can be any one of the admonition labels: + +* NOTE +* TIP +* WARNING +* CAUTION +* IMPORTANT +====