bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: m = re_badbox.match(line) if m: skipping = 1 else: self.update_file(line, pos) return something
6,200
def do_depend (self, *args): for arg in args: file = self.env.find_file(arg) if file: self.sources[file] = DependLeaf(self.env, file) else: msg.warn(_("dependency '%s' not found") % arg, **pos)
def do_depend (self, *args): for arg in args: file = self.env.find_file(arg) if file: self.sources[file] = DependLeaf(self.env, file) else: msg.warn(_("dependency '%s' not found") % arg, **pos)
6,201
def bibtex_needed (self): """ Return true if BibTeX must be run. """ if self.run_needed: return 1 self.msg(2, _("checking if BibTeX must be run..."))
def bibtex_needed (self): """ Return true if BibTeX must be run. """ if self.run_needed: return 1 self.msg(2, _("checking if BibTeX must be run..."))
6,202
def bibtex_needed (self): """ Return true if BibTeX must be run. """ if self.run_needed: return 1 self.msg(2, _("checking if BibTeX must be run..."))
def bibtex_needed (self): """ Return true if BibTeX must be run. """ if self.run_needed: return 1 self.msg(2, _("checking if BibTeX must be run..."))
6,203
def execute (self, prog, env={}): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The output is dicarded, but messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if env != {}: self.msg(2, _("with environment: %r") % env)
def execute (self, prog, env={}): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The output is dicarded, but messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if env != {}: self.msg(2, _("with environment: %r") % env)
6,204
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in file.readlines(): m = re_input.search(line) if m: self.include(m["file"]) fd.close()
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in fd.readlines(): m = re_input.search(line) if m: self.include(m["file"]) fd.close()
6,205
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in file.readlines(): m = re_input.search(line) if m: self.include(m["file"]) fd.close()
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in file.readlines(): m = re_input.search(line) if m: self.include(m.group("file"), list) fd.close()
6,206
def error (self, file, line, text, code): """ This method is called when the parsing of the log file found an error. The arguments are, respectively, the name of the file and the line number where the error occurred, the description of the error, and the offending code (up to the error). """ self.write(0, _("\nline %d in %s:\n %s") % (line, file, text)) if string.strip(code) != "": self.write(0, " --> " + code)
def error (self, file, line, text, code): """ This method is called when the parsing of the log file found an error. The arguments are, respectively, the name of the file and the line number where the error occurred, the description of the error, and the offending code (up to the error). """ self.write(0, _("\nline %d in %s:\n %s") % (line, file, text)) if code: self.write(0, " --> " + code)
6,207
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
6,208
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif parsing: m = re_line.match(line) if m: parsing = 0 skipping = 1 self.msg.error(pos[-1], int(m.group("line")), error, line[m.end():]) elif line[0:3] == "***": parsing = 0 skipping = 1 self.msg.abort(error, line[4:]) elif line[0] == "!": error = line[2:] parsing = 1 something = 1 else: # Here there is no error to show, so we use the text of the # line to track the source file name. However, there might be # confusing text in the log file, in particular when there is # an overfull/underfull box message (the text following this # is extracted from the source, and the extract may contain # unbalanced parentheses). Therefore we take care of this # specifically.
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif parsing: m = re_line.match(line) if m: parsing = 0 skipping = 1 self.msg.error(pos[-1], int(m.group("line")), error, m.group("text")) elif line[0:3] == "***": parsing = 0 skipping = 1 self.msg.abort(error, line[4:]) elif line[0] == "!": error = line[2:] parsing = 1 something = 1 else: # Here there is no error to show, so we use the text of the # line to track the source file name. However, there might be # confusing text in the log file, in particular when there is # an overfull/underfull box message (the text following this # is extracted from the source, and the extract may contain # unbalanced parentheses). Therefore we take care of this # specifically.
6,209
def __init__ (self, target, source, env): leaf = DependLeaf([source]) Depend.__init__(self, [target], {source: leaf}) self.env = env self.base = target[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base]
def __init__ (self, target, source, env): leaf = DependLeaf([source]) Depend.__init__(self, [target], {source: leaf}) self.env = env self.base = source[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base]
6,210
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = [] page = 1 something = 0 for line in self.lines: line = line.rstrip() if re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = ["(no file)"] page = 1 something = 0 for line in self.lines: line = line.rstrip() if re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,211
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = [] page = 1 something = 0 for line in self.lines: line = line.rstrip() if re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = [] page = 1 something = 0 for line in self.lines: line = line.rstrip() if skip: if line == "": skip = 0 elif re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,212
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = [] page = 1 something = 0 for line in self.lines: if line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = ["(no file)"] page = 1 something = 0 for line in self.lines: if line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,213
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = [] page = 1 something = 0 for line in self.lines: if line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = [] page = 1 something = 0 for line in self.lines: if skip: if line == "": skip = 0 elif re_hvbox.match(line): skip = 1 elif line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,214
def execute (self, prog, env={}): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The output is dicarded, but messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if env != {}: self.msg(2, _("with environment: %r") % env)
def execute (self, prog, env={}): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The output is dicarded, but messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if env != {}: self.msg(2, _("with environment: %r") % env)
6,215
def __init__ (self, env, tex, fig, vars, module=None, loc={}): """ The arguments of the constructor are, respectively, the figure's source, the LaTeX source produced, the EPS figure produced, the name to use for it (probably the same one), and the environment. """ leaf = DependLeaf(env, fig, loc=loc) self.env = env
def __init__ (self, env, tex, fig, vars, module=None, loc={}): """ The arguments of the constructor are, respectively, the figure's source, the LaTeX source produced, the EPS figure produced, the name to use for it (probably the same one), and the environment. """ leaf = DependLeaf(env, fig, loc=loc) self.env = env
6,216
def load_module (self, name, package=None): """ Attempt to register a module with the specified name. If an appropriate module is found, load it and store it in the object's dictionary. Return 0 if no module was found, 1 if a module was found and loaded, and 2 if the module was found but already loaded. """ if self.modules.has_key(name): return 2 try: file, path, descr = imp.find_module(name, [""]) except ImportError: if not package: return 0 try: pname = "" for p in package.split("."): pname = os.path.join(pname, p) file, path, descr = imp.find_module(join(pname, name)); except ImportError: return 0 module = imp.load_module(name, file, path, descr) file.close() self.modules[name] = module return 1
def load_module (self, name, package=None): """ Attempt to register a module with the specified name. If an appropriate module is found, load it and store it in the object's dictionary. Return 0 if no module was found, 1 if a module was found and loaded, and 2 if the module was found but already loaded. """ if self.modules.has_key(name): return 2 try: file, path, descr = imp.find_module(name, [""]) except ImportError: if not package: return 0 try: pname = "" for p in package.split("."): pname = os.path.join(pname, p) file, path, descr = imp.find_module(os.path.join(pname, name)); except ImportError: return 0 module = imp.load_module(name, file, path, descr) file.close() self.modules[name] = module return 1
6,217
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.pbase = doc.src_base self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.pbase = doc.src_base self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
6,218
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
6,219
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
6,220
def makeindex (self, dict): """ Register the standard index. """ self.indices["default"] = Index(self.doc, "idx", "ind", "ilg")
def makeindex (self, dict): """ Register the standard index. """ self.indices["default"] = Index(self.doc, "idx", "ind", "ilg")
6,221
def newindex (self, dict): """ Register a new index. """ m = re_newindex.match(dict["line"]) if not m: return index = dict["arg"] d = m.groupdict() self.indices[index] = Index(self.doc, d["idx"], d["ind"], "ilg") msg.log(_("index %s registered") % index, pkg="index")
def newindex (self, dict): """ Register a new index. """ m = re_newindex.match(dict["line"]) if not m: return index = dict["arg"] d = m.groupdict() self.register(index, d["idx"], d["ind"], "ilg") msg.log(_("index %s registered") % index, pkg="index")
6,222
def command (self, cmd, args): indices = self.indices if len(args) > 0: m = re_optarg.match(args[0]) if m: for index in m.group("list").split(","): if indices.has_key(index): indices[index].command(cmd, args[1:]) else: for index in indices.values(): index.command(cmd, args)
def command (self, cmd, args): indices = self.indices if len(args) > 0: m = re_optarg.match(args[0]) if m: for index in m.group("list").split(","): if indices.has_key(index): indices[index].command(cmd, args[1:]) else: for index in indices.values(): index.command(cmd, args)
6,223
def check (source, target, suffixes=suffixes): if self.env.may_produce(source): return 0 if suffixes == [""]: return 1 for suffix in suffixes: if source[-len(suffix):] == suffix: return 0 return 1
def check (source, target, suffixes=suffixes): if exists(target) and self.env.may_produce(source): return 0 if suffixes == [""]: return 1 for suffix in suffixes: if source[-len(suffix):] == suffix: return 0 return 1
6,224
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = [] page = 1 something = 0 for line in self.lines: line = line.rstrip() if re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = ["(no file)"] page = 1 something = 0 for line in self.lines: line = line.rstrip() if re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,225
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = [] page = 1 something = 0 for line in self.lines: line = line.rstrip() if re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_boxes (self): """ Display all messages related so underfull and overfull boxes. Return 0 if there is nothing to display. """ pos = [] page = 1 something = 0 for line in self.lines: line = line.rstrip() if skip: if line == "": skip = 0 elif re_hvbox.match(line): self.msg.info({"file":pos[-1], "page":page}, line) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,226
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = [] page = 1 something = 0 for line in self.lines: if line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = ["(no file)"] page = 1 something = 0 for line in self.lines: if line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,227
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = [] page = 1 something = 0 for line in self.lines: if line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
def show_warnings (self): """ Display all warnings. This function is pathetically dumb, as it simply shows all lines in the log that contain the substring 'Warning'. """ pos = [] page = 1 something = 0 for line in self.lines: if skip: if line == "": skip = 0 elif re_hvbox.match(line): skip = 1 elif line.find("Warning") != -1: self.msg.info( {"file":pos[-1], "page":page}, string.rstrip(line)) something = 1 else: self.update_file(line, pos) page = self.update_page(line, page) return something
6,228
def do_watch (self, *args): for arg in args: self.watch_file(arg)
def do_watch (self, *args): for arg in args: self.watch_file(arg)
6,229
def pre_compile (self): """ Prepare the source for compilation using package-specific functions. This function must return true on failure. This function sets `must_compile' to 1 if we already know that a compilation is needed, because it may avoid some unnecessary preprocessing (e.g. BibTeXing). """ if os.path.exists(self.src_base + ".aux"): self.aux_md5 = md5_file(self.src_base + ".aux") else: self.aux_md5 = None self.aux_md5_old = None
def pre_compile (self): """ Prepare the source for compilation using package-specific functions. This function must return true on failure. This function sets `must_compile' to 1 if we already know that a compilation is needed, because it may avoid some unnecessary preprocessing (e.g. BibTeXing). """ if os.path.exists(self.src_base + ".aux"): self.aux_md5 = md5_file(self.src_base + ".aux") else: self.aux_md5 = None self.aux_md5_old = None
6,230
def post_compile (self): """ Run the package-specific operations that are to be performed after each compilation of the main source. Returns true on failure. """ msg.log(_("running post-compilation scripts..."))
def post_compile (self): """ Run the package-specific operations that are to be performed after each compilation of the main source. Returns true on failure. """ msg.log(_("running post-compilation scripts..."))
6,231
def show_errors (self): self.log.show_errors()
def show_errors (self): self.log.show_errors()
6,232
def __init__ (self, env, dict): self.env = env env.add_hook("verbatimtabinput", self.input) env.add_hook("listinginput", self.input)
def __init__ (self, env, dict): self.env = env env.add_hook("verbatimtabinput", self.input) env.add_hook("listinginput", self.input)
6,233
def __init__ (self, env, dict): """ Initialize the state of the module and register appropriate functions in the main process. """ self.env = env self.msg = env.msg
def __init__ (self, env, dict): """ Initialize the state of the module and register appropriate functions in the main process. """ self.env = env self.msg = env.msg
6,234
def first_bib (self): """ Run BibTeX if needed before the first compilation. """ self.run_needed = self.first_run_needed() if self.env.must_compile: return 0 if self.run_needed: return self.run()
def first_bib (self): """ Run BibTeX if needed before the first compilation. This function also checks if BibTeX has been run by someone else, and in this case it tells the system that it should recompile the document. """ self.run_needed = self.first_run_needed() if self.env.must_compile: return 0 if self.run_needed: return self.run()
6,235
def run (self): """ This method actually runs BibTeX. """ self.msg(0, _("running BibTeX...")) if self.env.src_path != "": env = { "BIBINPUTS": "%s:%s" % (self.env.src_path, os.getenv("BIBINPUTS", "")) } else: env = {} if self.env.execute(["bibtex", "-terse", self.env.src_base], env): self.env.msg(0, _( "There were errors running BibTeX (see %s for details)." ) % (self.env.src_base + ".blg")) return 1 self.run_needed = 0 self.env.must_compile = 1 return 0
def run (self): """ This method actually runs BibTeX. """ self.msg(0, _("running BibTeX...")) if self.env.src_path != "": env = { "BIBINPUTS": "%s:%s" % (self.env.src_path, os.getenv("BIBINPUTS", "")) } else: env = {} if self.env.execute(["bibtex", self.env.src_base], env): self.env.msg(0, _( "There were errors running BibTeX (see %s for details)." ) % (self.env.src_base + ".blg")) return 1 self.run_needed = 0 self.env.must_compile = 1 return 0
6,236
def make (self): """ Make the destination file. This recursively makes all dependencies, then compiles the target if dependencies were modified. The semantics of the return value is the following: - 0 means that the process failed somewhere (in this node or in one of its dependencies) - 1 means that nothing had to be done - 2 means that something was recompiled (therefore nodes that depend on this one have to be remade) """ must_make = 0 for src in self.sources.values(): ret = src.make() if ret == 0: return 0 if ret == 2: must_make = 1 if must_make or self.should_make(): if self.run(): return 0 self.date = time.time() return 2 return 1
def make (self): """ Make the destination file. This recursively makes all dependencies, then compiles the target if dependencies were modified. The semantics of the return value is the following: - 0 means that the process failed somewhere (in this node or in one of its dependencies) - 1 means that nothing had to be done - 2 means that something was recompiled (therefore nodes that depend on this one have to be remade) """ must_make = 0 for src in self.sources.values(): ret = src.make() if ret == 0: return 0 if ret == 2: must_make = 1 if must_make or self.should_make(): if self.run(): return 0 self.date = int(time.time()) return 2 return 1
6,237
def __init__ (self, target, source, env): sources = [] self.include(source, sources) env.msg(2, "%s is made from %r" % (target, sources)) self.leaf = DependLeaf(sources) Depend.__init__(self, [target], {source: self.leaf}) self.env = env self.base = source[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base] if env.src_path != "": cmd = [ "env", "MPINPUTS=:%s:%s" % (self.env.src_path, os.getenv("MPINPUTS", ""))] + cmd
def __init__ (self, target, source, env): sources = [] self.include(source, sources) env.msg(2, _("%s is made from %r") % (target, sources)) self.leaf = DependLeaf(sources) Depend.__init__(self, [target], {source: self.leaf}) self.env = env self.base = source[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base] if env.src_path != "": cmd = [ "env", "MPINPUTS=:%s:%s" % (self.env.src_path, os.getenv("MPINPUTS", ""))] + cmd
6,238
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
def run (self): self.env.msg(0, _("running Metapost on %s.mp...") % self.base) self.env.execute(self.cmd)
6,239
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
6,240
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
6,241
def do_setup (): """ Run the setup() function from the distutils with appropriate arguments. """ from distutils.core import setup try: mandir = expand_vars(settings.sub, settings.sub["mandir"]) except NameError: mandir = "man" setup( name = "rubber", version = settings.sub["version"], description = "The Rubber system for building LaTeX documents", long_description = """\
def do_setup (): """ Run the setup() function from the distutils with appropriate arguments. """ from distutils.core import setup try: mandir = expand_vars(settings.sub, settings.sub["mandir"]) except NameError: mandir = "man" setup( name = "rubber", version = settings.sub["version"], description = "The Rubber system for building LaTeX documents", long_description = """\
6,242
def do_depend (self, *args): for arg in args: file = self.env.find_file(arg) if file: self.sources[file] = DependLeaf(self.env, file) else: msg.warn(_("dependency '%s' not found") % arg, **pos)
def do_depend (self, *args): for arg in args: file = self.env.find_file(arg) if file: self.sources[file] = DependLeaf(self.env, file) else: msg.warn(_("dependency '%s' not found") % arg, **pos)
6,243
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in file.readlines(): m = re_input.search(line) if m: self.include(m["file"]) fd.close()
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in fd.readlines(): m = re_input.search(line) if m: self.include(m["file"]) fd.close()
6,244
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in file.readlines(): m = re_input.search(line) if m: self.include(m["file"]) fd.close()
def include (self, source, list): """ This function tries to find a specified MetaPost source (currently all in the same directory), appends its actual name to the list, and parses it to find recursively included files. """ if exists(source + ".mp"): file = source + ".mp" elif exists(source): file = source else: return list.append(file) fd = open(file) for line in file.readlines(): m = re_input.search(line) if m: self.include(m.group("file"), list) fd.close()
6,245
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
6,246
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
6,247
def main (self, cmdline): self.env = Environment(self.msg) self.modules = [] self.act = None args = self.parse_opts(cmdline) self.msg(1, _( "This is Rubber's information extractor version %s.") % version)
def main (self, cmdline): self.env = Environment(self.msg) self.modules = [] self.act = None args = self.parse_opts(cmdline) self.msg(1, _( "This is Rubber's information extractor version %s.") % version)
6,248
def prepare (self, src): """ Check for the source file and prepare it for processing. """ if self.env.prepare(src): sys.exit(1) for mod in self.modules: colon = mod.find(":") if colon == -1: if self.env.modules.register(mod, { "arg": mod, "opt": None }): self.msg( 0, _("module %s could not be registered") % mod) else: arg = { "arg": mod[:colon], "opt": mod[colon+1:] } mod = mod[0:colon] if self.env.modules.register(mod, arg): self.msg( 0, _("module %s could not be registered") % mod) self.env.parse()
def prepare (self, src): """ Check for the source file and prepare it for processing. """ if self.env.set_source(src): sys.exit(1) if self.env.make_source(): sys.exit(1) for mod in self.modules: colon = mod.find(":") if colon == -1: if self.env.modules.register(mod, { "arg": mod, "opt": None }): self.msg( 0, _("module %s could not be registered") % mod) else: arg = { "arg": mod[:colon], "opt": mod[colon+1:] } mod = mod[0:colon] if self.env.modules.register(mod, arg): self.msg( 0, _("module %s could not be registered") % mod) self.env.parse()
6,249
def do_watch (self, *args): for arg in args: self.watch_file(arg)
def do_watch (self, *args): for arg in args: self.watch_file(arg)
6,250
def pre_compile (self): """ Prepare the source for compilation using package-specific functions. This function must return true on failure. This function sets `must_compile' to 1 if we already know that a compilation is needed, because it may avoid some unnecessary preprocessing (e.g. BibTeXing). """ if os.path.exists(self.src_base + ".aux"): self.aux_md5 = md5_file(self.src_base + ".aux") else: self.aux_md5 = None self.aux_md5_old = None
def pre_compile (self): """ Prepare the source for compilation using package-specific functions. This function must return true on failure. This function sets `must_compile' to 1 if we already know that a compilation is needed, because it may avoid some unnecessary preprocessing (e.g. BibTeXing). """ if os.path.exists(self.src_base + ".aux"): self.aux_md5 = md5_file(self.src_base + ".aux") else: self.aux_md5 = None self.aux_md5_old = None
6,251
def post_compile (self): """ Run the package-specific operations that are to be performed after each compilation of the main source. Returns true on failure. """ msg.log(_("running post-compilation scripts..."))
def post_compile (self): """ Run the package-specific operations that are to be performed after each compilation of the main source. Returns true on failure. """ msg.log(_("running post-compilation scripts..."))
6,252
def show_errors (self): self.log.show_errors()
def show_errors (self): self.log.show_errors()
6,253
def __init__ (self, env, dict): """ Initialize the state of the module and register appropriate functions in the main process. """ self.env = env self.msg = env.msg
def __init__ (self, env, dict): """ Initialize the state of the module and register appropriate functions in the main process. """ self.env = env self.msg = env.msg
6,254
def first_bib (self): """ Run BibTeX if needed before the first compilation. """ self.run_needed = self.first_run_needed() if self.env.must_compile: return 0 if self.run_needed: return self.run()
def first_bib (self): """ Run BibTeX if needed before the first compilation. This function also checks if BibTeX has been run by someone else, and in this case it tells the system that it should recompile the document. """ self.run_needed = self.first_run_needed() if self.env.must_compile: return 0 if self.run_needed: return self.run()
6,255
def run (self): """ This method actually runs BibTeX. """ self.msg(0, _("running BibTeX...")) if self.env.src_path != "": env = { "BIBINPUTS": "%s:%s" % (self.env.src_path, os.getenv("BIBINPUTS", "")) } else: env = {} if self.env.execute(["bibtex", "-terse", self.env.src_base], env): self.env.msg(0, _( "There were errors running BibTeX (see %s for details)." ) % (self.env.src_base + ".blg")) return 1 self.run_needed = 0 self.env.must_compile = 1 return 0
def run (self): """ This method actually runs BibTeX. """ self.msg(0, _("running BibTeX...")) if self.env.src_path != "": env = { "BIBINPUTS": "%s:%s" % (self.env.src_path, os.getenv("BIBINPUTS", "")) } else: env = {} if self.env.execute(["bibtex", self.env.src_base], env): self.env.msg(0, _( "There were errors running BibTeX (see %s for details)." ) % (self.env.src_base + ".blg")) return 1 self.run_needed = 0 self.env.must_compile = 1 return 0
6,256
def __init__ (self, target, source, env): leaf = DependLeaf([source]) Depend.__init__(self, [target], {source: leaf}) self.env = env self.base = target[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base]
def __init__ (self, target, source, env): leaf = DependLeaf([source]) Depend.__init__(self, [target], {source: leaf}) self.env = env self.base = source[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base]
6,257
# default suffixes for each device driver (taken from the .def files)
# default suffixes for each device driver (taken from the .def files)
6,258
def __init__ (self, env, tex, fig, vars, module=None, loc={}): """ The arguments of the constructor are, respectively, the figure's source, the LaTeX source produced, the EPS figure produced, the name to use for it (probably the same one), and the environment. """ leaf = DependLeaf(env, fig, loc=loc) self.env = env
def __init__ (self, env, tex, fig, vars, module=None, loc={}): """ The arguments of the constructor are, respectively, the figure's source, the LaTeX source produced, the EPS figure produced, the name to use for it (probably the same one), and the environment. """ leaf = DependLeaf(env, fig, loc=loc) self.env = env
6,259
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
6,260
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = self.vars.copy() for (key, val) in dict.items(): self.vars[key] = val self.vars_stack.append(saved)
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = {} for (key, val) in dict.items(): self.vars[key] = val self.vars_stack.append(saved)
6,261
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars = self.vars_stack[-1] del self.vars_stack[-1]
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars.update(self.vars_stack[-1]) del self.vars_stack[-1]
6,262
def __init__ (self, env, dict):
def __init__ (self, env, dict):
6,263
def run (self): if not self.expand_needed(): return 0 self.msg(0, _("writing %s...") % (self.out)) self.out_stream = open(self.out, "w") try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n") self.out_stream.close() self.env.something_done = 1
def run (self): self.msg(0, _("writing %s...") % (self.out)) self.out_stream = open(self.out, "w") try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n") self.out_stream.close() self.env.something_done = 1
6,264
def run (self): if not self.expand_needed(): return 0 self.msg(0, _("writing %s...") % (self.out)) self.out_stream = open(self.out, "w") try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n") self.out_stream.close() self.env.something_done = 1
def run (self): if not self.expand_needed(): return 0 self.msg(0, _("writing %s...") % (self.out)) self.out_stream = open(self.out, "w") try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n") self.out_stream.close() self.env.something_done = 1
6,265
def expand_path (self, path): # self.out_stream.write("%%--- beginning of file %s\n" % path) file = open(path)
def expand_path (self, path): # self.out_stream.write("%%--- beginning of file %s\n" % path) file = open(path)
6,266
def x_usepackage (self, dict): if not dict["arg"]: return remaining = []
def x_usepackage (self, dict): if not dict["arg"]: return remaining = []
6,267
def main (self, cmdline): """ Run Rubber for the specified command line. This processes each specified source in order (for making or cleaning). If an error happens while making one of the documents, the whole process stops. The method returns the program's exit code. """ self.prologue = [] self.epilogue = [] self.clean = 0 self.force = 0
def main (self, cmdline): """ Run Rubber for the specified command line. This processes each specified source in order (for making or cleaning). If an error happens while making one of the documents, the whole process stops. The method returns the program's exit code. """ self.prologue = [] self.epilogue = [] self.clean = 0 self.force = 0
6,268
def __init__ (self, message): """ Initialize the environment. This prepares the processing steps for the given file (all steps are initialized empty) and sets the regular expressions and the hook dictionary. """ self.msg = message self.msg(2, _("initializing Rubber..."))
def __init__ (self, message): """ Initialize the environment. This prepares the processing steps for the given file (all steps are initialized empty) and sets the regular expressions and the hook dictionary. """ self.msg = message self.msg(2, _("initializing Rubber..."))
6,269
def restart (self): """ Reinitialize the environment, in order to process a new document. This resets the process and the hook dictionary and unloads modules. """ self.msg(1, _("initializing...")) self.modules.clear() self.initialize()
def restart (self): """ Reinitialize the environment, in order to process a new document. This resets the process and the hook dictionary and unloads modules. """ self.msg(1, _("reinitializing...")) self.modules.clear() self.initialize()
6,270
def h_bibliography (self, dict): """ Called when the macro \\bibliography is found. This method actually registers the module bibtex (if not already done) and registers the databases. """ self.modules.register("bibtex", dict) for db in dict["arg"].split(","): self.modules["bibtex"].add_db(db)
def h_bibliography (self, dict): """ Called when the macro \\bibliography is found. This method actually registers the module bibtex (if not already done) and registers the databases. """ self.modules.register("bibtex", dict) for db in dict["arg"].split(","): self.modules["bibtex"].add_db(db)
6,271
def h_bibliographystyle (self, dict): """ Called when \\bibliographystyle is found. This registers the module bibtex (if not already done) and calls the method set_style() of the module. """ self.modules.register("bibtex", dict) self.modules["bibtex"].set_style(dict["arg"])
def h_bibliographystyle (self, dict): """ Called when \\bibliographystyle is found. This registers the module bibtex (if not already done) and calls the method set_style() of the module. """ self.modules.register("bibtex", dict) self.modules["bibtex"].set_style(dict["arg"])
6,272
def set_source (self, path): """ Specify the main source for the document. The exact path and file name are determined, and the source building process is updated if needed, according the the source file's extension. """ name = self.conf.find_input(path) if not name: self.msg(0, _("cannot find %s") % path) return 1 self.depends = {} (self.src_path, name) = split(name) if self.src_path != "": self.conf.path.append(self.src_path) (self.src_base, self.src_ext) = splitext(name) self.src_pbase = join(self.src_path, self.src_base)
def set_source (self, path): """ Specify the main source for the document. The exact path and file name are determined, and the source building process is updated if needed, according the the source file's extension. """ name = self.conf.find_input(path) if not name: self.msg(0, _("cannot find %s") % path) return 1 self.depends = {} (self.src_path, name) = split(name) if self.src_path == "": self.src_path = "." else: self.conf.path.append(self.src_path) (self.src_base, self.src_ext) = splitext(name) self.src_pbase = join(self.src_path, self.src_base)
6,273
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.pbase = doc.src_base self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
6,274
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
6,275
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
6,276
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test): return test elif exists(test + ".tex"): return test + ".tex" return None
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test) and isfile(test): return test elif exists(test + ".tex"): return test + ".tex" return None
6,277
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test): return test elif exists(test + ".tex"): return test + ".tex" return None
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test): return test elif exists(test + ".tex") and isfile(test + ".tex"): return test + ".tex" return None
6,278
def main (self, cmdline): self.env = Environment(self.msg) self.modules = [] self.act = None args = self.parse_opts(cmdline) self.msg(1, _( "This is Rubber's information extractor version %s.") % version)
def main (self, cmdline): self.env = Environment(self.msg) self.modules = [] self.act = None args = self.parse_opts(cmdline) self.msg(1, _( "This is Rubber's information extractor version %s.") % version)
6,279
def prepare (self, src): """ Check for the source file and prepare it for processing. """ if self.env.prepare(src): sys.exit(1) for mod in self.modules: colon = mod.find(":") if colon == -1: if self.env.modules.register(mod, { "arg": mod, "opt": None }): self.msg( 0, _("module %s could not be registered") % mod) else: arg = { "arg": mod[:colon], "opt": mod[colon+1:] } mod = mod[0:colon] if self.env.modules.register(mod, arg): self.msg( 0, _("module %s could not be registered") % mod) self.env.parse()
def prepare (self, src): """ Check for the source file and prepare it for processing. """ if self.env.set_source(src): sys.exit(1) if self.env.make_source(): sys.exit(1) for mod in self.modules: colon = mod.find(":") if colon == -1: if self.env.modules.register(mod, { "arg": mod, "opt": None }): self.msg( 0, _("module %s could not be registered") % mod) else: arg = { "arg": mod[:colon], "opt": mod[colon+1:] } mod = mod[0:colon] if self.env.modules.register(mod, arg): self.msg( 0, _("module %s could not be registered") % mod) self.env.parse()
6,280
def h_bibliography (self, dict): """ Called when the macro \\bibliography is found. This method actually registers the module bibtex (if not already done) and registers the databases. """ self.modules.register("bibtex", dict) for db in dict["arg"].split(","): self.modules["bibtex"].add_db(db)
def h_bibliography (self, dict): """ Called when the macro \\bibliography is found. This method actually registers the module bibtex (if not already done) and registers the databases. """ self.modules.register("bibtex", dict) for db in dict["arg"].split(","): self.modules["bibtex"].add_db(db)
6,281
def h_bibliographystyle (self, dict): """ Called when \\bibliographystyle is found. This registers the module bibtex (if not already done) and calls the method set_style() of the module. """ self.modules.register("bibtex", dict) self.modules["bibtex"].set_style(dict["arg"])
def h_bibliographystyle (self, dict): """ Called when \\bibliographystyle is found. This registers the module bibtex (if not already done) and calls the method set_style() of the module. """ self.modules.register("bibtex", dict) self.modules["bibtex"].set_style(dict["arg"])
6,282
def set_source (self, path): """ Specify the main source for the document. The exact path and file name are determined, and the source building process is updated if needed, according the the source file's extension. """ name = self.conf.find_input(path) if not name: self.msg(0, _("cannot find %s") % path) return 1 self.depends = {} (self.src_path, name) = split(name) if self.src_path != "": self.conf.path.append(self.src_path) (self.src_base, self.src_ext) = splitext(name) self.src_pbase = join(self.src_path, self.src_base)
def set_source (self, path): """ Specify the main source for the document. The exact path and file name are determined, and the source building process is updated if needed, according the the source file's extension. """ name = self.conf.find_input(path) if not name: self.msg(0, _("cannot find %s") % path) return 1 self.depends = {} (self.src_path, name) = split(name) if self.src_path == "": self.src_path = "." else: self.conf.path.append(self.src_path) (self.src_base, self.src_ext) = splitext(name) self.src_pbase = join(self.src_path, self.src_base)
6,283
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = self.vars.copy() for (key, val) in dict.items(): self.vars[key] = val self.vars_stack.append(saved)
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = {} for (key, val) in dict.items(): self.vars[key] = val self.vars_stack.append(saved)
6,284
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars = self.vars_stack[-1] del self.vars_stack[-1]
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars.update(self.vars_stack[-1]) del self.vars_stack[-1]
6,285
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = {} for (key, val) in dict.items(): saved[key] = self.vars[key] self.vars[key] = val self.vars_stack.append(saved)
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = self.vars.copy() for (key, val) in dict.items(): saved[key] = self.vars[key] self.vars[key] = val self.vars_stack.append(saved)
6,286
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = {} for (key, val) in dict.items(): saved[key] = self.vars[key] self.vars[key] = val self.vars_stack.append(saved)
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = {} for (key, val) in dict.items(): self.vars[key] = val self.vars_stack.append(saved)
6,287
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars.update(self.vars_stack[-1]) del self.vars_stack[-1]
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars = self.vars_stack[-1] del self.vars_stack[-1]
6,288
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
6,289
def update_file (self, line, stack): """ Parse the given line of log file for file openings and closings and update the list `stack'. Newly opened files are at the end, therefore stack[0] is the main source while stack[-1] is the current one. """ m = re_file.search(line) if not m: return while m: if line[m.start()] == '(': stack.append(m.group("file")) else: del stack[-1] line = line[m.end():] m = re_file.search(line) return
def update_file (self, line, stack): """ Parse the given line of log file for file openings and closings and update the list `stack'. Newly opened files are at the end, therefore stack[1] is the main source while stack[-1] is the current one. The first element, stack[0], contains the string \"(no file)\" for errors that may happen outside the source. """ m = re_file.search(line) if not m: return while m: if line[m.start()] == '(': stack.append(m.group("file")) else: del stack[-1] line = line[m.end():] m = re_file.search(line) return
6,290
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 skipping = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
6,291
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
6,292
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: m = re_badbox.match(line) if m: skipping = 1 else: self.update_file(line, pos) return something
6,293
def __init__ (self, level=1, write=None): """ Initialize the object with the specified verbosity level and an optional writing function. If no such function is specified, no message will be output until the 'write' field is changed. """ self.level = level self.write = write self.short = 0 self.path = "" self.cwd = join(curdir, "")
def __init__ (self, level=1, write=None): """ Initialize the object with the specified verbosity level and an optional writing function. If no such function is specified, no message will be output until the 'write' field is changed. """ self.level = level self.write = write self.short = 0 self.path = "" self.cwd = join(curdir, "")
6,294
def read_ini (self, filename): """ Read a set of rules from a file. See the texinfo documentation for the expected format of this file. """ from ConfigParser import ConfigParser cp = ConfigParser() cp.read(filename) for name in cp.sections(): rule = dict(cp.items(name)) rule["cost"] = cost = cp.getint(name, "cost") expr = re.compile(rule["target"] + "$") self.rules[name] = (expr, cost, rule)
def read_ini (self, filename): """ Read a set of rules from a file. See the texinfo documentation for the expected format of this file. """ from ConfigParser import ConfigParser cp = ConfigParser() cp.read(filename) for name in cp.sections(): rule = {} for key in cp.options(name): rule[key] = cp.get(name, key) rule["cost"] = cost = cp.getint(name, "cost") expr = re.compile(rule["target"] + "$") self.rules[name] = (expr, cost, rule)
6,295
def parse (self, errors=0, boxes=0, refs=0, warnings=0): """ Parse the log file for relevant information. The named arguments are booleans that indicate which information should be extracted: - errors: all errors - boxes: bad boxes - refs: warnings about references - warnings: all other warnings The function returns a generator. Each generated item is a dictionary that contains (some of) the following entries: - kind: the kind of information ("error", "box", "ref", "warning") - text: the text of the error or warning - code: the piece of code that caused an error - file, line, last, pkg: as used by Message.format_pos. """ if not self.lines: return last_file = None pos = [last_file] page = 1 parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found prefix = None # the prefix for warning messages from packages accu = "" # accumulated text from the previous line for line in self.lines: line = line[:-1] # remove the line feed
def parse (self, errors=0, boxes=0, refs=0, warnings=0): """ Parse the log file for relevant information. The named arguments are booleans that indicate which information should be extracted: - errors: all errors - boxes: bad boxes - refs: warnings about references - warnings: all other warnings The function returns a generator. Each generated item is a dictionary that contains (some of) the following entries: - kind: the kind of information ("error", "box", "ref", "warning") - text: the text of the error or warning - code: the piece of code that caused an error - file, line, last, pkg: as used by Message.format_pos. """ if not self.lines: return last_file = None pos = [last_file] page = 1 parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found prefix = None # the prefix for warning messages from packages accu = "" # accumulated text from the previous line for line in self.lines: line = line[:-1] # remove the line feed
6,296
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
6,297
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
6,298
def bibtex_needed (self): """ Return true if BibTeX must be run. """ if self.run_needed: return 1 self.msg(2, _("checking if BibTeX must be run..."))
def bibtex_needed (self): """ Return true if BibTeX must be run. """ if self.run_needed: return 1 self.msg(2, _("checking if BibTeX must be run..."))
6,299