1.1 --- a/moinformat/input/directory.py Sat Apr 13 00:07:45 2019 +0200
1.2 +++ b/moinformat/input/directory.py Sat Apr 13 00:08:31 2019 +0200
1.3 @@ -21,7 +21,7 @@
1.4
1.5 from moinformat.input.common import Input
1.6 from moinformat.utils.directory import Directory
1.7 -from os.path import sep
1.8 +from os.path import join, sep
1.9
1.10 class DirectoryInput(Input):
1.11
1.12 @@ -93,6 +93,24 @@
1.13
1.14 return self.readpath(self.dir.get_filename(filename), encoding)
1.15
1.16 + # Convenience methods.
1.17 +
1.18 + def get_attachment_filename(self, pagename, filename):
1.19 +
1.20 + """
1.21 + Return the full path of an attachment file for the given 'pagename'
1.22 + having the given 'filename'.
1.23 + """
1.24 +
1.25 + if not pagename:
1.26 + return None
1.27 +
1.28 + if self.nested:
1.29 + return self.dir.get_filename(join(self.to_filename(pagename),
1.30 + self.attachments_dir, filename))
1.31 + else:
1.32 + return self.dir.get_filename(join(self.attachments_dir, filename))
1.33 +
1.34 # NOTE: Translation methods should encode filenames appropriately.
1.35
1.36 def to_filename(self, pagename):