Package translate :: Package storage :: Module statsdb :: Class StatsCache

[hide private]
[frames] | no frames]

# Class StatsCache

source code

    object --+
             |
            StatsCache

An object instantiated as a singleton for each statsfile that provides access to the database cache from a pool of StatsCache objects.

Instance Methods | [hide private]

create(self) Create all tables and indexes. | source code

String or None

_getfileid(self, filename, check_mod_info=True, store=None, errors_return_empty=False) Attempt to find the fileid of the given file, if it hasn't been updated since the last record update. | source code

_getstoredcheckerconfig(self, checker) See if this checker configuration has been used before. | source code

_cacheunitstats(self, units, fileid, unitindex=None, file_totals_record={'fuzzysourcewords': 0, 'review': 0, 'untranslated': 0, 'total`...`) Cache the statistics for the supplied unit(s). | source code

_cachestore(self, store, realpath, mod_info) Calculates and caches the statistics of the given store unconditionally. | source code

filetotals(self, filename) Retrieves the statistics for the given file if possible, otherwise delegates to cachestore(). | source code

_cacheunitschecks(self, units, fileid, configid, checker, unitindex=None) Helper method for cachestorechecks() and recacheunit() | source code

cachestorechecks(self, fileid, store, checker, configid) Calculates and caches the error statistics of the given store unconditionally. | source code

get_unit_stats(self, fileid, unitid) | source code

recacheunit(self, filename, checker, unit) Recalculate all information for a specific unit. | source code

_checkerrors(self, filename, fileid, configid, checker, store) | source code

_geterrors(self, filename, fileid, configid, checker, store) | source code

_get_config_id(self, fileid, checker) | source code

filechecks(self, filename, checker, store=None) Retrieves the error statistics for the given file if possible, otherwise delegates to cachestorechecks(). | source code

file_fails_test(self, filename, checker, name) | source code

filestats(self, filename, checker, store=None) Return a dictionary of property names mapping sets of unit indices with those properties. | source code

unitstats(self, filename, _lang=None, store=None) Return a dictionary of property names mapping to arrays which map unit indices to property values. | source code

Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__init__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Static Methods | [hide private]

a new object with type S, a subtype of T

__new__(cls, statsfile=None) | source code

Class Variables | [hide private]

| _caches = ``{``}``
| defaultfile = `None`
| con = `None` This cache's connection
| cur = `None` The current cursor

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __new__(cls, statsfile=None)
Static Method

source code

Returns: a new object with type S, a subtype of T
Overrides: object.__new__
  (inherited documentation)

### _getfileid(self, filename, check_mod_info=True, store=None, errors_return_empty=False)

source code

Attempt to find the fileid of the given file, if it hasn't been updated since the last record update.

None is returned if either the file's record is not found, or if it is not up to date.

Parameters:
  - `filename` - the filename to retrieve the id for
  - `opt_mod_info` - an optional mod_info to consider in addition to the actual mod_info of the given file
Returns: String or None

### recacheunit(self, filename, checker, unit)

source code

Recalculate all information for a specific unit. This is necessary for updating all statistics when a translation of a unit took place, for example.

This method assumes that everything was up to date before (file totals, checks, checker config, etc.

### unitstats(self, filename, _lang=None, store=None)

source code

Return a dictionary of property names mapping to arrays which map unit indices to property values.

Please note that this is different from filestats, since filestats supplies sets of unit indices with a given property, whereas this method supplies arrays which map unit indices to given values.