Changeset View
Changeset View
Standalone View
Standalone View
documentation/tools/books-toc-examples-creator.py
Context not available. | |||||
def main(argv): | def main(argv): | ||||
justPrintOutput = False | justPrintOutput = False | ||||
offline = False | |||||
langargs = [] | langargs = [] | ||||
try: | try: | ||||
opts, args = getopt.gnu_getopt(argv,"hl:o",["language="]) | opts, args = getopt.gnu_getopt(argv,"hl:o:p",["language="]) | ||||
except getopt.GetoptError: | except getopt.GetoptError: | ||||
print('books-toc-examples-creator.py [-o] -l <language>') | print('books-toc-examples-creator.py [-o] [-p] -l <language>') | ||||
sys.exit(2) | sys.exit(2) | ||||
for opt, arg in opts: | for opt, arg in opts: | ||||
if opt == '-h': | if opt == '-h': | ||||
print('books-toc-examples-creator.py [-o] -l <language>') | print('books-toc-examples-creator.py [-o] [-p] -l <language>') | ||||
sys.exit() | sys.exit() | ||||
if opt == '-o': | if opt == '-o': | ||||
offline = True | |||||
if opt == '-p': | |||||
justPrintOutput = True | justPrintOutput = True | ||||
elif opt in ("-l", "--language"): | elif opt in ("-l", "--language"): | ||||
langargs = arg.replace(" ",",").split(',') | langargs = arg.replace(" ",",").split(',') | ||||
Context not available. | |||||
with open('./content/{0}/books/{1}/{2}'.format(language, book, chapter), 'r', encoding = 'utf-8') as chapterFile: | with open('./content/{0}/books/{1}/{2}'.format(language, book, chapter), 'r', encoding = 'utf-8') as chapterFile: | ||||
chapterContent = chapterFile.read().splitlines() | chapterContent = chapterFile.read().splitlines() | ||||
chapterFile.close() | chapterFile.close() | ||||
chapter = chapter.replace("/_index.adoc", "").replace(".adoc", "").replace("/chapter.adoc", "") | |||||
if offline: | |||||
chapter = chapter.replace("/_index.adoc", "/index.html").replace(".adoc", ".html").replace("/chapter.adoc", "/index.html") | |||||
else: | |||||
chapter = chapter.replace("/_index.adoc", "").replace(".adoc", "").replace("/chapter.adoc", "") | |||||
exampleId = "" | exampleId = "" | ||||
exampleTitle = "" | exampleTitle = "" | ||||
Context not available. |