1.1 --- a/moinformat/utils/directory.py Thu Apr 11 22:54:17 2019 +0200
1.2 +++ b/moinformat/utils/directory.py Thu Apr 11 23:13:56 2019 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Directory context functionality.
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 @@ -132,11 +132,12 @@
1.13
1.14 rename(self.get_filename(old), self.get_filename(new))
1.15
1.16 - def select_files(self, pattern):
1.17 + def select_files(self, pattern, recursive=False):
1.18
1.19 """
1.20 Return a list of filenames found within the directory matching
1.21 - 'pattern'. These filenames are relative to the directory.
1.22 + 'pattern'. These filenames are relative to the directory. If 'recursive'
1.23 + is specified and is a true value, subdirectories are also searched.
1.24 """
1.25
1.26 selected = []
1.27 @@ -144,6 +145,9 @@
1.28 # Obtain pathnames, directory names and filenames within the directory.
1.29
1.30 for dirpath, dirnames, filenames in walk(self.filename):
1.31 + if not recursive and dirpath != self.filename:
1.32 + continue
1.33 +
1.34 for filename in filenames:
1.35
1.36 # Qualify filenames with the directory path.