Indexers

Indexers establish order amongs items

class lfd.gui.imagechecker.indexers.EventIndexer(URI=None)[source]

Indexes Events database providing a convenient way to establish order among the items.

_getFromFrameId(run, camcol, filter, field, which=0)[source]

Queries the database for the Event and returns it. In case multiple Events correspond to the same frame identifier, supplying which selects one of the returned results.

The returned Event is expunged from the database session.

Parameters:
  • run (int) – run identifier
  • camcol (int) – camcol identifier
  • filter (str) – string identifier
  • field (int) – field identifier
  • which (int) – if multiple Events are returned, which one in particular is wanted
_getFromItemId(eventid)[source]

Given an unique Event id queries the database for the row and returns it as an appropriate object. The returned object is expunged from the database session.

Parameters:eventid (int) – unique id of the desired Event
commit()[source]

Add the object back to the session and commit any changes made to it.

event

Returns the event pointed to by the current index.

initFromDB(uri)[source]

Connects to a database and indexes all Events therein.

class lfd.gui.imagechecker.indexers.ImageIndexer(URI=None)[source]

Indexes Image database providing a convenient way to establish order among the items.

_getFromFrameId(run, camcol, filter, field, which=0)[source]

Queries the database for the Image and returns it. In case multiple Imagess correspond to the same frame identifier, supplying which selects one of the returned results.

The returned Image is expunged from the database session.

Parameters:
  • run (int) – run identifier
  • camcol (int) – camcol identifier
  • filter (str) – string identifier
  • field (int) – field identifier
  • which (int) – if multiple items are returned, which one in particular is wanted
_getFromItemId(imageid)[source]

Given an unique image id queries the database for the row and returns it as an appropriate object. The returned object is expunged from the database session.

Parameters:eventid (int) – unique id of the desired Event
image

Returns the image pointed to by the current index.

initFromDB(uri)[source]

Connects to a database and indexes all Images therein.

class lfd.gui.imagechecker.indexers.Indexer(items=None)[source]

Generic indexer of items in a database. Given a list of items or a database connection, session and table will produce an order-maintained list of item ids. Indexer allows us to move through the rows of the db in sequentiall or non-sequential manner while loading the currently pointed to object dynamically from the database.

Parameters:items (list, tuple) – list of unique ids of the objects from the db
current

current position of the index

Type:int
maxindex

the maximal value of the index

Type:int
items

unique ids of DB rows, the item[current] points to the currently selected row of the DB

Type:list
item

currently selected dynamically loaded from the DB as an object

Type:object
_Indexer__step(step)

Makes a positive (forward) or negative (backwards) step in the list of items and loads the newly pointed to object.

_getFromFrameId(*args, **kwargs)[source]

Given a frame identifier (run, camcol, filter, field), and possibly which, queries the database for the object and returns it. Should be implementation specific perogative of classes that inehrit from Indexer

_getFromItemId(*args, **kwargs)[source]

Given an unique object id queries the database for the row and returns it as an appropriate object. The returned object is expunged from the database session.

get(run=None, camcol=None, filter=None, field=None, which=0, itemid=None)[source]

If nothing is provided, jumps to the current index and loads the db row into item. If frame identifiers (run, camcol, filter, field) are given loads the object from the database and jumps the index to its position. If itemid is provided, loads the desired object and jumps to its index.

In some cases the frame identifiers can be shared among multiple rows (i.e. multiple Events on a Frame) in which case providing ‘which’ makes it possible to select a particular item from the returned set.

The selected item is expunged from the session.

Parameters:
  • run (int) – run identifier
  • camcol (int) – camcol identifier
  • filter (str) – string identifier
  • field (int) – field identifier
  • which (int) – if multiple items are returned, which one in particular is wanted
  • itemid (int) – unique id of the desired item
goto(index=None, itemid=None)[source]

If an ‘index’ is provided jumps to the given index. If ‘itemid’ is given, jumps to the index of the provided item id. If neither are given reloads the current item.

initFromDB(dbURI)[source]

Connects to the given DB URI and indexes wanted rows from it.

next()[source]

Makes a step forward and retrieves the item.

previous()[source]

Makes a step backwards and retrieves the item.

skip(steps)[source]

Skips ‘steps’ number of steps. Value of ‘steps’ can be positive or negative indicating forward or backward skip respectively.