rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
rgx = re.compile(r'\\html_math_output\s+(\w+)') | rgx = re.compile(r'\\html_math_output\s+(\d)') | def revert_math_output(document): " Revert \html_math_output to \html_use_mathml " i = find_token(document.header, "\\html_math_output", 0) if i == -1: return rgx = re.compile(r'\\html_math_output\s+(\w+)') m = rgx.match(document.header[i]) if rgx: newval = "false" val = m.group(1) if val != "MathML": newval = "true" d... |
newval = "false" | def revert_math_output(document): " Revert \html_math_output to \html_use_mathml " i = find_token(document.header, "\\html_math_output", 0) if i == -1: return rgx = re.compile(r'\\html_math_output\s+(\w+)') m = rgx.match(document.header[i]) if rgx: newval = "false" val = m.group(1) if val != "MathML": newval = "true" d... | |
if val != "MathML": newval = "true" document.header[i] = "\\html_use_mathml " + newval | if val == "1" or val == "2": newval = "false" else: document.warning("Unable to match " + document.header[i]) document.header[i] = "\\html_use_mathml " + newval | def revert_math_output(document): " Revert \html_math_output to \html_use_mathml " i = find_token(document.header, "\\html_math_output", 0) if i == -1: return rgx = re.compile(r'\\html_math_output\s+(\w+)') m = rgx.match(document.header[i]) if rgx: newval = "false" val = m.group(1) if val != "MathML": newval = "true" d... |
[381, []] | [381, []], [382, []] | def revert_equalspacing_xymatrix(document): " Revert a Formula with xymatrix@! to an ERT inset " i = 0 j = 0 has_preamble = False has_equal_spacing = False while True: found = -1 i = find_token(document.body, "\\begin_inset Formula", i) if i == -1: break j = find_end_of_inset(document.body, i) if j == -1: document.warn... |
revert = [[380, [revert_equalspacing_xymatrix]], | revert = [[381, [revert_notefontcolor]], [380, [revert_equalspacing_xymatrix]], | def revert_equalspacing_xymatrix(document): " Revert a Formula with xymatrix@! to an ERT inset " i = 0 j = 0 has_preamble = False has_equal_spacing = False while True: found = -1 i = find_token(document.body, "\\begin_inset Formula", i) if i == -1: break j = find_end_of_inset(document.body, i) if j == -1: document.warn... |
revert_use_makebox(document) | def revert_makebox(document): " Convert \\makebox to TeX code " i = 0 while 1: # only revert frameless boxes without an inner box i = find_token(document.body, '\\begin_inset Box Frameless', i) if i == -1: # remove the option use_makebox revert_use_makebox(document) return z = find_end_of_inset(document.body, i) if z =... | |
return j = find_token(document.body, 'use_makebox 1', i) if j < z and j != -1: y = find_token(document.body, "\\begin_layout", i) if y > z or y == -1: document.warning("Malformed LyX document: Can't find layout in box.") return document.body[z - 2:z + 1] = put_cmd_in_ert("}") k = find_token(document.body, 'hor_pos',... | i += 1 continue blay = find_token(document.body, "\\begin_layout", i, z) if blay == -1: document.warning("Malformed LyX document: Can't find layout in box.") i = z continue j = find_token(document.body, 'use_makebox', i, blay) if j == -1: i = z continue val = get_value(document.body, 'use_makebox', j) if val != "1": ... | def revert_makebox(document): " Convert \\makebox to TeX code " i = 0 while 1: # only revert frameless boxes without an inner box i = find_token(document.body, '\\begin_inset Box Frameless', i) if i == -1: # remove the option use_makebox revert_use_makebox(document) return z = find_end_of_inset(document.body, i) if z =... |
def revert_use_makebox(document): " Deletes use_makebox option of boxes " h = 0 while 1: h = find_token(document.body, 'use_makebox', 0) if h == -1: return del document.body[h] h += 1 | def revert_makebox(document): " Convert \\makebox to TeX code " i = 0 while 1: # only revert frameless boxes without an inner box i = find_token(document.body, '\\begin_inset Box Frameless', i) if i == -1: # remove the option use_makebox revert_use_makebox(document) return z = find_end_of_inset(document.body, i) if z =... | |
if os.name == "nt": full_path = os.path.join(directory, prog + ".exe") else: full_path = os.path.join(directory, prog) if os.access(full_path, os.X_OK): return os.path.basename(full_path) | for ext in extlist: full_path = os.path.join(directory, prog + ext) if os.access(full_path, os.X_OK): return os.path.basename(full_path) | def find_exe(candidates, path): for prog in candidates: for directory in path: if os.name == "nt": full_path = os.path.join(directory, prog + ".exe") else: full_path = os.path.join(directory, prog) if os.access(full_path, os.X_OK): # The thing is in the PATH already (or we wouldn't # have found it). Return just the ba... |
i = j | i += 1 | def revert_tabularvalign(document): " Revert the tabular valign option " i = 0 while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: return end = find_end_of_inset(document.body, i) if end == -1: document.warning("Can't find end of inset at line " + str(i)) i = j continue fline = find_token(... |
i = end | i += 1 | def revert_tabularvalign(document): " Revert the tabular valign option " i = 0 while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: return end = find_end_of_inset(document.body, i) if end == -1: document.warning("Can't find end of inset at line " + str(i)) i = j continue fline = find_token(... |
i = end + len(subst) | i += len(subst) | def revert_tabularvalign(document): " Revert the tabular valign option " i = 0 while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: return end = find_end_of_inset(document.body, i) if end == -1: document.warning("Can't find end of inset at line " + str(i)) i = j continue fline = find_token(... |
j = 0 | def revert_longtable_align(document): " Remove longtable alignment setting " i = 0 j = 0 while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: break # the alignment is 2 lines below \\begin_inset Tabular j = document.body[i + 2].find("longtabularalignment") if j == -1: break document.body[i ... | |
j = document.body[i + 2].find("longtabularalignment") | end = find_end_of_inset(document.body, i) if end == -1: document.warning("Can't find end of inset at line " + str(i)) i += 1 continue fline = find_token(document.body, "<features", i, end) if fline == -1: document.warning("Can't find features for inset at line " + str(i)) i += 1 continue j = document.body[fline].find("... | def revert_longtable_align(document): " Remove longtable alignment setting " i = 0 j = 0 while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: break # the alignment is 2 lines below \\begin_inset Tabular j = document.body[i + 2].find("longtabularalignment") if j == -1: break document.body[i ... |
break document.body[i + 2] = document.body[i + 2][:j - 1] document.body[i + 2] = document.body[i + 2] + '>' i = i + 1 | i += 1 continue document.body[fline] = document.body[fline][:j - 1] + '>' i += 1 | def revert_longtable_align(document): " Remove longtable alignment setting " i = 0 j = 0 while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: break # the alignment is 2 lines below \\begin_inset Tabular j = document.body[i + 2].find("longtabularalignment") if j == -1: break document.body[i ... |
revert_layout_command(document, "Special Paper Notice", "\\IEEEspecialpapernotice", 0) revert_layout_command(document, "After Title Text", "\\IEEEaftertitletext", 0) revert_layout_command(document, "Page headings", "\\markboth", 0) revert_layout_command(document, "Publication ID", "\\IEEEpubid", 0) note = '\\begin_layo... | layouts = ("Special Paper Notice", "After Title Text", "Publication ID", "Page headings", "Biography without photo") latexcmd = {"Special Paper Notice": "\\IEEEspecialpapernotice", "After Title Text": "\\IEEEaftertitletext", "Publication ID": "\\IEEEpubid"} obsoletedby = {"Page headings": "MarkBo... | def revert_IEEEtran(document): " Convert IEEEtran layouts and styles to TeX code " if document.textclass != "IEEEtran": return revert_flex_inset(document, "IEEE membership", "\\IEEEmembership", 0) revert_flex_inset(document, "Lowercase", "\\MakeLowercase", 0) revert_layout_command(document, "Special Paper Notice", "\\... |
[403, [convert_flexnames]] | [403, [convert_flexnames]], [404, [convert_prettyref]] | def convert_bibtexClearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " while True: i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return else: sides = int(document.header[i][12]) # o... |
revert = [[402, [revert_flexnames]], | revert = [[403, [revert_refstyle]], [402, [revert_flexnames]], | def convert_bibtexClearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " while True: i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return else: sides = int(document.header[i][12]) # o... |
i = 0 colorcode = "" while True: i = find_token(document.header, "\\fontcolor", i) if i == -1: return colorcode = get_value(document.header, '\\fontcolor', 0) del document.header[i] if colorcode == " continue red = string.atoi(colorcode[1:3],16) if red != 0: red = red + 1 redout = float(red) / 256 green = string.at... | i = find_token(document.header, "\\fontcolor", 0) if i == -1: return colorcode = get_value(document.header, '\\fontcolor', i) del document.header[i] if colorcode == " return red = hex2ratio(colorcode[1:3]) green = hex2ratio(colorcode[3:5]) blue = hex2ratio(colorcode[5:7]) insert_to_preamble(0, document, ['% Commands... | def revert_fontcolor(document): " Reverts font color to preamble code " i = 0 colorcode = "" while True: i = find_token(document.header, "\\fontcolor", i) if i == -1: return colorcode = get_value(document.header, '\\fontcolor', 0) del document.header[i] # don't clutter the preamble if backgroundcolor is not set if colo... |
[400, [convert_rule]] | [400, [convert_rule]], [401, []] | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i != -1: # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document.warnin... |
revert = [[399, [revert_rule]], | revert = [[400, [revert_diagram]], [399, [revert_rule]], | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i != -1: # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document.warnin... |
document.warning(str(i)) | def convert_bibtexClearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " while True: i = find_token(document.header, '\\papersides', 0) document.warning(str(i)) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return else: sides = int(do... | |
i = 0 j = 0 k = 0 | def revert_mhchem(document): "Revert mhchem loading to preamble code" i = 0 j = 0 k = 0 mhchem = "off" i = find_token(document.header, "\\use_mhchem 1", 0) if i != -1: mhchem = "auto" else: i = find_token(document.header, "\\use_mhchem 2", 0) if i != -1: mhchem = "on" if mhchem == "auto": j = find_token(document.body, ... | |
i = find_token(document.header, "\\use_mhchem 1", 0) if i != -1: | i = find_token(document.header, "\\use_mhchem", 0) if i == -1: document.warning("Malformed LyX document: Could not find mhchem setting.") | def revert_mhchem(document): "Revert mhchem loading to preamble code" i = 0 j = 0 k = 0 mhchem = "off" i = find_token(document.header, "\\use_mhchem 1", 0) if i != -1: mhchem = "auto" else: i = find_token(document.header, "\\use_mhchem 2", 0) if i != -1: mhchem = "on" if mhchem == "auto": j = find_token(document.body, ... |
i = find_token(document.header, "\\use_mhchem 2", 0) if i != -1: | val = get_value(document.header, "\\use_mhchem", i) if val == "1": mhchem = "auto" elif val == "2": | def revert_mhchem(document): "Revert mhchem loading to preamble code" i = 0 j = 0 k = 0 mhchem = "off" i = find_token(document.header, "\\use_mhchem 1", 0) if i != -1: mhchem = "auto" else: i = find_token(document.header, "\\use_mhchem 2", 0) if i != -1: mhchem = "on" if mhchem == "auto": j = find_token(document.body, ... |
j = find_token(document.body, "\\cf{", 0) if j != -1: mhchem = "on" else: j = find_token(document.body, "\\ce{", 0) if j != -1: mhchem = "on" | i = 0 while True: i = find_token(document.body, "\\begin_inset Formula", i) line = document.body[i] if line.find("\\ce{") != -1 or line.find("\\cf{") != 1: mhchem = "on" break | def revert_mhchem(document): "Revert mhchem loading to preamble code" i = 0 j = 0 k = 0 mhchem = "off" i = find_token(document.header, "\\use_mhchem 1", 0) if i != -1: mhchem = "auto" else: i = find_token(document.header, "\\use_mhchem 2", 0) if i != -1: mhchem = "on" if mhchem == "auto": j = find_token(document.body, ... |
add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) add_to_preamble(document, ["\\PassOptionsToPackage{version=3}{mhchem}"]) add_to_preamble(document, ["\\usepackage{mhchem}"]) k = find_token(document.header, "\\use_mhchem", 0) if k == -1: document.warning("Malformed LyX document: Could not find mhche... | pre = ["% lyx2lyx mhchem commands", "\\PassOptionsToPackage{version=3}{mhchem}", "\\usepackage{mhchem}"] add_to_preamble(document, pre) | def revert_mhchem(document): "Revert mhchem loading to preamble code" i = 0 j = 0 k = 0 mhchem = "off" i = find_token(document.header, "\\use_mhchem 1", 0) if i != -1: mhchem = "auto" else: i = find_token(document.header, "\\use_mhchem 2", 0) if i != -1: mhchem = "on" if mhchem == "auto": j = find_token(document.body, ... |
[397, [remove_Nameref]] | [397, [remove_Nameref]], [398, []] | def remove_Nameref(document): " Convert Nameref commands to nameref commands " i = 0 while 1: # It seems better to look for this, as most of the reference # insets won't be ones we care about. i = find_token(document.body, "LatexCommand Nameref" , i) if i == -1: break cmdloc = i i += 1 # Make sure it is actually in an... |
revert = [[396, []], | revert = [[397, [revert_mathrsfs]], [396, []], | def remove_Nameref(document): " Convert Nameref commands to nameref commands " i = 0 while 1: # It seems better to look for this, as most of the reference # insets won't be ones we care about. i = find_token(document.body, "LatexCommand Nameref" , i) if i == -1: break cmdloc = i i += 1 # Make sure it is actually in an... |
i = 0 ddots = re.compile(r'\\begin_inset Formula .*\\ddots', re.DOTALL) vdots = re.compile(r'\\begin_inset Formula .*\\vdots', re.DOTALL) iddots = re.compile(r'\\begin_inset Formula .*\\iddots', re.DOTALL) | def revert_mathdots(document): " Load mathdots if used in the document " i = 0 ddots = re.compile(r'\\begin_inset Formula .*\\ddots', re.DOTALL) vdots = re.compile(r'\\begin_inset Formula .*\\vdots', re.DOTALL) iddots = re.compile(r'\\begin_inset Formula .*\\iddots', re.DOTALL) mathdots = find_token(document.header, "\... | |
no = find_token(document.header, "\\use_mathdots 0" , 0) auto = find_token(document.header, "\\use_mathdots 1" , 0) yes = find_token(document.header, "\\use_mathdots 2" , 0) if mathdots != -1: | usedots = 1 if mathdots == -1: document.warning("No \\usemathdots line. Assuming auto.") else: | def revert_mathdots(document): " Load mathdots if used in the document " i = 0 ddots = re.compile(r'\\begin_inset Formula .*\\ddots', re.DOTALL) vdots = re.compile(r'\\begin_inset Formula .*\\vdots', re.DOTALL) iddots = re.compile(r'\\begin_inset Formula .*\\iddots', re.DOTALL) mathdots = find_token(document.header, "\... |
document.warning("Malformed LyX document: Can't find end of Formula inset.") return k = ddots.search("\n".join(document.body[i:j])) l = vdots.search("\n".join(document.body[i:j])) m = iddots.search("\n".join(document.body[i:j])) if (yes == -1) and ((no != -1) or (not k and not l and not m) or (auto != -1 and not m)): | document.warning("Malformed LyX document: Can't find end of Formula inset at line " + str(i)) | def revert_mathdots(document): " Load mathdots if used in the document " i = 0 ddots = re.compile(r'\\begin_inset Formula .*\\ddots', re.DOTALL) vdots = re.compile(r'\\begin_inset Formula .*\\vdots', re.DOTALL) iddots = re.compile(r'\\begin_inset Formula .*\\iddots', re.DOTALL) mathdots = find_token(document.header, "\... |
add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) add_to_preamble(document, ["\\@ifundefined{iddots}{\\usepackage{mathdots}}\n"]) return | code = "\n".join(document.body[i:j]) if code.find("\\iddots") != -1: add_to_preamble(document, ["% lyx2lyx mathdots addition", "\\@ifundefined{iddots}{\\usepackage{mathdots}}"]) return i = j | def revert_mathdots(document): " Load mathdots if used in the document " i = 0 ddots = re.compile(r'\\begin_inset Formula .*\\ddots', re.DOTALL) vdots = re.compile(r'\\begin_inset Formula .*\\vdots', re.DOTALL) iddots = re.compile(r'\\begin_inset Formula .*\\iddots', re.DOTALL) mathdots = find_token(document.header, "\... |
i = find_token(document.header, "\\use_esint" , 0) | i = find_token(document.header, "\\use_mhchem" , 0) if i == -1: i = find_token(document.header, "\\use_esint" , 0) | def convert_mathdots(document): " Load mathdots automatically " i = find_token(document.header, "\\use_esint" , 0) if i != -1: document.header.insert(i + 1, "\\use_mathdots 1") |
[371, []], | [371, [convert_mhchem]], | def revert_script(document): " Convert subscript/superscript inset to TeX code " i = 0 foundsubscript = False while 1: i = find_token(document.body, '\\begin_inset script', i) if i == -1: break z = find_end_of_inset(document.body, i) if z == -1: document.warning("Malformed LyX document: Can't find end of script inset."... |
def revert_equalspacing_xymatrix(document): " Revert a Formula with xymatrix@! to an ERT inset " i = 0 j = 0 has_preamble = 0 while True: found = -1 i = find_token(document.body, "\\begin_inset Formula", i) if i == -1: break j = find_end_of_inset(document.body, i) if j == -1: document.warning("Malformed LyX document: C... | def revert_inset_preview(document): " Dissolves the preview inset " i = 0 j = 0 k = 0 while True: i = find_token(document.body, "\\begin_inset Preview", i) if i == -1: return j = find_end_of_inset(document.body, i) if j == -1: document.warning("Malformed LyX document: Could not find end of Preview inset.") return #If t... | |
[380, []] | [380, []], [381, []] | def revert_inset_preview(document): " Dissolves the preview inset " i = 0 j = 0 k = 0 while True: i = find_token(document.body, "\\begin_inset Preview", i) if i == -1: return j = find_end_of_inset(document.body, i) if j == -1: document.warning("Malformed LyX document: Could not find end of Preview inset.") return #If t... |
revert = [[379, [revert_inset_preview]], | revert = [[380, [revert_equalspacing_xymatrix]], [379, [revert_inset_preview]], | def revert_inset_preview(document): " Dissolves the preview inset " i = 0 j = 0 k = 0 while True: i = find_token(document.body, "\\begin_inset Preview", i) if i == -1: return j = find_end_of_inset(document.body, i) if j == -1: document.warning("Malformed LyX document: Could not find end of Preview inset.") return #If t... |
add_to_preamble(document, "\\use_package{feyn}") | add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) add_to_preamble(document, "\\usepackage{feyn}") | def revert_diagram(document): i = 0 re_diagram = re.compile(r'\\begin_inset Formula .*\\Diagram', re.DOTALL) while True: i = find_token(document.body, '\\begin_inset Formula', i) if i == -1: return j = find_end_of_inset(document.body, i) if j == -1: document.warning("Malformed LyX document: Can't find end of line inset... |
" Reverts \\strikeout character style " while True: i = find_token(document.body, '\\strikeout', 0) if i == -1: return del document.body[i] def revert_uulinewave(document): " Reverts \\uuline, and \\uwave character styles " while True: i = find_token(document.body, '\\uuline', 0) if i == -1: break del document.body[i... | " Reverts \\strikeout character style " changed = False changed = revert_charstyles(document, "\\uuline", "\\uuline", changed) changed = revert_charstyles(document, "\\uwave", "\\uwave", changed) changed = revert_charstyles(document, "\\strikeout", "\\sout", changed) if changed == True: insert_to_preamble(0, document, ... | def revert_strikeout(document): " Reverts \\strikeout character style " while True: i = find_token(document.body, '\\strikeout', 0) if i == -1: return del document.body[i] |
" Convert IEEEtran layouts and styles to TeX codeT " | " Convert IEEEtran layouts and styles to TeX code " | def revert_IEEEtran(document): " Convert IEEEtran layouts and styles to TeX codeT " revert_flex_inset(document, "IEEE membership", "\\IEEEmembership", 0) revert_flex_inset(document, "Lowercase", "\\MakeLowercase", 0) |
[355, [revert_uulinewave]], | [355, []], | def revert_IEEEtran(document): " Convert IEEEtran layouts and styles to TeX codeT " revert_flex_inset(document, "IEEE membership", "\\IEEEmembership", 0) revert_flex_inset(document, "Lowercase", "\\MakeLowercase", 0) |
if modulemap.has_key(mod): | if mod in modulemap: | def revert_module_names(document): modulemap = { 'braille' : 'Braille', 'endnotes' : 'Endnote', 'foottoend' : 'Foot to End',\ 'hanging' : 'Hanging', 'linguistics' : 'Linguistics', 'logicalmkup' : 'Logical Markup', \ 'theorems-ams-extended' : 'Theorems (AMS-Extended)', 'theorems-ams' : 'Theorems (AMS)', \ 'theorems-chap... |
protected = (document.body[i].find("\\hspace*{}") != -1) length = get_value(document.body, '\\length', i + 1) | j = find_end_of_inset(document.body, i) if j == -1: document.warning("Can't find end of inset at line " + str(i)) i += 1 continue length = get_value(document.body, '\\length', i + 1, j) | def revert_percent_hspace_lengths(document): " Revert relative HSpace lengths to ERT " i = 0 while True: i = find_token(document.body, "\\begin_inset space \\hspace", i) if i == -1: break protected = (document.body[i].find("\\hspace*{}") != -1) # only revert if a custom length was set and if # it used a percent length ... |
return | i = j continue protected = (document.body[i].find("\\hspace*{}") != -1) | def revert_percent_hspace_lengths(document): " Revert relative HSpace lengths to ERT " i = 0 while True: i = find_token(document.body, "\\begin_inset space \\hspace", i) if i == -1: break protected = (document.body[i].find("\\hspace*{}") != -1) # only revert if a custom length was set and if # it used a percent length ... |
subst = [old_put_cmd_in_ert("\\hspace*{" + length + "}")] | subst = put_cmd_in_ert("\\hspace*{" + length + "}") | def revert_percent_hspace_lengths(document): " Revert relative HSpace lengths to ERT " i = 0 while True: i = find_token(document.body, "\\begin_inset space \\hspace", i) if i == -1: break protected = (document.body[i].find("\\hspace*{}") != -1) # only revert if a custom length was set and if # it used a percent length ... |
subst = [old_put_cmd_in_ert("\\hspace{" + length + "}")] document.body[i:i + 3] = subst i = i + 2 | subst = put_cmd_in_ert("\\hspace{" + length + "}") document.body[i:j + 1] = subst i = j | def revert_percent_hspace_lengths(document): " Revert relative HSpace lengths to ERT " i = 0 while True: i = find_token(document.body, "\\begin_inset space \\hspace", i) if i == -1: break protected = (document.body[i].find("\\hspace*{}") != -1) # only revert if a custom length was set and if # it used a percent length ... |
document.warning("Malformed document. No \\use_xetex param!") | def convert_use_xetex(document): " convert \\use_xetex to \\use_non_tex_fonts " i = 0 i = find_token(document.header, "\\use_xetex", 0) if i == -1: document.warning("Malformed document. No \\use_xetex param!") return val = get_value(document.header, "\\use_xetex", 0) document.header[i] = "\\use_non_tex_fonts " + val | |
return sides = int(document.header[i][12]) | document.warning("Assuming single sided.") sides = 1 else: val = get_value(document.header, "\\papersides", i) try: sides = int(val) except: pass if sides != 1 and sides != 2: document.warning("Invalid papersides value: " + val) document.warning("Assuming single sided.") sides = 1 | def convert_bibtex_clearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return sides = int(document.header[i][12]) j = 0 while True: ... |
m = find_token(document.body, 'options', j, k) if m == -1: | val = get_value(document.body, 'options', j, k) if not val: | def convert_bibtex_clearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return sides = int(document.header[i][12]) j = 0 while True: ... |
optline = document.body[m] idx = optline.find("bibtotoc") if idx == -1: | if val.find("bibtotoc") == -1: | def convert_bibtex_clearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return sides = int(document.header[i][12]) j = 0 while True: ... |
lay = j - 1 while lay >= 0: if document.body[lay].startswith("\\begin_layout"): break lay -= 1 if lay < 0: | lay = find_token_backwards(document.body, "\\begin_layout", j) if lay == -1: | def convert_bibtex_clearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return sides = int(document.header[i][12]) j = 0 while True: ... |
subst1 = '\\begin_layout Standard\n' \ + '\\begin_inset Newpage clearpage\n' \ + '\\end_inset\n\n\n' \ + '\\end_layout\n' subst2 = '\\begin_layout Standard\n' \ + '\\begin_inset Newpage cleardoublepage\n' \ + '\\end_inset\n\n\n' \ + '\\end_layout\n' | def convert_bibtex_clearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return sides = int(document.header[i][12]) j = 0 while True: ... | |
document.body.insert(lay, subst1) document.warning(subst1) | cmd = "clearpage" | def convert_bibtex_clearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return sides = int(document.header[i][12]) j = 0 while True: ... |
document.body.insert(lay, subst2) document.warning(subst2) j = k | cmd = "cleardoublepage" subst = ['\\begin_layout Standard', '\\begin_inset Newpage ' + cmd, '\\end_inset', '', '', '\\end_layout', ''] document.body[lay:lay] = subst j = k + len(subst) | def convert_bibtex_clearpage(document): " insert a clear(double)page bibliographystyle if bibtotoc option is used " i = find_token(document.header, '\\papersides', 0) if i == -1: document.warning("Malformed LyX document: Can't find papersides definition.") return sides = int(document.header[i][12]) j = 0 while True: ... |
if len(argv) != 6: | if len(argv) != 6 and len(argv) != 7: | def main(argv): # Parse and manipulate the command line arguments. if len(argv) != 6: error(usage(argv[0])) output_format = string.lower(argv[1]) dir, latex_file = os.path.split(argv[2]) if len(dir) != 0: os.chdir(dir) dpi = string.atoi(argv[3]) fg_color = make_texcolor(argv[4], False) bg_color = make_texcolor(argv[... |
latex = find_exe_or_terminate(["latex", "pplatex", "platex", "latex2e"], path) | if len(argv) == 7: latex = argv[6] else: latex = find_exe_or_terminate(["latex", "pplatex", "platex", "latex2e"], path) | def main(argv): # Parse and manipulate the command line arguments. if len(argv) != 6: error(usage(argv[0])) output_format = string.lower(argv[1]) dir, latex_file = os.path.split(argv[2]) if len(dir) != 0: os.chdir(dir) dpi = string.atoi(argv[3]) fg_color = make_texcolor(argv[4], False) bg_color = make_texcolor(argv[... |
vec = [ argv[0], argv[2], argv[3], argv[1], argv[4], argv[5] ] | vec = [ argv[0], argv[2], argv[3], argv[1], argv[4], argv[5], argv[6] ] | def main(argv): # Parse and manipulate the command line arguments. if len(argv) != 6: error(usage(argv[0])) output_format = string.lower(argv[1]) dir, latex_file = os.path.split(argv[2]) if len(dir) != 0: os.chdir(dir) dpi = string.atoi(argv[3]) fg_color = make_texcolor(argv[4], False) bg_color = make_texcolor(argv[... |
cmds = [["Nameref", "vref"], ["nameref", "ref"]] | cmds = ["Nameref", "nameref"] foundone = False rx = re.compile(r'reference "(.*)"') | def revert_nameref(document): " Convert namerefs to regular references " # We cannot really revert these properly, so we will # revert them to commands we understand. cmds = [["Nameref", "vref"], ["nameref", "ref"]] for cmd in cmds: i = 0 oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] while 1: i = ... |
oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] | oldcmd = "LatexCommand " + cmd | def revert_nameref(document): " Convert namerefs to regular references " # We cannot really revert these properly, so we will # revert them to commands we understand. cmds = [["Nameref", "vref"], ["nameref", "ref"]] for cmd in cmds: i = 0 oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] while 1: i = ... |
j = i - 10 if j < 0: j = 0 j = find_token(document.body, "\\begin_inset CommandInset ref", j) if j == -1 or j > i: i += 1 | stins = cmdloc - 10 if stins < 0: stins = 0 stins = find_token(document.body, "\\begin_inset CommandInset ref", stins) if stins == -1 or stins > cmdloc: | def revert_nameref(document): " Convert namerefs to regular references " # We cannot really revert these properly, so we will # revert them to commands we understand. cmds = [["Nameref", "vref"], ["nameref", "ref"]] for cmd in cmds: i = 0 oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] while 1: i = ... |
k = find_end_of_inset(document.body, i) if k == -1: document.warning("Can't find end of inset at line " + j + "!!") i += 1 | endins = find_end_of_inset(document.body, stins) if endins == -1: document.warning("Can't find end of inset at line " + stins + "!!") | def revert_nameref(document): " Convert namerefs to regular references " # We cannot really revert these properly, so we will # revert them to commands we understand. cmds = [["Nameref", "vref"], ["nameref", "ref"]] for cmd in cmds: i = 0 oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] while 1: i = ... |
if k < i: i += 1 | if endins < cmdloc: | def revert_nameref(document): " Convert namerefs to regular references " # We cannot really revert these properly, so we will # revert them to commands we understand. cmds = [["Nameref", "vref"], ["nameref", "ref"]] for cmd in cmds: i = 0 oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] while 1: i = ... |
document.body[i] = newcmd i += 1 | refline = find_token(document.body, "reference", stins) if refline == -1 or refline > endins: document.warning("Can't find reference for inset at line " + stinst + "!!") continue m = rx.match(document.body[refline]) if not m: document.warning("Can't match reference line: " + document.body[ref]) continue foundone = True... | def revert_nameref(document): " Convert namerefs to regular references " # We cannot really revert these properly, so we will # revert them to commands we understand. cmds = [["Nameref", "vref"], ["nameref", "ref"]] for cmd in cmds: i = 0 oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] while 1: i = ... |
[395, []] | [395, []], | def revert_nameref(document): " Convert namerefs to regular references " # We cannot really revert these properly, so we will # revert them to commands we understand. cmds = [["Nameref", "vref"], ["nameref", "ref"]] for cmd in cmds: i = 0 oldcmd = "LatexCommand " + cmd[0] newcmd = "LatexCommand " + cmd[1] while 1: i = ... |
def remove_option(document, m, option): | def remove_option(lines, m, option): | def remove_option(document, m, option): ''' removes option from line m. returns whether we did anything ''' l = document.body[m].find(option) if l == -1: return False val = document.body[m][l:].split('"')[1] document.body[m] = document.body[m][:l - 1] + document.body[m][l+len(option + '="' + val + '"'):] return True |
l = document.body[m].find(option) | l = lines[m].find(option) | def remove_option(document, m, option): ''' removes option from line m. returns whether we did anything ''' l = document.body[m].find(option) if l == -1: return False val = document.body[m][l:].split('"')[1] document.body[m] = document.body[m][:l - 1] + document.body[m][l+len(option + '="' + val + '"'):] return True |
val = document.body[m][l:].split('"')[1] document.body[m] = document.body[m][:l - 1] + document.body[m][l+len(option + '="' + val + '"'):] | val = lines[m][l:].split('"')[1] lines[m] = lines[m][:l - 1] + lines[m][l+len(option + '="' + val + '"'):] | def remove_option(document, m, option): ''' removes option from line m. returns whether we did anything ''' l = document.body[m].find(option) if l == -1: return False val = document.body[m][l:].split('"')[1] document.body[m] = document.body[m][:l - 1] + document.body[m][l+len(option + '="' + val + '"'):] return True |
l = 0 | i = 0 | def revert_align_decimal(document): l = 0 while True: l = document.body[l].find('alignment=decimal') if l == -1: break remove_option(document, l, 'decimal_point') document.body[l].replace('decimal', 'center') |
l = document.body[l].find('alignment=decimal') if l == -1: break remove_option(document, l, 'decimal_point') document.body[l].replace('decimal', 'center') | i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: return j = find_end_of_inset(document.body, i) if j == -1: document.warning("Unable to find end of Tabular inset at line " + str(i)) i += 1 continue cell = find_token(document.body, "<cell", i, j) if cell == -1: document.warning("Can't find any cells... | def revert_align_decimal(document): l = 0 while True: l = document.body[l].find('alignment=decimal') if l == -1: break remove_option(document, l, 'decimal_point') document.body[l].replace('decimal', 'center') |
newval = "MathML" | newval = "0" | def convert_math_output(document): " Convert \html_use_mathml to \html_math_output " i = find_token(document.header, "\\html_use_mathml", 0) if i == -1: return rgx = re.compile(r'\\html_use_mathml\s+(\w+)') m = rgx.match(document.header[i]) if rgx: newval = "MathML" val = m.group(1) if val != "true": newval = "Images" ... |
newval = "Images" | newval = "2" | def convert_math_output(document): " Convert \html_use_mathml to \html_math_output " i = find_token(document.header, "\\html_use_mathml", 0) if i == -1: return rgx = re.compile(r'\\html_use_mathml\s+(\w+)') m = rgx.match(document.header[i]) if rgx: newval = "MathML" val = m.group(1) if val != "true": newval = "Images" ... |
if rgx: newval = "0" val = m.group(1) if val != "true": newval = "2" document.header[i] = "\\html_math_output " + newval | newval = "0" if m: val = m.group(1) if val != "true": newval = "2" else: document.warning("Can't match " + document.header[i]) document.header[i] = "\\html_math_output " + newval | def convert_math_output(document): " Convert \html_use_mathml to \html_math_output " i = find_token(document.header, "\\html_use_mathml", 0) if i == -1: return rgx = re.compile(r'\\html_use_mathml\s+(\w+)') m = rgx.match(document.header[i]) if rgx: newval = "0" # MathML val = m.group(1) if val != "true": newval = "2" #... |
if line.find("\\ce{") != -1 or line.find("\\cf{") != 1: | if line.find("\\ce{") != -1 or line.find("\\cf{") != -1: | def revert_mhchem(document): "Revert mhchem loading to preamble code" mhchem = "off" i = find_token(document.header, "\\use_mhchem", 0) if i == -1: document.warning("Malformed LyX document: Could not find mhchem setting.") mhchem = "auto" else: val = get_value(document.header, "\\use_mhchem", i) if val == "1": mhchem ... |
val = get_value(document.header, "\\use_mathdots", mathdots) | def revert_mathdots(document): " Load mathdots if used in the document " mathdots = find_token(document.header, "\\use_mathdots" , 0) if mathdots == -1: document.warning("No \\usemathdots line. Assuming auto.") else: del document.header[mathdots] val = get_value(document.header, "\\use_mathdots", mathdots) try: usedot... | |
j = find_end_of_inset(document.body, i + 1) | j = find_end_of_inset(document.body, i) | def revert_tablines(document): i = 0 while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: return j = find_end_of_inset(document.body, i + 1) if j == -1: document.warning("Malformed LyX document: Could not find end of tabular.") continue m = i + 1 nrows = int(document.body[i+1].split('"')[3... |
if j > i + 6 or j == -1: | if j == -1: | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i == -1: return # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document... |
k = find_token(document.body, 'offset', i, j) if k != -1: offset = document.body[k][8:-1] else: offset = "" | offset = get_value(document.body, 'offset', i, j).strip('"') if offset: offset = '[' + offset + ']' | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i == -1: return # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document... |
l = find_token(document.body, 'width', i, j) if l != -1: width = document.body[l][7:-1] else: width = "100col%" | width = get_value(document.body, 'width', i, j, "100col%").strip('"') width = latex_length(width)[1] | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i == -1: return # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document... |
m = find_token(document.body, 'height', i, j) if m != -1: height = document.body[m][8:-1] else: height = "1pt" | height = get_value(document.body, 'height', i, j, "1pt").strip('"') height = latex_length(height)[1] | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i == -1: return # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document... |
if offset: subst = "\\rule[" + offset + "]{" + width + "}{" + height + "}" else: subst = "\\rule{" + width + "}{" + height + "}" | subst = "\\rule[" + offset + "]{" + width + "}{" + height + "}" | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i == -1: return # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document... |
i += 1 | i += len(subst) - (j - i) | def revert_rule(document): " Revert line insets to Tex code " i = 0 while 1: i = find_token(document.body, "\\begin_inset CommandInset line" , i) if i == -1: return # find end of inset j = find_token(document.body, "\\end_inset" , i) # assure we found the end_inset of the current inset if j > i + 6 or j == -1: document... |
if not self.root: logger.error("Not rooted, run 'mrsd init'.") return | if pargs.list_instances: names = [] for inst in self.cfg.get('reload', {}).get('instances', []): name = inst.get('name') if name: names.append(name) return names | def __call__(self, dists=None, pargs=None): if not self.root: logger.error("Not rooted, run 'mrsd init'.") return |
help='Zope-Username for logging into ZMI') | help='Zope-Username for logging into ZMI.') | def init_argparser(self, parser): """Add our arguments to a parser """ |
help='Password of Zope-User (--user)') | help='Password of Zope-User (--user).') | def init_argparser(self, parser): """Add our arguments to a parser """ |
help='Hostname where zope is running at') | help='Hostname where zope is running at.') | def init_argparser(self, parser): """Add our arguments to a parser """ |
help='Port where zope is running at') | help='Port where zope is running at.') | def init_argparser(self, parser): """Add our arguments to a parser """ |
help='Select a zope instance to reload') | help='Select a zope instance to reload.') parser.add_argument( '--list-instances', dest='list_instances', action='store_true', default=False, help='Lists all available instances.') | def init_argparser(self, parser): """Add our arguments to a parser """ |
for partname in enabled_parts: | for partname in enabled_parts.split(): | def _configure(self, buildout): """Called by the unload extension if mrsd.developer is defined in the extension of the buildout. This method looks up instance parts in buildout and stores host, port, username and password in the mrsd config file, which is then used as default values. """ |
if part.get('recipe') in supported_recipes: | if part and part.get('recipe') in supported_recipes: | def _configure(self, buildout): """Called by the unload extension if mrsd.developer is defined in the extension of the buildout. This method looks up instance parts in buildout and stores host, port, username and password in the mrsd config file, which is then used as default values. """ |
expargs = [sys.argv[0]] | expargs = [] | def __call__(self): parser = argparse.ArgumentParser( prog=self.name, formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) parser.add_argument( '-d', '--debug', dest='debug', action='store_true', default=False, help="Enable debugging output.", ) subparsers = parser.add_subparsers(help='cmd --help') for name, cmd i... |
if pargs.instance: | if getattr(pargs, 'instance', None): | def __call__(self, dists=None, pargs=None): if pargs.list_instances: names = [] for inst in self.cfg.get('reload', {}).get('instances', []): name = inst.get('name') if name: names.append(name) return names |
def generate(self, namespace): | def generate(self): | def generate(self, namespace): """Generate patches from customized bdists. """ check_call(['git', 'add', '.'], cwd=target.abspath) |
""" check_call(['git', 'add', '.'], cwd=target.abspath) | Limitations for now: one patchset per bdist, only apply to bdist with the same name. """ for name, abspath in self.cmds.list('cloned').items(): patches_dir = self.cfg['patches_dir'] if not os.path.isabs(patches_dir): patches_dir = os.path.join(self.root, patches_dir) targetdir = os.path.join(patches_dir, name) if not ... | def generate(self, namespace): """Generate patches from customized bdists. """ check_call(['git', 'add', '.'], cwd=target.abspath) |
pass def _patch(self, egg, patches): """Apply patches to egg """ for patch in patches: patch(egg) | pargs.action() | def __call__(self, pargs=None): |
return [x.abspath for x in cloned.values()] | return dict((x.__name__, x.abspath) for x in cloned.values()) | def __call__(self, channels=None, pargs=None): """So far we just list all distributions used by the current env """ if not os.path.isdir(os.path.join(self.root, 'eggs-mrsd')): os.mkdir(os.path.join(self.root, 'eggs-mrsd')) if not self.root: logger.error("Not rooted, run 'mrsd init'.") return if channels is None: if par... |
const=self.list help=self.list.__doc__ | const=self.list, help=self.list.__doc__, | def init_argparser(self, parser): """Add our arguments to a parser """ actions = parser.add_mutually_exclusive_group() action.add_argument( '--list', dest='action', action='store_const', const=self.list help=self.list.__doc__ default=True, ) action.add_argument( '--generate', dest='action', action='store_const', const=... |
const=self.generate help=self.list.__doc__ | const=self.generate, help=self.list.__doc__, | def init_argparser(self, parser): """Add our arguments to a parser """ actions = parser.add_mutually_exclusive_group() action.add_argument( '--list', dest='action', action='store_const', const=self.list help=self.list.__doc__ default=True, ) action.add_argument( '--generate', dest='action', action='store_const', const=... |
patches_dir = self.cfg.setdefault('patches_dir', 'eggs-patches') patches_dir = os.path.join( self.root or os.curdir, patches_dir, ) if not os.path.isdir(patches_dir): os.mkdir(patches_dir) | self.cfg.setdefault('patches_dir', 'eggs-patches') | def _initialize(self): # read a list of available patches patches_dir = self.cfg.setdefault('patches_dir', 'eggs-patches') patches_dir = os.path.join( self.root or os.curdir, patches_dir, ) if not os.path.isdir(patches_dir): os.mkdir(patches_dir) |
return [x for x in Directory(self.cfg['patches_dir'])] | return [x for x in Directory(self.patches_dir)] | def list(self): """List patches. """ return [x for x in Directory(self.cfg['patches_dir'])] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.