예제 #1
0
    def __init__(self, name, obj=None, parent=None):
        AttributeCollection.__init__(self)
        self.parent = None

        if obj == None:
            self.parameters = ParameterCollection()
        elif isinstance(obj, StepInstance) or isinstance(obj, StepDefinition):
            if name == None:
                self.setName(obj.getName())
            else:
                self.setName(name)
            self.setType(obj.getType())
            self.setDescrShort(obj.getDescrShort())
            self.parameters = ParameterCollection(obj.parameters)
        elif (obj == None) or isinstance(obj, ParameterCollection):
            # set attributes
            self.setName(name)
            self.setType("")
            self.setDescrShort("")
            self.parameters = ParameterCollection(obj)
        elif obj != None:
            raise TypeError('Can not create object type ' + str(type(self)) +
                            ' from the ' + str(type(obj)))

        self.step_commons = {}
        self.stepStatus = S_OK()
예제 #2
0
파일: Step.py 프로젝트: graciani/DIRAC
  def __init__( self, name, obj = None, parent = None ):
    AttributeCollection.__init__( self )
    self.parent = None

    if obj == None:
      self.parameters = ParameterCollection()
    elif isinstance( obj, StepInstance ) or isinstance( obj, StepDefinition ):
      if name == None:
          self.setName( obj.getName() )
      else:
          self.setName( name )
      self.setType( obj.getType() )
      self.setDescrShort( obj.getDescrShort() )
      self.parameters = ParameterCollection( obj.parameters )
    elif ( obj == None ) or isinstance( obj, ParameterCollection ):
      # set attributes
      self.setName( name )
      self.setType( "" )
      self.setDescrShort( "" )
      self.parameters = ParameterCollection( obj )
    elif obj != None:
      raise TypeError( 'Can not create object type ' + str( type( self ) ) + ' from the ' + str( type( obj ) ) )

    self.step_commons = {}
    self.stepStatus = S_OK()
예제 #3
0
파일: Step.py 프로젝트: graciani/DIRAC
  def __init__( self, step_type = None, obj = None, parent = None ):
    AttributeCollection.__init__( self )
    self.module_instances = None
    # this object can be shared with the workflow
    # to if its =None and workflow!=None we have to
    # pass everything above
    self.module_definitions = None
    self.parent = parent

    # sort out Parameters and class attributes
    if ( obj == None ) or isinstance( obj, ParameterCollection ):
      self.setType( 'notgiven' )
      self.setDescrShort( '' )
      self.setDescription( '' )
      self.setOrigin( '' )
      self.setVersion( 0.0 )
      self.parameters = ParameterCollection( obj ) # creating copy
      self.module_instances = InstancesPool( self )
      self.module_definitions = DefinitionsPool( self )
    elif isinstance( obj, StepDefinition ):
      self.setType( obj.getType() )
      self.setDescrShort( obj.getDescrShort() )
      self.setDescription( obj.getDescription() )
      self.setOrigin( obj.getOrigin() )
      self.setVersion( obj.getVersion() )
      # copy instances and definitions
      self.parameters = ParameterCollection( self, obj.parameters )
      self.module_instances = InstancesPool( self, obj.module_instances )
      if obj.module_definitions != None:
        self.module_definitions = DefinitionsPool( self. obj.module_definitions )
    else:
      raise TypeError( 'Can not create object type ' + str( type( self ) ) + ' from the ' + str( type( obj ) ) )
    if step_type :
      self.setType( step_type )
