def __init__(self, uDefinitionName, oDefinitions): self.dDefinitionSettingsJSON = OrderedDict() self.aDefinitionsSettings = [] self.oDefinitionVars = cDefinitionVars() self.oDefinitionVarsFromParent = cDefinitionVars() self.bImportActions = False self.bImportLanguages = False self.bImportPages = False self.bImportSettings = False self.bLoadedCached = False self.fRatio = 1.0 self.fRationX = 1.0 self.fRationY = 1.0 self.iDefMaxX = 1 self.iDefMaxY = 1 self.iFontSize_Button = 200 self.iFontSize_File = 200 self.iFontSize_Text = 200 self.iGapX = 0 self.iGapY = 0 self.oDefinitionPathes = Globals.dDefinitionPathes.get( uDefinitionName, cDefinitionPathes(uDefinitionName)) self.oDefinitions = oDefinitions self.oET_Root = None self.oRepManEntry = None self.oTree = None self.sET_Data = '' self.uAlias = u'' self.uDefaultFont = u'' self.uDefDescription = u'' self.uDefPublicTitle = u'' self.uName = uDefinitionName self.uParentDefinitionName = u''
def ScanDefinitionNames() -> Dict: """ Parses the Definition description to give definition names """ uDefinitionName: str oDefinitionPathes: cDefinitionPathes oRepManagerEntry: cRepManagerEntry dDefinitionReps: Dict = {} aHide: List[str] = [ "appfavorites_template", "cmdfavorites_template", "tvfavorites_template", "activity_template" ] for uDefinitionName in Globals.aDefinitionList: if not uDefinitionName in aHide: if Globals.dDefinitionPathes.get(uDefinitionName) is None: oDefinitionPathes = cDefinitionPathes( uDefinitionName=uDefinitionName) Globals.dDefinitionPathes[uDefinitionName] = oDefinitionPathes oRepManagerEntry = cRepManagerEntry( oFileName=Globals.dDefinitionPathes[uDefinitionName]. oFnDefinition) if oRepManagerEntry.ParseFromXML(): dDefinitionReps[ uDefinitionName] = oRepManagerEntry.oRepEntry.uName return dDefinitionReps
def __init__(self, *, uDefinitionName: str, oDefinitions: cDefinitions): self.dDefinitionSettingsJSON: OrderedDict = OrderedDict() self.aDefinitionsSettings: List[Dict] = [] self.oDefinitionVars: cDefinitionVars = cDefinitionVars() self.oDefinitionVarsFromParent: cDefinitionVars = cDefinitionVars() self.bImportActions: bool = False self.bImportLanguages: bool = False self.bImportPages: bool = False self.bImportSettings: bool = False self.bLoadedCached: bool = False self.fRatio: float = 1.0 self.fRationX: float = 1.0 self.fRationY: float = 1.0 self.iDefMaxX: int = 1 self.iDefMaxY: int = 1 self.uFontSize_Button: str = u'200' self.uFontSize_File: str = u'200' self.uFontSize_Text: str = u'200' self.iGapX: int = 0 self.iGapY: int = 0 self.oDefinitionPathes: cDefinitionPathes = Globals.dDefinitionPathes.get( uDefinitionName, cDefinitionPathes(uDefinitionName=uDefinitionName)) self.oDefinitions = oDefinitions self.oET_Root: Optional[Element] = None self.oRepManEntry: Optional[cRepManagerEntry] = None self.sET_Data: str = '' self.uAlias: str = u'' self.uDefaultFont: str = u'' self.uDefDescription: str = u'' self.uDefPublicTitle: str = u'' self.uName: str = uDefinitionName self.uParentDefinitionName: str = u''
def InitPathes(self) -> None: """ init all used pathes by the app (root pathes needs to be initialized) """ Globals.oPathSkin = self.oPathSkinRoot + Globals.uSkinName oPathCheck = Globals.oPathSharedDocuments + "elements" + ( "skin_" + Globals.uSkinName) if oPathCheck.Exists(): Globals.oPathStandardPages = oPathCheck else: Globals.oPathStandardPages = (Globals.oPathSharedDocuments + "elements") + "skin_default" Globals.oPathUserDownload = OS_GetUserDownloadsDataPath() Globals.oPathStandardElements = Globals.oPathStandardPages Globals.oPathStandardPages = Globals.oPathStandardPages + "pages" Globals.oFnElementIncludeWrapper = cFileName( Globals.oPathStandardElements) + u'block_elementincludewrapper.xml' Globals.oFnSkinXml = cFileName(Globals.oPathSkin) + u'skin.xml' Globals.oPathSounds = cPath(Globals.oPathSoundsRoot) + self.uSoundsName Globals.oFnSoundsXml = cFileName(Globals.oPathSounds) + u'sounds.xml' Globals.oPathFonts = Globals.oPathResources + u'fonts' Globals.oFnGestureLog = cFileName( Globals.oPathUserDownload) + u'gestures.log' Globals.oFnLangInfo = cFileName(Globals.oPathLanguageRoot + Globals.uLanguage) + u'langinfo.xml' Globals.oFnAction = cFileName(Globals.oPathAction) + u'actions.xml' Globals.oFnActionEarlyAppStart = cFileName( Globals.oPathAction) + u'actionsearly.xml' Globals.oFnActionFreshInstall = cFileName( Globals.oPathAppReal + u'actions') + u'actionsfallback.xml' Globals.oFnCredits = cFileName(Globals.oPathAppReal) + u'credits.txt' Globals.oPathGestures = cPath(Globals.oPathAction) Globals.oFnGestures = cFileName( Globals.oPathGestures) + u'gestures.xml' Globals.oFnLog = cFileName('').ImportFullPath( uFnFullName=FileHandler.filename) Globals.oFnLicense = cFileName(Globals.oPathAppReal) + u'license.txt' Globals.oPathCookie = Globals.oPathTmp Globals.uScriptLanguageFileTail = u'/languages/' + Globals.uLanguage + '/strings.xml' Globals.uScriptLanguageFallBackTail = u'/languages/English/strings.xml' Globals.oFnInterfaceLanguage = cFileName( Globals.oPathInterface + u'/%s/languages/' + Globals.uLanguage) + u'strings.xml' Globals.oFnInterfaceLanguageFallBack = cFileName( Globals.oPathInterface + u'/%s/languages/English') + u'strings.xml' oDefinitionPathes = cDefinitionPathes( uDefinitionName=Globals.uDefinitionName) Globals.dDefinitionPathes[Globals.uDefinitionName] = oDefinitionPathes SetDefinitionPathes(uDefinitionName=Globals.uDefinitionName) Globals.aLogoPackFolderNames = Globals.oPathTVLogos.GetFolderList( bFullPath=False) if Globals.oDefinitionPathes.oPathDefinition.Exists(): Globals.oDefinitionPathes.oPathDefinitionAtlas.Create()
def SetDefinitionPathes(uDefinitionName, uDefinitionPathName=u''): """ Sets the definition pathes to a specific definition """ if not uDefinitionName in Globals.dDefinitionPathes: oDefinitionPathes = cDefinitionPathes(uDefinitionName, uDefinitionPathName) Globals.dDefinitionPathes[uDefinitionName] = oDefinitionPathes Globals.oDefinitionPathes = Globals.dDefinitionPathes[uDefinitionName] SetVar(uVarName=u'DEFINITIONPATH', oVarValue=Globals.oDefinitionPathes.oPathDefinition.string) SetVar(uVarName=u'DEFINITIONFILENAME', oVarValue=Globals.oDefinitionPathes.oFnDefinition.string) SetVar(uVarName=u'DEFINITIONNAME', oVarValue=Globals.uDefinitionName) SetVar(uVarName=u'DEFINITIONPATHSKINELEMENTS', oVarValue=Globals.oDefinitionPathes.oPathDefinitionSkinElements.string)
def ScanDefinitionNames(): """ Parses the Definition description to give definition names """ if len(this.dDefinitionReps) == 0: for uDefinitionName in Globals.aDefinitionList: if Globals.dDefinitionPathes.get(uDefinitionName) is None: oDefinitionPathes = cDefinitionPathes(uDefinitionName) Globals.dDefinitionPathes[uDefinitionName] = oDefinitionPathes oRepManagerEntry = cRepManagerEntry( Globals.dDefinitionPathes[uDefinitionName].oFnDefinition) if oRepManagerEntry.ParseFromXML(): this.dDefinitionReps[ uDefinitionName] = oRepManagerEntry.oRepEntry.uName
def __GetUsedDefinitions_Sub(self, uDefinitionName, bImportActions, bImportLanguages, bImportPages, bImportSettings, uParentDefinitionName, uParentDefinitionAlias, aDefinitionVarsFromParent, uAlias): aAdditionalDefVars = {} if not uAlias in self.dDefinitionList_Dict: oDefinitionPathes = cDefinitionPathes(uDefinitionName) SetVar(uVarName="DEFINITIONPATH[%s]" % (uDefinitionName), oVarValue=oDefinitionPathes.oPathDefinition.string) SetVar( uVarName="DEFINITIONPATHSKINELEMENTS[%s]" % (uDefinitionName), oVarValue=oDefinitionPathes.oPathDefinitionSkinElements.string) Globals.dDefinitionPathes[uDefinitionName] = oDefinitionPathes SetDefinitionPathes(uDefinitionName) oFnDefinition = Globals.oDefinitionPathes.oFnDefinition Logger.debug(u'TheScreen: Load Definition XmlFile:' + oFnDefinition) oDefinition = cDefinition(uDefinitionName, self) oDefinition.uParentDefinitionName = uParentDefinitionName oDefinition.bImportActions = bImportActions oDefinition.bImportLanguages = bImportLanguages oDefinition.bImportPages = bImportPages oDefinition.bImportSettings = bImportSettings oDefinition.oDefinitionVarsFromParent = aDefinitionVarsFromParent #we read the definitionvars first with raw funtions sET_Data = CachedFile(Globals.oDefinitionPathes.oFnDefinition) oET_Root = fromstring(sET_Data) oRef = oET_Root.find('def_parameter') # And merge / Replace the existing Vars oDefinition.oDefinitionVars.clear() oDefinition.oDefinitionVars.update( ToOrderedDic( GetXMLTextValue(oRef, u'definitionvars', False, u'{}'))) if len(aDefinitionVarsFromParent) > 0: for uVarName in oDefinition.oDefinitionVars: if uVarName in oDefinition.oDefinitionVarsFromParent: oDefinition.oDefinitionVars[ uVarName] = oDefinition.oDefinitionVarsFromParent[ uVarName] else: Logger.warning( "Importing definition %s from %s: Definition varname not passed: '%s', using default %s" % (oDefinition.uName, uParentDefinitionName, uVarName, oDefinition.oDefinitionVars[uVarName])) for uVarName in aDefinitionVarsFromParent: if not uVarName in oDefinition.oDefinitionVars: oDefinition.oDefinitionVars[ uVarName] = oDefinition.oDefinitionVarsFromParent[ uVarName] aAdditionalDefVars[ uVarName] = oDefinition.oDefinitionVarsFromParent[ uVarName] for uKey in oDefinition.oDefinitionVars: uVar = oDefinition.oDefinitionVars[uKey] if "$cookie(" in uVar: uValue = GetCookieValue(uVar) oDefinition.oDefinitionVars[uKey] = uValue if uAlias == u'': # this works on all python versions for uKey in oDefinition.oDefinitionVars: uAlias = oDefinition.oDefinitionVars[uKey] break if uAlias == '': uAlias = uDefinitionName oDefinition.uDefPublicTitle = uDefinitionName #create a default alias def var uAliasDefVar = "definition_alias_" + uAlias if oDefinition.oDefinitionVars.get(uAliasDefVar) is None: SetDefVar(uVarName=uAliasDefVar, uVarValue=uAlias, dArray=oDefinition.oDefinitionVars) else: oDefinition.uDefPublicTitle = "%s [%s]" % (uAlias, uDefinitionName) oDefinition.uAlias = uAlias if not uAlias in self.dDefinitionList_Dict: # create defvars for import pages aTmpDefinitionVars = copy(oDefinition.oDefinitionVars) for uVar in aTmpDefinitionVars: if not uVar.endswith("_IMPORTPAGES"): if bImportPages: SetDefVar(uVarName=uVar + "_IMPORTPAGES", uVarValue="1", dArray=oDefinition.oDefinitionVars) else: SetDefVar(uVarName=uVar + "_IMPORTPAGES", uVarValue="0", dArray=oDefinition.oDefinitionVars) #and now again with adjusted definitionvars oET_Root = Orca_FromString(sET_Data, oDefinition, "root") oDefinition.oET_Root = oET_Root oDefinition.sET_Data = sET_Data self.AddDefinition(oDefinition) oXMLIncludes = oET_Root.find('definitionimports') if oXMLIncludes is not None: for oXMLInclude in oXMLIncludes.findall('definition'): uDefinitionNameImp = GetXMLTextValue( oXMLInclude, u'', True, '') bImportActionsImp = GetXMLBoolAttribute( oXMLInclude, u'importactions', False, False) bImportLanguagesImp = GetXMLBoolAttribute( oXMLInclude, u'importlanguages', False, False) bImportPagesImp = GetXMLBoolAttribute( oXMLInclude, u'importpages', False, False) bImportSettingsImp = GetXMLBoolAttribute( oXMLInclude, u'importsettings', False, False) uAliasImp = GetXMLTextAttribute( oXMLInclude, u'alias', False, '') aDefinitionVarsImp = cDefinitionVars() aDefinitionVarsImp.update( ToDic( GetXMLTextAttribute(oXMLInclude, u'definitionvars', False, {}))) # Pass Through of additional Definitionvars for uVarName in aAdditionalDefVars: if not uVarName in aDefinitionVarsImp: aDefinitionVarsImp[ uVarName] = aAdditionalDefVars[uVarName] self.__GetUsedDefinitions_Sub( uDefinitionNameImp, bImportActionsImp, bImportLanguagesImp, bImportPagesImp, bImportSettingsImp, oDefinition.uName, oDefinition.uAlias, aDefinitionVarsImp, uAliasImp) else: Logger.debug( u'GetUsedDefinitions: Skipping duplicate xml %s [%s]' % (uAlias, uDefinitionName)) else: Logger.debug( u'GetUsedDefinitions: Skipping duplicate xml %s [%s]' % (uAlias, uDefinitionName))