Exemple #1
0
    def LoadActions(self):
        """ parses the definition specific actions """
        Logger.info(u'Loading Actions for definition:' + self.uDefPublicTitle)
        SetDefinitionContext(self.uName)
        if Globals.oFnAction.Exists():
            sET_Data = CachedFile(Globals.oFnAction)
            sET_Data = ReplaceDefVars(sET_Data, self.oDefinitionVars)
            oET_Root = Orca_FromString(sET_Data, self,
                                       Globals.oFnAction.string)
            Orca_include(oET_Root, orca_et_loader)
            SetDefinitionContext(self.uName)
            Globals.oActions.LoadActionsSub(oET_Root, u'pagestartactions',
                                            u'pagestartaction',
                                            Globals.oActions.dActionsPageStart,
                                            Globals.oFnAction)
            Globals.oActions.LoadActionsSub(oET_Root, u'pagestartactions',
                                            u'pagestopaction',
                                            Globals.oActions.dActionsPageStop,
                                            Globals.oFnAction)
            Globals.oActions.LoadActionsSub(oET_Root, u'actions', u'action',
                                            Globals.oActions.dActionsCommands,
                                            Globals.oFnAction)

            SetVar(uVarName=u'ORCASTANDARDPAGESTARTACTIONSINCLUDED',
                   oVarValue=u"1")
            SetVar(uVarName=u'ORCASTANDARDACTIONSINCLUDED', oVarValue=u"1")
        RestoreDefinitionContext()
        return
Exemple #2
0
    def LoadXMLFile(self) -> bool:
        """ The main function to load the xml """

        SetDefinitionContext(uDefinitionName=self.uName)
        Globals.oTheScreen.LogToSplashScreen2(uText=self.uDefDescription)
        Logger.info(u'Loading definition XmlFile:' +
                    Globals.oDefinitionPathes.oFnDefinition)

        oET_Root: Element = self.oET_Root
        try:
            Logger.debug(u'Definition %s (%s): Loading xml includes' %
                         (self.uName, self.uAlias))
            Orca_include(
                oElem=oET_Root,
                pLoader=orca_et_loader,
                uFileName=Globals.oDefinitionPathes.oFnDefinition.string)
            SetDefinitionContext(uDefinitionName=self.uName)
        except Exception as e:
            StartWait()
            ShowErrorPopUp(
                uTitle="LoadXMLFile:Fatal Error",
                uMessage=LogError(
                    uMsg=u'Fatal Error: definition xml file faulty:' +
                    self.uName,
                    oException=e),
                bAbort=True)

        SetVar(uVarName='ORCASTANDARDPAGESINCLUDED', oVarValue="1")

        Globals.oTheScreen.uDefName = self.oRepManEntry.oRepEntry.uName
        self.oDefinitions.uDefinitionAuthor = self.oRepManEntry.oRepEntry.uAuthor
        self.oDefinitions.uDefinitionVersion = self.oRepManEntry.oRepEntry.uVersion
        SetVar(uVarName=u'DEFINITIONAUTHOR',
               oVarValue=self.oDefinitions.uDefinitionAuthor)
        SetVar(uVarName=u'DEFINITIONVERSION',
               oVarValue=self.oDefinitions.uDefinitionVersion)
        SetVar(uVarName=u'DEFINITIONSUPPORT',
               oVarValue=self.oDefinitions.uDefinitionSupport)

        Logger.debug(u'Definition [%s] : Ratios %fx%f:' %
                     (self.uName, self.fRationX, self.fRationY))
        if self.bImportPages:
            # get a list of all pages and add Them
            oXMLPages: Element = oET_Root.find('pages')
            for oXMLPage in oXMLPages.findall('page'):
                Globals.oTheScreen.oScreenPages.AddPageFromXmlNode(
                    oXMLPage=oXMLPage)
            oXMLPageImport: Element = oXMLPages.find('pageimport')
            if oXMLPageImport is not None:
                for oXMLPage in oXMLPageImport.findall('page'):
                    Globals.oTheScreen.oScreenPages.AddPageFromXmlNode(
                        oXMLPage=oXMLPage)

            Globals.oNotifications.SendNotification(
                uNotification="DEFINITIONPAGESLOADED", **{"definition": self})
        RestoreDefinitionContext()

        return True
