diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-02-05 19:04:23 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-02-05 19:04:23 -0500 |
commit | dbdef26b5b1968b49b49966da045799b8553ebe1 (patch) | |
tree | 98248bd21c5d1539a61f348c7b1994551c8298b4 | |
parent | 6f15ba031a6ad3295ae21caa84f725a49f479b9a (diff) | |
download | external_python_setuptools-dbdef26b5b1968b49b49966da045799b8553ebe1.tar.gz external_python_setuptools-dbdef26b5b1968b49b49966da045799b8553ebe1.tar.bz2 external_python_setuptools-dbdef26b5b1968b49b49966da045799b8553ebe1.zip |
Rename the path attribute to entries_path for clarity. Added a docstring. Refactored 'find' method for flatness.
--HG--
extra : source : 686317ef97be5076001b23e61f552dc1e85e29c8
-rwxr-xr-x | setuptools/command/sdist.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 04cbccdf..76e1c5f1 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -21,11 +21,15 @@ def walk_revctrl(dirname=''): #TODO will need test case class re_finder(object): + """ + Finder that locates files based on entries in a file matched by a + regular expression. + """ def __init__(self, path, pattern, postproc=lambda x: x): self.pattern = pattern self.postproc = postproc - self.path = convert_path(path) + self.entries_path = convert_path(path) def _finder(self, dirname, filename): f = open(filename,'rU') @@ -38,18 +42,20 @@ class re_finder(object): # postproc was formerly used when the svn finder # was an re_finder for calling unescape path = self.postproc(path) - yield svn_utils.joinpath(dirname,path) + yield svn_utils.joinpath(dirname, path) def find(self, dirname=''): - path = svn_utils.joinpath(dirname, self.path) - - if os.path.isfile(path): - for path in self._finder(dirname,path): - if os.path.isfile(path): - yield path - elif os.path.isdir(path): - for item in self.find(path): - yield item + path = svn_utils.joinpath(dirname, self.entries_path) + + if not os.path.isfile(path): + # entries file doesn't exist + return + for path in self._finder(dirname,path): + if os.path.isfile(path): + yield path + elif os.path.isdir(path): + for item in self.find(path): + yield item __call__ = find |