[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command sdist.py, 1.3, 1.4
pje@users.sourceforge.net
pje at users.sourceforge.net
Sat Jul 9 06:21:36 CEST 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30120/setuptools/command
Modified Files:
sdist.py
Log Message:
Include ``svn:externals`` directories in source distributions as well as
normal subversion-controlled files and directories.
Index: sdist.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/sdist.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sdist.py 8 Jul 2005 05:09:23 -0000 1.3
+++ sdist.py 9 Jul 2005 04:21:22 -0000 1.4
@@ -6,15 +6,23 @@
("<","<"), (">", ">"), (""", '"'), ("'", "'"),
("&", "&")
]
+
def unescape(data):
for old,new in entities:
data = data.replace(old,new)
return data
-patterns = [
- (convert_path('CVS/Entries'), re.compile(r"^\w?/([^/]+)/", re.M), None),
- (convert_path('.svn/entries'), re.compile(r'name="([^"]+)"'), unescape),
-]
+def re_finder(pattern, postproc=None):
+ def find(dirname, filename):
+ f = open(filename,'rU')
+ data = f.read()
+ f.close()
+ for match in pattern.finditer(data):
+ path = match.group(1)
+ if postproc:
+ path = postproc(path)
+ yield joinpath(dirname,path)
+ return find
def joinpath(prefix,suffix):
if not prefix:
@@ -31,14 +39,6 @@
-
-
-
-
-
-
-
-
def walk_revctrl(dirname='', memo=None):
"""Find all files under revision control"""
if memo is None:
@@ -46,38 +46,47 @@
if dirname in memo:
# Don't rescan a scanned directory
return
- for path, pattern, postproc in patterns:
+ for path, finder in finders:
path = joinpath(dirname,path)
if os.path.isfile(path):
- f = open(path,'rU')
- data = f.read()
- f.close()
- for match in pattern.finditer(data):
- path = match.group(1)
- if postproc:
- path = postproc(path)
- path = joinpath(dirname,path)
+ for path in finder(dirname,path):
if os.path.isfile(path):
yield path
elif os.path.isdir(path):
for item in walk_revctrl(path, memo):
yield item
+def externals_finder(dirname, filename):
+ """Find any 'svn:externals' directories"""
+ found = False
+ f = open(filename,'rb')
+ for line in iter(f.readline, ''): # can't use direct iter!
+ parts = line.split()
+ if len(parts)==2:
+ kind,length = parts
+ data = f.read(int(length))
+ if kind=='K' and data=='svn:externals':
+ found = True
+ elif kind=='V' and found:
+ f.close()
+ break
+ else:
+ f.close()
+ return
+ for line in data.splitlines():
+ parts = line.split()
+ if parts:
+ yield joinpath(dirname, parts[0])
-
-
-
-
-
-
-
-
-
-
-
-
+finders = [
+ (convert_path('CVS/Entries'),
+ re_finder(re.compile(r"^\w?/([^/]+)/", re.M))),
+ (convert_path('.svn/entries'),
+ re_finder(re.compile(r'name="([^"]+)"'), unescape)),
+ (convert_path('.svn/dir-props'), externals_finder),
+]
class sdist(_sdist):
@@ -112,12 +121,3 @@
-
-
-
-
-
-
-
-
-
More information about the Python-checkins
mailing list