Exemple #3
0
    def SetPictureNormal(self, uPictureNormal, bClearCache=False):
        """ sets the picture """

        try:
            uNewDefinitionContext = u''

            if "DEFINITIONPATH[" in uPictureNormal:
                uNewDefinitionContext, uPictureNormal = GetSetDefinitionName(
                    uPictureNormal)
            elif Globals.uDefinitionContext != self.uDefinitionContext:
                uNewDefinitionContext = self.uDefinitionContext
                SetDefinitionContext(uNewDefinitionContext)
            self.uPictureNormalVar = uPictureNormal
            self.oFnPictureNormal = self.oFnPictureNormal.Clear(
            ).ImportFullPath(ReplaceVars(uPictureNormal))

            if self.oObject:
                self.oObject.source = ToAtlas(self.oFnPictureNormal)
                if bClearCache:
                    self.oObject.reload()

            if uNewDefinitionContext != '':
                RestoreDefinitionContext()
        except Exception as e:
            LogError(u"Can't set picture:" + uPictureNormal, e)
            return False

        return True
Exemple #4
0
    def SetPictureNormal(self,
                         uFnPictureNormal: str,
                         bClearCache: bool = False) -> bool:
        """ sets the picture """

        try:
            uNewDefinitionContext: str = u''

            if "DEFINITIONPATH[" in uFnPictureNormal:
                uNewDefinitionContext, uFnPictureNormal = GetSetDefinitionName(
                    uText=uFnPictureNormal)
            elif Globals.uDefinitionContext != self.uDefinitionContext:
                uNewDefinitionContext = self.uDefinitionContext
                SetDefinitionContext(uDefinitionName=uNewDefinitionContext)
            self.uFnPictureNormalVar = uFnPictureNormal
            self.oFnPictureNormal = self.oFnPictureNormal.Clear(
            ).ImportFullPath(uFnFullName=ReplaceVars(uFnPictureNormal))
            if self.oObject:
                self.oObject.source = ToAtlas(oFileName=self.oFnPictureNormal)
                if bClearCache:
                    if self.oObject._coreimage.filename is not None:
                        self.oObject.reload()
            if uNewDefinitionContext != '':
                RestoreDefinitionContext()
        except Exception as e:
            LogError(uMsg=u"Can't set picture:" + uFnPictureNormal,
                     oException=e)
            return False

        return True
Exemple #5
0
    def LoadSettings(self, uDefinitionName, fSplashScreenPercentageStartValue):
        """ Loads the settimgs for a specific definition """

        fSplashScreenPercentageRange = 10.0

        if not uDefinitionName:
            # Scheduling Loading Definition Settings
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(
                self.aDefinitionList_List)

            aActions = Globals.oEvents.CreateSimpleActionList([{
                'name':
                'Show Message that we load the settings',
                'string':
                'showsplashtext',
                'maintext':
                '$lvar(414)'
            }])
            for oDefinition in reversed(self.aDefinitionList_List):
                fPercentage = fPercentage + fPercentageStep
                Globals.oEvents.AddToSimpleActionList(
                    aActions, [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }, {
                        'name': 'Load the settings for the Definition',
                        'string': 'loaddefinitionsettings',
                        'definitionname': oDefinition.uAlias
                    }])

            # Lets parse them (to init all default vars
            Globals.oEvents.AddToSimpleActionList(
                aActions, [{
                    'name': 'Parse all Settings and set defaults',
                    'string': 'loaddefinitionsettings',
                    'definitionname': 'PARSESETTINGS'
                }])
            #Execute the Queue
            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
            #just to put it somewhere
            for uHintKey in self.dInstallationsHints:
                self.uInstallationHint += self.dInstallationsHints[uHintKey]
            SetVar(uVarName="INSTALLATIONHINT",
                   oVarValue=self.uInstallationHint)

        else:
            oDef = self.dDefinitionList_Dict[uDefinitionName]
            SetDefinitionContext(oDef.uName)
            oDef.ParseSettings()
            RestoreDefinitionContext()
