[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/integrator src/GIParser.py src/GIObjects.p...
From: |
Jan Ischebeck |
Subject: |
gnue/integrator src/GIParser.py src/GIObjects.p... |
Date: |
Thu, 21 Nov 2002 18:48:48 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/11/21 18:48:48
Modified files:
integrator/src : GIParser.py GIObjects.py GIClient.py
Added files:
integrator/samples: sample.gmd
integrator/src : GISources.py
Log message:
some experiments with regexp and merging
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/integrator/samples/sample.gmd?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/integrator/src/GISources.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/integrator/src/GIParser.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/integrator/src/GIObjects.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/integrator/src/GIClient.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/integrator/src/GIClient.py
diff -c gnue/integrator/src/GIClient.py:1.1 gnue/integrator/src/GIClient.py:1.2
*** gnue/integrator/src/GIClient.py:1.1 Wed Sep 18 20:17:34 2002
--- gnue/integrator/src/GIClient.py Thu Nov 21 18:48:48 2002
***************
*** 32,38 ****
import string
from gnue.integrator.GIParser import loadMapping
! from gnue.integrator import Actions
from gnue.common import GDebug
from gnue.common.FileUtils import openResource
from gnue.common import GDataObjects, GConnections
--- 32,38 ----
import string
from gnue.integrator.GIParser import loadMapping
! #from gnue.integrator import Actions
from gnue.common import GDebug
from gnue.common.FileUtils import openResource
from gnue.common import GDataObjects, GConnections
***************
*** 75,88 ****
fileHandle = openResource(mappingFile)
! mapping = loadMapping (fileHandle)
fileHandle.close()
# add connections object to top object
! mapping._connections=self.connections
if __name__ == '__main__':
--- 75,89 ----
fileHandle = openResource(mappingFile)
! mapping = loadMapping (fileHandle, self.connections)
fileHandle.close()
# add connections object to top object
! # mapping._connections=self.connections
+ mapping.run()
if __name__ == '__main__':
Index: gnue/integrator/src/GIObjects.py
diff -c gnue/integrator/src/GIObjects.py:1.3
gnue/integrator/src/GIObjects.py:1.4
*** gnue/integrator/src/GIObjects.py:1.3 Mon Nov 4 14:14:09 2002
--- gnue/integrator/src/GIObjects.py Thu Nov 21 18:48:48 2002
***************
*** 27,51 ****
# NOTES:
#
! import sys, string, os, os.path
! from gnue.common import GObjects, GDebug, GConfig, GRootObj
from gnue.reports import GREngine,GRExceptions
import GIParser
! # Base class for all Navigator objects
class GIObject(GObjects.GObj):
pass
! class GIMappings(GRootObj, GIObject):
!
def __init__(self, parent=None):
! GRootObj.GRootObj.__init__(self, 'mappings',
GIParser.getXMLelements,GIParser)
! GNObject.__init__(self, parent, type="GIMappings")
! class GIMapping(GIObject):
def __init__(self, parent):
! GNObject.__init__(self, parent, type="GIMapping")
--- 27,173 ----
# NOTES:
#
! import sys, string, os, os.path, re
! from gnue.common import GObjects, GDebug, GConfig, GDataSource
! from gnue.common.GRootObj import GRootObj
from gnue.reports import GREngine,GRExceptions
import GIParser
! # Base class for all Integrator objects
class GIObject(GObjects.GObj):
pass
! class GIMappings(GRootObj,GIObject):
def __init__(self, parent=None):
! GRootObj.__init__(self, 'mappings', GIParser.getXMLelements,GIParser)
! GIObject.__init__(self, parent, type="GIMappings")
! self._datasourceDictionary={}
!
! def run(self):
! for child in self._children:
! if child._type=="GIMapping":
! child.run()
!
! class GIMapping(GIObject):
! def __init__(self, parent):
! GIObject.__init__(self, parent, type="GIMapping")
+ def run(self):
+ GDebug.printMesg(5,"Start Mapping %s." % self.title)
+ for child in self._children:
+ if child._type=="GIProcess":
+ child.run()
! class GISubMapping(GIObject):
! def __init__(self, parent):
! GIObject.__init__(self, parent, type="GISubMapping")
!
! class GISources(GIObject):
! def __init__(self, parent):
! GIObject.__init__(self, parent, type="GISources")
!
! class GIProcess(GIObject):
! def __init__(self, parent):
! GIObject.__init__(self, parent, type="GIProcess")
! self.InputSources={}
! self.OutputSources={}
! self.InputRset={}
! self.OutputRset={}
!
! def run(self):
! for dts in self.InputSources.keys():
! if not self.InputSources[dts].hasMaster():
! self.InputRset[dts]=self.InputSources[dts].createResultSet({})
! for dts in self.OutputSources.keys():
! if not self.OutputSources[dts].hasMaster():
! self.OutputRset[dts]=self.OutputSources[dts].createEmptyResultSet()
! # print self.InputRset
! for rset in self.InputRset.keys():
! rec=self.InputRset[rset].firstRecord()
! while rec:
! for child in self._children:
! if child._type=="GIAction":
! child.process(self.InputRset[rset].current)
! rec=self.InputRset[rset].nextRecord()
! # print "INPUT:", self.InputSources
! # print "OUTPUT:", self.OutputSources
!
!
! class GIAction(GIObject):
! def __init__(self, parent):
! GIObject.__init__(self, parent, type="GIAction")
! self._inits = [self.initialize]
!
! def initialize(self):
! inpCount=0
! outCount=0
! for child in self._children:
! if child.type=="src":
! inpCount+=1
! if child.type=="dest":
! outCount+=1
!
! if hasattr(self,"mergemask") and self.mergemask!="":
! # should use regex instead
! self.mergecount=string.count(self.mergemask,'@')
! if self.mergecount!=inpCount:
! raise Error,"Merge mask parameter not equal to number of fields"
!
! else:
! self.mergemask='@1'
!
! if hasattr(self,"splitmask") and self.splitmask!="":
! self.splitre=re.compile(self.splitmask)
!
!
!
! def process(self, row):
! # merge first
! inpCount=1
! out=self.mergemask
! for child in self._children:
! if child.type=="src":
! out=string.replace(out,'@%s' % inpCount, '%s' %
row.getField(child.name))
! inpCount+=1
! print row.getField(child.name),' ',
!
! if hasattr(self,"splitre"):
! mymatch=self.splitre.match(out)
! if mymatch==None:
! if hasattr(self,'on-fail'):
! pass
! return
!
! out=mymatch.groups()
! else:
! out = [out]
! print ' -> ',out
!
! class GIField(GIObject):
! def __init__(self, parent):
! GIObject.__init__(self, parent, type="GIField")
! self._inits = [self.initialize]
!
! def initialize(self):
! self._mappings = self.findParentOfType('GIMappings')
! self._process = self.findParentOfType('GIProcess')
! self._datasource = \
! self._mappings._datasourceDictionary[
! string.lower(self.datasource)]
!
! self._datasource.referenceField(self.name, None)
! if self.type=="src":
! self._process.InputSources[
! string.lower(self.datasource)]=self._datasource
!
! if self.type=="dest":
! self._process.OutputSources[
! string.lower(self.datasource)]=self._datasource
!
! class GITrigger(GIObject):
def __init__(self, parent):
! GIObject.__init__(self, parent, type="GITrigger")
+
Index: gnue/integrator/src/GIParser.py
diff -c gnue/integrator/src/GIParser.py:1.1 gnue/integrator/src/GIParser.py:1.2
*** gnue/integrator/src/GIParser.py:1.1 Wed Sep 18 20:17:34 2002
--- gnue/integrator/src/GIParser.py Thu Nov 21 18:48:48 2002
***************
*** 19,25 ****
# Copyright 2002 Free Software Foundation
#
# FILE:
! # GNParser.py
#
# DESCRIPTION:
# Class that contains a sax based xml processor for GNUE Integrator
--- 19,25 ----
# Copyright 2002 Free Software Foundation
#
# FILE:
! # GIParser.py
#
# DESCRIPTION:
# Class that contains a sax based xml processor for GNUE Integrator
***************
*** 27,33 ****
# NOTES:
#
! from gnue.common import GParser
import copy, types
from gnue.common import GTypecast
--- 27,33 ----
# NOTES:
#
! from gnue.common import GParser, GDataSource
import copy, types
from gnue.common import GTypecast
***************
*** 56,64 ****
# not want the loaded form to connect to databases, etc)
#######################################################
! def loadMapping(buffer, initialize=1):
! return GParser.loadXMLObject (buffer, xmlProcessHandler, 'GNProcesses',
'processes',
! initialize, attributes={})
xmlElements = None
--- 56,65 ----
# not want the loaded form to connect to databases, etc)
#######################################################
! def loadMapping(buffer, connections, initialize=1):
! return GParser.loadXMLObject(buffer, xmlProcessHandler, 'GIMappings',
! 'mappings',initialize,
! attributes={"_connections" :connections})
xmlElements = None
***************
*** 69,75 ****
global xmlElements
if xmlElements == None:
! import GNObjects
xmlElements = {
'mappings': {
--- 70,77 ----
global xmlElements
if xmlElements == None:
! import GIObjects
! import GISources
xmlElements = {
'mappings': {
***************
*** 92,97 ****
--- 94,187 ----
'title': {
'Typecast': GTypecast.text } },
'ParentTags': ('mappings',) },
+
+ 'sources': {
+ 'BaseClass': GISources.GISources,
+ 'Attributes': {},
+ 'ParentTags': ('mappings',) },
+
+ 'process': {
+ 'BaseClass': GIObjects.GIProcess,
+ 'Attributes': {
+ 'rowmapping': {
+ 'ValueSet': {
+ 'merge': {},
+ 'split': {},
+ 'simple': {}},
+ 'Default': 'simple',
+ 'Typecast': GTypecast.name }},
+ 'ParentTags': ('mapping',) },
+
+ 'submapping': {
+ 'BaseClass': GIObjects.GISubMapping,
+ 'Attributes': {},
+ 'ParentTags': ('mapping',) },
+
+
+ 'action': {
+ 'BaseClass': GIObjects.GIAction,
+ 'Attributes': {
+ 'type': {
+ 'Required': 1,
+ 'ValueSet': {
+ 'merge': {},
+ 'split': {},
+ 'copy': {}}},
+ # 'parameter': {
+ # 'Required': 1,
+ # 'Typecast': GTypecast.name },
+ 'on-fail': {
+ # 'Required': 1,
+ 'Typecast': GTypecast.name },
+ 'splitmask': {
+ # 'Required': 1,
+ 'Typecast': GTypecast.name },
+ 'mergemask': {
+ # 'Required': 1,
+ 'Default':'@1',
+ 'Typecast': GTypecast.name }},
+ 'ParentTags': ('process',) },
+
+ 'field': {
+ 'BaseClass': GIObjects.GIField,
+ 'Attributes': {
+ 'name': {
+ 'Required': 1,
+ 'Typecast': GTypecast.name },
+ 'type': {
+ 'Required': 1,
+ 'ValueSet': {
+ 'src': {},
+ 'dest': {}}},
+ 'datasource': {
+ # 'Required': 1,
+ 'Typecast': GTypecast.name }},
+ 'ParentTags': ('merge',) },
+
+
+ 'trigger': {
+ 'BaseClass': GIObjects.GITrigger,
+ 'Attributes': {
+ 'type': {
+ 'Required': 1,
+ 'Typecast': GTypecast.name },
+ 'todts': {
+ # 'Required': 1,
+ 'Typecast': GTypecast.name }},
+ 'ParentTags': ('rowmapping','process','mapping') }
+ };
+
+ #
+ # Add DataSource elements
+ #
+ xmlElements.update(
+ GDataSource.getXMLelements(
+ updates={'datasource': {
+ 'BaseClass': GISources.GIDataSource,
+ 'ParentTags': ('sources',) } #,
+ #'cparam': {
+ # 'BaseClass': GFObjects.GFCParam }
+ }))
return xmlElements
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/integrator src/GIParser.py src/GIObjects.p...,
Jan Ischebeck <=