diff options
author | Philip Thiem <ptthiem@gmail.com> | 2013-07-20 17:45:04 -0500 |
---|---|---|
committer | Philip Thiem <ptthiem@gmail.com> | 2013-07-20 17:45:04 -0500 |
commit | b4ba33898f4d67af70319a0bb64edca72fc3ecee (patch) | |
tree | 6570fef0f808141aed5b93275f8b86469224eee4 /setuptools/command/sdist.py | |
parent | 411379b73db3bc4955e369affc448cd10ac025e6 (diff) | |
download | external_python_setuptools-b4ba33898f4d67af70319a0bb64edca72fc3ecee.tar.gz external_python_setuptools-b4ba33898f4d67af70319a0bb64edca72fc3ecee.tar.bz2 external_python_setuptools-b4ba33898f4d67af70319a0bb64edca72fc3ecee.zip |
Additional Tests, Various fixes, and encoding dealings
--HG--
extra : rebase_source : 2734e79e08e194923eab8c70f92cb77bce7daccf
Diffstat (limited to 'setuptools/command/sdist.py')
-rwxr-xr-x | setuptools/command/sdist.py | 84 |
1 files changed, 35 insertions, 49 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 5cc2139b..e1112ff9 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -8,73 +8,58 @@ from setuptools import svn_utils READMES = ('README', 'README.rst', 'README.txt') -entities = [ - ("<","<"), (">", ">"), (""", '"'), ("'", "'"), - ("&", "&") -] -def unescape(data): - for old,new in entities: - data = data.replace(old,new) - return data +def walk_revctrl(dirname=''): + """Find all files under revision control""" + for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): + for item in ep.load()(dirname): + yield item + + +#TODO will need test case +class re_finder(object): -def re_finder(pattern, postproc=None): - def find(dirname, filename): + def __init__(self, path, pattern, postproc=None): + self.pattern = pattern + self.postproc = postproc + self.path = convert_path(path) + + def _finder(self, dirname, filename): f = open(filename,'rU') - data = f.read() - f.close() - for match in pattern.finditer(data): + try: + data = f.read() + finally: + f.close() + for match in self.pattern.finditer(data): path = match.group(1) if postproc: + #postproc used to be used when the svn finder + #was an re_finder for calling unescape path = postproc(path) - yield joinpath(dirname,path) - return find - -def joinpath(prefix,suffix): - if not prefix: - return suffix - return os.path.join(prefix,suffix) - - - + yield svn_utils.joinpath(dirname,path) + def __call__(self, dirname=''): + path = svn_utils.joinpath(dirname, self.path) - - - - -def walk_revctrl(dirname=''): - """Find all files under revision control""" - for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): - for item in ep.load()(dirname): - yield item - -def _default_revctrl(dirname=''): - for path, finder in finders: - path = joinpath(dirname,path) if os.path.isfile(path): - for path in finder(dirname,path): + for path in self._finder(dirname,path): if os.path.isfile(path): yield path elif os.path.isdir(path): - for item in _default_revctrl(path): + for item in self.find(path): yield item -def entries_externals_finder(dirname, filename): - for record in svn_utils.parse_dir_entries(dirname): - yield joinpath(dirname, record) - - for name in svn_utils.parse_externals(dirname): - yield joinpath(dirname, name) +def _default_revctrl(dirname=''): + 'Primary svn_cvs entry point' + for finder in finders: + for item in finder(dirname): + yield item finders = [ - (convert_path('CVS/Entries'), - re_finder(re.compile(r"^\w?/([^/]+)/", re.M))), - #combined externals due to common interface - #combined externals and enteries due to lack of dir_props in 1.7 - (convert_path('.svn/entries'), entries_externals_finder), + re_finder('CVS/Entries', re.compile(r"^\w?/([^/]+)/", re.M)), + svn_utils.svn_finder, ] @@ -88,6 +73,7 @@ finders = [ + class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" |