Exemple #6
0
def GetSetDefinitionName(uText):
    uRet = ''
    iLoc = uText.find('[')
    if not iLoc == -1:
        iLoc2 = uText.find(']', iLoc)
        if not iLoc2 == -1:
            uRet = uText[iLoc + 1:iLoc2]
            if not uRet == '':
                SetDefinitionContext(uRet)
                uText = uText[:iLoc] + uText[iLoc2 + 1:]

    return uRet, uText
Exemple #7
0
 def LoadGestures(self):
     """ Loads all Gestures descriptions for a definition """
     Logger.info('Loading Gestures for definition:' + self.uDefPublicTitle)
     if not self.uName in aLoadedGestures:
         aLoadedGestures.append(self.uName)
         if Globals.oFnGestures.Exists():
             SetDefinitionContext(self.uName)
             oET_Root = LoadXMLFile(Globals.oFnGestures)
             Orca_include(oET_Root, orca_et_loader)
             LoadGesturesFromXML(oET_Root, u'gestures', u'gesture')
         RestoreDefinitionContext()
     SetVar(uVarName="ORCASTANDARDGESTURESINCLUDED", oVarValue="1")
Exemple #8
0
    def ExecuteActionLoadLanguages(self,oAction:cAction) -> eReturnCode:

        """
        loadlanguages:
            Loads the core languages, which are there even without the online resources or a specific language file
            Parameter:
            languagefilename: if give a specific language file will be loaded, otherwise the core languages are loaded
            definition: the definition name for the definition vars
        """
        self.oEventDispatcher.LogAction(uTxt=u'LoadLanguages',oAction=oAction)
        uLanguageFileName:str  = oAction.dActionPars.get("languagefilename","")
        uDefinitionAlias:str   = oAction.dActionPars.get("definitionalias","")
        uDefinition:str        = oAction.dActionPars.get("definition","")

        if uDefinitionAlias:
            uOrgDefinitionContext:str = Globals.uDefinitionContext
            SetDefinitionContext(uDefinitionName = uDefinitionAlias,uDefinitionPathName=uDefinition)
            Globals.oTheScreen.LoadLanguage(uLanguageFileName = uLanguageFileName)
            SetDefinitionContext(uDefinitionName = uOrgDefinitionContext)
        else:
            Globals.oTheScreen.LoadLanguage(uLanguageFileName=uLanguageFileName)
        return eReturnCode.Nothing
Exemple #9
0
    def LoadActions(self) -> None:
        """ parses the definition specific actions """
        Logger.info(u'Loading Actions for definition:' + self.uDefPublicTitle)
        uET_Data: str
        SetDefinitionContext(uDefinitionName=self.uName)
        if Globals.oFnAction.Exists():
            uET_Data = CachedFile(oFileName=Globals.oFnAction)
            uET_Data = ReplaceDefVars(uET_Data, self.oDefinitionVars)
            oET_Root: Element = Orca_FromString(
                uET_Data=uET_Data,
                oDef=self,
                uFileName=Globals.oFnAction.string)
            Orca_include(oET_Root, orca_et_loader)
            SetDefinitionContext(uDefinitionName=self.uName)
            Globals.oActions.LoadActionsSub(
                oET_Root=oET_Root,
                uSegmentTag=u'pagestartactions',
                uListTag=u'pagestartaction',
                dTargetDic=Globals.oActions.dActionsPageStart,
                uFileName=Globals.oFnAction)
            Globals.oActions.LoadActionsSub(
                oET_Root=oET_Root,
                uSegmentTag=u'pagestartactions',
                uListTag=u'pagestopaction',
                dTargetDic=Globals.oActions.dActionsPageStop,
                uFileName=Globals.oFnAction)
            Globals.oActions.LoadActionsSub(
                oET_Root=oET_Root,
                uSegmentTag=u'actions',
                uListTag=u'action',
                dTargetDic=Globals.oActions.dActionsCommands,
                uFileName=Globals.oFnAction)

            SetVar(uVarName=u'ORCASTANDARDPAGESTARTACTIONSINCLUDED',
                   oVarValue=u"1")
            SetVar(uVarName=u'ORCASTANDARDACTIONSINCLUDED', oVarValue=u"1")
        RestoreDefinitionContext()
        return None
