Exemple #1
0
def getXmlPrefDict(prefFilePath=None):  
    """open an xml pref file and return a dictionary
    if prefFilePath == None, return a default

    >>> a = getXmlPrefDict(None)
    >>> a['athena']['debug']
    '0'
    """
    doc = None
    if prefFilePath != None:
        f = open(prefFilePath, 'r') 
        try:
            doc = xml.dom.minidom.parse(f)
        # this may be bad, but there could be many errors:
        # xml.parsers.expat.ExpatError
        # xml.sax._exceptions.SAXParseException
        # not worth the risk; just get new prefs
        except: # catch all exceptions
            # cant parse the preference files
            doc = None
        finally:
            f.close() 
    else:
        doc = None
    if doc != None:
        procData = xmlTools.xmlToPy(doc)
        return procData['preferences']
    else: # cant load this data, get new data
        return getDefaultPrefDict() 
Exemple #2
0
def getXmlPrefDict(prefFilePath=None):
    """open an xml pref file and return a dictionary
    if prefFilePath == None, return a default

    >>> a = getXmlPrefDict(None)
    >>> a['athena']['debug']
    '0'
    """
    doc = None
    if prefFilePath != None:
        f = open(prefFilePath, 'r')
        try:
            doc = xml.dom.minidom.parse(f)
        # this may be bad, but there could be many errors:
        # xml.parsers.expat.ExpatError
        # xml.sax._exceptions.SAXParseException
        # not worth the risk; just get new prefs
        except:  # catch all exceptions
            # cant parse the preference files
            doc = None
        finally:
            f.close()
    else:
        doc = None
    if doc != None:
        procData = xmlTools.xmlToPy(doc)
        return procData['preferences']
    else:  # cant load this data, get new data
        return getDefaultPrefDict()
Exemple #3
0
def extractXML(path):
    """open an xml file and return a dictionary
    dictionary built from attribute key value pairs
    missing attributes are not added (backwards compat done in athenaObj
    """
    # added universal new line support; should provide cross-plat access
    f = open(path, 'r')
    doc = xml.dom.minidom.parse(f)
    f.close()
    procData = xmlTools.xmlToPy(doc)
    aData = procData['athenaObject']['athena']  #athena Data
    pData = procData['athenaObject']['paths']  #path Data
    tData = procData['athenaObject']['textures']  #tData
    return aData, pData, tData
Exemple #4
0
def extractXML(path):
    """open an xml file and return a dictionary
    dictionary built from attribute key value pairs
    missing attributes are not added (backwards compat done in athenaObj
    """
    # added universal new line support; should provide cross-plat access
    f = open(path, "rU")
    doc = xml.dom.minidom.parse(f)
    f.close()
    procData = xmlTools.xmlToPy(doc)
    aData = procData["athenaObject"]["athena"]  # athena Data
    pData = procData["athenaObject"]["paths"]  # path Data
    tData = procData["athenaObject"]["textures"]  # tData
    return aData, pData, tData