ccpnmodel.ccpncore.memops.scripts.core package¶
Submodules¶
ccpnmodel.ccpncore.memops.scripts.core.FileModelAdapt module¶
Module Documentation here
- class ccpnmodel.ccpncore.memops.scripts.core.FileModelAdapt.FileModelAdapt[source]¶
Bases:
ccpnmodel.ccpncore.memops.scripts.core.ModelAdapt.ModelAdapt
Python-specific version of ModelAdapt
ccpnmodel.ccpncore.memops.scripts.core.LanguageInterface module¶
Module Documentation here
- class ccpnmodel.ccpncore.memops.scripts.core.LanguageInterface.LanguageInterface[source]¶
Bases:
object
- callKwFunc(func, obj=None, params=None, setVarTo=None, kwDict={})[source]¶
call function with keyword-value parameters. kwDict keys are assumed to be strings, kwDict values are assumed to be printable as given (hint - use toLiteral for literals). the result is set to setVarTo, unless this is None
NB for languages that do not accept keyword-value parameters, the information is passed in a dictionary variable that is put last on the variable list. callKwFunc will only work for functions that have this behaviour.
- collectionNotNoneAndNotEmpty(collection, isUnique, isOrdered, varType=None)[source]¶
NBNB TBD do we need this and the following?
- getByIndexInCollection(index, collection, isUnique, isOrdered, varType=None)[source]¶
get value by index. Works only on ordered collections. Returns an expression
- getDictKeys(dictVar)[source]¶
set dict keys as collection or iterable NB must be valid as initValue to newCollection
- getDictValues(dictVar)[source]¶
set dict values as collection or iterable NB must be valid as initValue to newCollection
- getFuncParams(op, defineFunc=True)[source]¶
get parameters as list of strings. If defineFunc get strings for function definition. Else get strings for function calls, assuming you use same variable names as the definition. This second form is used e.g. to call constructors in factory functions.
- indexInCollection(var, collection, isUnique, isOrdered, varType=None)[source]¶
expression giving index of var in collection. Must work on ordered collections as well as any unordered collections that are implemented as sequences.
- newCollection(collection, isUnique, isOrdered, varType=None, initValues=None, isFrozen=False, needDeclType=False, useAdd=False)[source]¶
make new collection, possibly initialising it.
collection is the variable name to set the new collection to.
If collection is set, newCollection code will set the variable. If collection is None an expression will be returned.
if initValues if a string expression the new collection will be
initialised from this string expression at runtime.
- . If initValues is a collection of literals the code will initialise
the new collection to these values. NB this requires collection != None
if isFrozen the new collection will be frozen.
if initValuesObject is True, initValues represents an object rather than a collection
useAdd is a Java hack
- newDict(dictVar=None, keyType=None, valueType=None, needDeclType=False)[source]¶
if dictVar is None returns expression, else write statement
- replaceInCollection(oldvar, newvar, collection, isUnique, isOrdered, varType=None)[source]¶
replace oldVar with newvar in collection. Will raise appropriate error if oldvar not present If the result breaks uniqueness or type constraints the collection is left unmodified and an error is raised.
- setByIndexInCollection(indexvar, var, collection, isUnique, isOrdered, varType=None)[source]¶
set value by index of var in collection. Must work on ordered collections as well as any unordered collections that are implemented as sequences.
- toLiteral(value)[source]¶
String representation of ‘value’ that will work as a literal in an expression. For languages that makes the distinction this will be an ‘object’ rather than a ‘raw’ literal. NB for objects that have no equivalent literal, behaviour is unpredictable
ccpnmodel.ccpncore.memops.scripts.core.ModelAdapt module¶
Module Documentation here
- class ccpnmodel.ccpncore.memops.scripts.core.ModelAdapt.ModelAdapt[source]¶
Bases:
ccpnmodel.ccpncore.memops.metamodel.ModelTraverse.ModelTraverse
This class processes and modifies an input model, specifically adding operations that are absent in the basic model but needed for generation. Assumes that basic model is valid. All additions in this file are independent of language, implementation and task. May be overridden in subclasses to handle specific changes.
- addClassOperations(inClass)[source]¶
Add operations not linked to an element (e.g. init, delete, checkValid)
- addDataObjTypeOperations(inClass)[source]¶
Add operations not linked to an element (e.g. init, checkValid)
- addParentLink(clazz)[source]¶
Add element and getter for parent link (synonym for the real one) Must be treated as special case later.
- addRoleOperations(elem, inClass)[source]¶
select, and find or create operations specific for roles or DataObjType attrs (findFirst, findAll, new)
- checkOpForDerived(elem, inClass, opType)[source]¶
verify existence of op for derived element and check the op.
- checkOpParameter(par, inClass, params)[source]¶
check an existing operation parameter conforms to the rules.
- checkOperation(op, opData, inClass, opSubType=None)[source]¶
check an existing operation conforms to the rules, and adds missing information (target, parameters) where it can be deduced from context.
- getOpData(target, opType, inClass=None)[source]¶
Get opData for opType, taking special cases into account
- getOpDocumentation(opData, inClass, opSubType=None, copyElemDoc=True)[source]¶
get documentation for generated operation
- getOperationName(target, opType, opSubType=None)[source]¶
get name of operation - NB does not use actual operation object, which may not exist yet
Note that opSubType!=None is used as an operation name suffix. If subOp is found and contains a ‘suffix’ item, this will be used instead.
- initClass(complexDataType)¶
processing actions for start of complexDataType
- initDataObjType(complexDataType)¶
processing actions for start of complexDataType
- makeOperations(target, opType, inClass, elem=None)[source]¶
get existing operation and check it, or create a new one Some error checking and bookkeeping for existing operations
NB elem passed in separately for the ‘new’ operations, where it is the childRole pointing to the class to create. Otherwise it is set equal to the target.
- newElement(clazz, **params)[source]¶
make new element of class clazz using parameter dict params Sets isImplicit to True and the Guid to a dummy value, if not already set.
- newOpParameter(op, inClass, params)[source]¶
Delegate Operation parameter creation to appropriate function
- opDocTemplate = '%s for %s'¶
- parDocTemplate = ' the %s'¶
- preprocessModel()[source]¶
pre-process model - handle multiple inheritance and select implementation-dependent classes
ccpnmodel.ccpncore.memops.scripts.core.PyFileModelAdapt module¶
Module Documentation here
- class ccpnmodel.ccpncore.memops.scripts.core.PyFileModelAdapt.PyFileModelAdapt(**kw)[source]¶
Bases:
ccpnmodel.ccpncore.memops.scripts.core.PyModelAdapt.PyModelAdapt
,ccpnmodel.ccpncore.memops.scripts.core.FileModelAdapt.FileModelAdapt
Python-specific version of ModelAdapt
ccpnmodel.ccpncore.memops.scripts.core.PyLanguage module¶
Module Documentation here
- class ccpnmodel.ccpncore.memops.scripts.core.PyLanguage.PyLanguage[source]¶
Bases:
ccpnmodel.ccpncore.memops.scripts.core.LanguageInterface.LanguageInterface
,ccpnmodel.ccpncore.memops.metamodel.TextWriter.TextWriter
,object
- callKwFunc(func, obj=None, params=None, setVarTo=None, kwDict={})[source]¶
call function with keyword-value parameters. kwDict keys are assumed to be strings, kwDict values are assumed to be printable as given (hint - use toLiteral for literals). the result is set to setVarTo, unless this is None
NB for languages that do not accept keyword-value parameters, the information is passed in a dictionary variable that is put last on the variable list. callKwFunc will only work for functions that have this behaviour.
- collectionNotNoneAndNotEmpty(collection, isUnique, isOrdered, varType=None)[source]¶
NBNB TBD do we need this and the following?
- createDir(dirName)[source]¶
set up as recursive function (instead of using os.makedirs) as some implementations might want to do other things in each directory.
- getByIndexInCollection(index, collection, isUnique, isOrdered, varType=None)[source]¶
get value by index. Works only on ordered collections. Returns an expression
- getCollection(var, collection, isUnique, isOrdered, varType=None)[source]¶
Get first element from ordered collection, and random element from others. Works whether modifiable or not.
- getDictKeys(dictVar)[source]¶
set dict keys as collection or iterable NB must be valid as initValue to newCollection
- getDictValues(dictVar)[source]¶
set dict values as collection or iterable NB must be valid as initValue to newCollection
- getFuncParams(op, defineFunc=True)[source]¶
get parameters as list of strings. If defineFunc get strings for function definition. Else get strings for function calls, assuming you use same variable names as the definition. This second form is used e.g. to call constructors in factory functions.
- indexInCollection(var, collection, isUnique, isOrdered, varType=None)[source]¶
expression giving index of var in collection. Must work on ordered collections as well as any unordered collections that are implemented as sequences.
- newCollection(collection, isUnique, isOrdered, varType=None, initValues=None, isFrozen=False, needDeclType=False, useAdd=False)[source]¶
initValues must be a string variable name (referring to an iterable) an iterable of literals, or None
- newDict(dictVar=None, keyType=None, valueType=None, needDeclType=False)[source]¶
if dictVar is None returns expression, else write statement
- raiseApiError(errorMsg, obj=None, obj2=None, obj3=None, inOp=None)[source]¶
NB obj and obj2 and obj3 must evaluate to a single Python object More specifically you can pass in a tuple, like ‘(a,b,c)’ but not a comma-separated list, like ‘a,b,c’
- replaceInCollection(oldvar, newvar, collection, isUnique, isOrdered, varType=None)[source]¶
resulting code may raise KeyError (for unique, nonordered) or ValueError (for all others)
- setByIndexInCollection(indexvar, var, collection, isUnique, isOrdered, varType=None)[source]¶
set value by index of var in collection. Must work on ordered collections as well as any unordered collections that are implemented as sequences.
- stringSlice(val, fromStart=0, fromEnd=None)[source]¶
Slice string. Uses Python convention with positive and negative indices
ccpnmodel.ccpncore.memops.scripts.core.PyModelAdapt module¶
Module Documentation here
- class ccpnmodel.ccpncore.memops.scripts.core.PyModelAdapt.PyModelAdapt[source]¶
Bases:
ccpnmodel.ccpncore.memops.scripts.core.ModelAdapt.ModelAdapt
Python-specific version of ModelAdapt
- addClassOperations(inClass)[source]¶
Add operations not linked to an element (e.g. init, delete, checkValid)
- addDataObjTypeOperations(inClass)[source]¶
Add operations not linked to an element (e.g. init, delete, checkValid)
- getOpDocumentation(opData, inClass, opSubType=None, copyElemDoc=False)[source]¶
get documentation for generated operation copyElemDoc defaults to False in Python we have the element documentation on the properties
- initClass(complexDataType)¶
processing actions for class
- initDataObjType(complexDataType)¶
processing actions for class
ccpnmodel.ccpncore.memops.scripts.core.PyType module¶
Module Documentation here
- class ccpnmodel.ccpncore.memops.scripts.core.PyType.PyType[source]¶
Bases:
ccpnmodel.ccpncore.memops.scripts.core.TypeInterface.TypeInterface
ccpnmodel.ccpncore.memops.scripts.core.TypeInterface module¶
Module Documentation here