Exemple #10
0
def GetSetDefinitionName(*, uText: str) -> Tuple:
    """
    Gets the definitionname from a string and sets the definitioncontext
    :param uText:
    :return: A Tuple of defintionanme and long defintion description
    """
    uRet: str = ''
    iLoc2: int
    iLoc: int = uText.find('[')
    if not iLoc == -1:
        iLoc2 = uText.find(']', iLoc)
        if not iLoc2 == -1:
            uRet = uText[iLoc + 1:iLoc2]
            if not uRet == '':
                SetDefinitionContext(uDefinitionName=uRet)
                uText = uText[:iLoc] + uText[iLoc2 + 1:]

    return uRet, uText
Exemple #11
0
    def InitInterFaceSettings(self, uDefinitionName,
                              fSplashScreenPercentageStartValue):
        """ Init The Interface settings of a definition  """

        fSplashScreenPercentageRange = 10.0

        if not uDefinitionName:
            # Scheduling Initialize Interface settings
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(
                self.aDefinitionList_List)

            aActions = Globals.oEvents.CreateSimpleActionList([{
                'name':
                'Show Message the we initialize the interfaces',
                'string':
                'showsplashtext',
                'maintext':
                '$lvar(418)'
            }])

            for oDefinition in reversed(self.aDefinitionList_List):
                fPercentage = fPercentage + fPercentageStep
                Globals.oEvents.AddToSimpleActionList(
                    aActions, [{
                        'name': 'Update Percentage and Interface Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }, {
                        'name': 'Initialize the Interface',
                        'string': 'initinterfacesettings',
                        'definitionname': oDefinition.uAlias
                    }])
            Globals.oEvents.AddToSimpleActionList(
                aActions, [{
                    'name': 'Show Message the we write all interface settings',
                    'string': 'showsplashtext',
                    'subtext': "$lvar(456)",
                    'percentage': str(fPercentage)
                }, {
                    'name': 'Write all interface settings',
                    'string': 'initinterfacesettings',
                    'definitionname': 'WRITEALLSETTINGS'
                }])

            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)

        elif uDefinitionName == "WRITEALLSETTINGS":
            for uInterfaceName in self.dInitInterfaceSettings:
                if uInterfaceName in Globals.oInterFaces.oInterfaceList:
                    oInterface = Globals.oInterFaces.dInterfaces.get(
                        uInterfaceName)
                    if oInterface is None:
                        Logger.info(
                            'Need to load unrecognized Interface [%s] for configuration'
                            % (uInterfaceName))
                        Globals.oInterFaces.LoadInterface(uInterfaceName)
                        oInterface = Globals.oInterFaces.dInterfaces.get(
                            uInterfaceName)
                    if oInterface is not None:
                        for uConfigurationName in self.dInitInterfaceSettings[
                                uInterfaceName]:
                            oInterface.oInterFaceConfig.WriteDefinitionConfig(
                                uSectionName=uConfigurationName,
                                dSettings=self.dInitInterfaceSettings[
                                    uInterfaceName][uConfigurationName])
                else:
                    Logger.warning(
                        'Interface [%s] not on device, so it will not be configured!'
                        % (uInterfaceName))

        else:
            oDef = self.dDefinitionList_Dict[uDefinitionName]
            SetDefinitionContext(oDef.uName)
            oXMLRoot = oDef.oET_Root
            oDef.InitInterFaceSettings(oXMLRoot)
            RestoreDefinitionContext()
