[Zope-CVS] CVS: Products/AdaptableStorage/gateway_fs - FSConnection.py:1.6.2.5
Christian Zagrodnick
cz@gocept.com
Tue, 4 Feb 2003 12:48:37 -0500
Update of /cvs-repository/Products/AdaptableStorage/gateway_fs
In directory cvs.zope.org:/tmp/cvs-serv28507/gateway_fs
Modified Files:
Tag: zagy-patches
FSConnection.py
Log Message:
- Changed hidden_filenames list to a regular expression.
=== Products/AdaptableStorage/gateway_fs/FSConnection.py 1.6.2.4 => 1.6.2.5 ===
--- Products/AdaptableStorage/gateway_fs/FSConnection.py:1.6.2.4 Tue Feb 4 12:29:36 2003
+++ Products/AdaptableStorage/gateway_fs/FSConnection.py Tue Feb 4 12:48:34 2003
@@ -50,11 +50,12 @@
basepath = ''
- def __init__(self, basepath, hidden_filename_prefix='.', hidden_filenames=[]):
+ def __init__(self, basepath, hidden_filename_prefix='.',
+ hidden_filenames='$f^'):
+ # $f^ never matches anything
self.basepath = basepath
self.hidden_filename_prefix = hidden_filename_prefix
- self.hidden_filenames = map(lambda x: x.strip(),
- hidden_filenames.split(','))
+ self.hidden_filenames = re.compile(hidden_filenames)
self._final = 0
# _pending holds the data to be written.
# _pending: { subpath string -> { section_name -> data } }
@@ -137,7 +138,7 @@
for name in os.listdir(path):
if name.startswith(self.hidden_filename_prefix):
continue
- if name in self.hidden_filenames:
+ if self.hidden_filenames.search(name) is not None:
continue
names.append(name)
# Return a sequence instead of a string.
@@ -247,8 +248,9 @@
existing = os.listdir(path)
prefix = self.hidden_filename_prefix
for fn in existing:
- if (not fn.startswith(prefix) and not fn in self.hidden_filenames
- and not linked.get(fn)):
+ if (not fn.startswith(prefix)
+ and self.hidden_filenames.search(fn) is None
+ and not linked.get(fn)):
item_fn = os.path.join(path, fn)
if os.path.isdir(item_fn):
rmtree(item_fn)
@@ -275,7 +277,8 @@
if non_containers.get(dir):
raise FSWriteError(
"Not a directory: %s" % dir)
- if os.path.split(subpath)[1] in self.hidden_filenames:
+ if (self.hidden_filenames.search(os.path.split(subpath)[1])
+ is not None):
raise FSWriteError(
'The id %s is not allowed.' % (os.path.split(subpath)[1], ))