1 | $NetBSD: patch-ac,v 1.1 2006/06/01 09:09:52 tonio Exp $ |
---|
2 | |
---|
3 | --- /dev/null 2006-06-01 10:55:34.000000000 +0200 |
---|
4 | +++ src/rules/latex/import.py |
---|
5 | @@ -0,0 +1,20 @@ |
---|
6 | +""" |
---|
7 | +Support for package 'import' in Rubber. |
---|
8 | +""" |
---|
9 | + |
---|
10 | +from os.path import basename |
---|
11 | +import re |
---|
12 | +import rubber |
---|
13 | + |
---|
14 | +re_ipath = re.compile("{(?P<prefix>[^{}]*)}") |
---|
15 | +class Module (rubber.rules.latex.Module): |
---|
16 | + def __init__ (self, doc, dict): |
---|
17 | + self.doc = doc |
---|
18 | + doc.add_hook("import", self.import_doc) |
---|
19 | + |
---|
20 | + def import_doc (self, dict): |
---|
21 | + if not dict["arg"]: |
---|
22 | + return 0 |
---|
23 | + self.doc.env.path.append(dict["arg"]) |
---|
24 | + m = re_ipath.match(dict["line"]) |
---|
25 | + self.doc.input_file(m.group("prefix") + ".tex") |
---|