Exemple #12
0
def Orca_includesub(oElem: Union[Element, List[Element]],
                    pLoader: Callable,
                    uOrgDefinitionContext: str,
                    oDef: cDefinition,
                    uFileName: str = "Unknown Filename") -> Element:
    """ sub function for the include loader """
    global bBlockInclude

    aElemens: List[Element] = []
    oReplacementVars: cDefinitionVars = cDefinitionVars()
    oSaveReplacementVars: cDefinitionVars = cDefinitionVars()

    for e in oElem:
        aElemens.append(e)

    if oDef:
        oReplacementVars = oDef.oDefinitionVars

    i: int = 0

    for e in aElemens:
        if oDef:
            e.set('definitionalias', oDef.uAlias)

        if e.tag == 'startskip':
            if CheckCondition(oPar=e):
                bBlockInclude = True

        if e.tag == 'stopskip':
            bBlockInclude = False

        if e.tag == ElementInclude.XINCLUDE_INCLUDE:

            if CheckCondition(oPar=e) and not bBlockInclude:

                # process xinclude directive
                uHref: str = e.get("href")
                uHref = ReplaceVars(uHref)
                uParse: str = e.get("parse", None)
                if uParse is None:
                    uParse = "xml"

                if uParse == "xml":
                    uNewDefinitionContext = u''
                    if "DEFINITIONPATH[" in uHref:
                        uNewDefinitionContext, uHref = GetSetDefinitionName(
                            uText=uHref)

                    oTmpReplacementVars = e.get("definitionvars")
                    if oTmpReplacementVars is None:
                        oTmpReplacementVars = oReplacementVars

                    aIncludeReplacementVars = e.get("includedefinitionvars")
                    if aIncludeReplacementVars is None:
                        aIncludeReplacementVars = cDefinitionVars()
                    else:
                        aIncludeReplacementVars = ToDic(
                            aIncludeReplacementVars)

                    aIncludeReplacementVars = aIncludeReplacementVars.copy()

                    if oTmpReplacementVars is not None:
                        oTmpReplacementVars = oTmpReplacementVars.copy()
                        oSaveReplacementVars = oReplacementVars
                        oReplacementVars = oTmpReplacementVars
                        oReplacementVars.update(aIncludeReplacementVars)
                        if oDef:
                            oDef.oDefinitionVars = oTmpReplacementVars

                    aNodes: List[Element] = pLoader(uHref, uParse, None,
                                                    oReplacementVars)
                    oNodes: Element

                    # included element not found
                    if len(aNodes) == 0:
                        del oElem[i]
                        i -= 1
                    else:
                        uHref2 = uHref
                        if uNewDefinitionContext == u'':
                            oNodes = Orca_includesub(aNodes, pLoader,
                                                     uOrgDefinitionContext,
                                                     oDef, uHref2)
                        else:
                            oNodes = Orca_includesub(aNodes, pLoader,
                                                     uNewDefinitionContext,
                                                     oDef, uHref2)

                        if oTmpReplacementVars is not None:
                            oReplacementVars = oSaveReplacementVars
                            if oDef:
                                oDef.oDefinitionVars = oSaveReplacementVars

                        if uNewDefinitionContext != u'':
                            SetDefinitionContext(
                                uDefinitionName=uOrgDefinitionContext)

                        # we got a valid list of nodes
                        bFirst: bool = True
                        for oNode in oNodes:
                            oNode = copy(oNode)
                            if e.tail:
                                oNode.tail = (oNode.tail or "") + e.tail
                            if bFirst:
                                oElem[i] = oNode
                                bFirst = False
                            else:
                                oElem.insert(i, oNode)
                                i += 1
        else:
            Orca_includesub(e, pLoader, uOrgDefinitionContext, oDef, uFileName)
            # pass
        i += 1
    return oElem
