(lookfor, eager=None)
| 191 | |
| 192 | @cachedQuery(1, "lookfor") |
| 193 | def getGroup(lookfor, eager=None): |
| 194 | if isinstance(lookfor, int): |
| 195 | if eager is None: |
| 196 | group = get_gamedata_session().query(Group).get(lookfor) |
| 197 | else: |
| 198 | group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.ID == lookfor).first() |
| 199 | elif isinstance(lookfor, str): |
| 200 | if lookfor in groupNameMap: |
| 201 | id = groupNameMap[lookfor] |
| 202 | if eager is None: |
| 203 | group = get_gamedata_session().query(Group).get(id) |
| 204 | else: |
| 205 | group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.ID == id).first() |
| 206 | else: |
| 207 | # Group names are unique, so we can use first() instead of one() |
| 208 | group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.name == lookfor).first() |
| 209 | if group is not None: |
| 210 | groupNameMap[lookfor] = group.ID |
| 211 | else: |
| 212 | raise TypeError("Need integer or string as argument") |
| 213 | return group |
| 214 | |
| 215 | |
| 216 | categoryNameMap = {} |
no test coverage detected