コード例 #1
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getFit(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                fit = saveddata_session.query(Fit).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                fit = saveddata_session.query(Fit).options(*eager).filter(Fit.ID == fitID).first()
    else:
        raise TypeError("Need integer as argument")
    return fit
コード例 #2
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getSquad(squadID, eager=None):
    if isinstance(squadID, int):
        if eager is None:
            with sd_lock:
                squad = saveddata_session.query(Squad).get(squadID)
        else:
            eager = processEager(eager)
            with sd_lock:
                squad = saveddata_session.query(Squad).options(*eager).filter(Fleet.ID == squadID).first()
    else:
        raise TypeError("Need integer as argument")
    return squad
コード例 #3
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getWing(wingID, eager=None):
    if isinstance(wingID, int):
        if eager is None:
            with sd_lock:
                wing = saveddata_session.query(Wing).get(wingID)
        else:
            eager = processEager(eager)
            with sd_lock:
                wing = saveddata_session.query(Wing).options(*eager).filter(Wing.ID == wingID).first()
    else:
        raise TypeError("Need integer as argument")
    return wing
コード例 #4
0
ファイル: queries.py プロジェクト: MrNukealizer/Pyfa
def getImplantSet(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                pattern = saveddata_session.query(ImplantSet).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        eager = processEager(eager)
        with sd_lock:
            pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.name == lookfor).first()
    else:
        raise TypeError("Improper argument")
    return pattern
コード例 #5
0
def countFitsWithShip(lookfor, ownerID=None, where=None, eager=None):
    """
    Get all the fits using a certain ship.
    If no user is passed, do this for all users.
    """
    if ownerID is not None and not isinstance(ownerID, int):
        raise TypeError("OwnerID must be integer")

    if isinstance(lookfor, int):
        filter = Fit.shipID == lookfor
    elif isinstance(lookfor, list):
        if len(lookfor) == 0:
            return 0
        filter = Fit.shipID.in_(lookfor)
    else:
        raise TypeError("You must supply either an integer or ShipID must be integer")

    if ownerID is not None:
        filter = and_(filter, Fit.ownerID == ownerID)

    filter = processWhere(filter, where)
    eager = processEager(eager)
    with sd_lock:
        count = saveddata_session.query(Fit).options(*eager).filter(filter).count()

    return count
コード例 #6
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getPrice(typeID):
    if isinstance(typeID, int):
        with sd_lock:
            price = saveddata_session.query(Price).get(typeID)
    else:
        raise TypeError("Need integer as argument")
    return price
コード例 #7
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getMiscData(field):
    if isinstance(field, basestring):
        with sd_lock:
            data = saveddata_session.query(MiscData).get(field)
    else:
        raise TypeError("Need string as argument")
    return data
コード例 #8
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getDamagePattern(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                pattern = saveddata_session.query(DamagePattern).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                pattern = saveddata_session.query(DamagePattern).options(*eager).filter(DamagePattern.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        eager = processEager(eager)
        with sd_lock:
            pattern = saveddata_session.query(DamagePattern).options(*eager).filter(DamagePattern.name == lookfor).first()
    else:
        raise TypeError("Need integer or string as argument")
    return pattern
コード例 #9
0
ファイル: queries.py プロジェクト: Sectoid/Pyfa
def getUser(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                user = saveddata_session.query(User).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                user = saveddata_session.query(User).options(*eager).filter(User.ID == lookfor).first()
    elif isinstance(lookfor, str):
        eager = processEager(eager)
        with sd_lock:
            user = saveddata_session.query(User).options(*eager).filter(User.username == lookfor).first()
    else:
        raise TypeError("Need integer or string as argument")
    return user
コード例 #10
0
def getCrestCharacter(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            with sd_lock:
                character = saveddata_session.query(CrestChar).get(lookfor)
        else:
            eager = processEager(eager)
            with sd_lock:
                character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        eager = processEager(eager)
        with sd_lock:
            character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.name == lookfor).first()
    else:
        raise TypeError("Need integer or string as argument")
    return character
コード例 #11
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getSquadsIDsWithFitID(fitID):
    if isinstance(fitID, int):
        with sd_lock:
            squads = saveddata_session.query(squadmembers_table.c.squadID).filter(squadmembers_table.c.memberID == fitID).all()
            squads = tuple(entry[0] for entry in squads)
            return squads
    else:
        raise TypeError("Need integer as argument")
コード例 #12
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def getProjectedFits(fitID):
    if isinstance(fitID, int):
        with sd_lock:
            filter = and_(projectedFits_table.c.sourceID == fitID, Fit.ID == projectedFits_table.c.victimID)
            fits = saveddata_session.query(Fit).filter(filter).all()
            return fits
    else:
        raise TypeError("Need integer as argument")
コード例 #13
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getCharactersForUser(lookfor, eager=None):
    if isinstance(lookfor, int):
        eager = processEager(eager)
        with sd_lock:
            characters = saveddata_session.query(Character).options(*eager).filter(Character.ownerID == lookfor).all()
    else:
        raise TypeError("Need integer as argument")
    return characters
コード例 #14
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def searchFits(nameLike, where=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")
    # Prepare our string for request
    nameLike = u"%{0}%".format(sqlizeString(nameLike))

    #Add any extra components to the search to our where clause
    filter = processWhere(Fit.name.like(nameLike, escape="\\"), where)
    eager = processEager(eager)
    with sd_lock:
        fits = saveddata_session.query(Fit).options(*eager).filter(filter).all()
    return fits
コード例 #15
0
ファイル: queries.py プロジェクト: Sectoid/Pyfa
def getFitsWithModules(typeIDs, eager=None):
    """
    Get all the fits that have typeIDs fitted to them
    """

    if not hasattr(typeIDs, "__iter__"):
        typeIDs = (typeIDs,)

    eager = processEager(eager)
    with sd_lock:
        fits = removeInvalid(saveddata_session.query(Fit).join(Module).options(*eager).filter(Module.itemID.in_(typeIDs)).all())

    return fits
コード例 #16
0
ファイル: queries.py プロジェクト: Sectoid/Pyfa
def getSsoCharacter(lookfor, clientHash, eager=None):
    filter = SsoCharacter.client == clientHash

    if isinstance(lookfor, int):
        filter = and_(filter, SsoCharacter.ID == lookfor)
    elif isinstance(lookfor, str):
        filter = and_(filter, SsoCharacter.characterName == lookfor)
    else:
        raise TypeError("Need integer or string as argument")

    eager = processEager(eager)
    with sd_lock:
        character = saveddata_session.query(SsoCharacter).options(*eager).filter(filter).first()

    return character
コード例 #17
0
ファイル: queries.py プロジェクト: DaManDOH/Pyfa
def getBoosterFits(ownerID=None, where=None, eager=None):
    """
    Get all the fits that are flagged as a boosting ship
    If no user is passed, do this for all users.
    """

    if ownerID is not None and not isinstance(ownerID, int):
        raise TypeError("OwnerID must be integer")
    filter = Fit.booster == 1
    if ownerID is not None:
        filter = and_(filter, Fit.ownerID == ownerID)

    filter = processWhere(filter, where)
    eager = processEager(eager)
    with sd_lock:
        fits = saveddata_session.query(Fit).options(*eager).filter(filter).all()
    return fits
コード例 #18
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def countFitsWithShip(shipID, ownerID=None, where=None, eager=None):
    """
    Get all the fits using a certain ship.
    If no user is passed, do this for all users.
    """
    if isinstance(shipID, int):
        if ownerID is not None and not isinstance(ownerID, int):
            raise TypeError("OwnerID must be integer")
        filter = Fit.shipID == shipID
        if ownerID is not None:
            filter = and_(filter, Fit.ownerID == ownerID)

        filter = processWhere(filter, where)
        eager = processEager(eager)
        with sd_lock:
            count = saveddata_session.query(Fit).options(*eager).filter(filter).count()
    else:
        raise TypeError("ShipID must be integer")
    return count
コード例 #19
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getDamagePatternList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(DamagePattern).options(*eager).all()
    return patterns
コード例 #20
0
def getSsoCharacters(clientHash, eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(SsoCharacter).filter(SsoCharacter.client == clientHash).options(*eager).all()
    return characters
コード例 #21
0
ファイル: queries.py プロジェクト: mecnoc/Pyfa
def getDamagePatternList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(DamagePattern).options(*eager).all()
    return patterns
コード例 #22
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def clearPrices():
    with sd_lock:
        deleted_rows = saveddata_session.query(Price).delete()
    commit()
    return deleted_rows
コード例 #23
0
ファイル: queries.py プロジェクト: mecnoc/Pyfa
def clearOverrides():
    with sd_lock:
        deleted_rows = saveddata_session.query(Override).delete()
    commit()
    return deleted_rows
コード例 #24
0
ファイル: queries.py プロジェクト: Sectoid/Pyfa
def getSsoCharacters(clientHash, eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(SsoCharacter).filter(SsoCharacter.client == clientHash).options(*eager).all()
    return characters
コード例 #25
0
ファイル: queries.py プロジェクト: mecnoc/Pyfa
def getAllOverrides(eager=None):
    return saveddata_session.query(Override).all()
コード例 #26
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def getFleetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fleets = saveddata_session.query(Fleet).options(*eager).all()
    return fleets
コード例 #27
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def countAllFits():
    with sd_lock:
        count = saveddata_session.query(Fit).count()
    return count
コード例 #28
0
ファイル: queries.py プロジェクト: mecnoc/Pyfa
def getOverrides(itemID, eager=None):
    if isinstance(itemID, int):
        return saveddata_session.query(Override).filter(
            Override.itemID == itemID).all()
    else:
        raise TypeError("Need integer as argument")
コード例 #29
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def getTargetResistsList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(TargetResists).options(*eager).all()
    return patterns
コード例 #30
0
def getImplantSetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        sets = saveddata_session.query(ImplantSet).options(*eager).all()
    return sets
コード例 #31
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getCharacterList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(Character).options(*eager).all()
    return characters
コード例 #32
0
def clearDamagePatterns():
    with sd_lock:
        deleted_rows = saveddata_session.query(DamagePattern).filter(DamagePattern.name != 'Uniform').delete()
    commit()
    return deleted_rows
コード例 #33
0
ファイル: queries.py プロジェクト: mecnoc/Pyfa
def getTargetResistsList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        patterns = saveddata_session.query(TargetResists).options(*eager).all()
    return patterns
コード例 #34
0
def getOverrides(itemID, eager=None):
    if isinstance(itemID, int):
        return saveddata_session.query(Override).filter(Override.itemID == itemID).all()
    else:
        raise TypeError("Need integer as argument")
コード例 #35
0
ファイル: queries.py プロジェクト: mecnoc/Pyfa
def clearPrices():
    with sd_lock:
        deleted_rows = saveddata_session.query(Price).delete()
    commit()
    return deleted_rows
コード例 #36
0
def clearOverrides():
    with sd_lock:
        deleted_rows = saveddata_session.query(Override).delete()
    commit()
    return deleted_rows
コード例 #37
0
ファイル: queries.py プロジェクト: Dennovin/Pyfa
def getFleetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fleets = saveddata_session.query(Fleet).options(*eager).all()
    return fleets
コード例 #38
0
def getAllOverrides(eager=None):
    return saveddata_session.query(Override).all()
コード例 #39
0
def getImplantSetList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        sets = saveddata_session.query(ImplantSet).options(*eager).all()
    return sets
コード例 #40
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def countAllFits():
    with sd_lock:
        count = saveddata_session.query(Fit).count()
    return count
コード例 #41
0
def clearTargetProfiles():
    with sd_lock:
        deleted_rows = saveddata_session.query(TargetProfile).delete()
    commit()
    return deleted_rows
コード例 #42
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def getFitList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fits = removeInvalid(saveddata_session.query(Fit).options(*eager).all())

    return fits
コード例 #43
0
def getFitList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        fits = removeInvalid(saveddata_session.query(Fit).options(*eager).all())

    return fits
コード例 #44
0
ファイル: queries.py プロジェクト: poettler-ric/Pyfa
def getCharacterList(eager=None):
    eager = processEager(eager)
    with sd_lock:
        characters = saveddata_session.query(Character).options(*eager).all()
    return characters