def do_order (self, *args): for opt in args: if opt == "standard": self.opts = [] elif opt == "german": self.opts.append("-g") elif opt == "letter": self.opts.append("-l") else: msg.warn( _("unknown option '%s' for 'makeidx.order'") % opt)
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, and execute all delayed commands for this module. The dictionary describes the command that caused the registration. """ if self.has_key(name): msg.debug(_("module %s already registered") % name) return 2 # First look for a script moddir = "" mod = None for path in "", join(moddir, "modules"): file = join(path, name + ".rub") if exists(file): mod = ScriptModule(self.env, file) msg.log(_("script module %s registered") % name) break # Then look for a Python module if not mod: if Plugins.register(self, name) == 0: msg.debug(_("no support found for %s") % name) return 0 mod = self.modules[name].Module(self.env, dict) msg.log(_("built-in module %s registered") % name) # Run any delayed commands. if self.commands.has_key(name): for (cmd, args, vars) in self.commands[name]: msg.push_pos(vars) try: mod.command(cmd, args) except AttributeError: msg.warn(_("unknown directive '%s.%s'") % (name, cmd)) except TypeError: msg.warn(_("wrong syntax for '%s.%s'") % (name, cmd)) msg.pop_pos() del self.commands[name] self.objects[name] = mod return 1
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, and execute all delayed commands for this module. The dictionary describes the command that caused the registration. """ if self.has_key(name): msg.debug(_("module %s already registered") % name) return 2 # First look for a script moddir = "" mod = None for path in "", join(moddir, "modules"): file = join(path, name + ".rub") if exists(file): mod = ScriptModule(self.env, file) msg.log(_("script module %s registered") % name) break # Then look for a Python module if not mod: if Plugins.register(self, name) == 0: msg.debug(_("no support found for %s") % name) return 0 mod = self.modules[name].Module(self.env, dict) msg.log(_("built-in module %s registered") % name) # Run any delayed commands. if self.commands.has_key(name): for (cmd, args, vars) in self.commands[name]: msg.push_pos(vars) try: mod.command(cmd, args) except AttributeError: msg.warn(_("unknown directive '%s.%s'") % (name, cmd)) except TypeError: msg.warn(_("wrong syntax for '%s.%s'") % (name, cmd)) msg.pop_pos() del self.commands[name] self.objects[name] = mod return 1
def print_misschars(self): """ Sort the characters not handled by the selected font, and print them as a warning. """ missed_chars = [] for c in self.log.get_misschars(): missed_chars.append((c["uchar"], c["font"])) # Strip redundant missed chars missed_chars = list(set(missed_chars)) missed_chars.sort() for m in missed_chars: # The log file is encoded in UTF8 (xetex) or in latin1 (pdftex) try: uchar = m[0].decode("utf8") except: uchar = m[0].decode("latin1") # Check we have a real char (e.g. not something like '^^a3') if len(uchar) == 1: msg.warn("Character U+%X (%s) not in font '%s'" % \ (ord(uchar), m[0], m[1])) else: msg.warn("Character '%s' not in font '%s'" % (m[0], m[1]))
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 msg.progress(_("processing index %s") % self.source) if self.tool == "makeindex": cmd = ["makeindex", "-o", self.target] + self.opts cmd.extend(["-t", self.transcript]) if self.style: cmd.extend(["-s", self.style]) cmd.append(self.source) path_var = "INDEXSTYLE" elif self.tool == "xindy": cmd = ["texindy", "--quiet"] for opt in self.opts: if opt == "-g": if self.lang != "": msg.warn(_("'language' overrides 'order german'"), pkg="index") else: self.lang = "german-din" elif opt == "-l": self.modules.append("letter-ordering") msg.warn(_("use 'module letter-ordering' instead of 'order letter'"), pkg="index") else: msg.error("unknown option to xindy: %s" % opt, pkg="index") for mod in self.modules: cmd.extend(["--module", mod]) if self.lang: cmd.extend(["--language", self.lang]) cmd.append(self.source) path_var = "XINDY_SEARCHPATH" if self.path != []: env = { path_var: string.join(self.path + [os.getenv(path_var, "")], ":") } else: env = {} msg.debug(" ".join(cmd)) # Makeindex outputs everything to stderr, even progress messages rc = subprocess.call(cmd, stderr=msg.stdout) if (rc != 0): msg.error(_("could not make index %s") % self.target) return 1 # Beware with UTF-8 encoding, makeindex with headings can be messy if self.doc.encoding == "utf8" and self.style: f = file(self.target, "r") error = 0 for line in f: try: line.decode("utf8") except: error = 1 break f.close() if error: print "here" # Retry without style msg.log(_("%s on UTF8 failed. Retry...") % self.tool) self.style = "" self.md5 = None return self.post_compile() self.doc.must_compile = 1 return 0