Exemple #13
0
    def LoadSettings(self, *, uDefinitionName: str,
                     fSplashScreenPercentageStartValue: float) -> None:
        """ Loads the settings for a specific definition """

        oDefinition: cDefinition
        aCommands: List[Dict[str, str]]
        uHintKey: str
        fSplashScreenPercentageRange: float = 10.0

        if not uDefinitionName:
            # Scheduling Loading Definition Settings
            fPercentage: float = fSplashScreenPercentageStartValue
            fPercentageStep: float = fSplashScreenPercentageRange / len(self)

            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message that we load the settings',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(414)'
                }])
            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Load the settings for the Definition',
                    'string': 'loaddefinitionsettings',
                    'definitionname': oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)

            # Lets parse them (to init all default vars
            Globals.oEvents.AddToSimpleActionList(
                aActionList=aActions,
                aActions=[{
                    'name': 'Parse all Settings and set defaults',
                    'string': 'loaddefinitionsettings',
                    'definitionname': 'PARSESETTINGS'
                }])
            #Execute the Queue
            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
            #just to put it somewhere
            for uHintKey in self.dInstallationsHints:
                self.uInstallationHint += self.dInstallationsHints[uHintKey]
            SetVar(uVarName="INSTALLATIONHINT",
                   oVarValue=self.uInstallationHint)

        else:
            oDefinition = self[uDefinitionName]
            SetDefinitionContext(uDefinitionName=oDefinition.uName)
            oDefinition.ParseSettings()
            RestoreDefinitionContext()
        return None
Exemple #14
0
    def InitInterFaceSettings(
            self, *, uDefinitionName: str,
            fSplashScreenPercentageStartValue: float) -> None:
        """ Init The Interface settings of a definition  """

        aCommands: List[Dict[str, str]]
        oInterface: cBaseInterFace
        fSplashScreenPercentageRange = 10.0

        if not uDefinitionName:
            # Scheduling Initialize Interface settings
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(self)

            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message the we initialize the interfaces',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(418)'
                }])

            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Interface Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Initialize the Interface',
                    'string': 'initinterfacesettings',
                    'definitionname': oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)
            Globals.oEvents.AddToSimpleActionList(
                aActionList=aActions,
                aActions=[{
                    'name': 'Show Message the we write all interface settings',
                    'string': 'showsplashtext',
                    'subtext': "$lvar(456)",
                    'percentage': str(fPercentage)
                }, {
                    'name': 'Write all interface settings',
                    'string': 'initinterfacesettings',
                    'definitionname': 'WRITEALLSETTINGS'
                }])

            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)

        elif uDefinitionName == "WRITEALLSETTINGS":
            for uInterfaceName in self.dInitInterfaceSettings:
                if uInterfaceName in Globals.oInterFaces.aObjectNameList:
                    oInterface = Globals.oInterFaces.GetInterface(
                        uInterfaceName)
                    if oInterface is None:
                        Logger.info(
                            'Need to load unrecognized Interface [%s] for configuration'
                            % uInterfaceName)
                        Globals.oInterFaces.LoadInterface(uInterfaceName)
                        oInterface = Globals.oInterFaces.GetInterface(
                            uInterfaceName)
                    if oInterface is not None:
                        for uConfigurationName in self.dInitInterfaceSettings[
                                uInterfaceName]:
                            oInterface.oObjectConfig.WriteDefinitionConfig(
                                uSectionName=uConfigurationName,
                                dSettings=self.dInitInterfaceSettings[
                                    uInterfaceName][uConfigurationName])
                else:
                    Logger.warning(
                        'Interface [%s] not on device, so it will not be configured!'
                        % uInterfaceName)

        else:
            oDef: cDefinition = self[uDefinitionName]
            SetDefinitionContext(uDefinitionName=oDef.uName)
            oDef.InitInterFaceSettings(oXMLRoot=oDef.oET_Root)
            RestoreDefinitionContext()
        return None
