|
From: <mk...@us...> - 2003-04-11 18:07:10
|
Update of /cvsroot/csp/APPLICATIONS/SimData/SimData
In directory sc8-pr-cvs1:/tmp/cvs-serv9567/SimData
Modified Files:
Compile.py Parse.py
Log Message:
see CHANGES.current
Index: Compile.py
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/SimData/Compile.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Compile.py 18 Mar 2003 10:04:04 -0000 1.1
--- Compile.py 11 Apr 2003 18:06:37 -0000 1.2
***************
*** 129,133 ****
print "Compiling '%s' from '%s'" % (self.outfile, self.infile)
DEBUG(1, "Opening input archive")
! master = ObjectXMLArchive(self.infile);
DEBUG(1, "Loading all objects")
resetWarnings()
--- 129,134 ----
print "Compiling '%s' from '%s'" % (self.outfile, self.infile)
DEBUG(1, "Opening input archive")
! prefix = os.path.splitext(os.path.basename(self.outfile))[0]
! master = ObjectXMLArchive(prefix, self.infile);
DEBUG(1, "Loading all objects")
resetWarnings()
***************
*** 160,163 ****
--- 161,165 ----
compiled.addObject(object, id)
self.dumpBadPaths(all, paths)
+ print "Finished."
def dumpBadPaths(self, all, paths):
Index: Parse.py
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/SimData/Parse.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Parse.py 26 Mar 2003 22:10:01 -0000 1.2
--- Parse.py 11 Apr 2003 18:06:37 -0000 1.3
***************
*** 60,64 ****
sys.exit(1)
! def path_to_id(path):
if path.endswith('.gz'): path = path[:-3]
if path.endswith('.xml'): path = path[:-4]
--- 60,64 ----
sys.exit(1)
! def path_to_id(prefix, path):
if path.endswith('.gz'): path = path[:-3]
if path.endswith('.xml'): path = path[:-4]
***************
*** 70,79 ****
else:
break;
! return '.'.join(parts)
def id_to_path(id):
return apply(os.path.join, id.split('.'))
class ElementHandler(ContentHandler):
--- 70,94 ----
else:
break;
! return prefix + ":" + '.'.join(parts)
def id_to_path(id):
+ parts = id.split(':')
+ if len(parts) == 2:
+ id = parts[1]
return apply(os.path.join, id.split('.'))
+ # convert to absolute path id
+ def adjust_path(base, id):
+ if ':' in id:
+ return id
+ if not id.startswith("."):
+ return base + "." + id
+ parts = base.split(':')
+ if len(parts) == 2:
+ prefix, base = parts
+ else:
+ prefix, base = "", base
+ return prefix + ":" + id[1:]
class ElementHandler(ContentHandler):
***************
*** 194,198 ****
return name in ('List', 'Enum', 'Path', 'Int', 'Bool', 'Number', 'Float',
'String', 'Date', 'Vector', 'Matrix', 'External',
! 'Object')
def end(self):
--- 209,213 ----
return name in ('List', 'Enum', 'Path', 'Int', 'Bool', 'Number', 'Float',
'String', 'Date', 'Vector', 'Matrix', 'External',
! 'Object', 'Quat')
def end(self):
***************
*** 210,215 ****
f = spread
elif self._type == "path":
! def path(x):
y = SimData.Path()
y.setPath(x)
return y
--- 225,231 ----
f = spread
elif self._type == "path":
! def path(x, base = self._base):
y = SimData.Path()
+ x = adjust_path(base, x)
y.setPath(x)
return y
***************
*** 313,316 ****
--- 329,340 ----
self._element.parseXML(self._c)
+ class QuatHandler(SimpleHandler):
+
+ def __init__(self, id, base, name, attrs):
+ SimpleHandler.__init__(self, id, base, name, attrs)
+
+ def end(self):
+ self._element = SimData.Quaternion()
+ self._element.parseXML(self._c)
class DateHandler(SimpleHandler):
***************
*** 384,391 ****
else:
source = self._c.strip()
! if not source.startswith("."):
! source = self._base + "." + source
! else:
! source = source[1:]
self._element = source
self._paths.append(source)
--- 408,412 ----
else:
source = self._c.strip()
! source = adjust_path(self._base, source)
self._element = source
self._paths.append(source)
***************
*** 541,547 ****
class FileHandler(ElementHandler):
! def __init__(self, path=None, id=None):
if path is not None:
! id = path_to_id(path)
self._id = id
id = id.split('.')
--- 562,568 ----
class FileHandler(ElementHandler):
! def __init__(self, prefix="", path=None, id=None):
if path is not None:
! id = path_to_id(prefix, path)
self._id = id
id = id.split('.')
***************
*** 632,636 ****
MASTER = None
! def __init__(self, path):
if ObjectXMLArchive.MASTER is not None:
raise "Can only create one ObjectXMLArchive object"
--- 653,657 ----
MASTER = None
! def __init__(self, prefix, path):
if ObjectXMLArchive.MASTER is not None:
raise "Can only create one ObjectXMLArchive object"
***************
*** 641,654 ****
self._externals = {}
self._cache = None
! def getObject(self, id):
! if not self._objects.has_key(id):
! self._objects[id] = self.loadObject(id)
! return self._objects[id]
!
! def loadObject(self, id):
! path = id_to_path(id)
! path = os.path.join(self._basepath, path);
! return self.loadPath(path, id)
def loadPath(self, path, id):
--- 662,676 ----
self._externals = {}
self._cache = None
+ self._prefix = prefix
! # def getObject(self, id):
! # if not self._objects.has_key(id):
! # self._objects[id] = self.loadObject(id)
! # return self._objects[id]
! #
! # def loadObject(self, id):
! # path = id_to_path(id)
! # path = os.path.join(self._basepath, path);
! # return self.loadPath(path, id)
def loadPath(self, path, id):
***************
*** 722,726 ****
if filename.endswith('.xml') \
or filename.endswith('.xml.gz'):
! id = path_to_id(filepath)
DEBUG(2, "Loading object '%s' from '%s'" % (id, fullpath))
self._objects[id] = self.loadPath(fullpath, id)
--- 744,748 ----
if filename.endswith('.xml') \
or filename.endswith('.xml.gz'):
! id = path_to_id(self._prefix, filepath)
DEBUG(2, "Loading object '%s' from '%s'" % (id, fullpath))
self._objects[id] = self.loadPath(fullpath, id)
|