1.1 --- a/moinformat/input/directory.py Thu Apr 11 22:54:17 2019 +0200
1.2 +++ b/moinformat/input/directory.py Thu Apr 11 23:13:56 2019 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Directory input context.
1.6
1.7 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -49,9 +49,11 @@
1.13
1.14 "Return all pages in the context."
1.15
1.16 + nested = self.level_sep == sep
1.17 +
1.18 # Ignore dotfiles.
1.19
1.20 - return map(self.to_pagename, self.dir.select_files("[!.]*"))
1.21 + return map(self.to_pagename, self.dir.select_files("[!.]*", nested))
1.22
1.23 # Page characteristics.
1.24
1.25 @@ -59,8 +61,9 @@
1.26
1.27 "Return the subpage filenames of 'pagename'."
1.28
1.29 + nested = self.level_sep == sep
1.30 pattern = self.to_filename("%s/*" % pagename)
1.31 - return self.dir.select_files(pattern)
1.32 + return self.dir.select_files(pattern, nested)
1.33
1.34 def subpages(self, pagename):
1.35
2.1 --- a/moinformat/utils/directory.py Thu Apr 11 22:54:17 2019 +0200
2.2 +++ b/moinformat/utils/directory.py Thu Apr 11 23:13:56 2019 +0200
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 Directory context functionality.
2.6
2.7 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -132,11 +132,12 @@
2.13
2.14 rename(self.get_filename(old), self.get_filename(new))
2.15
2.16 - def select_files(self, pattern):
2.17 + def select_files(self, pattern, recursive=False):
2.18
2.19 """
2.20 Return a list of filenames found within the directory matching
2.21 - 'pattern'. These filenames are relative to the directory.
2.22 + 'pattern'. These filenames are relative to the directory. If 'recursive'
2.23 + is specified and is a true value, subdirectories are also searched.
2.24 """
2.25
2.26 selected = []
2.27 @@ -144,6 +145,9 @@
2.28 # Obtain pathnames, directory names and filenames within the directory.
2.29
2.30 for dirpath, dirnames, filenames in walk(self.filename):
2.31 + if not recursive and dirpath != self.filename:
2.32 + continue
2.33 +
2.34 for filename in filenames:
2.35
2.36 # Qualify filenames with the directory path.