예제 #4
0
파일: Module.py 프로젝트: acasajus/DIRAC
  def __init__( self, type_ = None, obj = None, parent = None ):
    # we can create an object from another module
    # or from the ParameterCollection
    AttributeCollection.__init__( self )
    self.main_class_obj = None  # used for the interpretation only
    # self.module_obj = None     # used for the interpretation only
    self.parent = parent

    if ( obj == None ) or isinstance( obj, ParameterCollection ):
      self.setType( 'notgiven' )
      self.setDescrShort( '' )
      self.setDescription( '' )
      self.setRequired( '' )
      self.setBody( '' )
      self.setOrigin( '' )
      self.setVersion( 0.0 )
      self.parameters = ParameterCollection( obj )  # creating copy

    elif isinstance( obj, ModuleDefinition ):
      self.setType( obj.getType() )
      self.setDescrShort( obj.getDescrShort() )
      self.setDescription( obj.getDescription() )
      self.setBody( obj.getBody() )
      self.setRequired( obj.getRequired() )
      self.setOrigin( obj.getOrigin() )
      self.setVersion( obj.getVersion() )
      self.parameters = ParameterCollection( obj.parameters )
    else:
      raise TypeError( 'Can not create object type ' + str( type( self ) ) + ' from the ' + str( type( obj ) ) )
    if type_ :
      self.setType( type_ )
예제 #5
0
파일: Step.py 프로젝트: graciani/DIRAC
 def compare( self, s ):
   ''' Custom Step comparison operation
   '''
   ret = AttributeCollection.compare( self, s ) and self.module_instances.compare( s )
   if self.module_definitions.getOwner() == self:
     ret = ret and self.module_definitions.compare( s )
   return ret
예제 #6
0
 def compare(self, s):
     ''' Custom Step comparison operation
 '''
     ret = AttributeCollection.compare(
         self, s) and self.module_instances.compare(s)
     if self.module_definitions.getOwner() == self:
         ret = ret and self.module_definitions.compare(s)
     return ret
예제 #7
0
파일: Workflow.py 프로젝트: graciani/DIRAC
 def __str__( self ):
   '''Creates a string representation of itself
   '''
   ret = str( self.getName() ) + ':\n' + AttributeCollection.__str__( self ) + self.parameters.__str__()
   ret = ret + str( self.step_definitions )
   ret = ret + str( self.step_instances )
   ret = ret + str( self.module_definitions )
   return ret
예제 #8
0
파일: Step.py 프로젝트: graciani/DIRAC
 def toXML( self ):
   ''' Generate the Step XML representation
   '''
   ret = '<StepInstance>\n'
   ret = ret + AttributeCollection.toXML( self )
   ret = ret + self.parameters.toXML()
   ret = ret + '</StepInstance>\n'
   return ret
예제 #9
0
파일: Step.py 프로젝트: graciani/DIRAC
 def __str__( self ):
   ret = str( type( self ) ) + ':\n' + AttributeCollection.__str__( self ) + self.parameters.__str__()
   if self.module_definitions != None:
     ret = ret + str( self.module_definitions )
   else:
     ret = ret + 'Module definitions shared in Workflow\n'
   ret = ret + str( self.module_instances )
   return ret
예제 #10
0
 def toXML(self):
     ''' Generate the Step XML representation
 '''
     ret = '<StepInstance>\n'
     ret = ret + AttributeCollection.toXML(self)
     ret = ret + self.parameters.toXML()
     ret = ret + '</StepInstance>\n'
     return ret
예제 #11
0
 def toXML(self):
     ret = '<StepDefinition>\n'
     ret = ret + AttributeCollection.toXML(self)
     ret = ret + self.parameters.toXML()
     if self.module_definitions != None:
         ret = ret + self.module_definitions.toXML()
     ret = ret + self.module_instances.toXML()
     ret = ret + '</StepDefinition>\n'
     return ret
예제 #12
0
 def __str__(self):
     ret = str(type(self)) + ':\n' + AttributeCollection.__str__(
         self) + self.parameters.__str__()
     if self.module_definitions != None:
         ret = ret + str(self.module_definitions)
     else:
         ret = ret + 'Module definitions shared in Workflow\n'
     ret = ret + str(self.module_instances)
     return ret
예제 #13
0
 def __str__(self):
     '''Creates a string representation of itself
 '''
     ret = str(self.getName()) + ':\n' + AttributeCollection.__str__(
         self) + self.parameters.__str__()
     ret = ret + str(self.step_definitions)
     ret = ret + str(self.step_instances)
     ret = ret + str(self.module_definitions)
     return ret