Exemple #15
0
def Orca_includesub(elem,
                    loader,
                    uOrgDefinitionContext,
                    oDef,
                    uFileName="Unknown Filename"):
    """ sub function for the include loader """
    global bBlockInclude

    elemens = []
    oReplacementVars = cDefinitionVars()
    for e in elem:
        elemens.append(e)

    if oDef:
        oReplacementVars = oDef.oDefinitionVars

    i = 0
    for e in elemens:
        e.set('definitioncontext', uOrgDefinitionContext)
        if oDef:
            e.set('definitionalias', oDef.uAlias)
        e.set('linefilename', uFileName)

        if e.tag == 'startskip':
            if CheckCondition(e):
                bBlockInclude = True

        if e.tag == 'stopskip':
            bBlockInclude = False

        if e.tag == ElementInclude.XINCLUDE_INCLUDE:

            if CheckCondition(e) and not bBlockInclude:

                # process xinclude directive
                href = e.get("href")
                parse = e.get("parse", "xml")
                if parse == "xml":
                    uNewDefinitionContext = u''
                    if "DEFINITIONPATH[" in href:
                        uNewDefinitionContext, href = GetSetDefinitionName(
                            href)

                    oTmpReplacementVars = e.get("definitionvars")
                    if oTmpReplacementVars is None:
                        oTmpReplacementVars = oReplacementVars

                    aIncludeReplacementVars = e.get("includedefinitionvars")
                    if aIncludeReplacementVars is None:
                        aIncludeReplacementVars = cDefinitionVars()
                    else:
                        aIncludeReplacementVars = ToDic(
                            aIncludeReplacementVars)

                    #
                    aIncludeReplacementVars = aIncludeReplacementVars.copy()

                    if oTmpReplacementVars is not None:
                        oTmpReplacementVars = oTmpReplacementVars.copy()
                        #oTmpReplacementVars=ToDic(oTmpReplacementVars)
                        aSaveReplacementVars = oReplacementVars
                        oReplacementVars = oTmpReplacementVars
                        oReplacementVars.update(aIncludeReplacementVars)
                        if oDef:
                            oDef.oDefinitionVars = oTmpReplacementVars

                    oFnHRefRedirect = Globals.oTheScreen.oSkin.dSkinRedirects.get(
                        cFileName(u'').ImportFullPath(ReplaceVars(href)))
                    if oFnHRefRedirect is not None:
                        oFnHRef = oFnHRefRedirect.string
                    oFnHRef = cFileName(u'').ImportFullPath(ReplaceVars(href))
                    nodes = loader(oFnHRef.string, parse, None,
                                   oReplacementVars)

                    if nodes is not None:
                        if uNewDefinitionContext == u'':
                            nodes = Orca_includesub(nodes, loader,
                                                    uOrgDefinitionContext,
                                                    oDef, oFnHRef.string)
                        else:
                            nodes = Orca_includesub(nodes, loader,
                                                    uNewDefinitionContext,
                                                    oDef, oFnHRef.string)

                    if oTmpReplacementVars is not None:
                        oReplacementVars = aSaveReplacementVars
                        if oDef:
                            oDef.oDefinitionVars = aSaveReplacementVars

                    if uNewDefinitionContext != u'':
                        SetDefinitionContext(uOrgDefinitionContext)

                    if isinstance(nodes, list):
                        bFirst = True
                        for node in nodes:
                            node = copy(node)
                            if e.tail:
                                node.tail = (node.tail or "") + e.tail
                            if bFirst:
                                elem[i] = node
                                bFirst = False
                            else:
                                elem.insert(i, node)
                                i = i + 1
                    elif nodes is None:
                        del elem[i]
                        i = i - 1
                    else:
                        nodes = copy(nodes)
                        if e.tail:
                            nodes.tail = (nodes.tail or "") + e.tail
                        elem[i] = nodes
        else:
            Orca_includesub(e, loader, uOrgDefinitionContext, oDef, uFileName)
        i = i + 1
    return elem