Beispiel #1
0
def getParser(filepath):
    extension = os.path.splitext(filepath)[1]
    if extension == ".csv":
        return tabular.Tabular()
    if extension == ".json":
        return jsoner.JSONer()
    elif extension == ".db" or extension == ".sqlite":
        try:
            tableNames = core.getDbTableNames( filepath )
        except:
            raise UnrecognizedDBError("Error reading from %s" % filepath)
        if "handle" in tableNames:
            return ios6.IOS6()
        elif "group_member" in tableNames:
            return ios5.IOS5()
        elif "TextMessage" in tableNames:
            return googlevoice.GoogleVoice()
        elif "sms" in tableNames:
            return android.Android()
        print term.red_on_black("unrecognized database details and structure:")
        print getDbInfo( file.name )
        raise UnrecognizedDBError("Unknown sqlite database: [%s]" % os.path.basename(filepath))
    elif extension == "":
        return bugle.Bugle()
    elif extension == ".xml":
        return xmlmms.XMLmms()
    raise UnrecognizedDBError("Unknown extension %s" % extension)
Beispiel #2
0
def getParser(file):
    extension = os.path.splitext(file.name)[1]
    if extension == ".csv":
        return csv.CSV()
    elif extension == ".db" or extension == ".sqlite":
        file.close()
        tableNames = core.getDbTableNames(file.name)
        if "handle" in tableNames:
            return ios6.IOS6()
        elif "group_member" in tableNames:
            return ios5.IOS5()
        elif "TextMessage" in tableNames:
            return googlevoice.GoogleVoice()
        elif "sms" in tableNames:
            return android.Android()
    elif extension == ".xml":
        return xmlmms.XMLmms()
    raise UnrecognizedDBError()