- if er.errno == errno.EISDIR:
- return 'DIR'
- raise er
-
- def get_attrs(self):
- if 'attrs' in self.__dict__:
- return self.attrs
- self.attrs = {}
- try:
- file = open(self._text_filename(), 'rt')
- attr_re = re.compile(r"^#(\S*)(.*)$")
- for line in file:
- m = attr_re.match(line)
- if not m:
- break
- self.attrs[m.group(1)] = m.group(2).strip()
- #print "bernie: attrs[" + m.group(1) + "] = " + m.group(2) + "<br>\n"
- except IOError, er:
- if er.errno != errno.ENOENT:
- raise er
- return self.attrs
-
- def get_attr(self, name, default):
- return self.get_attrs().get(name, default)
+ if err.errno == errno.EISDIR:
+ return self.format_dir()
+ raise err
+
+ def format_dir(self):
+ out = '== '
+ pathname = ''
+ for dirname in self.page_name.split('/'):
+ pathname = (pathname + '/' + dirname) if pathname else dirname
+ out += '[[' + pathname + '|' + dirname + ']]/'
+ out += ' ==\n'
+
+ for filename in page_list(self._filename(), file_re):
+ if img_re.match(filename):
+ if image_maxwidth:
+ maxwidth_arg = '|maxwidth=' + str(image_maxwidth)
+ out += '{{' + self.page_name + '/' + filename + '|' + filename + maxwidth_arg + '}}\n'
+ else:
+ out += ' * [[' + self.page_name + '/' + filename + ']]\n'
+ return out
+
+ def pragmas(self):
+ if not '_pragmas' in self.__dict__:
+ self._pragmas = {}
+ try:
+ f = open(self._filename(), 'rt')
+ attr_re = re.compile(r"^#(\S*)(.*)$")
+ for line in f:
+ m = attr_re.match(line)
+ if not m:
+ break
+ self._pragmas[m.group(1)] = m.group(2).strip()
+ #print "bernie: _pragmas[" + m.group(1) + "] = " + m.group(2) + "<br>\n"
+ except IOError, err:
+ if err.errno != errno.ENOENT and err.errno != errno.EISDIR:
+ raise err
+ return self._pragmas
+
+ def pragma(self, name, default):
+ return self.pragmas().get(name, default)