[Calypso] [PATCH 05/20] Use listdir rather than glob.
Jelmer Vernooij
jelmer at jelmer.uk
Sat Apr 9 16:09:22 PDT 2016
On Sun, Apr 10, 2016 at 12:48:20AM +0200, Guido Günther wrote:
> On Sat, Apr 09, 2016 at 07:16:51PM +0000, Jelmer Vernooij wrote:
> > From: Jelmer Vernooij <jelmer at jelmer.uk>
> >
> > ---
> > calypso/webdav.py | 21 ++++++++++-----------
> > 1 file changed, 10 insertions(+), 11 deletions(-)
> >
> > diff --git a/calypso/webdav.py b/calypso/webdav.py
> > index 526f24b..26374e9 100644
> > --- a/calypso/webdav.py
> > +++ b/calypso/webdav.py
> > @@ -30,7 +30,6 @@ import os
> > import codecs
> > import time
> > import hashlib
> > -import glob
> > import logging
> > import tempfile
> > import vobject
> > @@ -297,23 +296,24 @@ class Collection(object):
> > return
> > self.log.debug("Scan %s", self.path)
> > self.mtime = mtime
> > - filenames = glob.glob(self.pattern)
> > + filenames = os.listdir(self.path)
> > newfiles = []
> > for filename in filenames:
> > + filepath = os.path.join(self.path, filename)
> > for file in self.files:
> > - if filename == file.path:
> > + if filepath == file.path:
> > newfiles.append(file)
> > if not file.is_up_to_date():
> > - self.log.debug("Changed %s", filename)
> > - self.scan_file(filename)
> > + self.log.debug("Changed %s", filepath)
> > + self.scan_file(filepath)
> > break
> > else:
> > - if os.path.isdir(filename):
> > - self.log.debug("Ignoring directory %s in scan_dir", filename)
> > + if os.path.isdir(filepath):
> > + self.log.debug("Ignoring directory %s in scan_dir", filepath)
> > else:
> > - self.log.debug("New %s", filename)
> > - newfiles.append(Pathtime(filename))
> > - self.insert_file(filename)
> > + self.log.debug("New %s", filepath)
> > + newfiles.append(Pathtime(filepath))
> > + self.insert_file(filepath)
> > for file in self.files:
> > if not file.path in filenames:
> > self.log.debug("Removed %s", file.path)
> > @@ -332,7 +332,6 @@ class Collection(object):
> > self.urlpath = path
> > self.owner = paths.url_to_owner(path)
> > self.path = paths.url_to_file(path)
> > - self.pattern = os.path.join(self.path, "*")
> > self.files = []
> > self.my_items = []
> > self.mtime = 0
>
> This does't apply for me. I also wonder what the motivation is? Speed?
Yes, speed and just that there is no use for glob here if we're
matching all files.
Updated patch attached.
Jelmer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no-glob.diff
Type: text/x-diff
Size: 2370 bytes
Desc: not available
URL: <http://keithp.com/pipermail/calypso/attachments/20160409/79a71a38/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://keithp.com/pipermail/calypso/attachments/20160409/79a71a38/attachment.sig>
More information about the Calypso
mailing list