Update of /cvsroot/boost/boost/tools/buildbot/src/boost
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28931/boost
Modified Files:
patchwork.py
Log Message:
Fixes to allow individual patch files in the patchwork.
Index: patchwork.py
===================================================================
RCS file: /cvsroot/boost/boost/tools/buildbot/src/boost/patchwork.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- patchwork.py 10 Mar 2007 20:10:57 -0000 1.1
+++ patchwork.py 7 May 2007 23:42:20 -0000 1.2
@@ -15,6 +15,28 @@
import re
+class patchwork_module:
+
+ def __init__(self,zip_path):
+ self.zip_path = zip_path
+ self.zip = zipfile.ZipFile(zip_path,'r')
+
+ def execute(self, args, scope = globals(), scripts = None):
+ if scripts:
+ script = None
+ files = self.zip.namelist()
+ reScripts = re.compile(scripts)
+ for zipPath in files:
+ if reScripts.match(zipPath):
+ if not zipPath.endswith('/'):
+ zipPath = os.path.dirname(zipPath)
+ script = zipPath+os.path.basename(args[0])
+ break
+ print "Running: %s" % (script)
+ exec self.zip.read(script) in scope
+ else:
+ exec self.zip.read(args[0]) in scope
+
class patchwork_globals:
def __init__(self):
@@ -29,18 +51,17 @@
_g_ = patchwork_globals()
-def _key_and_file_(file_match,file_entry):
- m = re.match(file_match,file_entry)
- if m:
- return [ map(lambda y: int(y), m.groups()), file_entry ]
- else:
- return None
-
#~ Define a module path, which can be a zip file, and its packages.
def def_modules(dir_and_file,packages):
#~ print "--- patchwork.def_modules(%s,{...})" % (dir_and_file)
- #~ pathDir = os.path.dirname
+ def _key_and_file_(file_match,file_entry):
+ m = re.match(file_match,file_entry)
+ if m:
+ return [ map(lambda y: int(y), m.groups()), file_entry ]
+ else:
+ return None
+
dir = filter(
None,
map(
@@ -53,19 +74,26 @@
path = os.path.join(dir_and_file[0],dir[0][1])
print "Using: %s" % (path)
+ module = None
if path.endswith('.zip') and not _g_.importers.has_key(path):
- zip = zipfile.ZipFile(path,'r')
+ module = patchwork_module(path)
+ zip = module.zip
files = zip.namelist()
_g_.importers[path] = zipimport.zipimporter(path)
for package in packages.keys():
- rePackage = re.compile(packages[package])
- for zipPath in files:
- if rePackage.match(zipPath):
- if not zipPath.endswith('/'):
- zipPath = os.path.dirname(zipPath)
- #~ print "--- patchwork.def_modules found zip path %s" %
(zipPath)
- _g_.packages[package] = { 'path' : zipPath, 'importer' :
path }
- break
+ if os.path.exists(packages[package]):
+ #~ print "--| SRC FILE: %s" % (packages[package]);
+ _g_.packages[package] = { 'path' : packages[package],
'importer' : path }
+ else:
+ rePackage = re.compile(packages[package])
+ for zipPath in files:
+ if rePackage.match(zipPath):
+ if not zipPath.endswith('/'):
+ zipPath = os.path.dirname(zipPath)
+ #~ print "--- patchwork.def_modules found zip path %s"
% (zipPath)
+ #~ print "--| ZIP FILE: %s" % (zipPath);
+ _g_.packages[package] = { 'path' : zipPath, 'importer'
: path }
+ break
_g_.packages_to_search = _g_.packages.keys()
_g_.packages_to_search.sort()
_g_.packages_to_search.reverse()
@@ -73,6 +101,8 @@
else:
raise ImportError
+ return module
+
def _open_(filename, mode = 'r', bufsize = -1):
#~ print "--- patchwork.open(%s,%s,%d)\n" % (filename,mode,bufsize)
@@ -88,19 +118,32 @@
#~ Direct loader of modules, and packages, from other importers.
class patchwork_loader:
- def __init__(self,importer,path):
- #~ print "--- patchwork.patchwork_loader.__init__"
+ def __init__(self,importer,module,path):
+ #~ print "--- patchwork_loader.__init__(self,importer,\n\t%s,\n\t%s)"
% (module,path)
self.importer = importer
+ self.module = module
self.path = path
+ def find_module(self,fullname,path=None):
+ #~ print "--- patchwork_loader.find_module(self,\n\t%s,\n\t%s)" %
(fullname,path)
+ return self.importer.find_module(fullname,path=path)
+
def load_module(self,fullname):
- #~ print "--- %s.load_module(self,%s)" % (self,fullname)
+ #~ print "--- patchwork_loader.load_module(self,\n\t%s)" % (fullname)
source = ""
- source +=
self.importer.get_data(self.path).replace("\r\n","\n").replace("\r","\n")
+ if os.path.exists(self.path):
+ #~ print "\tRC FILE: %s" % (self.path);
+ source += file(self.path,"rU").read()
+ else:
+ #~ print "\tZIP FILE: %s" % (self.path);
+ source +=
self.importer.get_data(self.path).replace("\r\n","\n").replace("\r","\n")
source += "\n\n"
- source += "from boost.patchwork import _open_ as open, _file_ as
file\n"
+ #~ source += "print '[%s].[open] == %s ... %s' % (__name__,open,
isinstance(open,type) )\n"
+ #~ source += "print '[%s].[file] == %s ... %s' % (__name__,file,
isinstance(file,type) )\n"
+ source += "if isinstance(open,type):\n\tfrom boost.patchwork import
_open_ as open\n"
+ source += "if isinstance(file,type):\n\tfrom boost.patchwork import
_file_ as file\n"
code = compiler.compile(source,self.path,'exec')
mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
mod.__file__ = os.path.join(self.importer.archive,self.path)
@@ -116,7 +159,7 @@
class patchwork_importer:
def __init__(self,archivepath):
- #~ print "--- %s.__init__(self,%s)" % (self,archivepath)
+ #~ print "--- patchwork_importer.__init__(self,%s)" % (archivepath)
found = None
for importer in _g_.importers.keys():
@@ -128,7 +171,7 @@
raise ImportError
def find_module(self,fullname,path=None):
- #~ print "--- %s.find_module(self,%s,%s)" % (self,fullname,path)
+ print "--- patchwork_importer.find_module(self,\n\t%s,\n\t%s)" %
(fullname,path)
loader = None
for package in _g_.packages_to_search:
@@ -139,19 +182,34 @@
fullname_base = fullname.split('.')[len(package_dirname):]
importer = _g_.importers[_g_.packages[package]['importer']]
- path_base =
os.path.join(_g_.packages[package]['path'],*fullname_base)
+ if os.path.exists(_g_.packages[package]['path']):
+ path_base = _g_.packages[package]['path']
+ else:
+ path_base =
os.path.join(_g_.packages[package]['path'],*fullname_base)
- if
importer._files.has_key(os.path.join(path_base,"__init__")+".py"):
+ if os.path.exists(os.path.join(path_base,"__init__")+".py"):
#~ Source package.
- loader = patchwork_loader(importer,
+ loader = patchwork_loader(importer,fullname,
+ os.path.join(path_base,"__init__")+".py")
+ elif os.path.exists(path_base):
+ #~ Source module.
+ loader = patchwork_loader(importer,fullname,
+ path_base)
+ elif os.path.exists(path_base+".py"):
+ #~ Source module.
+ loader = patchwork_loader(importer,fullname,
+ path_base+".py")
+ elif
importer._files.has_key(os.path.join(path_base,"__init__")+".py"):
+ #~ Source package.
+ loader = patchwork_loader(importer,fullname,
os.path.join(path_base,"__init__")+".py")
elif importer._files.has_key(path_base+".py"):
#~ Source module.
- loader = patchwork_loader(importer,
+ loader = patchwork_loader(importer,fullname,
path_base+".py")
if loader:
- #~ print "--- %s.find_module(self,%s,%s)" %
(self,fullname,path)
+ #~ print "--- patchwork_importer.find_module(self,%s,%s)"
% (fullname,path)
#~ print "--- package = %s" % (package)
#~ print "--- %s.path = %s" % (loader,loader.path)
break;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs