diff --git a/.gitignore b/.gitignore index 3458040..eda28b2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ PonormeSeDoPythonu3/ buildPDF/ *~ *.zip -changelog.html \ No newline at end of file +changelog.html +PonormeSeDoPythonu3single.html +PonormeSeDoPythonu3.pdf diff --git a/clean.bat b/clean.bat index 3a150cd..8097a62 100644 --- a/clean.bat +++ b/clean.bat @@ -1,4 +1,6 @@ del *.zip del *~ +del changelog.html +del PonormeSeDoPythonu3single.html +del PonormeSeDoPythonu3.pdf rmdir /S /Q buildPDF -rmdir /S /Q PonormeSeDoPythonu3 \ No newline at end of file diff --git a/pack.bat b/pack.bat index c045c58..22541e5 100644 --- a/pack.bat +++ b/pack.bat @@ -1,6 +1,6 @@ -zip -r PonormeSeDoPythonu3 PonormeSeDoPythonu3 pushd buildPDF -zip -r PonormeSeDoPythonu3pdf PonormeSeDoPythonu3.pdf -move PonormeSeDoPythonu3pdf.zip .. +copy PonormeSeDoPythonu3.pdf .. +copy single.html PonormeSeDoPythonu3single.html popd -call ziphtml.bat \ No newline at end of file +rem Přibalí i vygenerovaný changelog.html a PonormeSeDoPythonu3single.html +zip -r PonormeSeDoPythonu3-html *.html *.css examples/* i/* j/* diff --git a/util/buildchangelog.py b/util/buildchangelog.py index 02f4a3f..88f5e29 100644 --- a/util/buildchangelog.py +++ b/util/buildchangelog.py @@ -33,7 +33,7 @@

Generováno pro český překlad. - + ''' pgmPath = os.path.split(os.path.realpath(__file__))[0] @@ -48,10 +48,13 @@ def gitLogLines(): line = line.decode('utf-8') except UnicodeDecodeError: line = line.decode('cp1250') # první git commit byl v cp1250 - yield line.replace('<', '<') + yield line # Generovaný výstupní soubor. with open(chlogname, 'w', encoding='utf-8', newline='\n') as f: f.write(head) - f.write(''.join(gitLogLines()).replace('&', '&')) + content = ''.join(gitLogLines()) + content = content.replace('&', '&') + content = content.replace('<', '<') + f.write(content) f.write(foot) diff --git a/util/flatten2.py b/util/flatten2.py index f8bdfd6..95ee108 100644 --- a/util/flatten2.py +++ b/util/flatten2.py @@ -11,52 +11,19 @@ utilDir = os.path.split(os.path.realpath(__file__))[0] srcDir = os.path.realpath(os.path.join(utilDir, '..')) buildPDFDir = os.path.realpath(os.path.join(utilDir, '..', 'buildPDF')) -buildHTMLDir = os.path.realpath(os.path.join(utilDir, '..', 'PonormeSeDoPythonu3')) - - -def srcGen(filename): - with open(filename, encoding='utf-8') as f: - content = f.read() - - # Rectify some of the problems generated by MemoQ in the translated - # content (some newlines were somehow replaced by a space). - content = content.replace(' , kde koncové lomítko vyjadřuje adresář. - # Zde se řeší jen speciální případ. - ahrefRex = re.compile(r'') - content = ahrefRex.sub(r'', content) - - # Write the corrected content to the file with the same name, but to - # the buildDir (nasty side effect only to get the file for checking - # of what could cause problems in the next flattening process). - fname = os.path.join(buildHTMLDir, os.path.basename(filename)) - f = open(fname, 'w', encoding='utf-8') - f.write(content) - f.close() - - # Yield the lines of the content as if they were read from a text file. - for line in content.splitlines(True): # keep ends - yield line - print('Corrected HTML', repr(os.path.basename(filename))) - + def copyNames(srcDir, dstDir, nameLst): """Okopíruje jména z nameLst z adresáře srcDir do dstDir. - + Pokud destDir neexistuje, bude nejdříve vytvořen. Pokud jméno - z nameLst odpovídá podadresáři, bude případný existující cílový + z nameLst odpovídá podadresáři, bude případný existující cílový podadresář nejdříve smazán a okopírován celý zdrojový znovu. """ # Pokud neexistuje cílový adresář, vyrobíme jej. if not os.path.isdir(dstDir): os.makedirs(dstDir) - + for name in nameLst: src = os.path.join(srcDir, name) dst = os.path.join(dstDir, name) @@ -68,7 +35,7 @@ def copyNames(srcDir, dstDir, nameLst): shutil.copytree(src, dst) elif os.path.isfile(src): shutil.copy2(src, dst) - + # Set list of chapters in the order defined by the index.html. Append also # the files that are not there (about, colophon). @@ -103,7 +70,6 @@ def copyNames(srcDir, dstDir, nameLst): ] # Připravíme cílové adresáře pro HTML a PDF (kopie potřebného). -copyNames(srcDir, buildHTMLDir, ['i', 'j', 'examples', 'dip3.css']) copyNames(utilDir, buildPDFDir, ['dip3.css', 'prince.css']) copyNames(srcDir, buildPDFDir, ['i', 'examples']) @@ -127,7 +93,7 @@ def copyNames(srcDir, dstDir, nameLst): fname = os.path.join(utilDir, 'single-footer.html') with open(fname, encoding='utf-8') as f: footer = f.read() - + singleName = os.path.join(buildPDFDir, 'single.html') with open(singleName, 'w', encoding='utf-8') as out: out.write(header) # Header before the style definitions. @@ -157,27 +123,28 @@ def copyNames(srcDir, dstDir, nameLst): chapter_id = "chapter-" + id_suffix filename = os.path.join(srcDir, fname) out.write("

\n".format(chapter_id)) - for line in srcGen(filename): - if line.startswith(''): - line = line.replace('', '
') - out.write(line) - - if line.count('

'): - include = True - if line.count('

©') or line.count('

©'): - include = False - if line.count('

".format(id_suffix, x.group(1)), line) - line = same_chapter_fragment_href.sub(lambda x: "", line) - line = chapter_fragment_href.sub(lambda x: "".format(x.group(1).replace('.html', ''), x.group(2)) , line) - out.write(line) + with open(filename, encoding='utf-8') as f: + for line in f: + if line.startswith(''): + line = line.replace('', '') + out.write(line) + + if line.count('

'): + include = True + if line.count('

©') or line.count('

©'): + include = False + if line.count('

".format(id_suffix, x.group(1)), line) + line = same_chapter_fragment_href.sub(lambda x: "", line) + line = chapter_fragment_href.sub(lambda x: "".format(x.group(1).replace('.html', ''), x.group(2)) , line) + out.write(line) out.write("\n") @@ -189,7 +156,7 @@ def copyNames(srcDir, dstDir, nameLst): programFiles = os.getenv('ProgramFiles(x86)') if programFiles is None: programFiles = os.getenv('ProgramFiles') - + prince = os.path.join(programFiles, 'Prince', 'Engine', 'bin', 'Prince.exe') prince = os.path.normpath(prince)