repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
rodluger/everest
everest/missions/k2/k2.py
TargetDirectory
def TargetDirectory(ID, season, relative=False, **kwargs): ''' Returns the location of the :py:mod:`everest` data on disk for a given target. :param ID: The target ID :param int season: The target season number :param bool relative: Relative path? Default :py:obj:`False` ''' if season...
python
def TargetDirectory(ID, season, relative=False, **kwargs): ''' Returns the location of the :py:mod:`everest` data on disk for a given target. :param ID: The target ID :param int season: The target season number :param bool relative: Relative path? Default :py:obj:`False` ''' if season...
[ "def", "TargetDirectory", "(", "ID", ",", "season", ",", "relative", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "season", "is", "None", ":", "return", "None", "if", "relative", ":", "path", "=", "''", "else", ":", "path", "=", "EVEREST_DA...
Returns the location of the :py:mod:`everest` data on disk for a given target. :param ID: The target ID :param int season: The target season number :param bool relative: Relative path? Default :py:obj:`False`
[ "Returns", "the", "location", "of", "the", ":", "py", ":", "mod", ":", "everest", "data", "on", "disk", "for", "a", "given", "target", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/k2.py#L1766-L1785
train
rodluger/everest
everest/missions/k2/k2.py
DVSFile
def DVSFile(ID, season, cadence='lc'): ''' Returns the name of the DVS PDF for a given target. :param ID: The target ID :param int season: The target season number :param str cadence: The cadence type. Default `lc` ''' if cadence == 'sc': strcadence = '_sc' else: strca...
python
def DVSFile(ID, season, cadence='lc'): ''' Returns the name of the DVS PDF for a given target. :param ID: The target ID :param int season: The target season number :param str cadence: The cadence type. Default `lc` ''' if cadence == 'sc': strcadence = '_sc' else: strca...
[ "def", "DVSFile", "(", "ID", ",", "season", ",", "cadence", "=", "'lc'", ")", ":", "if", "cadence", "==", "'sc'", ":", "strcadence", "=", "'_sc'", "else", ":", "strcadence", "=", "''", "return", "'hlsp_everest_k2_llc_%d-c%02d_kepler_v%s_dvs%s.pdf'", "%", "(", ...
Returns the name of the DVS PDF for a given target. :param ID: The target ID :param int season: The target season number :param str cadence: The cadence type. Default `lc`
[ "Returns", "the", "name", "of", "the", "DVS", "PDF", "for", "a", "given", "target", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/k2.py#L1801-L1816
train
rodluger/everest
everest/missions/k2/k2.py
GetTargetCBVs
def GetTargetCBVs(model): ''' Returns the design matrix of CBVs for the given target. :param model: An instance of the :py:obj:`everest` model for the target ''' # Get the info season = model.season name = model.name # We use the LC light curves as CBVs; there aren't # enough SC ...
python
def GetTargetCBVs(model): ''' Returns the design matrix of CBVs for the given target. :param model: An instance of the :py:obj:`everest` model for the target ''' # Get the info season = model.season name = model.name # We use the LC light curves as CBVs; there aren't # enough SC ...
[ "def", "GetTargetCBVs", "(", "model", ")", ":", "# Get the info", "season", "=", "model", ".", "season", "name", "=", "model", ".", "name", "# We use the LC light curves as CBVs; there aren't", "# enough SC light curves to get a good set", "if", "name", ".", "endswith", ...
Returns the design matrix of CBVs for the given target. :param model: An instance of the :py:obj:`everest` model for the target
[ "Returns", "the", "design", "matrix", "of", "CBVs", "for", "the", "given", "target", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/k2.py#L1847-L1867
train
rodluger/everest
everest/missions/k2/k2.py
FitCBVs
def FitCBVs(model): ''' Fits the CBV design matrix to the de-trended flux of a given target. This is called internally whenever the user accesses the :py:attr:`fcor` attribute. :param model: An instance of the :py:obj:`everest` model for the target ''' # Get cbvs? if model.XCBV is Non...
python
def FitCBVs(model): ''' Fits the CBV design matrix to the de-trended flux of a given target. This is called internally whenever the user accesses the :py:attr:`fcor` attribute. :param model: An instance of the :py:obj:`everest` model for the target ''' # Get cbvs? if model.XCBV is Non...
[ "def", "FitCBVs", "(", "model", ")", ":", "# Get cbvs?", "if", "model", ".", "XCBV", "is", "None", ":", "GetTargetCBVs", "(", "model", ")", "# The number of CBVs to use", "ncbv", "=", "model", ".", "cbv_num", "# Need to treat short and long cadences differently", "i...
Fits the CBV design matrix to the de-trended flux of a given target. This is called internally whenever the user accesses the :py:attr:`fcor` attribute. :param model: An instance of the :py:obj:`everest` model for the target
[ "Fits", "the", "CBV", "design", "matrix", "to", "the", "de", "-", "trended", "flux", "of", "a", "given", "target", ".", "This", "is", "called", "internally", "whenever", "the", "user", "accesses", "the", ":", "py", ":", "attr", ":", "fcor", "attribute", ...
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/k2.py#L1870-L1984
train
rodluger/everest
everest/missions/k2/k2.py
StatsToCSV
def StatsToCSV(campaign, model='nPLD'): ''' Generate the CSV file used in the search database for the documentation. ''' statsfile = os.path.join(EVEREST_SRC, 'missions', 'k2', 'tables', 'c%02d_%s.cdpp' % (campaign, model)) csvfile = os.path.join(os.path.dirname(EVEREST_...
python
def StatsToCSV(campaign, model='nPLD'): ''' Generate the CSV file used in the search database for the documentation. ''' statsfile = os.path.join(EVEREST_SRC, 'missions', 'k2', 'tables', 'c%02d_%s.cdpp' % (campaign, model)) csvfile = os.path.join(os.path.dirname(EVEREST_...
[ "def", "StatsToCSV", "(", "campaign", ",", "model", "=", "'nPLD'", ")", ":", "statsfile", "=", "os", ".", "path", ".", "join", "(", "EVEREST_SRC", ",", "'missions'", ",", "'k2'", ",", "'tables'", ",", "'c%02d_%s.cdpp'", "%", "(", "campaign", ",", "model"...
Generate the CSV file used in the search database for the documentation.
[ "Generate", "the", "CSV", "file", "used", "in", "the", "search", "database", "for", "the", "documentation", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/k2.py#L1987-L2004
train
lsbardel/python-stdnet
stdnet/utils/zset.py
zset.remove
def remove(self, item): '''Remove ``item`` for the :class:`zset` it it exists. If found it returns the score of the item removed.''' score = self._dict.pop(item, None) if score is not None: self._sl.remove(score) return score
python
def remove(self, item): '''Remove ``item`` for the :class:`zset` it it exists. If found it returns the score of the item removed.''' score = self._dict.pop(item, None) if score is not None: self._sl.remove(score) return score
[ "def", "remove", "(", "self", ",", "item", ")", ":", "score", "=", "self", ".", "_dict", ".", "pop", "(", "item", ",", "None", ")", "if", "score", "is", "not", "None", ":", "self", ".", "_sl", ".", "remove", "(", "score", ")", "return", "score" ]
Remove ``item`` for the :class:`zset` it it exists. If found it returns the score of the item removed.
[ "Remove", "item", "for", "the", ":", "class", ":", "zset", "it", "it", "exists", ".", "If", "found", "it", "returns", "the", "score", "of", "the", "item", "removed", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/zset.py#L52-L58
train
lsbardel/python-stdnet
stdnet/apps/columnts/redis.py
RedisColumnTS.fields
def fields(self): '''Return a tuple of ordered fields for this :class:`ColumnTS`.''' key = self.id + ':fields' encoding = self.client.encoding return tuple(sorted((f.decode(encoding) for f in self.client.smembers(key))))
python
def fields(self): '''Return a tuple of ordered fields for this :class:`ColumnTS`.''' key = self.id + ':fields' encoding = self.client.encoding return tuple(sorted((f.decode(encoding) for f in self.client.smembers(key))))
[ "def", "fields", "(", "self", ")", ":", "key", "=", "self", ".", "id", "+", "':fields'", "encoding", "=", "self", ".", "client", ".", "encoding", "return", "tuple", "(", "sorted", "(", "(", "f", ".", "decode", "(", "encoding", ")", "for", "f", "in"...
Return a tuple of ordered fields for this :class:`ColumnTS`.
[ "Return", "a", "tuple", "of", "ordered", "fields", "for", "this", ":", "class", ":", "ColumnTS", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/redis.py#L38-L43
train
lsbardel/python-stdnet
stdnet/odm/related.py
do_pending_lookups
def do_pending_lookups(event, sender, **kwargs): """Handle any pending relations to the sending model. Sent from class_prepared.""" key = (sender._meta.app_label, sender._meta.name) for callback in pending_lookups.pop(key, []): callback(sender)
python
def do_pending_lookups(event, sender, **kwargs): """Handle any pending relations to the sending model. Sent from class_prepared.""" key = (sender._meta.app_label, sender._meta.name) for callback in pending_lookups.pop(key, []): callback(sender)
[ "def", "do_pending_lookups", "(", "event", ",", "sender", ",", "*", "*", "kwargs", ")", ":", "key", "=", "(", "sender", ".", "_meta", ".", "app_label", ",", "sender", ".", "_meta", ".", "name", ")", "for", "callback", "in", "pending_lookups", ".", "pop...
Handle any pending relations to the sending model. Sent from class_prepared.
[ "Handle", "any", "pending", "relations", "to", "the", "sending", "model", ".", "Sent", "from", "class_prepared", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/related.py#L66-L71
train
lsbardel/python-stdnet
stdnet/odm/related.py
Many2ManyThroughModel
def Many2ManyThroughModel(field): '''Create a Many2Many through model with two foreign key fields and a CompositeFieldId depending on the two foreign keys.''' from stdnet.odm import ModelType, StdModel, ForeignKey, CompositeIdField name_model = field.model._meta.name name_relmodel = field.relmodel....
python
def Many2ManyThroughModel(field): '''Create a Many2Many through model with two foreign key fields and a CompositeFieldId depending on the two foreign keys.''' from stdnet.odm import ModelType, StdModel, ForeignKey, CompositeIdField name_model = field.model._meta.name name_relmodel = field.relmodel....
[ "def", "Many2ManyThroughModel", "(", "field", ")", ":", "from", "stdnet", ".", "odm", "import", "ModelType", ",", "StdModel", ",", "ForeignKey", ",", "CompositeIdField", "name_model", "=", "field", ".", "model", ".", "_meta", ".", "name", "name_relmodel", "=",...
Create a Many2Many through model with two foreign key fields and a CompositeFieldId depending on the two foreign keys.
[ "Create", "a", "Many2Many", "through", "model", "with", "two", "foreign", "key", "fields", "and", "a", "CompositeFieldId", "depending", "on", "the", "two", "foreign", "keys", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/related.py#L77-L114
train
lsbardel/python-stdnet
stdnet/odm/related.py
makeMany2ManyRelatedManager
def makeMany2ManyRelatedManager(formodel, name_relmodel, name_formodel): '''formodel is the model which the manager .''' class _Many2ManyRelatedManager(Many2ManyRelatedManager): pass _Many2ManyRelatedManager.formodel = formodel _Many2ManyRelatedManager.name_relmodel = name_relmodel ...
python
def makeMany2ManyRelatedManager(formodel, name_relmodel, name_formodel): '''formodel is the model which the manager .''' class _Many2ManyRelatedManager(Many2ManyRelatedManager): pass _Many2ManyRelatedManager.formodel = formodel _Many2ManyRelatedManager.name_relmodel = name_relmodel ...
[ "def", "makeMany2ManyRelatedManager", "(", "formodel", ",", "name_relmodel", ",", "name_formodel", ")", ":", "class", "_Many2ManyRelatedManager", "(", "Many2ManyRelatedManager", ")", ":", "pass", "_Many2ManyRelatedManager", ".", "formodel", "=", "formodel", "_Many2ManyRel...
formodel is the model which the manager .
[ "formodel", "is", "the", "model", "which", "the", "manager", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/related.py#L265-L274
train
lsbardel/python-stdnet
stdnet/odm/related.py
RelatedManager.session
def session(self, session=None): '''Override :meth:`Manager.session` so that this :class:`RelatedManager` can retrieve the session from the :attr:`related_instance` if available. ''' if self.related_instance: session = self.related_instance.session # we...
python
def session(self, session=None): '''Override :meth:`Manager.session` so that this :class:`RelatedManager` can retrieve the session from the :attr:`related_instance` if available. ''' if self.related_instance: session = self.related_instance.session # we...
[ "def", "session", "(", "self", ",", "session", "=", "None", ")", ":", "if", "self", ".", "related_instance", ":", "session", "=", "self", ".", "related_instance", ".", "session", "# we have a session, we either create a new one return the same session\r", "if", "sessi...
Override :meth:`Manager.session` so that this :class:`RelatedManager` can retrieve the session from the :attr:`related_instance` if available.
[ "Override", ":", "meth", ":", "Manager", ".", "session", "so", "that", "this", ":", "class", ":", "RelatedManager", "can", "retrieve", "the", "session", "from", "the", ":", "attr", ":", "related_instance", "if", "available", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/related.py#L176-L187
train
lsbardel/python-stdnet
stdnet/odm/related.py
Many2ManyRelatedManager.add
def add(self, value, session=None, **kwargs): '''Add ``value``, an instance of :attr:`formodel` to the :attr:`through` model. This method can only be accessed by an instance of the model for which this related manager is an attribute.''' s, instance = self.session_instance('add', value, session, **k...
python
def add(self, value, session=None, **kwargs): '''Add ``value``, an instance of :attr:`formodel` to the :attr:`through` model. This method can only be accessed by an instance of the model for which this related manager is an attribute.''' s, instance = self.session_instance('add', value, session, **k...
[ "def", "add", "(", "self", ",", "value", ",", "session", "=", "None", ",", "*", "*", "kwargs", ")", ":", "s", ",", "instance", "=", "self", ".", "session_instance", "(", "'add'", ",", "value", ",", "session", ",", "*", "*", "kwargs", ")", "return",...
Add ``value``, an instance of :attr:`formodel` to the :attr:`through` model. This method can only be accessed by an instance of the model for which this related manager is an attribute.
[ "Add", "value", "an", "instance", "of", ":", "attr", ":", "formodel", "to", "the", ":", "attr", ":", "through", "model", ".", "This", "method", "can", "only", "be", "accessed", "by", "an", "instance", "of", "the", "model", "for", "which", "this", "rela...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/related.py#L237-L242
train
lsbardel/python-stdnet
stdnet/odm/related.py
Many2ManyRelatedManager.remove
def remove(self, value, session=None): '''Remove *value*, an instance of ``self.model`` from the set of elements contained by the field.''' s, instance = self.session_instance('remove', value, session) # update state so that the instance does look persistent instance.get_state(iid=i...
python
def remove(self, value, session=None): '''Remove *value*, an instance of ``self.model`` from the set of elements contained by the field.''' s, instance = self.session_instance('remove', value, session) # update state so that the instance does look persistent instance.get_state(iid=i...
[ "def", "remove", "(", "self", ",", "value", ",", "session", "=", "None", ")", ":", "s", ",", "instance", "=", "self", ".", "session_instance", "(", "'remove'", ",", "value", ",", "session", ")", "# update state so that the instance does look persistent\r", "inst...
Remove *value*, an instance of ``self.model`` from the set of elements contained by the field.
[ "Remove", "*", "value", "*", "an", "instance", "of", "self", ".", "model", "from", "the", "set", "of", "elements", "contained", "by", "the", "field", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/related.py#L244-L250
train
lsbardel/python-stdnet
stdnet/apps/searchengine/processors/__init__.py
metaphone_processor
def metaphone_processor(words): '''Double metaphone word processor.''' for word in words: for w in double_metaphone(word): if w: w = w.strip() if w: yield w
python
def metaphone_processor(words): '''Double metaphone word processor.''' for word in words: for w in double_metaphone(word): if w: w = w.strip() if w: yield w
[ "def", "metaphone_processor", "(", "words", ")", ":", "for", "word", "in", "words", ":", "for", "w", "in", "double_metaphone", "(", "word", ")", ":", "if", "w", ":", "w", "=", "w", ".", "strip", "(", ")", "if", "w", ":", "yield", "w" ]
Double metaphone word processor.
[ "Double", "metaphone", "word", "processor", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/processors/__init__.py#L18-L25
train
lsbardel/python-stdnet
stdnet/apps/searchengine/processors/__init__.py
tolerant_metaphone_processor
def tolerant_metaphone_processor(words): '''Double metaphone word processor slightly modified so that when no words are returned by the algorithm, the original word is returned.''' for word in words: r = 0 for w in double_metaphone(word): if w: w = w.strip() ...
python
def tolerant_metaphone_processor(words): '''Double metaphone word processor slightly modified so that when no words are returned by the algorithm, the original word is returned.''' for word in words: r = 0 for w in double_metaphone(word): if w: w = w.strip() ...
[ "def", "tolerant_metaphone_processor", "(", "words", ")", ":", "for", "word", "in", "words", ":", "r", "=", "0", "for", "w", "in", "double_metaphone", "(", "word", ")", ":", "if", "w", ":", "w", "=", "w", ".", "strip", "(", ")", "if", "w", ":", "...
Double metaphone word processor slightly modified so that when no words are returned by the algorithm, the original word is returned.
[ "Double", "metaphone", "word", "processor", "slightly", "modified", "so", "that", "when", "no", "words", "are", "returned", "by", "the", "algorithm", "the", "original", "word", "is", "returned", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/processors/__init__.py#L28-L40
train
lsbardel/python-stdnet
stdnet/apps/searchengine/processors/__init__.py
stemming_processor
def stemming_processor(words): '''Porter Stemmer word processor''' stem = PorterStemmer().stem for word in words: word = stem(word, 0, len(word)-1) yield word
python
def stemming_processor(words): '''Porter Stemmer word processor''' stem = PorterStemmer().stem for word in words: word = stem(word, 0, len(word)-1) yield word
[ "def", "stemming_processor", "(", "words", ")", ":", "stem", "=", "PorterStemmer", "(", ")", ".", "stem", "for", "word", "in", "words", ":", "word", "=", "stem", "(", "word", ",", "0", ",", "len", "(", "word", ")", "-", "1", ")", "yield", "word" ]
Porter Stemmer word processor
[ "Porter", "Stemmer", "word", "processor" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/processors/__init__.py#L43-L48
train
rodluger/everest
everest/pool.py
Pool
def Pool(pool='AnyPool', **kwargs): ''' Chooses between the different pools. If ``pool == 'AnyPool'``, chooses based on availability. ''' if pool == 'MPIPool': return MPIPool(**kwargs) elif pool == 'MultiPool': return MultiPool(**kwargs) elif pool == 'SerialPool': r...
python
def Pool(pool='AnyPool', **kwargs): ''' Chooses between the different pools. If ``pool == 'AnyPool'``, chooses based on availability. ''' if pool == 'MPIPool': return MPIPool(**kwargs) elif pool == 'MultiPool': return MultiPool(**kwargs) elif pool == 'SerialPool': r...
[ "def", "Pool", "(", "pool", "=", "'AnyPool'", ",", "*", "*", "kwargs", ")", ":", "if", "pool", "==", "'MPIPool'", ":", "return", "MPIPool", "(", "*", "*", "kwargs", ")", "elif", "pool", "==", "'MultiPool'", ":", "return", "MultiPool", "(", "*", "*", ...
Chooses between the different pools. If ``pool == 'AnyPool'``, chooses based on availability.
[ "Chooses", "between", "the", "different", "pools", ".", "If", "pool", "==", "AnyPool", "chooses", "based", "on", "availability", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/pool.py#L504-L525
train
rodluger/everest
everest/pool.py
MPIPool.wait
def wait(self): """ If this isn't the master process, wait for instructions. """ if self.is_master(): raise RuntimeError("Master node told to await jobs.") status = MPI.Status() while True: # Event loop. # Sit here and await instruct...
python
def wait(self): """ If this isn't the master process, wait for instructions. """ if self.is_master(): raise RuntimeError("Master node told to await jobs.") status = MPI.Status() while True: # Event loop. # Sit here and await instruct...
[ "def", "wait", "(", "self", ")", ":", "if", "self", ".", "is_master", "(", ")", ":", "raise", "RuntimeError", "(", "\"Master node told to await jobs.\"", ")", "status", "=", "MPI", ".", "Status", "(", ")", "while", "True", ":", "# Event loop.", "# Sit here a...
If this isn't the master process, wait for instructions.
[ "If", "this", "isn", "t", "the", "master", "process", "wait", "for", "instructions", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/pool.py#L220-L269
train
rodluger/everest
everest/pool.py
MPIPool.map
def map(self, function, tasks): """ Like the built-in :py:func:`map` function, apply a function to all of the values in a list and return the list of results. :param function: The function to apply to the list. :param tasks: The list of elements. ...
python
def map(self, function, tasks): """ Like the built-in :py:func:`map` function, apply a function to all of the values in a list and return the list of results. :param function: The function to apply to the list. :param tasks: The list of elements. ...
[ "def", "map", "(", "self", ",", "function", ",", "tasks", ")", ":", "ntask", "=", "len", "(", "tasks", ")", "# If not the master just wait for instructions.", "if", "not", "self", ".", "is_master", "(", ")", ":", "self", ".", "wait", "(", ")", "return", ...
Like the built-in :py:func:`map` function, apply a function to all of the values in a list and return the list of results. :param function: The function to apply to the list. :param tasks: The list of elements.
[ "Like", "the", "built", "-", "in", ":", "py", ":", "func", ":", "map", "function", "apply", "a", "function", "to", "all", "of", "the", "values", "in", "a", "list", "and", "return", "the", "list", "of", "results", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/pool.py#L271-L380
train
rodluger/everest
everest/pool.py
MPIPool.close
def close(self): """ Just send a message off to all the pool members which contains the special :class:`_close_pool_message` sentinel. """ if self.is_master(): for i in range(self.size): self.comm.isend(_close_pool_message(), dest=i + 1)
python
def close(self): """ Just send a message off to all the pool members which contains the special :class:`_close_pool_message` sentinel. """ if self.is_master(): for i in range(self.size): self.comm.isend(_close_pool_message(), dest=i + 1)
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "is_master", "(", ")", ":", "for", "i", "in", "range", "(", "self", ".", "size", ")", ":", "self", ".", "comm", ".", "isend", "(", "_close_pool_message", "(", ")", ",", "dest", "=", "i", ...
Just send a message off to all the pool members which contains the special :class:`_close_pool_message` sentinel.
[ "Just", "send", "a", "message", "off", "to", "all", "the", "pool", "members", "which", "contains", "the", "special", ":", "class", ":", "_close_pool_message", "sentinel", "." ]
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/pool.py#L388-L396
train
lsbardel/python-stdnet
stdnet/odm/struct.py
commit_when_no_transaction
def commit_when_no_transaction(f): '''Decorator for committing changes when the instance session is not in a transaction.''' def _(self, *args, **kwargs): r = f(self, *args, **kwargs) return self.session.add(self) if self.session is not None else r _.__name__ = f.__name__ _.__doc_...
python
def commit_when_no_transaction(f): '''Decorator for committing changes when the instance session is not in a transaction.''' def _(self, *args, **kwargs): r = f(self, *args, **kwargs) return self.session.add(self) if self.session is not None else r _.__name__ = f.__name__ _.__doc_...
[ "def", "commit_when_no_transaction", "(", "f", ")", ":", "def", "_", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "r", "=", "f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self", ".", "session", ...
Decorator for committing changes when the instance session is not in a transaction.
[ "Decorator", "for", "committing", "changes", "when", "the", "instance", "session", "is", "not", "in", "a", "transaction", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L32-L40
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Structure.backend
def backend(self): '''Returns the :class:`stdnet.BackendStructure`. ''' session = self.session if session is not None: if self._field: return session.model(self._field.model).backend else: return session.model(self).backend
python
def backend(self): '''Returns the :class:`stdnet.BackendStructure`. ''' session = self.session if session is not None: if self._field: return session.model(self._field.model).backend else: return session.model(self).backend
[ "def", "backend", "(", "self", ")", ":", "session", "=", "self", ".", "session", "if", "session", "is", "not", "None", ":", "if", "self", ".", "_field", ":", "return", "session", ".", "model", "(", "self", ".", "_field", ".", "model", ")", ".", "ba...
Returns the :class:`stdnet.BackendStructure`.
[ "Returns", "the", ":", "class", ":", "stdnet", ".", "BackendStructure", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L257-L265
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Structure.read_backend
def read_backend(self): '''Returns the :class:`stdnet.BackendStructure`. ''' session = self.session if session is not None: if self._field: return session.model(self._field.model).read_backend else: return session.model(self...
python
def read_backend(self): '''Returns the :class:`stdnet.BackendStructure`. ''' session = self.session if session is not None: if self._field: return session.model(self._field.model).read_backend else: return session.model(self...
[ "def", "read_backend", "(", "self", ")", ":", "session", "=", "self", ".", "session", "if", "session", "is", "not", "None", ":", "if", "self", ".", "_field", ":", "return", "session", ".", "model", "(", "self", ".", "_field", ".", "model", ")", ".", ...
Returns the :class:`stdnet.BackendStructure`.
[ "Returns", "the", ":", "class", ":", "stdnet", ".", "BackendStructure", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L268-L276
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Structure.size
def size(self): '''Number of elements in the :class:`Structure`.''' if self.cache.cache is None: return self.read_backend_structure().size() else: return len(self.cache.cache)
python
def size(self): '''Number of elements in the :class:`Structure`.''' if self.cache.cache is None: return self.read_backend_structure().size() else: return len(self.cache.cache)
[ "def", "size", "(", "self", ")", ":", "if", "self", ".", "cache", ".", "cache", "is", "None", ":", "return", "self", ".", "read_backend_structure", "(", ")", ".", "size", "(", ")", "else", ":", "return", "len", "(", "self", ".", "cache", ".", "cach...
Number of elements in the :class:`Structure`.
[ "Number", "of", "elements", "in", "the", ":", "class", ":", "Structure", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L288-L293
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Structure.load_data
def load_data(self, data, callback=None): '''Load ``data`` from the :class:`stdnet.BackendDataServer`.''' return self.backend.execute( self.value_pickler.load_iterable(data, self.session), callback)
python
def load_data(self, data, callback=None): '''Load ``data`` from the :class:`stdnet.BackendDataServer`.''' return self.backend.execute( self.value_pickler.load_iterable(data, self.session), callback)
[ "def", "load_data", "(", "self", ",", "data", ",", "callback", "=", "None", ")", ":", "return", "self", ".", "backend", ".", "execute", "(", "self", ".", "value_pickler", ".", "load_iterable", "(", "data", ",", "self", ".", "session", ")", ",", "callba...
Load ``data`` from the :class:`stdnet.BackendDataServer`.
[ "Load", "data", "from", "the", ":", "class", ":", "stdnet", ".", "BackendDataServer", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L305-L308
train
lsbardel/python-stdnet
stdnet/odm/struct.py
PairMixin.values
def values(self): '''Iteratir over values of :class:`PairMixin`.''' if self.cache.cache is None: backend = self.read_backend return backend.execute(backend.structure(self).values(), self.load_values) else: return self....
python
def values(self): '''Iteratir over values of :class:`PairMixin`.''' if self.cache.cache is None: backend = self.read_backend return backend.execute(backend.structure(self).values(), self.load_values) else: return self....
[ "def", "values", "(", "self", ")", ":", "if", "self", ".", "cache", ".", "cache", "is", "None", ":", "backend", "=", "self", ".", "read_backend", "return", "backend", ".", "execute", "(", "backend", ".", "structure", "(", "self", ")", ".", "values", ...
Iteratir over values of :class:`PairMixin`.
[ "Iteratir", "over", "values", "of", ":", "class", ":", "PairMixin", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L356-L363
train
lsbardel/python-stdnet
stdnet/odm/struct.py
PairMixin.pair
def pair(self, pair): '''Add a *pair* to the structure.''' if len(pair) == 1: # if only one value is passed, the value must implement a # score function which retrieve the first value of the pair # (score in zset, timevalue in timeseries, field value in ...
python
def pair(self, pair): '''Add a *pair* to the structure.''' if len(pair) == 1: # if only one value is passed, the value must implement a # score function which retrieve the first value of the pair # (score in zset, timevalue in timeseries, field value in ...
[ "def", "pair", "(", "self", ",", "pair", ")", ":", "if", "len", "(", "pair", ")", "==", "1", ":", "# if only one value is passed, the value must implement a\r", "# score function which retrieve the first value of the pair\r", "# (score in zset, timevalue in timeseries, field valu...
Add a *pair* to the structure.
[ "Add", "a", "*", "pair", "*", "to", "the", "structure", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L365-L377
train
lsbardel/python-stdnet
stdnet/odm/struct.py
KeyValueMixin.remove
def remove(self, *keys): '''Remove *keys* from the key-value container.''' dumps = self.pickler.dumps self.cache.remove([dumps(v) for v in keys])
python
def remove(self, *keys): '''Remove *keys* from the key-value container.''' dumps = self.pickler.dumps self.cache.remove([dumps(v) for v in keys])
[ "def", "remove", "(", "self", ",", "*", "keys", ")", ":", "dumps", "=", "self", ".", "pickler", ".", "dumps", "self", ".", "cache", ".", "remove", "(", "[", "dumps", "(", "v", ")", "for", "v", "in", "keys", "]", ")" ]
Remove *keys* from the key-value container.
[ "Remove", "*", "keys", "*", "from", "the", "key", "-", "value", "container", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L486-L489
train
lsbardel/python-stdnet
stdnet/odm/struct.py
OrderedMixin.count
def count(self, start, stop): '''Count the number of elements bewteen *start* and *stop*.''' s1 = self.pickler.dumps(start) s2 = self.pickler.dumps(stop) return self.backend_structure().count(s1, s2)
python
def count(self, start, stop): '''Count the number of elements bewteen *start* and *stop*.''' s1 = self.pickler.dumps(start) s2 = self.pickler.dumps(stop) return self.backend_structure().count(s1, s2)
[ "def", "count", "(", "self", ",", "start", ",", "stop", ")", ":", "s1", "=", "self", ".", "pickler", ".", "dumps", "(", "start", ")", "s2", "=", "self", ".", "pickler", ".", "dumps", "(", "stop", ")", "return", "self", ".", "backend_structure", "("...
Count the number of elements bewteen *start* and *stop*.
[ "Count", "the", "number", "of", "elements", "bewteen", "*", "start", "*", "and", "*", "stop", "*", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L520-L524
train
lsbardel/python-stdnet
stdnet/odm/struct.py
OrderedMixin.irange
def irange(self, start=0, end=-1, callback=None, withscores=True, **options): '''Return the range by rank between start and end.''' backend = self.read_backend res = backend.structure(self).irange(start, end, withscores=withscores,...
python
def irange(self, start=0, end=-1, callback=None, withscores=True, **options): '''Return the range by rank between start and end.''' backend = self.read_backend res = backend.structure(self).irange(start, end, withscores=withscores,...
[ "def", "irange", "(", "self", ",", "start", "=", "0", ",", "end", "=", "-", "1", ",", "callback", "=", "None", ",", "withscores", "=", "True", ",", "*", "*", "options", ")", ":", "backend", "=", "self", ".", "read_backend", "res", "=", "backend", ...
Return the range by rank between start and end.
[ "Return", "the", "range", "by", "rank", "between", "start", "and", "end", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L537-L546
train
lsbardel/python-stdnet
stdnet/odm/struct.py
OrderedMixin.pop_range
def pop_range(self, start, stop, callback=None, withscores=True): '''pop a range by score from the :class:`OrderedMixin`''' s1 = self.pickler.dumps(start) s2 = self.pickler.dumps(stop) backend = self.backend res = backend.structure(self).pop_range(s1, s2, withscores=withscor...
python
def pop_range(self, start, stop, callback=None, withscores=True): '''pop a range by score from the :class:`OrderedMixin`''' s1 = self.pickler.dumps(start) s2 = self.pickler.dumps(stop) backend = self.backend res = backend.structure(self).pop_range(s1, s2, withscores=withscor...
[ "def", "pop_range", "(", "self", ",", "start", ",", "stop", ",", "callback", "=", "None", ",", "withscores", "=", "True", ")", ":", "s1", "=", "self", ".", "pickler", ".", "dumps", "(", "start", ")", "s2", "=", "self", ".", "pickler", ".", "dumps",...
pop a range by score from the :class:`OrderedMixin`
[ "pop", "a", "range", "by", "score", "from", "the", ":", "class", ":", "OrderedMixin" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L548-L556
train
lsbardel/python-stdnet
stdnet/odm/struct.py
OrderedMixin.ipop_range
def ipop_range(self, start=0, stop=-1, callback=None, withscores=True): '''pop a range from the :class:`OrderedMixin`''' backend = self.backend res = backend.structure(self).ipop_range(start, stop, withscores=withscores) if not callba...
python
def ipop_range(self, start=0, stop=-1, callback=None, withscores=True): '''pop a range from the :class:`OrderedMixin`''' backend = self.backend res = backend.structure(self).ipop_range(start, stop, withscores=withscores) if not callba...
[ "def", "ipop_range", "(", "self", ",", "start", "=", "0", ",", "stop", "=", "-", "1", ",", "callback", "=", "None", ",", "withscores", "=", "True", ")", ":", "backend", "=", "self", ".", "backend", "res", "=", "backend", ".", "structure", "(", "sel...
pop a range from the :class:`OrderedMixin`
[ "pop", "a", "range", "from", "the", ":", "class", ":", "OrderedMixin" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L558-L565
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Sequence.push_back
def push_back(self, value): '''Appends a copy of *value* at the end of the :class:`Sequence`.''' self.cache.push_back(self.value_pickler.dumps(value)) return self
python
def push_back(self, value): '''Appends a copy of *value* at the end of the :class:`Sequence`.''' self.cache.push_back(self.value_pickler.dumps(value)) return self
[ "def", "push_back", "(", "self", ",", "value", ")", ":", "self", ".", "cache", ".", "push_back", "(", "self", ".", "value_pickler", ".", "dumps", "(", "value", ")", ")", "return", "self" ]
Appends a copy of *value* at the end of the :class:`Sequence`.
[ "Appends", "a", "copy", "of", "*", "value", "*", "at", "the", "end", "of", "the", ":", "class", ":", "Sequence", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L583-L586
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Sequence.pop_back
def pop_back(self): '''Remove the last element from the :class:`Sequence`.''' backend = self.backend return backend.execute(backend.structure(self).pop_back(), self.value_pickler.loads)
python
def pop_back(self): '''Remove the last element from the :class:`Sequence`.''' backend = self.backend return backend.execute(backend.structure(self).pop_back(), self.value_pickler.loads)
[ "def", "pop_back", "(", "self", ")", ":", "backend", "=", "self", ".", "backend", "return", "backend", ".", "execute", "(", "backend", ".", "structure", "(", "self", ")", ".", "pop_back", "(", ")", ",", "self", ".", "value_pickler", ".", "loads", ")" ]
Remove the last element from the :class:`Sequence`.
[ "Remove", "the", "last", "element", "from", "the", ":", "class", ":", "Sequence", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L588-L592
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Set.add
def add(self, value): '''Add *value* to the set''' return self.cache.update((self.value_pickler.dumps(value),))
python
def add(self, value): '''Add *value* to the set''' return self.cache.update((self.value_pickler.dumps(value),))
[ "def", "add", "(", "self", ",", "value", ")", ":", "return", "self", ".", "cache", ".", "update", "(", "(", "self", ".", "value_pickler", ".", "dumps", "(", "value", ")", ",", ")", ")" ]
Add *value* to the set
[ "Add", "*", "value", "*", "to", "the", "set" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L613-L615
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Set.update
def update(self, values): '''Add iterable *values* to the set''' d = self.value_pickler.dumps return self.cache.update(tuple((d(v) for v in values)))
python
def update(self, values): '''Add iterable *values* to the set''' d = self.value_pickler.dumps return self.cache.update(tuple((d(v) for v in values)))
[ "def", "update", "(", "self", ",", "values", ")", ":", "d", "=", "self", ".", "value_pickler", ".", "dumps", "return", "self", ".", "cache", ".", "update", "(", "tuple", "(", "(", "d", "(", "v", ")", "for", "v", "in", "values", ")", ")", ")" ]
Add iterable *values* to the set
[ "Add", "iterable", "*", "values", "*", "to", "the", "set" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L618-L621
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Set.discard
def discard(self, value): '''Remove an element *value* from a set if it is a member.''' return self.cache.remove((self.value_pickler.dumps(value),))
python
def discard(self, value): '''Remove an element *value* from a set if it is a member.''' return self.cache.remove((self.value_pickler.dumps(value),))
[ "def", "discard", "(", "self", ",", "value", ")", ":", "return", "self", ".", "cache", ".", "remove", "(", "(", "self", ".", "value_pickler", ".", "dumps", "(", "value", ")", ",", ")", ")" ]
Remove an element *value* from a set if it is a member.
[ "Remove", "an", "element", "*", "value", "*", "from", "a", "set", "if", "it", "is", "a", "member", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L624-L626
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Set.difference_update
def difference_update(self, values): '''Remove an iterable of *values* from the set.''' d = self.value_pickler.dumps return self.cache.remove(tuple((d(v) for v in values)))
python
def difference_update(self, values): '''Remove an iterable of *values* from the set.''' d = self.value_pickler.dumps return self.cache.remove(tuple((d(v) for v in values)))
[ "def", "difference_update", "(", "self", ",", "values", ")", ":", "d", "=", "self", ".", "value_pickler", ".", "dumps", "return", "self", ".", "cache", ".", "remove", "(", "tuple", "(", "(", "d", "(", "v", ")", "for", "v", "in", "values", ")", ")",...
Remove an iterable of *values* from the set.
[ "Remove", "an", "iterable", "of", "*", "values", "*", "from", "the", "set", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L630-L633
train
lsbardel/python-stdnet
stdnet/odm/struct.py
List.pop_front
def pop_front(self): '''Remove the first element from of the list.''' backend = self.backend return backend.execute(backend.structure(self).pop_front(), self.value_pickler.loads)
python
def pop_front(self): '''Remove the first element from of the list.''' backend = self.backend return backend.execute(backend.structure(self).pop_front(), self.value_pickler.loads)
[ "def", "pop_front", "(", "self", ")", ":", "backend", "=", "self", ".", "backend", "return", "backend", ".", "execute", "(", "backend", ".", "structure", "(", "self", ")", ".", "pop_front", "(", ")", ",", "self", ".", "value_pickler", ".", "loads", ")"...
Remove the first element from of the list.
[ "Remove", "the", "first", "element", "from", "of", "the", "list", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L640-L644
train
lsbardel/python-stdnet
stdnet/odm/struct.py
List.block_pop_back
def block_pop_back(self, timeout=10): '''Remove the last element from of the list. If no elements are available, blocks for at least ``timeout`` seconds.''' value = yield self.backend_structure().block_pop_back(timeout) if value is not None: yield self.value_pickler.loads(value)
python
def block_pop_back(self, timeout=10): '''Remove the last element from of the list. If no elements are available, blocks for at least ``timeout`` seconds.''' value = yield self.backend_structure().block_pop_back(timeout) if value is not None: yield self.value_pickler.loads(value)
[ "def", "block_pop_back", "(", "self", ",", "timeout", "=", "10", ")", ":", "value", "=", "yield", "self", ".", "backend_structure", "(", ")", ".", "block_pop_back", "(", "timeout", ")", "if", "value", "is", "not", "None", ":", "yield", "self", ".", "va...
Remove the last element from of the list. If no elements are available, blocks for at least ``timeout`` seconds.
[ "Remove", "the", "last", "element", "from", "of", "the", "list", ".", "If", "no", "elements", "are", "available", "blocks", "for", "at", "least", "timeout", "seconds", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L646-L651
train
lsbardel/python-stdnet
stdnet/odm/struct.py
List.block_pop_front
def block_pop_front(self, timeout=10): '''Remove the first element from of the list. If no elements are available, blocks for at least ``timeout`` seconds.''' value = yield self.backend_structure().block_pop_front(timeout) if value is not None: yield self.value_pickler.loads(val...
python
def block_pop_front(self, timeout=10): '''Remove the first element from of the list. If no elements are available, blocks for at least ``timeout`` seconds.''' value = yield self.backend_structure().block_pop_front(timeout) if value is not None: yield self.value_pickler.loads(val...
[ "def", "block_pop_front", "(", "self", ",", "timeout", "=", "10", ")", ":", "value", "=", "yield", "self", ".", "backend_structure", "(", ")", ".", "block_pop_front", "(", "timeout", ")", "if", "value", "is", "not", "None", ":", "yield", "self", ".", "...
Remove the first element from of the list. If no elements are available, blocks for at least ``timeout`` seconds.
[ "Remove", "the", "first", "element", "from", "of", "the", "list", ".", "If", "no", "elements", "are", "available", "blocks", "for", "at", "least", "timeout", "seconds", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L653-L658
train
lsbardel/python-stdnet
stdnet/odm/struct.py
List.push_front
def push_front(self, value): '''Appends a copy of ``value`` to the beginning of the list.''' self.cache.push_front(self.value_pickler.dumps(value))
python
def push_front(self, value): '''Appends a copy of ``value`` to the beginning of the list.''' self.cache.push_front(self.value_pickler.dumps(value))
[ "def", "push_front", "(", "self", ",", "value", ")", ":", "self", ".", "cache", ".", "push_front", "(", "self", ".", "value_pickler", ".", "dumps", "(", "value", ")", ")" ]
Appends a copy of ``value`` to the beginning of the list.
[ "Appends", "a", "copy", "of", "value", "to", "the", "beginning", "of", "the", "list", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L661-L663
train
lsbardel/python-stdnet
stdnet/odm/struct.py
Zset.rank
def rank(self, value): '''The rank of a given *value*. This is the position of *value* in the :class:`OrderedMixin` container.''' value = self.value_pickler.dumps(value) return self.backend_structure().rank(value)
python
def rank(self, value): '''The rank of a given *value*. This is the position of *value* in the :class:`OrderedMixin` container.''' value = self.value_pickler.dumps(value) return self.backend_structure().rank(value)
[ "def", "rank", "(", "self", ",", "value", ")", ":", "value", "=", "self", ".", "value_pickler", ".", "dumps", "(", "value", ")", "return", "self", ".", "backend_structure", "(", ")", ".", "rank", "(", "value", ")" ]
The rank of a given *value*. This is the position of *value* in the :class:`OrderedMixin` container.
[ "The", "rank", "of", "a", "given", "*", "value", "*", ".", "This", "is", "the", "position", "of", "*", "value", "*", "in", "the", ":", "class", ":", "OrderedMixin", "container", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L672-L676
train
lsbardel/python-stdnet
stdnet/odm/struct.py
TS.rank
def rank(self, dte): '''The rank of a given *dte* in the timeseries''' timestamp = self.pickler.dumps(dte) return self.backend_structure().rank(timestamp)
python
def rank(self, dte): '''The rank of a given *dte* in the timeseries''' timestamp = self.pickler.dumps(dte) return self.backend_structure().rank(timestamp)
[ "def", "rank", "(", "self", ",", "dte", ")", ":", "timestamp", "=", "self", ".", "pickler", ".", "dumps", "(", "dte", ")", "return", "self", ".", "backend_structure", "(", ")", ".", "rank", "(", "timestamp", ")" ]
The rank of a given *dte* in the timeseries
[ "The", "rank", "of", "a", "given", "*", "dte", "*", "in", "the", "timeseries" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L708-L711
train
lsbardel/python-stdnet
stdnet/odm/struct.py
TS.ipop
def ipop(self, index): '''Pop a value at *index* from the :class:`TS`. Return ``None`` if index is not out of bound.''' backend = self.backend res = backend.structure(self).ipop(index) return backend.execute(res, lambda r: self._load_get_data(r, index...
python
def ipop(self, index): '''Pop a value at *index* from the :class:`TS`. Return ``None`` if index is not out of bound.''' backend = self.backend res = backend.structure(self).ipop(index) return backend.execute(res, lambda r: self._load_get_data(r, index...
[ "def", "ipop", "(", "self", ",", "index", ")", ":", "backend", "=", "self", ".", "backend", "res", "=", "backend", ".", "structure", "(", "self", ")", ".", "ipop", "(", "index", ")", "return", "backend", ".", "execute", "(", "res", ",", "lambda", "...
Pop a value at *index* from the :class:`TS`. Return ``None`` if index is not out of bound.
[ "Pop", "a", "value", "at", "*", "index", "*", "from", "the", ":", "class", ":", "TS", ".", "Return", "None", "if", "index", "is", "not", "out", "of", "bound", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L713-L719
train
lsbardel/python-stdnet
stdnet/odm/struct.py
TS.times
def times(self, start, stop, callback=None, **kwargs): '''The times between times *start* and *stop*.''' s1 = self.pickler.dumps(start) s2 = self.pickler.dumps(stop) backend = self.read_backend res = backend.structure(self).times(s1, s2, **kwargs) return backend.exe...
python
def times(self, start, stop, callback=None, **kwargs): '''The times between times *start* and *stop*.''' s1 = self.pickler.dumps(start) s2 = self.pickler.dumps(stop) backend = self.read_backend res = backend.structure(self).times(s1, s2, **kwargs) return backend.exe...
[ "def", "times", "(", "self", ",", "start", ",", "stop", ",", "callback", "=", "None", ",", "*", "*", "kwargs", ")", ":", "s1", "=", "self", ".", "pickler", ".", "dumps", "(", "start", ")", "s2", "=", "self", ".", "pickler", ".", "dumps", "(", "...
The times between times *start* and *stop*.
[ "The", "times", "between", "times", "*", "start", "*", "and", "*", "stop", "*", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L721-L727
train
lsbardel/python-stdnet
stdnet/odm/struct.py
TS.itimes
def itimes(self, start=0, stop=-1, callback=None, **kwargs): '''The times between rank *start* and *stop*.''' backend = self.read_backend res = backend.structure(self).itimes(start, stop, **kwargs) return backend.execute(res, callback or self.load_keys)
python
def itimes(self, start=0, stop=-1, callback=None, **kwargs): '''The times between rank *start* and *stop*.''' backend = self.read_backend res = backend.structure(self).itimes(start, stop, **kwargs) return backend.execute(res, callback or self.load_keys)
[ "def", "itimes", "(", "self", ",", "start", "=", "0", ",", "stop", "=", "-", "1", ",", "callback", "=", "None", ",", "*", "*", "kwargs", ")", ":", "backend", "=", "self", ".", "read_backend", "res", "=", "backend", ".", "structure", "(", "self", ...
The times between rank *start* and *stop*.
[ "The", "times", "between", "rank", "*", "start", "*", "and", "*", "stop", "*", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L729-L733
train
lsbardel/python-stdnet
stdnet/odm/query.py
Q.get_field
def get_field(self, field): '''A :class:`Q` performs a series of operations and ultimately generate of set of matched elements ``ids``. If on the other hand, a different field is required, it can be specified with the :meth:`get_field` method. For example, lets say a model has a field called ``object_id`` ...
python
def get_field(self, field): '''A :class:`Q` performs a series of operations and ultimately generate of set of matched elements ``ids``. If on the other hand, a different field is required, it can be specified with the :meth:`get_field` method. For example, lets say a model has a field called ``object_id`` ...
[ "def", "get_field", "(", "self", ",", "field", ")", ":", "if", "field", "!=", "self", ".", "_get_field", ":", "if", "field", "not", "in", "self", ".", "_meta", ".", "dfields", ":", "raise", "QuerySetError", "(", "'Model \"{0}\" has no field \"{1}\".'", ".", ...
A :class:`Q` performs a series of operations and ultimately generate of set of matched elements ``ids``. If on the other hand, a different field is required, it can be specified with the :meth:`get_field` method. For example, lets say a model has a field called ``object_id`` which contains ids of another model, we ...
[ "A", ":", "class", ":", "Q", "performs", "a", "series", "of", "operations", "and", "ultimately", "generate", "of", "set", "of", "matched", "elements", "ids", ".", "If", "on", "the", "other", "hand", "a", "different", "field", "is", "required", "it", "can...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L103-L127
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.filter
def filter(self, **kwargs): '''Create a new :class:`Query` with additional clauses corresponding to ``where`` or ``limit`` in a ``SQL SELECT`` statement. :parameter kwargs: dictionary of limiting clauses. :rtype: a new :class:`Query` instance. For example:: qs = session.query(MyModel) resul...
python
def filter(self, **kwargs): '''Create a new :class:`Query` with additional clauses corresponding to ``where`` or ``limit`` in a ``SQL SELECT`` statement. :parameter kwargs: dictionary of limiting clauses. :rtype: a new :class:`Query` instance. For example:: qs = session.query(MyModel) resul...
[ "def", "filter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "q", "=", "self", ".", "_clone", "(", ")", "if", "self", ".", "fargs", ":", "kwargs", "=", "update_dictionary", "(", "self", ".", "fargs", ".", "copy", "(", ")"...
Create a new :class:`Query` with additional clauses corresponding to ``where`` or ``limit`` in a ``SQL SELECT`` statement. :parameter kwargs: dictionary of limiting clauses. :rtype: a new :class:`Query` instance. For example:: qs = session.query(MyModel) result = qs.filter(group = 'planet')
[ "Create", "a", "new", ":", "class", ":", "Query", "with", "additional", "clauses", "corresponding", "to", "where", "or", "limit", "in", "a", "SQL", "SELECT", "statement", ".", ":", "parameter", "kwargs", ":", "dictionary", "of", "limiting", "clauses", ".", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L401-L420
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.exclude
def exclude(self, **kwargs): '''Returns a new :class:`Query` with additional clauses corresponding to ``EXCEPT`` in a ``SQL SELECT`` statement. :parameter kwargs: dictionary of limiting clauses. :rtype: a new :class:`Query` instance. Using an equivalent example to the :meth:`filter` method:: qs ...
python
def exclude(self, **kwargs): '''Returns a new :class:`Query` with additional clauses corresponding to ``EXCEPT`` in a ``SQL SELECT`` statement. :parameter kwargs: dictionary of limiting clauses. :rtype: a new :class:`Query` instance. Using an equivalent example to the :meth:`filter` method:: qs ...
[ "def", "exclude", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "q", "=", "self", ".", "_clone", "(", ")", "if", "self", ".", "eargs", ":", "kwargs", "=", "update_dictionary", "(", "self", ".", "eargs", ".", "copy", "(", ")...
Returns a new :class:`Query` with additional clauses corresponding to ``EXCEPT`` in a ``SQL SELECT`` statement. :parameter kwargs: dictionary of limiting clauses. :rtype: a new :class:`Query` instance. Using an equivalent example to the :meth:`filter` method:: qs = session.query(MyModel) result1 = q...
[ "Returns", "a", "new", ":", "class", ":", "Query", "with", "additional", "clauses", "corresponding", "to", "EXCEPT", "in", "a", "SQL", "SELECT", "statement", ".", ":", "parameter", "kwargs", ":", "dictionary", "of", "limiting", "clauses", ".", ":", "rtype", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L422-L443
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.union
def union(self, *queries): '''Return a new :class:`Query` obtained form the union of this :class:`Query` with one or more *queries*. For example, lets say we want to have the union of two queries obtained from the :meth:`filter` method:: query = session.query(MyModel) qs = query.filter(field1 = ...
python
def union(self, *queries): '''Return a new :class:`Query` obtained form the union of this :class:`Query` with one or more *queries*. For example, lets say we want to have the union of two queries obtained from the :meth:`filter` method:: query = session.query(MyModel) qs = query.filter(field1 = ...
[ "def", "union", "(", "self", ",", "*", "queries", ")", ":", "q", "=", "self", ".", "_clone", "(", ")", "q", ".", "unions", "+=", "queries", "return", "q" ]
Return a new :class:`Query` obtained form the union of this :class:`Query` with one or more *queries*. For example, lets say we want to have the union of two queries obtained from the :meth:`filter` method:: query = session.query(MyModel) qs = query.filter(field1 = 'bla').union(query.filter(field2 = 'foo...
[ "Return", "a", "new", ":", "class", ":", "Query", "obtained", "form", "the", "union", "of", "this", ":", "class", ":", "Query", "with", "one", "or", "more", "*", "queries", "*", ".", "For", "example", "lets", "say", "we", "want", "to", "have", "the",...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L445-L456
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.intersect
def intersect(self, *queries): '''Return a new :class:`Query` obtained form the intersection of this :class:`Query` with one or more *queries*. Workds the same way as the :meth:`union` method.''' q = self._clone() q.intersections += queries return q
python
def intersect(self, *queries): '''Return a new :class:`Query` obtained form the intersection of this :class:`Query` with one or more *queries*. Workds the same way as the :meth:`union` method.''' q = self._clone() q.intersections += queries return q
[ "def", "intersect", "(", "self", ",", "*", "queries", ")", ":", "q", "=", "self", ".", "_clone", "(", ")", "q", ".", "intersections", "+=", "queries", "return", "q" ]
Return a new :class:`Query` obtained form the intersection of this :class:`Query` with one or more *queries*. Workds the same way as the :meth:`union` method.
[ "Return", "a", "new", ":", "class", ":", "Query", "obtained", "form", "the", "intersection", "of", "this", ":", "class", ":", "Query", "with", "one", "or", "more", "*", "queries", "*", ".", "Workds", "the", "same", "way", "as", "the", ":", "meth", ":...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L458-L464
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.sort_by
def sort_by(self, ordering): '''Sort the query by the given field :parameter ordering: a string indicating the class:`Field` name to sort by. If prefixed with ``-``, the sorting will be in descending order, otherwise in ascending order. :return type: a new :class:`Query` instance. ''' i...
python
def sort_by(self, ordering): '''Sort the query by the given field :parameter ordering: a string indicating the class:`Field` name to sort by. If prefixed with ``-``, the sorting will be in descending order, otherwise in ascending order. :return type: a new :class:`Query` instance. ''' i...
[ "def", "sort_by", "(", "self", ",", "ordering", ")", ":", "if", "ordering", ":", "ordering", "=", "self", ".", "_meta", ".", "get_sorting", "(", "ordering", ",", "QuerySetError", ")", "q", "=", "self", ".", "_clone", "(", ")", "q", ".", "data", "[", ...
Sort the query by the given field :parameter ordering: a string indicating the class:`Field` name to sort by. If prefixed with ``-``, the sorting will be in descending order, otherwise in ascending order. :return type: a new :class:`Query` instance.
[ "Sort", "the", "query", "by", "the", "given", "field", ":", "parameter", "ordering", ":", "a", "string", "indicating", "the", "class", ":", "Field", "name", "to", "sort", "by", ".", "If", "prefixed", "with", "-", "the", "sorting", "will", "be", "in", "...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L466-L478
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.search
def search(self, text, lookup=None): '''Search *text* in model. A search engine needs to be installed for this function to be available. :parameter text: a string to search. :return type: a new :class:`Query` instance. ''' q = self._clone() q.text = (text, lookup) return q
python
def search(self, text, lookup=None): '''Search *text* in model. A search engine needs to be installed for this function to be available. :parameter text: a string to search. :return type: a new :class:`Query` instance. ''' q = self._clone() q.text = (text, lookup) return q
[ "def", "search", "(", "self", ",", "text", ",", "lookup", "=", "None", ")", ":", "q", "=", "self", ".", "_clone", "(", ")", "q", ".", "text", "=", "(", "text", ",", "lookup", ")", "return", "q" ]
Search *text* in model. A search engine needs to be installed for this function to be available. :parameter text: a string to search. :return type: a new :class:`Query` instance.
[ "Search", "*", "text", "*", "in", "model", ".", "A", "search", "engine", "needs", "to", "be", "installed", "for", "this", "function", "to", "be", "available", ".", ":", "parameter", "text", ":", "a", "string", "to", "search", ".", ":", "return", "type"...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L480-L489
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.where
def where(self, code, load_only=None): '''For :ref:`backend <db-index>` supporting scripting, it is possible to construct complex queries which execute the scripting *code* against each element in the query. The *coe* should reference an instance of :attr:`model` by ``this`` keyword. :parameter code: a v...
python
def where(self, code, load_only=None): '''For :ref:`backend <db-index>` supporting scripting, it is possible to construct complex queries which execute the scripting *code* against each element in the query. The *coe* should reference an instance of :attr:`model` by ``this`` keyword. :parameter code: a v...
[ "def", "where", "(", "self", ",", "code", ",", "load_only", "=", "None", ")", ":", "if", "code", ":", "q", "=", "self", ".", "_clone", "(", ")", "q", ".", "data", "[", "'where'", "]", "=", "(", "code", ",", "load_only", ")", "return", "q", "els...
For :ref:`backend <db-index>` supporting scripting, it is possible to construct complex queries which execute the scripting *code* against each element in the query. The *coe* should reference an instance of :attr:`model` by ``this`` keyword. :parameter code: a valid expression in the scripting language of the da...
[ "For", ":", "ref", ":", "backend", "<db", "-", "index", ">", "supporting", "scripting", "it", "is", "possible", "to", "construct", "complex", "queries", "which", "execute", "the", "scripting", "*", "code", "*", "against", "each", "element", "in", "the", "q...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L491-L510
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.search_queries
def search_queries(self, q): '''Return a new :class:`QueryElem` for *q* applying a text search.''' if self.text: searchengine = self.session.router.search_engine if searchengine: return searchengine.search_model(q, *self.text) else: ...
python
def search_queries(self, q): '''Return a new :class:`QueryElem` for *q* applying a text search.''' if self.text: searchengine = self.session.router.search_engine if searchengine: return searchengine.search_model(q, *self.text) else: ...
[ "def", "search_queries", "(", "self", ",", "q", ")", ":", "if", "self", ".", "text", ":", "searchengine", "=", "self", ".", "session", ".", "router", ".", "search_engine", "if", "searchengine", ":", "return", "searchengine", ".", "search_model", "(", "q", ...
Return a new :class:`QueryElem` for *q* applying a text search.
[ "Return", "a", "new", ":", "class", ":", "QueryElem", "for", "*", "q", "*", "applying", "a", "text", "search", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L512-L521
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.load_related
def load_related(self, related, *related_fields): '''It returns a new :class:`Query` that automatically follows the foreign-key relationship ``related``. :parameter related: A field name corresponding to a :class:`ForeignKey` in :attr:`Query.model`. :parameter related_fields: optional :class:`Field` ...
python
def load_related(self, related, *related_fields): '''It returns a new :class:`Query` that automatically follows the foreign-key relationship ``related``. :parameter related: A field name corresponding to a :class:`ForeignKey` in :attr:`Query.model`. :parameter related_fields: optional :class:`Field` ...
[ "def", "load_related", "(", "self", ",", "related", ",", "*", "related_fields", ")", ":", "field", "=", "self", ".", "_get_related_field", "(", "related", ")", "if", "not", "field", ":", "raise", "FieldError", "(", "'\"%s\" is not a related field for \"%s\"'", "...
It returns a new :class:`Query` that automatically follows the foreign-key relationship ``related``. :parameter related: A field name corresponding to a :class:`ForeignKey` in :attr:`Query.model`. :parameter related_fields: optional :class:`Field` names for the ``related`` model to load. If not provided,...
[ "It", "returns", "a", "new", ":", "class", ":", "Query", "that", "automatically", "follows", "the", "foreign", "-", "key", "relationship", "related", ".", ":", "parameter", "related", ":", "A", "field", "name", "corresponding", "to", "a", ":", "class", ":"...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L523-L546
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.load_only
def load_only(self, *fields): '''This is provides a :ref:`performance boost <increase-performance>` in cases when you need to load a subset of fields of your model. The boost achieved is less than the one obtained when using :meth:`Query.load_related`, since it does not reduce the number of requests to the...
python
def load_only(self, *fields): '''This is provides a :ref:`performance boost <increase-performance>` in cases when you need to load a subset of fields of your model. The boost achieved is less than the one obtained when using :meth:`Query.load_related`, since it does not reduce the number of requests to the...
[ "def", "load_only", "(", "self", ",", "*", "fields", ")", ":", "q", "=", "self", ".", "_clone", "(", ")", "new_fields", "=", "[", "]", "for", "field", "in", "fields", ":", "if", "JSPLITTER", "in", "field", ":", "bits", "=", "field", ".", "split", ...
This is provides a :ref:`performance boost <increase-performance>` in cases when you need to load a subset of fields of your model. The boost achieved is less than the one obtained when using :meth:`Query.load_related`, since it does not reduce the number of requests to the database. However, it can save you lots o...
[ "This", "is", "provides", "a", ":", "ref", ":", "performance", "boost", "<increase", "-", "performance", ">", "in", "cases", "when", "you", "need", "to", "load", "a", "subset", "of", "fields", "of", "your", "model", ".", "The", "boost", "achieved", "is",...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L548-L573
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.dont_load
def dont_load(self, *fields): '''Works like :meth:`load_only` to provides a :ref:`performance boost <increase-performance>` in cases when you need to load all fields except a subset specified by *fields*. ''' q = self._clone() fs = unique_tuple(q.exclude_fields, fields) q.exclude_...
python
def dont_load(self, *fields): '''Works like :meth:`load_only` to provides a :ref:`performance boost <increase-performance>` in cases when you need to load all fields except a subset specified by *fields*. ''' q = self._clone() fs = unique_tuple(q.exclude_fields, fields) q.exclude_...
[ "def", "dont_load", "(", "self", ",", "*", "fields", ")", ":", "q", "=", "self", ".", "_clone", "(", ")", "fs", "=", "unique_tuple", "(", "q", ".", "exclude_fields", ",", "fields", ")", "q", ".", "exclude_fields", "=", "fs", "if", "fs", "else", "No...
Works like :meth:`load_only` to provides a :ref:`performance boost <increase-performance>` in cases when you need to load all fields except a subset specified by *fields*.
[ "Works", "like", ":", "meth", ":", "load_only", "to", "provides", "a", ":", "ref", ":", "performance", "boost", "<increase", "-", "performance", ">", "in", "cases", "when", "you", "need", "to", "load", "all", "fields", "except", "a", "subset", "specified",...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L575-L583
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.get
def get(self, **kwargs): '''Return an instance of a model matching the query. A special case is the query on ``id`` which provides a direct access to the :attr:`session` instances. If the given primary key is present in the session, the object is returned directly without performing any query.''' r...
python
def get(self, **kwargs): '''Return an instance of a model matching the query. A special case is the query on ``id`` which provides a direct access to the :attr:`session` instances. If the given primary key is present in the session, the object is returned directly without performing any query.''' r...
[ "def", "get", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "filter", "(", "*", "*", "kwargs", ")", ".", "items", "(", "callback", "=", "self", ".", "model", ".", "get_unique_instance", ")" ]
Return an instance of a model matching the query. A special case is the query on ``id`` which provides a direct access to the :attr:`session` instances. If the given primary key is present in the session, the object is returned directly without performing any query.
[ "Return", "an", "instance", "of", "a", "model", "matching", "the", "query", ".", "A", "special", "case", "is", "the", "query", "on", "id", "which", "provides", "a", "direct", "access", "to", "the", ":", "attr", ":", "session", "instances", ".", "If", "...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L594-L600
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.construct
def construct(self): '''Build the :class:`QueryElement` representing this query.''' if self.__construct is None: self.__construct = self._construct() return self.__construct
python
def construct(self): '''Build the :class:`QueryElement` representing this query.''' if self.__construct is None: self.__construct = self._construct() return self.__construct
[ "def", "construct", "(", "self", ")", ":", "if", "self", ".", "__construct", "is", "None", ":", "self", ".", "__construct", "=", "self", ".", "_construct", "(", ")", "return", "self", ".", "__construct" ]
Build the :class:`QueryElement` representing this query.
[ "Build", "the", ":", "class", ":", "QueryElement", "representing", "this", "query", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L615-L619
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.backend_query
def backend_query(self, **kwargs): '''Build and return the :class:`stdnet.utils.async.BackendQuery`. This is a lazy method in the sense that it is evaluated once only and its result stored for future retrieval.''' q = self.construct() return q if isinstance(q, EmptyQuery) else q.backend_que...
python
def backend_query(self, **kwargs): '''Build and return the :class:`stdnet.utils.async.BackendQuery`. This is a lazy method in the sense that it is evaluated once only and its result stored for future retrieval.''' q = self.construct() return q if isinstance(q, EmptyQuery) else q.backend_que...
[ "def", "backend_query", "(", "self", ",", "*", "*", "kwargs", ")", ":", "q", "=", "self", ".", "construct", "(", ")", "return", "q", "if", "isinstance", "(", "q", ",", "EmptyQuery", ")", "else", "q", ".", "backend_query", "(", "*", "*", "kwargs", "...
Build and return the :class:`stdnet.utils.async.BackendQuery`. This is a lazy method in the sense that it is evaluated once only and its result stored for future retrieval.
[ "Build", "and", "return", "the", ":", "class", ":", "stdnet", ".", "utils", ".", "async", ".", "BackendQuery", ".", "This", "is", "a", "lazy", "method", "in", "the", "sense", "that", "it", "is", "evaluated", "once", "only", "and", "its", "result", "sto...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L621-L626
train
lsbardel/python-stdnet
stdnet/odm/query.py
Query.aggregate
def aggregate(self, kwargs): '''Aggregate lookup parameters.''' meta = self._meta fields = meta.dfields field_lookups = {} for name, value in iteritems(kwargs): bits = name.split(JSPLITTER) field_name = bits.pop(0) if field_name not in ...
python
def aggregate(self, kwargs): '''Aggregate lookup parameters.''' meta = self._meta fields = meta.dfields field_lookups = {} for name, value in iteritems(kwargs): bits = name.split(JSPLITTER) field_name = bits.pop(0) if field_name not in ...
[ "def", "aggregate", "(", "self", ",", "kwargs", ")", ":", "meta", "=", "self", ".", "_meta", "fields", "=", "meta", ".", "dfields", "field_lookups", "=", "{", "}", "for", "name", ",", "value", "in", "iteritems", "(", "kwargs", ")", ":", "bits", "=", ...
Aggregate lookup parameters.
[ "Aggregate", "lookup", "parameters", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/query.py#L698-L742
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
models_from_model
def models_from_model(model, include_related=False, exclude=None): '''Generator of all model in model.''' if exclude is None: exclude = set() if model and model not in exclude: exclude.add(model) if isinstance(model, ModelType) and not model._meta.abstract: yield model ...
python
def models_from_model(model, include_related=False, exclude=None): '''Generator of all model in model.''' if exclude is None: exclude = set() if model and model not in exclude: exclude.add(model) if isinstance(model, ModelType) and not model._meta.abstract: yield model ...
[ "def", "models_from_model", "(", "model", ",", "include_related", "=", "False", ",", "exclude", "=", "None", ")", ":", "if", "exclude", "is", "None", ":", "exclude", "=", "set", "(", ")", "if", "model", "and", "model", "not", "in", "exclude", ":", "exc...
Generator of all model in model.
[ "Generator", "of", "all", "model", "in", "model", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L281-L307
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
model_iterator
def model_iterator(application, include_related=True, exclude=None): '''A generator of :class:`StdModel` classes found in *application*. :parameter application: A python dotted path or an iterable over python dotted-paths where models are defined. Only models defined in these paths are considered. For exampl...
python
def model_iterator(application, include_related=True, exclude=None): '''A generator of :class:`StdModel` classes found in *application*. :parameter application: A python dotted path or an iterable over python dotted-paths where models are defined. Only models defined in these paths are considered. For exampl...
[ "def", "model_iterator", "(", "application", ",", "include_related", "=", "True", ",", "exclude", "=", "None", ")", ":", "if", "exclude", "is", "None", ":", "exclude", "=", "set", "(", ")", "application", "=", "native_str", "(", "application", ")", "if", ...
A generator of :class:`StdModel` classes found in *application*. :parameter application: A python dotted path or an iterable over python dotted-paths where models are defined. Only models defined in these paths are considered. For example:: from stdnet.odm import model_iterator APPS = ('stdnet.contrib....
[ "A", "generator", "of", ":", "class", ":", "StdModel", "classes", "found", "in", "*", "application", "*", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L310-L363
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
Router.set_search_engine
def set_search_engine(self, engine): '''Set the search ``engine`` for this :class:`Router`.''' self._search_engine = engine self._search_engine.set_router(self)
python
def set_search_engine(self, engine): '''Set the search ``engine`` for this :class:`Router`.''' self._search_engine = engine self._search_engine.set_router(self)
[ "def", "set_search_engine", "(", "self", ",", "engine", ")", ":", "self", ".", "_search_engine", "=", "engine", "self", ".", "_search_engine", ".", "set_router", "(", "self", ")" ]
Set the search ``engine`` for this :class:`Router`.
[ "Set", "the", "search", "engine", "for", "this", ":", "class", ":", "Router", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L112-L115
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
Router.register
def register(self, model, backend=None, read_backend=None, include_related=True, **params): '''Register a :class:`Model` with this :class:`Router`. If the model was already registered it does nothing. :param model: a :class:`Model` class. :param backend: a :class:`stdnet.BackendDataServer` or ...
python
def register(self, model, backend=None, read_backend=None, include_related=True, **params): '''Register a :class:`Model` with this :class:`Router`. If the model was already registered it does nothing. :param model: a :class:`Model` class. :param backend: a :class:`stdnet.BackendDataServer` or ...
[ "def", "register", "(", "self", ",", "model", ",", "backend", "=", "None", ",", "read_backend", "=", "None", ",", "include_related", "=", "True", ",", "*", "*", "params", ")", ":", "backend", "=", "backend", "or", "self", ".", "_default_backend", "backen...
Register a :class:`Model` with this :class:`Router`. If the model was already registered it does nothing. :param model: a :class:`Model` class. :param backend: a :class:`stdnet.BackendDataServer` or a :ref:`connection string <connection-string>`. :param read_backend: Optional :class:`stdnet.BackendDataServer` for ...
[ "Register", "a", ":", "class", ":", "Model", "with", "this", ":", "class", ":", "Router", ".", "If", "the", "model", "was", "already", "registered", "it", "does", "nothing", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L117-L160
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
Router.from_uuid
def from_uuid(self, uuid, session=None): '''Retrieve a :class:`Model` from its universally unique identifier ``uuid``. If the ``uuid`` does not match any instance an exception will raise. ''' elems = uuid.split('.') if len(elems) == 2: model = get_model_from_hash(elems[0]) ...
python
def from_uuid(self, uuid, session=None): '''Retrieve a :class:`Model` from its universally unique identifier ``uuid``. If the ``uuid`` does not match any instance an exception will raise. ''' elems = uuid.split('.') if len(elems) == 2: model = get_model_from_hash(elems[0]) ...
[ "def", "from_uuid", "(", "self", ",", "uuid", ",", "session", "=", "None", ")", ":", "elems", "=", "uuid", ".", "split", "(", "'.'", ")", "if", "len", "(", "elems", ")", "==", "2", ":", "model", "=", "get_model_from_hash", "(", "elems", "[", "0", ...
Retrieve a :class:`Model` from its universally unique identifier ``uuid``. If the ``uuid`` does not match any instance an exception will raise.
[ "Retrieve", "a", ":", "class", ":", "Model", "from", "its", "universally", "unique", "identifier", "uuid", ".", "If", "the", "uuid", "does", "not", "match", "any", "instance", "an", "exception", "will", "raise", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L162-L175
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
Router.flush
def flush(self, exclude=None, include=None, dryrun=False): '''Flush :attr:`registered_models`. :param exclude: optional list of model names to exclude. :param include: optional list of model names to include. :param dryrun: Doesn't remove anything, simply collect managers to...
python
def flush(self, exclude=None, include=None, dryrun=False): '''Flush :attr:`registered_models`. :param exclude: optional list of model names to exclude. :param include: optional list of model names to include. :param dryrun: Doesn't remove anything, simply collect managers to...
[ "def", "flush", "(", "self", ",", "exclude", "=", "None", ",", "include", "=", "None", ",", "dryrun", "=", "False", ")", ":", "exclude", "=", "exclude", "or", "[", "]", "results", "=", "[", "]", "for", "manager", "in", "self", ".", "_registered_model...
Flush :attr:`registered_models`. :param exclude: optional list of model names to exclude. :param include: optional list of model names to include. :param dryrun: Doesn't remove anything, simply collect managers to flush. :return:
[ "Flush", ":", "attr", ":", "registered_models", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L177-L198
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
Router.unregister
def unregister(self, model=None): '''Unregister a ``model`` if provided, otherwise it unregister all registered models. Return a list of unregistered model managers or ``None`` if no managers were removed.''' if model is not None: try: manager = self._registered_models.pop(mo...
python
def unregister(self, model=None): '''Unregister a ``model`` if provided, otherwise it unregister all registered models. Return a list of unregistered model managers or ``None`` if no managers were removed.''' if model is not None: try: manager = self._registered_models.pop(mo...
[ "def", "unregister", "(", "self", ",", "model", "=", "None", ")", ":", "if", "model", "is", "not", "None", ":", "try", ":", "manager", "=", "self", ".", "_registered_models", ".", "pop", "(", "model", ")", "except", "KeyError", ":", "return", "if", "...
Unregister a ``model`` if provided, otherwise it unregister all registered models. Return a list of unregistered model managers or ``None`` if no managers were removed.
[ "Unregister", "a", "model", "if", "provided", "otherwise", "it", "unregister", "all", "registered", "models", ".", "Return", "a", "list", "of", "unregistered", "model", "managers", "or", "None", "if", "no", "managers", "were", "removed", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L200-L215
train
lsbardel/python-stdnet
stdnet/odm/mapper.py
Router.register_applications
def register_applications(self, applications, models=None, backends=None): '''A higher level registration functions for group of models located on application modules. It uses the :func:`model_iterator` function to iterate through all :class:`Model` models available in ``applications`` and register them using t...
python
def register_applications(self, applications, models=None, backends=None): '''A higher level registration functions for group of models located on application modules. It uses the :func:`model_iterator` function to iterate through all :class:`Model` models available in ``applications`` and register them using t...
[ "def", "register_applications", "(", "self", ",", "applications", ",", "models", "=", "None", ",", "backends", "=", "None", ")", ":", "return", "list", "(", "self", ".", "_register_applications", "(", "applications", ",", "models", ",", "backends", ")", ")" ...
A higher level registration functions for group of models located on application modules. It uses the :func:`model_iterator` function to iterate through all :class:`Model` models available in ``applications`` and register them using the :func:`register` low level method. :parameter applications: A String or a list of ...
[ "A", "higher", "level", "registration", "functions", "for", "group", "of", "models", "located", "on", "application", "modules", ".", "It", "uses", "the", ":", "func", ":", "model_iterator", "function", "to", "iterate", "through", "all", ":", "class", ":", "M...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/mapper.py#L217-L242
train
lsbardel/python-stdnet
stdnet/backends/redisb/client/async.py
Redis.execute_script
def execute_script(self, name, keys, *args, **options): '''Execute a script. makes sure all required scripts are loaded. ''' script = get_script(name) if not script: raise redis.RedisError('No such script "%s"' % name) address = self.address() if addr...
python
def execute_script(self, name, keys, *args, **options): '''Execute a script. makes sure all required scripts are loaded. ''' script = get_script(name) if not script: raise redis.RedisError('No such script "%s"' % name) address = self.address() if addr...
[ "def", "execute_script", "(", "self", ",", "name", ",", "keys", ",", "*", "args", ",", "*", "*", "options", ")", ":", "script", "=", "get_script", "(", "name", ")", "if", "not", "script", ":", "raise", "redis", ".", "RedisError", "(", "'No such script ...
Execute a script. makes sure all required scripts are loaded.
[ "Execute", "a", "script", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/async.py#L40-L57
train
lsbardel/python-stdnet
stdnet/odm/search.py
SearchEngine.register
def register(self, model, related=None): '''Register a :class:`StdModel` with this search :class:`SearchEngine`. When registering a model, every time an instance is created, it will be indexed by the search engine. :param model: a :class:`StdModel` class. :param related: a list of related fields to inclu...
python
def register(self, model, related=None): '''Register a :class:`StdModel` with this search :class:`SearchEngine`. When registering a model, every time an instance is created, it will be indexed by the search engine. :param model: a :class:`StdModel` class. :param related: a list of related fields to inclu...
[ "def", "register", "(", "self", ",", "model", ",", "related", "=", "None", ")", ":", "update_model", "=", "UpdateSE", "(", "self", ",", "related", ")", "self", ".", "REGISTERED_MODELS", "[", "model", "]", "=", "update_model", "self", ".", "router", ".", ...
Register a :class:`StdModel` with this search :class:`SearchEngine`. When registering a model, every time an instance is created, it will be indexed by the search engine. :param model: a :class:`StdModel` class. :param related: a list of related fields to include in the index.
[ "Register", "a", ":", "class", ":", "StdModel", "with", "this", "search", ":", "class", ":", "SearchEngine", ".", "When", "registering", "a", "model", "every", "time", "an", "instance", "is", "created", "it", "will", "be", "indexed", "by", "the", "search",...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/search.py#L67-L78
train
lsbardel/python-stdnet
stdnet/odm/search.py
SearchEngine.words_from_text
def words_from_text(self, text, for_search=False): '''Generator of indexable words in *text*. This functions loop through the :attr:`word_middleware` attribute to process the text. :param text: string from which to extract words. :param for_search: flag indicating if the the words will be used for search...
python
def words_from_text(self, text, for_search=False): '''Generator of indexable words in *text*. This functions loop through the :attr:`word_middleware` attribute to process the text. :param text: string from which to extract words. :param for_search: flag indicating if the the words will be used for search...
[ "def", "words_from_text", "(", "self", ",", "text", ",", "for_search", "=", "False", ")", ":", "if", "not", "text", ":", "return", "[", "]", "word_gen", "=", "self", ".", "split_text", "(", "text", ")", "for", "middleware", ",", "fors", "in", "self", ...
Generator of indexable words in *text*. This functions loop through the :attr:`word_middleware` attribute to process the text. :param text: string from which to extract words. :param for_search: flag indicating if the the words will be used for search or to index the database. This flug is used in conjunctio...
[ "Generator", "of", "indexable", "words", "in", "*", "text", "*", ".", "This", "functions", "loop", "through", "the", ":", "attr", ":", "word_middleware", "attribute", "to", "process", "the", "text", ".", ":", "param", "text", ":", "string", "from", "which"...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/search.py#L86-L112
train
lsbardel/python-stdnet
stdnet/odm/search.py
SearchEngine.add_word_middleware
def add_word_middleware(self, middleware, for_search=True): '''Add a *middleware* function to the list of :attr:`word_middleware`, for preprocessing words to be indexed. :param middleware: a callable receving an iterable over words. :param for_search: flag indicating if the *middleware* can be used for th...
python
def add_word_middleware(self, middleware, for_search=True): '''Add a *middleware* function to the list of :attr:`word_middleware`, for preprocessing words to be indexed. :param middleware: a callable receving an iterable over words. :param for_search: flag indicating if the *middleware* can be used for th...
[ "def", "add_word_middleware", "(", "self", ",", "middleware", ",", "for_search", "=", "True", ")", ":", "if", "hasattr", "(", "middleware", ",", "'__call__'", ")", ":", "self", ".", "word_middleware", ".", "append", "(", "(", "middleware", ",", "for_search",...
Add a *middleware* function to the list of :attr:`word_middleware`, for preprocessing words to be indexed. :param middleware: a callable receving an iterable over words. :param for_search: flag indicating if the *middleware* can be used for the text to search. Default: ``True``.
[ "Add", "a", "*", "middleware", "*", "function", "to", "the", "list", "of", ":", "attr", ":", "word_middleware", "for", "preprocessing", "words", "to", "be", "indexed", ".", ":", "param", "middleware", ":", "a", "callable", "receving", "an", "iterable", "ov...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/search.py#L123-L132
train
lsbardel/python-stdnet
stdnet/odm/search.py
SearchEngine.query
def query(self, model): '''Return a query for ``model`` when it needs to be indexed. ''' session = self.router.session() fields = tuple((f.name for f in model._meta.scalarfields if f.type == 'text')) qs = session.query(model).load_only(*fields) ...
python
def query(self, model): '''Return a query for ``model`` when it needs to be indexed. ''' session = self.router.session() fields = tuple((f.name for f in model._meta.scalarfields if f.type == 'text')) qs = session.query(model).load_only(*fields) ...
[ "def", "query", "(", "self", ",", "model", ")", ":", "session", "=", "self", ".", "router", ".", "session", "(", ")", "fields", "=", "tuple", "(", "(", "f", ".", "name", "for", "f", "in", "model", ".", "_meta", ".", "scalarfields", "if", "f", "."...
Return a query for ``model`` when it needs to be indexed.
[ "Return", "a", "query", "for", "model", "when", "it", "needs", "to", "be", "indexed", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/search.py#L142-L151
train
lsbardel/python-stdnet
stdnet/utils/version.py
get_version
def get_version(version): "Returns a PEP 386-compliant version number from *version*." assert len(version) == 5 assert version[3] in ('alpha', 'beta', 'rc', 'final') parts = 2 if version[2] == 0 else 3 main = '.'.join(map(str, version[:parts])) sub = '' if version[3] == 'alpha' and ve...
python
def get_version(version): "Returns a PEP 386-compliant version number from *version*." assert len(version) == 5 assert version[3] in ('alpha', 'beta', 'rc', 'final') parts = 2 if version[2] == 0 else 3 main = '.'.join(map(str, version[:parts])) sub = '' if version[3] == 'alpha' and ve...
[ "def", "get_version", "(", "version", ")", ":", "assert", "len", "(", "version", ")", "==", "5", "assert", "version", "[", "3", "]", "in", "(", "'alpha'", ",", "'beta'", ",", "'rc'", ",", "'final'", ")", "parts", "=", "2", "if", "version", "[", "2"...
Returns a PEP 386-compliant version number from *version*.
[ "Returns", "a", "PEP", "386", "-", "compliant", "version", "number", "from", "*", "version", "*", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/version.py#L20-L34
train
rodluger/everest
everest/transit.py
Get_RpRs
def Get_RpRs(d, **kwargs): ''' Returns the value of the planet radius over the stellar radius for a given depth :py:obj:`d`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`. ''' if ps is None: raise Exception("Unable to import `pysyzygy`.") def Depth(RpRs, **kwa...
python
def Get_RpRs(d, **kwargs): ''' Returns the value of the planet radius over the stellar radius for a given depth :py:obj:`d`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`. ''' if ps is None: raise Exception("Unable to import `pysyzygy`.") def Depth(RpRs, **kwa...
[ "def", "Get_RpRs", "(", "d", ",", "*", "*", "kwargs", ")", ":", "if", "ps", "is", "None", ":", "raise", "Exception", "(", "\"Unable to import `pysyzygy`.\"", ")", "def", "Depth", "(", "RpRs", ",", "*", "*", "kwargs", ")", ":", "return", "1", "-", "ps...
Returns the value of the planet radius over the stellar radius for a given depth :py:obj:`d`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`.
[ "Returns", "the", "value", "of", "the", "planet", "radius", "over", "the", "stellar", "radius", "for", "a", "given", "depth", ":", "py", ":", "obj", ":", "d", "given", "the", ":", "py", ":", "class", ":", "everest", ".", "pysyzygy", "transit", ":", "...
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/transit.py#L118-L134
train
rodluger/everest
everest/transit.py
Get_rhos
def Get_rhos(dur, **kwargs): ''' Returns the value of the stellar density for a given transit duration :py:obj:`dur`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`. ''' if ps is None: raise Exception("Unable to import `pysyzygy`.") assert dur >= 0.01 and dur <...
python
def Get_rhos(dur, **kwargs): ''' Returns the value of the stellar density for a given transit duration :py:obj:`dur`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`. ''' if ps is None: raise Exception("Unable to import `pysyzygy`.") assert dur >= 0.01 and dur <...
[ "def", "Get_rhos", "(", "dur", ",", "*", "*", "kwargs", ")", ":", "if", "ps", "is", "None", ":", "raise", "Exception", "(", "\"Unable to import `pysyzygy`.\"", ")", "assert", "dur", ">=", "0.01", "and", "dur", "<=", "0.5", ",", "\"Invalid value for the durat...
Returns the value of the stellar density for a given transit duration :py:obj:`dur`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`.
[ "Returns", "the", "value", "of", "the", "stellar", "density", "for", "a", "given", "transit", "duration", ":", "py", ":", "obj", ":", "dur", "given", "the", ":", "py", ":", "class", ":", "everest", ".", "pysyzygy", "transit", ":", "py", ":", "obj", "...
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/transit.py#L137-L161
train
rodluger/everest
everest/transit.py
Transit
def Transit(time, t0=0., dur=0.1, per=3.56789, depth=0.001, **kwargs): ''' A `Mandel-Agol <http://adsabs.harvard.edu/abs/2002ApJ...580L.171M>`_ transit model, but with the depth and the duration as primary input variables. :param numpy.ndarray time: The time array :param float t0: The time of f...
python
def Transit(time, t0=0., dur=0.1, per=3.56789, depth=0.001, **kwargs): ''' A `Mandel-Agol <http://adsabs.harvard.edu/abs/2002ApJ...580L.171M>`_ transit model, but with the depth and the duration as primary input variables. :param numpy.ndarray time: The time array :param float t0: The time of f...
[ "def", "Transit", "(", "time", ",", "t0", "=", "0.", ",", "dur", "=", "0.1", ",", "per", "=", "3.56789", ",", "depth", "=", "0.001", ",", "*", "*", "kwargs", ")", ":", "if", "ps", "is", "None", ":", "raise", "Exception", "(", "\"Unable to import `p...
A `Mandel-Agol <http://adsabs.harvard.edu/abs/2002ApJ...580L.171M>`_ transit model, but with the depth and the duration as primary input variables. :param numpy.ndarray time: The time array :param float t0: The time of first transit in units of \ :py:obj:`BJD` - 2454833. :param float dur...
[ "A", "Mandel", "-", "Agol", "<http", ":", "//", "adsabs", ".", "harvard", ".", "edu", "/", "abs", "/", "2002ApJ", "...", "580L", ".", "171M", ">", "_", "transit", "model", "but", "with", "the", "depth", "and", "the", "duration", "as", "primary", "inp...
6779591f9f8b3556847e2fbf761bdfac7520eaea
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/transit.py#L164-L191
train
lsbardel/python-stdnet
examples/tsmodels.py
TimeSeries.intervals
def intervals(self, startdate, enddate, parseinterval=None): '''Given a ``startdate`` and an ``enddate`` dates, evaluate the date intervals from which data is not available. It return a list of two-dimensional tuples containing start and end date for the interval. The list could cont...
python
def intervals(self, startdate, enddate, parseinterval=None): '''Given a ``startdate`` and an ``enddate`` dates, evaluate the date intervals from which data is not available. It return a list of two-dimensional tuples containing start and end date for the interval. The list could cont...
[ "def", "intervals", "(", "self", ",", "startdate", ",", "enddate", ",", "parseinterval", "=", "None", ")", ":", "return", "missing_intervals", "(", "startdate", ",", "enddate", ",", "self", ".", "data_start", ",", "self", ".", "data_end", ",", "dateconverter...
Given a ``startdate`` and an ``enddate`` dates, evaluate the date intervals from which data is not available. It return a list of two-dimensional tuples containing start and end date for the interval. The list could contain 0, 1 or 2 tuples.
[ "Given", "a", "startdate", "and", "an", "enddate", "dates", "evaluate", "the", "date", "intervals", "from", "which", "data", "is", "not", "available", ".", "It", "return", "a", "list", "of", "two", "-", "dimensional", "tuples", "containing", "start", "and", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/tsmodels.py#L35-L42
train
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.front
def front(self, *fields): '''Return the front pair of the structure''' v, f = tuple(self.irange(0, 0, fields=fields)) if v: return (v[0], dict(((field, f[field][0]) for field in f)))
python
def front(self, *fields): '''Return the front pair of the structure''' v, f = tuple(self.irange(0, 0, fields=fields)) if v: return (v[0], dict(((field, f[field][0]) for field in f)))
[ "def", "front", "(", "self", ",", "*", "fields", ")", ":", "v", ",", "f", "=", "tuple", "(", "self", ".", "irange", "(", "0", ",", "0", ",", "fields", "=", "fields", ")", ")", "if", "v", ":", "return", "(", "v", "[", "0", "]", ",", "dict", ...
Return the front pair of the structure
[ "Return", "the", "front", "pair", "of", "the", "structure" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L52-L56
train
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.istats
def istats(self, start=0, end=-1, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from *start* to *end*. :param start: Optional index (rank) where to start the analysis. :param end: Optional index (rank) where to end the analysis. :param fields: Optional subset of ...
python
def istats(self, start=0, end=-1, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from *start* to *end*. :param start: Optional index (rank) where to start the analysis. :param end: Optional index (rank) where to end the analysis. :param fields: Optional subset of ...
[ "def", "istats", "(", "self", ",", "start", "=", "0", ",", "end", "=", "-", "1", ",", "fields", "=", "None", ")", ":", "backend", "=", "self", ".", "read_backend", "return", "backend", ".", "execute", "(", "backend", ".", "structure", "(", "self", ...
Perform a multivariate statistic calculation of this :class:`ColumnTS` from *start* to *end*. :param start: Optional index (rank) where to start the analysis. :param end: Optional index (rank) where to end the analysis. :param fields: Optional subset of :meth:`fields` to perform analysis on. If not provided ...
[ "Perform", "a", "multivariate", "statistic", "calculation", "of", "this", ":", "class", ":", "ColumnTS", "from", "*", "start", "*", "to", "*", "end", "*", ".", ":", "param", "start", ":", "Optional", "index", "(", "rank", ")", "where", "to", "start", "...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L102-L113
train
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.stats
def stats(self, start, end, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from a *start* date/datetime to an *end* date/datetime. :param start: Start date for analysis. :param end: End date for analysis. :param fields: Optional subset of :meth:`fields` to perfo...
python
def stats(self, start, end, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from a *start* date/datetime to an *end* date/datetime. :param start: Start date for analysis. :param end: End date for analysis. :param fields: Optional subset of :meth:`fields` to perfo...
[ "def", "stats", "(", "self", ",", "start", ",", "end", ",", "fields", "=", "None", ")", ":", "start", "=", "self", ".", "pickler", ".", "dumps", "(", "start", ")", "end", "=", "self", ".", "pickler", ".", "dumps", "(", "end", ")", "backend", "=",...
Perform a multivariate statistic calculation of this :class:`ColumnTS` from a *start* date/datetime to an *end* date/datetime. :param start: Start date for analysis. :param end: End date for analysis. :param fields: Optional subset of :meth:`fields` to perform analysis on. If not provided all fields are in...
[ "Perform", "a", "multivariate", "statistic", "calculation", "of", "this", ":", "class", ":", "ColumnTS", "from", "a", "*", "start", "*", "date", "/", "datetime", "to", "an", "*", "end", "*", "date", "/", "datetime", ".", ":", "param", "start", ":", "St...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L115-L129
train
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.imulti_stats
def imulti_stats(self, start=0, end=-1, series=None, fields=None, stats=None): '''Perform cross multivariate statistics calculation of this :class:`ColumnTS` and other optional *series* from *start* to *end*. :parameter start: the start rank. :parameter start: the end rank :paramet...
python
def imulti_stats(self, start=0, end=-1, series=None, fields=None, stats=None): '''Perform cross multivariate statistics calculation of this :class:`ColumnTS` and other optional *series* from *start* to *end*. :parameter start: the start rank. :parameter start: the end rank :paramet...
[ "def", "imulti_stats", "(", "self", ",", "start", "=", "0", ",", "end", "=", "-", "1", ",", "series", "=", "None", ",", "fields", "=", "None", ",", "stats", "=", "None", ")", ":", "stats", "=", "stats", "or", "self", ".", "default_multi_stats", "ba...
Perform cross multivariate statistics calculation of this :class:`ColumnTS` and other optional *series* from *start* to *end*. :parameter start: the start rank. :parameter start: the end rank :parameter field: name of field to perform multivariate statistics. :parameter series: a list of two elements tuple cont...
[ "Perform", "cross", "multivariate", "statistics", "calculation", "of", "this", ":", "class", ":", "ColumnTS", "and", "other", "optional", "*", "series", "*", "from", "*", "start", "*", "to", "*", "end", "*", ".", ":", "parameter", "start", ":", "the", "s...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L131-L149
train
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.merge
def merge(self, *series, **kwargs): '''Merge this :class:`ColumnTS` with several other *series*. :parameters series: a list of tuples where the nth element is a tuple of the form:: (wight_n, ts_n1, ts_n2, ..., ts_nMn) The result will be calculated using the formula:: ts = weight_1*ts_1...
python
def merge(self, *series, **kwargs): '''Merge this :class:`ColumnTS` with several other *series*. :parameters series: a list of tuples where the nth element is a tuple of the form:: (wight_n, ts_n1, ts_n2, ..., ts_nMn) The result will be calculated using the formula:: ts = weight_1*ts_1...
[ "def", "merge", "(", "self", ",", "*", "series", ",", "*", "*", "kwargs", ")", ":", "session", "=", "self", ".", "session", "if", "not", "session", ":", "raise", "SessionNotAvailable", "(", "'No session available'", ")", "self", ".", "check_router", "(", ...
Merge this :class:`ColumnTS` with several other *series*. :parameters series: a list of tuples where the nth element is a tuple of the form:: (wight_n, ts_n1, ts_n2, ..., ts_nMn) The result will be calculated using the formula:: ts = weight_1*ts_11*ts_12*...*ts_1M1 + weight_2*ts_21*ts_22*...*ts...
[ "Merge", "this", ":", "class", ":", "ColumnTS", "with", "several", "other", "*", "series", "*", ".", ":", "parameters", "series", ":", "a", "list", "of", "tuples", "where", "the", "nth", "element", "is", "a", "tuple", "of", "the", "form", "::", "(", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L171-L188
train
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.merged_series
def merged_series(cls, *series, **kwargs): '''Merge ``series`` and return the results without storing data in the backend server.''' router, backend = cls.check_router(None, *series) if backend: target = router.register(cls(), backend) router.session().add(target) ...
python
def merged_series(cls, *series, **kwargs): '''Merge ``series`` and return the results without storing data in the backend server.''' router, backend = cls.check_router(None, *series) if backend: target = router.register(cls(), backend) router.session().add(target) ...
[ "def", "merged_series", "(", "cls", ",", "*", "series", ",", "*", "*", "kwargs", ")", ":", "router", ",", "backend", "=", "cls", ".", "check_router", "(", "None", ",", "*", "series", ")", "if", "backend", ":", "target", "=", "router", ".", "register"...
Merge ``series`` and return the results without storing data in the backend server.
[ "Merge", "series", "and", "return", "the", "results", "without", "storing", "data", "in", "the", "backend", "server", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L191-L202
train
lsbardel/python-stdnet
stdnet/utils/skiplist.py
skiplist.rank
def rank(self, score): '''Return the 0-based index (rank) of ``score``. If the score is not available it returns a negative integer which absolute score is the left most closest index with score less than *score*.''' node = self.__head rank = 0 for i in range(self.__level-1, -1, -1): ...
python
def rank(self, score): '''Return the 0-based index (rank) of ``score``. If the score is not available it returns a negative integer which absolute score is the left most closest index with score less than *score*.''' node = self.__head rank = 0 for i in range(self.__level-1, -1, -1): ...
[ "def", "rank", "(", "self", ",", "score", ")", ":", "node", "=", "self", ".", "__head", "rank", "=", "0", "for", "i", "in", "range", "(", "self", ".", "__level", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "while", "node", ".", "next", ...
Return the 0-based index (rank) of ``score``. If the score is not available it returns a negative integer which absolute score is the left most closest index with score less than *score*.
[ "Return", "the", "0", "-", "based", "index", "(", "rank", ")", "of", "score", ".", "If", "the", "score", "is", "not", "available", "it", "returns", "a", "negative", "integer", "which", "absolute", "score", "is", "the", "left", "most", "closest", "index",...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/skiplist.py#L74-L87
train
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.make_object
def make_object(self, state=None, backend=None): '''Create a new instance of :attr:`model` from a *state* tuple.''' model = self.model obj = model.__new__(model) self.load_state(obj, state, backend) return obj
python
def make_object(self, state=None, backend=None): '''Create a new instance of :attr:`model` from a *state* tuple.''' model = self.model obj = model.__new__(model) self.load_state(obj, state, backend) return obj
[ "def", "make_object", "(", "self", ",", "state", "=", "None", ",", "backend", "=", "None", ")", ":", "model", "=", "self", ".", "model", "obj", "=", "model", ".", "__new__", "(", "model", ")", "self", ".", "load_state", "(", "obj", ",", "state", ",...
Create a new instance of :attr:`model` from a *state* tuple.
[ "Create", "a", "new", "instance", "of", ":", "attr", ":", "model", "from", "a", "*", "state", "*", "tuple", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L201-L206
train
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.is_valid
def is_valid(self, instance): '''Perform validation for *instance* and stores serialized data, indexes and errors into local cache. Return ``True`` if the instance is ready to be saved to database.''' dbdata = instance.dbdata data = dbdata['cleaned_data'] = {} errors = dbdata['erro...
python
def is_valid(self, instance): '''Perform validation for *instance* and stores serialized data, indexes and errors into local cache. Return ``True`` if the instance is ready to be saved to database.''' dbdata = instance.dbdata data = dbdata['cleaned_data'] = {} errors = dbdata['erro...
[ "def", "is_valid", "(", "self", ",", "instance", ")", ":", "dbdata", "=", "instance", ".", "dbdata", "data", "=", "dbdata", "[", "'cleaned_data'", "]", "=", "{", "}", "errors", "=", "dbdata", "[", "'errors'", "]", "=", "{", "}", "#Loop over scalar fields...
Perform validation for *instance* and stores serialized data, indexes and errors into local cache. Return ``True`` if the instance is ready to be saved to database.
[ "Perform", "validation", "for", "*", "instance", "*", "and", "stores", "serialized", "data", "indexes", "and", "errors", "into", "local", "cache", ".", "Return", "True", "if", "the", "instance", "is", "ready", "to", "be", "saved", "to", "database", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L239-L262
train
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.backend_fields
def backend_fields(self, fields): '''Return a two elements tuple containing a list of fields names and a list of field attribute names.''' dfields = self.dfields processed = set() names = [] atts = [] pkname = self.pkname() for name in fields: ...
python
def backend_fields(self, fields): '''Return a two elements tuple containing a list of fields names and a list of field attribute names.''' dfields = self.dfields processed = set() names = [] atts = [] pkname = self.pkname() for name in fields: ...
[ "def", "backend_fields", "(", "self", ",", "fields", ")", ":", "dfields", "=", "self", ".", "dfields", "processed", "=", "set", "(", ")", "names", "=", "[", "]", "atts", "=", "[", "]", "pkname", "=", "self", ".", "pkname", "(", ")", "for", "name", ...
Return a two elements tuple containing a list of fields names and a list of field attribute names.
[ "Return", "a", "two", "elements", "tuple", "containing", "a", "list", "of", "fields", "names", "and", "a", "list", "of", "field", "attribute", "names", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L292-L316
train
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.as_dict
def as_dict(self): '''Model metadata in a dictionary''' pk = self.pk id_type = 3 if pk.type == 'auto': id_type = 1 return {'id_name': pk.name, 'id_type': id_type, 'sorted': bool(self.ordering), 'autoincr': self....
python
def as_dict(self): '''Model metadata in a dictionary''' pk = self.pk id_type = 3 if pk.type == 'auto': id_type = 1 return {'id_name': pk.name, 'id_type': id_type, 'sorted': bool(self.ordering), 'autoincr': self....
[ "def", "as_dict", "(", "self", ")", ":", "pk", "=", "self", ".", "pk", "id_type", "=", "3", "if", "pk", ".", "type", "==", "'auto'", ":", "id_type", "=", "1", "return", "{", "'id_name'", ":", "pk", ".", "name", ",", "'id_type'", ":", "id_type", "...
Model metadata in a dictionary
[ "Model", "metadata", "in", "a", "dictionary" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L318-L330
train
lsbardel/python-stdnet
stdnet/odm/base.py
Model.get_state
def get_state(self, **kwargs): '''Return the current :class:`ModelState` for this :class:`Model`. If ``kwargs`` parameters are passed a new :class:`ModelState` is created, otherwise it returns the cached value.''' dbdata = self.dbdata if 'state' not in dbdata or kwargs: dbdata[...
python
def get_state(self, **kwargs): '''Return the current :class:`ModelState` for this :class:`Model`. If ``kwargs`` parameters are passed a new :class:`ModelState` is created, otherwise it returns the cached value.''' dbdata = self.dbdata if 'state' not in dbdata or kwargs: dbdata[...
[ "def", "get_state", "(", "self", ",", "*", "*", "kwargs", ")", ":", "dbdata", "=", "self", ".", "dbdata", "if", "'state'", "not", "in", "dbdata", "or", "kwargs", ":", "dbdata", "[", "'state'", "]", "=", "ModelState", "(", "self", ",", "*", "*", "kw...
Return the current :class:`ModelState` for this :class:`Model`. If ``kwargs`` parameters are passed a new :class:`ModelState` is created, otherwise it returns the cached value.
[ "Return", "the", "current", ":", "class", ":", "ModelState", "for", "this", ":", "class", ":", "Model", ".", "If", "kwargs", "parameters", "are", "passed", "a", "new", ":", "class", ":", "ModelState", "is", "created", "otherwise", "it", "returns", "the", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L475-L482
train
lsbardel/python-stdnet
stdnet/odm/base.py
Model.uuid
def uuid(self): '''Universally unique identifier for an instance of a :class:`Model`. ''' pk = self.pkvalue() if not pk: raise self.DoesNotExist( 'Object not saved. Cannot obtain universally unique id') return self.get_uuid(pk)
python
def uuid(self): '''Universally unique identifier for an instance of a :class:`Model`. ''' pk = self.pkvalue() if not pk: raise self.DoesNotExist( 'Object not saved. Cannot obtain universally unique id') return self.get_uuid(pk)
[ "def", "uuid", "(", "self", ")", ":", "pk", "=", "self", ".", "pkvalue", "(", ")", "if", "not", "pk", ":", "raise", "self", ".", "DoesNotExist", "(", "'Object not saved. Cannot obtain universally unique id'", ")", "return", "self", ".", "get_uuid", "(", "pk"...
Universally unique identifier for an instance of a :class:`Model`.
[ "Universally", "unique", "identifier", "for", "an", "instance", "of", "a", ":", "class", ":", "Model", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L493-L500
train
lsbardel/python-stdnet
stdnet/odm/base.py
Model.backend
def backend(self, client=None): '''The :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).backend
python
def backend(self, client=None): '''The :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).backend
[ "def", "backend", "(", "self", ",", "client", "=", "None", ")", ":", "session", "=", "self", ".", "session", "if", "session", ":", "return", "session", ".", "model", "(", "self", ")", ".", "backend" ]
The :class:`stdnet.BackendDatServer` for this instance. It can be ``None``.
[ "The", ":", "class", ":", "stdnet", ".", "BackendDatServer", "for", "this", "instance", ".", "It", "can", "be", "None", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L517-L524
train
lsbardel/python-stdnet
stdnet/odm/base.py
Model.read_backend
def read_backend(self, client=None): '''The read :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).read_backend
python
def read_backend(self, client=None): '''The read :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).read_backend
[ "def", "read_backend", "(", "self", ",", "client", "=", "None", ")", ":", "session", "=", "self", ".", "session", "if", "session", ":", "return", "session", ".", "model", "(", "self", ")", ".", "read_backend" ]
The read :class:`stdnet.BackendDatServer` for this instance. It can be ``None``.
[ "The", "read", ":", "class", ":", "stdnet", ".", "BackendDatServer", "for", "this", "instance", ".", "It", "can", "be", "None", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L527-L534
train
lsbardel/python-stdnet
stdnet/odm/models.py
create_model
def create_model(name, *attributes, **params): '''Create a :class:`Model` class for objects requiring and interface similar to :class:`StdModel`. We refers to this type of models as :ref:`local models <local-models>` since instances of such models are not persistent on a :class:`stdnet.BackendDataServer`. :param n...
python
def create_model(name, *attributes, **params): '''Create a :class:`Model` class for objects requiring and interface similar to :class:`StdModel`. We refers to this type of models as :ref:`local models <local-models>` since instances of such models are not persistent on a :class:`stdnet.BackendDataServer`. :param n...
[ "def", "create_model", "(", "name", ",", "*", "attributes", ",", "*", "*", "params", ")", ":", "params", "[", "'register'", "]", "=", "False", "params", "[", "'attributes'", "]", "=", "attributes", "kwargs", "=", "{", "'manager_class'", ":", "params", "....
Create a :class:`Model` class for objects requiring and interface similar to :class:`StdModel`. We refers to this type of models as :ref:`local models <local-models>` since instances of such models are not persistent on a :class:`stdnet.BackendDataServer`. :param name: Name of the model class. :param attributes: posit...
[ "Create", "a", ":", "class", ":", "Model", "class", "for", "objects", "requiring", "and", "interface", "similar", "to", ":", "class", ":", "StdModel", ".", "We", "refers", "to", "this", "type", "of", "models", "as", ":", "ref", ":", "local", "models", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L290-L307
train
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.loadedfields
def loadedfields(self): '''Generator of fields loaded from database''' if self._loadedfields is None: for field in self._meta.scalarfields: yield field else: fields = self._meta.dfields processed = set() for name in self._loadedfiel...
python
def loadedfields(self): '''Generator of fields loaded from database''' if self._loadedfields is None: for field in self._meta.scalarfields: yield field else: fields = self._meta.dfields processed = set() for name in self._loadedfiel...
[ "def", "loadedfields", "(", "self", ")", ":", "if", "self", ".", "_loadedfields", "is", "None", ":", "for", "field", "in", "self", ".", "_meta", ".", "scalarfields", ":", "yield", "field", "else", ":", "fields", "=", "self", ".", "_meta", ".", "dfields...
Generator of fields loaded from database
[ "Generator", "of", "fields", "loaded", "from", "database" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L57-L77
train
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.fieldvalue_pairs
def fieldvalue_pairs(self, exclude_cache=False): '''Generator of fields,values pairs. Fields correspond to the ones which have been loaded (usually all of them) or not loaded but modified. Check the :ref:`load_only <performance-loadonly>` query function for more details. If *exclude_cache* evaluates to ``True`...
python
def fieldvalue_pairs(self, exclude_cache=False): '''Generator of fields,values pairs. Fields correspond to the ones which have been loaded (usually all of them) or not loaded but modified. Check the :ref:`load_only <performance-loadonly>` query function for more details. If *exclude_cache* evaluates to ``True`...
[ "def", "fieldvalue_pairs", "(", "self", ",", "exclude_cache", "=", "False", ")", ":", "for", "field", "in", "self", ".", "_meta", ".", "scalarfields", ":", "if", "exclude_cache", "and", "field", ".", "as_cache", ":", "continue", "name", "=", "field", ".", ...
Generator of fields,values pairs. Fields correspond to the ones which have been loaded (usually all of them) or not loaded but modified. Check the :ref:`load_only <performance-loadonly>` query function for more details. If *exclude_cache* evaluates to ``True``, fields with :attr:`Field.as_cache` attribute set to ``Tru...
[ "Generator", "of", "fields", "values", "pairs", ".", "Fields", "correspond", "to", "the", "ones", "which", "have", "been", "loaded", "(", "usually", "all", "of", "them", ")", "or", "not", "loaded", "but", "modified", ".", "Check", "the", ":", "ref", ":",...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L79-L95
train
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.clear_cache_fields
def clear_cache_fields(self): '''Set cache fields to ``None``. Check :attr:`Field.as_cache` for information regarding fields which are considered cache.''' for field in self._meta.scalarfields: if field.as_cache: setattr(self, field.name, None)
python
def clear_cache_fields(self): '''Set cache fields to ``None``. Check :attr:`Field.as_cache` for information regarding fields which are considered cache.''' for field in self._meta.scalarfields: if field.as_cache: setattr(self, field.name, None)
[ "def", "clear_cache_fields", "(", "self", ")", ":", "for", "field", "in", "self", ".", "_meta", ".", "scalarfields", ":", "if", "field", ".", "as_cache", ":", "setattr", "(", "self", ",", "field", ".", "name", ",", "None", ")" ]
Set cache fields to ``None``. Check :attr:`Field.as_cache` for information regarding fields which are considered cache.
[ "Set", "cache", "fields", "to", "None", ".", "Check", ":", "attr", ":", "Field", ".", "as_cache", "for", "information", "regarding", "fields", "which", "are", "considered", "cache", "." ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L97-L102
train