예제 #14
0
파일: Step.py 프로젝트: graciani/DIRAC
 def toXML( self ):
   ret = '<StepDefinition>\n'
   ret = ret + AttributeCollection.toXML( self )
   ret = ret + self.parameters.toXML()
   if self.module_definitions != None:
     ret = ret + self.module_definitions.toXML()
   ret = ret + self.module_instances.toXML()
   ret = ret + '</StepDefinition>\n'
   return ret
예제 #15
0
 def toXML(self):
     '''Creates an XML representation of itself
 '''
     # THIS is very important that Definitions should be written before instances
     ret = '<Workflow>\n'
     ret = ret + AttributeCollection.toXML(self)
     ret = ret + self.parameters.toXML()
     ret = ret + self.module_definitions.toXML()
     ret = ret + self.step_definitions.toXML()
     ret = ret + self.step_instances.toXML()
     ret = ret + '</Workflow>\n'
     return ret
예제 #16
0
파일: Workflow.py 프로젝트: graciani/DIRAC
 def toXML( self ):
   '''Creates an XML representation of itself
   '''
   # THIS is very important that Definitions should be written before instances
   ret = '<Workflow>\n'
   ret = ret + AttributeCollection.toXML( self )
   ret = ret + self.parameters.toXML()
   ret = ret + self.module_definitions.toXML()
   ret = ret + self.step_definitions.toXML()
   ret = ret + self.step_instances.toXML()
   ret = ret + '</Workflow>\n'
   return ret
예제 #17
0
    def __init__(self, obj=None, name=None):
        ''' Be aware that 1-st param is an obj not a name!!!!
        obj can me a string with XML representation or with filename
        also obj can be a Workflow or ParameterCollections
    '''
        AttributeCollection.__init__(self)
        if (obj == None) or isinstance(obj, ParameterCollection):
            self.setName('notgiven')
            self.setType('')
            self.setDescrShort('')
            self.setDescription('')
            self.setOrigin('')
            self.setVersion(0.0)
            self.parameters = ParameterCollection(obj)
            self.step_instances = InstancesPool(self)
            self.step_definitions = DefinitionsPool(self)
            self.module_definitions = DefinitionsPool(self)

        elif isinstance(obj, Workflow):
            self.fromWorkflow(obj)
        elif isinstance(obj, str):
            self.parameters = ParameterCollection(None)
            self.step_instances = InstancesPool(self)
            self.step_definitions = DefinitionsPool(self)
            self.module_definitions = DefinitionsPool(self)
            # if obj is an XML string
            if obj.startswith('<'):
                fromXMLString(obj, self)
            else:
                fromXMLFile(obj, self)
        elif obj != None:
            raise TypeError('Can not create object type ' + str(type(self)) +
                            ' from the ' + str(type(obj)))

        if name:
            self.setName(name)
        self.workflow_commons = {}
        self.workflowStatus = S_OK()
예제 #18
0
파일: Module.py 프로젝트: acasajus/DIRAC
  def __init__( self, name, obj = None, parent = None ):
    AttributeCollection.__init__( self )
    self.instance_obj = None  # used for the interpretation only
    self.parent = parent

    if obj == None:
      self.parameters = ParameterCollection()
    elif isinstance( obj, ModuleInstance ) or isinstance( obj, ModuleDefinition ):
      if name == None:
        self.setName( obj.getName() )
      else:
        self.setName( name )
      self.setType( obj.getType() )
      self.setDescrShort( obj.getDescrShort() )
      self.parameters = ParameterCollection( obj.parameters )
    elif isinstance( obj, ParameterCollection ):
      # set attributes
      self.setName( name )
      self.setType( "" )
      self.setDescrShort( "" )
      self.parameters = ParameterCollection( obj )
    elif obj != None:
      raise TypeError( 'Can not create object type ' + str( type( self ) ) + ' from the ' + str( type( obj ) ) )
예제 #19
0
파일: Workflow.py 프로젝트: graciani/DIRAC
  def __init__( self, obj = None, name = None ):
    ''' Be aware that 1-st param is an obj not a name!!!!
        obj can me a string with XML representation or with filename
        also obj can be a Workflow or ParameterCollections
    '''
    AttributeCollection.__init__( self )
    if ( obj == None ) or isinstance( obj, ParameterCollection ):
      self.setName( 'notgiven' )
      self.setType( '' )
      self.setDescrShort( '' )
      self.setDescription( '' )
      self.setOrigin( '' )
      self.setVersion( 0.0 )
      self.parameters = ParameterCollection( obj )
      self.step_instances = InstancesPool( self )
      self.step_definitions = DefinitionsPool( self )
      self.module_definitions = DefinitionsPool( self )

    elif isinstance( obj, Workflow ):
      self.fromWorkflow( obj )
    elif isinstance( obj, str ):
      self.parameters = ParameterCollection( None )
      self.step_instances = InstancesPool( self )
      self.step_definitions = DefinitionsPool( self )
      self.module_definitions = DefinitionsPool( self )
      # if obj is an XML string
      if obj.startswith( '<' ):
        fromXMLString( obj, self )
      else:
        fromXMLFile( obj, self )
    elif obj != None:
      raise TypeError( 'Can not create object type ' + str( type( self ) ) + ' from the ' + str( type( obj ) ) )

    if name :
      self.setName( name )
    self.workflow_commons = {}
    self.workflowStatus = S_OK()
예제 #20
0
    def __init__(self, step_type=None, obj=None, parent=None):
        AttributeCollection.__init__(self)
        self.module_instances = None
        # this object can be shared with the workflow
        # to if its =None and workflow!=None we have to
        # pass everything above
        self.module_definitions = None
        self.parent = parent

        # sort out Parameters and class attributes
        if (obj == None) or isinstance(obj, ParameterCollection):
            self.setType('notgiven')
            self.setDescrShort('')
            self.setDescription('')
            self.setOrigin('')
            self.setVersion(0.0)
            self.parameters = ParameterCollection(obj)  # creating copy
            self.module_instances = InstancesPool(self)
            self.module_definitions = DefinitionsPool(self)
        elif isinstance(obj, StepDefinition):
            self.setType(obj.getType())
            self.setDescrShort(obj.getDescrShort())
            self.setDescription(obj.getDescription())
            self.setOrigin(obj.getOrigin())
            self.setVersion(obj.getVersion())
            # copy instances and definitions
            self.parameters = ParameterCollection(self, obj.parameters)
            self.module_instances = InstancesPool(self, obj.module_instances)
            if obj.module_definitions != None:
                self.module_definitions = DefinitionsPool(
                    self.obj.module_definitions)
        else:
            raise TypeError('Can not create object type ' + str(type(self)) +
                            ' from the ' + str(type(obj)))
        if step_type:
            self.setType(step_type)
예제 #21
0
 def __str__(self):
     ''' Step string representation
 '''
     return str(type(self)) + ':\n' + AttributeCollection.__str__(
         self) + self.parameters.__str__()
예제 #22
0
파일: Step.py 프로젝트: graciani/DIRAC
 def __str__( self ):
   ''' Step string representation
   '''
   return str( type( self ) ) + ':\n' + AttributeCollection.__str__( self ) + self.parameters.__str__()
예제 #23
0
파일: Module.py 프로젝트: acasajus/DIRAC
 def __str__( self ):
   return str( type( self ) ) + ':\n' + AttributeCollection.__str__( self ) + self.parameters.__str__()
예제 #24
0
파일: Module.py 프로젝트: acasajus/DIRAC
 def toXML( self ):
   ret = '<ModuleDefinition>\n'
   ret = ret + AttributeCollection.toXML( self )
   ret = ret + self.parameters.toXML()
   ret = ret + '</ModuleDefinition>\n'
   return ret