repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
seibert-media/Highton
highton/models/highton_model.py
HightonModel.to_serializable_value
def to_serializable_value(self): """ Parses the Hightonmodel to a serializable value such dicts, lists, strings This can be used to save the model in a NoSQL database :return: the serialized HightonModel :rtype: dict """ return_dict = {} for name, field i...
python
def to_serializable_value(self): """ Parses the Hightonmodel to a serializable value such dicts, lists, strings This can be used to save the model in a NoSQL database :return: the serialized HightonModel :rtype: dict """ return_dict = {} for name, field i...
[ "def", "to_serializable_value", "(", "self", ")", ":", "return_dict", "=", "{", "}", "for", "name", ",", "field", "in", "self", ".", "__dict__", ".", "items", "(", ")", ":", "if", "isinstance", "(", "field", ",", "fields", ".", "Field", ")", ":", "re...
Parses the Hightonmodel to a serializable value such dicts, lists, strings This can be used to save the model in a NoSQL database :return: the serialized HightonModel :rtype: dict
[ "Parses", "the", "Hightonmodel", "to", "a", "serializable", "value", "such", "dicts", "lists", "strings", "This", "can", "be", "used", "to", "save", "the", "model", "in", "a", "NoSQL", "database" ]
train
https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/models/highton_model.py#L24-L36
justquick/django-native-tags
native_tags/contrib/_markup.py
textile
def textile(text, **kwargs): """ Applies Textile conversion to a string, and returns the HTML. This is simply a pass-through to the ``textile`` template filter included in ``django.contrib.markup``, which works around issues PyTextile has with Unicode strings. If you're not using Django but ...
python
def textile(text, **kwargs): """ Applies Textile conversion to a string, and returns the HTML. This is simply a pass-through to the ``textile`` template filter included in ``django.contrib.markup``, which works around issues PyTextile has with Unicode strings. If you're not using Django but ...
[ "def", "textile", "(", "text", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "contrib", ".", "markup", ".", "templatetags", ".", "markup", "import", "textile", "return", "textile", "(", "text", ")" ]
Applies Textile conversion to a string, and returns the HTML. This is simply a pass-through to the ``textile`` template filter included in ``django.contrib.markup``, which works around issues PyTextile has with Unicode strings. If you're not using Django but want to use Textile with ``MarkupFormatt...
[ "Applies", "Textile", "conversion", "to", "a", "string", "and", "returns", "the", "HTML", ".", "This", "is", "simply", "a", "pass", "-", "through", "to", "the", "textile", "template", "filter", "included", "in", "django", ".", "contrib", ".", "markup", "wh...
train
https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_markup.py#L7-L19
justquick/django-native-tags
native_tags/contrib/_markup.py
restructuredtext
def restructuredtext(text, **kwargs): """ Applies reStructuredText conversion to a string, and returns the HTML. """ from docutils import core parts = core.publish_parts(source=text, writer_name='html4css1', **kwargs) return ...
python
def restructuredtext(text, **kwargs): """ Applies reStructuredText conversion to a string, and returns the HTML. """ from docutils import core parts = core.publish_parts(source=text, writer_name='html4css1', **kwargs) return ...
[ "def", "restructuredtext", "(", "text", ",", "*", "*", "kwargs", ")", ":", "from", "docutils", "import", "core", "parts", "=", "core", ".", "publish_parts", "(", "source", "=", "text", ",", "writer_name", "=", "'html4css1'", ",", "*", "*", "kwargs", ")",...
Applies reStructuredText conversion to a string, and returns the HTML.
[ "Applies", "reStructuredText", "conversion", "to", "a", "string", "and", "returns", "the", "HTML", "." ]
train
https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_markup.py#L29-L39
exa-analytics/exa
exa/typed.py
_typed_from_items
def _typed_from_items(items): """ Construct strongly typed attributes (properties) from a dictionary of name and :class:`~exa.typed.Typed` object pairs. See Also: :func:`~exa.typed.typed` """ dct = {} for name, attr in items: if isinstance(attr, Typed): dct[name]...
python
def _typed_from_items(items): """ Construct strongly typed attributes (properties) from a dictionary of name and :class:`~exa.typed.Typed` object pairs. See Also: :func:`~exa.typed.typed` """ dct = {} for name, attr in items: if isinstance(attr, Typed): dct[name]...
[ "def", "_typed_from_items", "(", "items", ")", ":", "dct", "=", "{", "}", "for", "name", ",", "attr", "in", "items", ":", "if", "isinstance", "(", "attr", ",", "Typed", ")", ":", "dct", "[", "name", "]", "=", "attr", "(", "name", ")", "return", "...
Construct strongly typed attributes (properties) from a dictionary of name and :class:`~exa.typed.Typed` object pairs. See Also: :func:`~exa.typed.typed`
[ "Construct", "strongly", "typed", "attributes", "(", "properties", ")", "from", "a", "dictionary", "of", "name", "and", ":", "class", ":", "~exa", ".", "typed", ".", "Typed", "object", "pairs", "." ]
train
https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/typed.py#L47-L59
exa-analytics/exa
exa/typed.py
typed
def typed(cls): """ Class decorator that updates a class definition with strongly typed property attributes. See Also: If the class will be inherited, use :class:`~exa.typed.TypedClass`. """ for name, attr in _typed_from_items(vars(cls).items()).items(): setattr(cls, name, attr)...
python
def typed(cls): """ Class decorator that updates a class definition with strongly typed property attributes. See Also: If the class will be inherited, use :class:`~exa.typed.TypedClass`. """ for name, attr in _typed_from_items(vars(cls).items()).items(): setattr(cls, name, attr)...
[ "def", "typed", "(", "cls", ")", ":", "for", "name", ",", "attr", "in", "_typed_from_items", "(", "vars", "(", "cls", ")", ".", "items", "(", ")", ")", ".", "items", "(", ")", ":", "setattr", "(", "cls", ",", "name", ",", "attr", ")", "return", ...
Class decorator that updates a class definition with strongly typed property attributes. See Also: If the class will be inherited, use :class:`~exa.typed.TypedClass`.
[ "Class", "decorator", "that", "updates", "a", "class", "definition", "with", "strongly", "typed", "property", "attributes", "." ]
train
https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/typed.py#L62-L72
exa-analytics/exa
exa/typed.py
yield_typed
def yield_typed(obj_or_cls): """ Generator that yields typed object names of the class (or object's class). Args: obj_or_cls (object): Class object or instance of class Returns: name (array): Names of class attributes that are strongly typed """ if not isinstance(obj_or_cls, ty...
python
def yield_typed(obj_or_cls): """ Generator that yields typed object names of the class (or object's class). Args: obj_or_cls (object): Class object or instance of class Returns: name (array): Names of class attributes that are strongly typed """ if not isinstance(obj_or_cls, ty...
[ "def", "yield_typed", "(", "obj_or_cls", ")", ":", "if", "not", "isinstance", "(", "obj_or_cls", ",", "type", ")", ":", "obj_or_cls", "=", "type", "(", "obj_or_cls", ")", "for", "attrname", "in", "dir", "(", "obj_or_cls", ")", ":", "if", "hasattr", "(", ...
Generator that yields typed object names of the class (or object's class). Args: obj_or_cls (object): Class object or instance of class Returns: name (array): Names of class attributes that are strongly typed
[ "Generator", "that", "yields", "typed", "object", "names", "of", "the", "class", "(", "or", "object", "s", "class", ")", "." ]
train
https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/typed.py#L75-L93
kennknowles/python-rightarrow
rightarrow/constraintsolve.py
reconcile
def reconcile(constraint): ''' Returns an assignment of type variable names to types that makes this constraint satisfiable, or a Refutation ''' if isinstance(constraint.subtype, NamedType): if isinstance(constraint.supertype, NamedType): if constraint.subtype.name == constr...
python
def reconcile(constraint): ''' Returns an assignment of type variable names to types that makes this constraint satisfiable, or a Refutation ''' if isinstance(constraint.subtype, NamedType): if isinstance(constraint.supertype, NamedType): if constraint.subtype.name == constr...
[ "def", "reconcile", "(", "constraint", ")", ":", "if", "isinstance", "(", "constraint", ".", "subtype", ",", "NamedType", ")", ":", "if", "isinstance", "(", "constraint", ".", "supertype", ",", "NamedType", ")", ":", "if", "constraint", ".", "subtype", "."...
Returns an assignment of type variable names to types that makes this constraint satisfiable, or a Refutation
[ "Returns", "an", "assignment", "of", "type", "variable", "names", "to", "types", "that", "makes", "this", "constraint", "satisfiable", "or", "a", "Refutation" ]
train
https://github.com/kennknowles/python-rightarrow/blob/86c83bde9d2fba6d54744eac9abedd1c248b7e73/rightarrow/constraintsolve.py#L28-L61
zetaops/pyoko
pyoko/fields.py
File.clean_value
def clean_value(self, val): """ val = :param dict val: {"content":"", "name":"", "ext":"", "type":""} :return: """ if isinstance(val, dict): if self.random_name: val['random_name'] = self.random_name if 'file_name' in val.keys(): ...
python
def clean_value(self, val): """ val = :param dict val: {"content":"", "name":"", "ext":"", "type":""} :return: """ if isinstance(val, dict): if self.random_name: val['random_name'] = self.random_name if 'file_name' in val.keys(): ...
[ "def", "clean_value", "(", "self", ",", "val", ")", ":", "if", "isinstance", "(", "val", ",", "dict", ")", ":", "if", "self", ".", "random_name", ":", "val", "[", "'random_name'", "]", "=", "self", ".", "random_name", "if", "'file_name'", "in", "val", ...
val = :param dict val: {"content":"", "name":"", "ext":"", "type":""} :return:
[ "val", "=", ":", "param", "dict", "val", ":", "{", "content", ":", "name", ":", "ext", ":", "type", ":", "}", ":", "return", ":" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/fields.py#L278-L297
zetaops/pyoko
pyoko/model.py
Model.prnt
def prnt(self): """ Prints DB data representation of the object. """ print("= = = =\n\n%s object key: \033[32m%s\033[0m" % (self.__class__.__name__, self.key)) pprnt(self._data or self.clean_value())
python
def prnt(self): """ Prints DB data representation of the object. """ print("= = = =\n\n%s object key: \033[32m%s\033[0m" % (self.__class__.__name__, self.key)) pprnt(self._data or self.clean_value())
[ "def", "prnt", "(", "self", ")", ":", "print", "(", "\"= = = =\\n\\n%s object key: \\033[32m%s\\033[0m\"", "%", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "key", ")", ")", "pprnt", "(", "self", ".", "_data", "or", "self", ".", "clean...
Prints DB data representation of the object.
[ "Prints", "DB", "data", "representation", "of", "the", "object", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L121-L126
zetaops/pyoko
pyoko/model.py
Model.get_choices_for
def get_choices_for(self, field): """ Get the choices for the given fields. Args: field (str): Name of field. Returns: List of tuples. [(name, value),...] """ choices = self._fields[field].choices if isinstance(choices, six.string_types):...
python
def get_choices_for(self, field): """ Get the choices for the given fields. Args: field (str): Name of field. Returns: List of tuples. [(name, value),...] """ choices = self._fields[field].choices if isinstance(choices, six.string_types):...
[ "def", "get_choices_for", "(", "self", ",", "field", ")", ":", "choices", "=", "self", ".", "_fields", "[", "field", "]", ".", "choices", "if", "isinstance", "(", "choices", ",", "six", ".", "string_types", ")", ":", "return", "[", "(", "d", "[", "'v...
Get the choices for the given fields. Args: field (str): Name of field. Returns: List of tuples. [(name, value),...]
[ "Get", "the", "choices", "for", "the", "given", "fields", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L169-L183
zetaops/pyoko
pyoko/model.py
Model.set_data
def set_data(self, data, from_db=False): """ Fills the object's fields with given data dict. Internally calls the self._load_data() method. Args: data (dict): Data to fill object's fields. from_db (bool): if data coming from db then we will use relate...
python
def set_data(self, data, from_db=False): """ Fills the object's fields with given data dict. Internally calls the self._load_data() method. Args: data (dict): Data to fill object's fields. from_db (bool): if data coming from db then we will use relate...
[ "def", "set_data", "(", "self", ",", "data", ",", "from_db", "=", "False", ")", ":", "self", ".", "_load_data", "(", "data", ",", "from_db", ")", "return", "self" ]
Fills the object's fields with given data dict. Internally calls the self._load_data() method. Args: data (dict): Data to fill object's fields. from_db (bool): if data coming from db then we will use related field type's _load_data method Returns: ...
[ "Fills", "the", "object", "s", "fields", "with", "given", "data", "dict", ".", "Internally", "calls", "the", "self", ".", "_load_data", "()", "method", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L185-L199
zetaops/pyoko
pyoko/model.py
Model._apply_cell_filters
def _apply_cell_filters(self, context): """ Applies the field restrictions based on the return value of the context's "has_permission()" method. Stores them on self._unpermitted_fields. Returns: List of unpermitted fields names. """ self.setattrs(_i...
python
def _apply_cell_filters(self, context): """ Applies the field restrictions based on the return value of the context's "has_permission()" method. Stores them on self._unpermitted_fields. Returns: List of unpermitted fields names. """ self.setattrs(_i...
[ "def", "_apply_cell_filters", "(", "self", ",", "context", ")", ":", "self", ".", "setattrs", "(", "_is_unpermitted_fields_set", "=", "True", ")", "for", "perm", ",", "fields", "in", "self", ".", "Meta", ".", "field_permissions", ".", "items", "(", ")", ":...
Applies the field restrictions based on the return value of the context's "has_permission()" method. Stores them on self._unpermitted_fields. Returns: List of unpermitted fields names.
[ "Applies", "the", "field", "restrictions", "based", "on", "the", "return", "value", "of", "the", "context", "s", "has_permission", "()", "method", ".", "Stores", "them", "on", "self", ".", "_unpermitted_fields", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L207-L220
zetaops/pyoko
pyoko/model.py
Model.get_unpermitted_fields
def get_unpermitted_fields(self): """ Gives unpermitted fields for current context/user. Returns: List of unpermitted field names. """ return (self._unpermitted_fields if self._is_unpermitted_fields_set else self._apply_cell_filters(self._context))
python
def get_unpermitted_fields(self): """ Gives unpermitted fields for current context/user. Returns: List of unpermitted field names. """ return (self._unpermitted_fields if self._is_unpermitted_fields_set else self._apply_cell_filters(self._context))
[ "def", "get_unpermitted_fields", "(", "self", ")", ":", "return", "(", "self", ".", "_unpermitted_fields", "if", "self", ".", "_is_unpermitted_fields_set", "else", "self", ".", "_apply_cell_filters", "(", "self", ".", "_context", ")", ")" ]
Gives unpermitted fields for current context/user. Returns: List of unpermitted field names.
[ "Gives", "unpermitted", "fields", "for", "current", "context", "/", "user", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L222-L230
zetaops/pyoko
pyoko/model.py
Model._update_new_linked_model
def _update_new_linked_model(self, internal, linked_mdl_ins, link): """ Iterates through linked_models of given model instance to match it's "reverse" with given link's "field" values. """ # If there is a link between two sides (A and B), if a link from A to B, # link sh...
python
def _update_new_linked_model(self, internal, linked_mdl_ins, link): """ Iterates through linked_models of given model instance to match it's "reverse" with given link's "field" values. """ # If there is a link between two sides (A and B), if a link from A to B, # link sh...
[ "def", "_update_new_linked_model", "(", "self", ",", "internal", ",", "linked_mdl_ins", ",", "link", ")", ":", "# If there is a link between two sides (A and B), if a link from A to B,", "# link should be saved at B but it is not necessary to control again data in A.", "# If internal fie...
Iterates through linked_models of given model instance to match it's "reverse" with given link's "field" values.
[ "Iterates", "through", "linked_models", "of", "given", "model", "instance", "to", "match", "it", "s", "reverse", "with", "given", "link", "s", "field", "values", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L264-L304
zetaops/pyoko
pyoko/model.py
Model._handle_changed_fields
def _handle_changed_fields(self, old_data): """ Looks for changed relation fields between new and old data (before/after save). Creates back_link references for updated fields. Args: old_data: Object's data before save. """ for link in self.get_links(is_set=F...
python
def _handle_changed_fields(self, old_data): """ Looks for changed relation fields between new and old data (before/after save). Creates back_link references for updated fields. Args: old_data: Object's data before save. """ for link in self.get_links(is_set=F...
[ "def", "_handle_changed_fields", "(", "self", ",", "old_data", ")", ":", "for", "link", "in", "self", ".", "get_links", "(", "is_set", "=", "False", ")", ":", "fld_id", "=", "un_camel_id", "(", "link", "[", "'field'", "]", ")", "if", "not", "old_data", ...
Looks for changed relation fields between new and old data (before/after save). Creates back_link references for updated fields. Args: old_data: Object's data before save.
[ "Looks", "for", "changed", "relation", "fields", "between", "new", "and", "old", "data", "(", "before", "/", "after", "save", ")", ".", "Creates", "back_link", "references", "for", "updated", "fields", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L312-L326
zetaops/pyoko
pyoko/model.py
Model.reload
def reload(self): """ Reloads current instance from DB store """ self._load_data(self.objects.data().filter(key=self.key)[0][0], True)
python
def reload(self): """ Reloads current instance from DB store """ self._load_data(self.objects.data().filter(key=self.key)[0][0], True)
[ "def", "reload", "(", "self", ")", ":", "self", ".", "_load_data", "(", "self", ".", "objects", ".", "data", "(", ")", ".", "filter", "(", "key", "=", "self", ".", "key", ")", "[", "0", "]", "[", "0", "]", ",", "True", ")" ]
Reloads current instance from DB store
[ "Reloads", "current", "instance", "from", "DB", "store" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L336-L340
zetaops/pyoko
pyoko/model.py
Model._handle_uniqueness
def _handle_uniqueness(self): """ Checks marked as unique and unique_together fields of the Model at each creation and update, and if it violates the uniqueness raises IntegrityError. First, looks at the fields which marked as "unique". If Model's unique fields did not change, i...
python
def _handle_uniqueness(self): """ Checks marked as unique and unique_together fields of the Model at each creation and update, and if it violates the uniqueness raises IntegrityError. First, looks at the fields which marked as "unique". If Model's unique fields did not change, i...
[ "def", "_handle_uniqueness", "(", "self", ")", ":", "def", "_getattr", "(", "u", ")", ":", "try", ":", "return", "self", ".", "_field_values", "[", "u", "]", "except", "KeyError", ":", "return", "getattr", "(", "self", ",", "u", ")", "if", "self", "....
Checks marked as unique and unique_together fields of the Model at each creation and update, and if it violates the uniqueness raises IntegrityError. First, looks at the fields which marked as "unique". If Model's unique fields did not change, it means that there is still a record at db with sa...
[ "Checks", "marked", "as", "unique", "and", "unique_together", "fields", "of", "the", "Model", "at", "each", "creation", "and", "update", "and", "if", "it", "violates", "the", "uniqueness", "raises", "IntegrityError", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L390-L455
zetaops/pyoko
pyoko/model.py
Model.save
def save(self, internal=False, meta=None, index_fields=None): """ Save's object to DB. Do not override this method, use pre_save and post_save methods. Args: internal (bool): True if called within model. Used to prevent unneccessary calls to pre_save and ...
python
def save(self, internal=False, meta=None, index_fields=None): """ Save's object to DB. Do not override this method, use pre_save and post_save methods. Args: internal (bool): True if called within model. Used to prevent unneccessary calls to pre_save and ...
[ "def", "save", "(", "self", ",", "internal", "=", "False", ",", "meta", "=", "None", ",", "index_fields", "=", "None", ")", ":", "for", "f", "in", "self", ".", "on_save", ":", "f", "(", "self", ")", "if", "not", "(", "internal", "or", "self", "."...
Save's object to DB. Do not override this method, use pre_save and post_save methods. Args: internal (bool): True if called within model. Used to prevent unneccessary calls to pre_save and post_save methods. meta (dict): JSON serializable meta da...
[ "Save", "s", "object", "to", "DB", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L457-L504
zetaops/pyoko
pyoko/model.py
Model.changed_fields
def changed_fields(self, from_db=False): """ Args: from_db (bool): Check changes against actual db data Returns: list: List of fields names which their values changed. """ if self.exist: current_dict = self.clean_value() # `from_db`...
python
def changed_fields(self, from_db=False): """ Args: from_db (bool): Check changes against actual db data Returns: list: List of fields names which their values changed. """ if self.exist: current_dict = self.clean_value() # `from_db`...
[ "def", "changed_fields", "(", "self", ",", "from_db", "=", "False", ")", ":", "if", "self", ".", "exist", ":", "current_dict", "=", "self", ".", "clean_value", "(", ")", "# `from_db` attr is set False as default, when a `ListNode` is", "# initialized just after above `c...
Args: from_db (bool): Check changes against actual db data Returns: list: List of fields names which their values changed.
[ "Args", ":", "from_db", "(", "bool", ")", ":", "Check", "changes", "against", "actual", "db", "data", "Returns", ":", "list", ":", "List", "of", "fields", "names", "which", "their", "values", "changed", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L506-L526
zetaops/pyoko
pyoko/model.py
Model.is_changed
def is_changed(self, field, from_db=False): """ Args: field (string): Field name. from_db (bool): Check changes against actual db data Returns: bool: True if given fields value is changed. """ return field in self.changed_fields(from_db=from_d...
python
def is_changed(self, field, from_db=False): """ Args: field (string): Field name. from_db (bool): Check changes against actual db data Returns: bool: True if given fields value is changed. """ return field in self.changed_fields(from_db=from_d...
[ "def", "is_changed", "(", "self", ",", "field", ",", "from_db", "=", "False", ")", ":", "return", "field", "in", "self", ".", "changed_fields", "(", "from_db", "=", "from_db", ")" ]
Args: field (string): Field name. from_db (bool): Check changes against actual db data Returns: bool: True if given fields value is changed.
[ "Args", ":", "field", "(", "string", ")", ":", "Field", "name", ".", "from_db", "(", "bool", ")", ":", "Check", "changes", "against", "actual", "db", "data" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L528-L537
zetaops/pyoko
pyoko/model.py
Model.blocking_save
def blocking_save(self, query_dict=None, meta=None, index_fields=None): """ Saves object to DB. Waits till the backend properly indexes the new object. Args: query_dict(dict) : contains keys - values of the model fields meta (dict): JSON serializable meta data for loggi...
python
def blocking_save(self, query_dict=None, meta=None, index_fields=None): """ Saves object to DB. Waits till the backend properly indexes the new object. Args: query_dict(dict) : contains keys - values of the model fields meta (dict): JSON serializable meta data for loggi...
[ "def", "blocking_save", "(", "self", ",", "query_dict", "=", "None", ",", "meta", "=", "None", ",", "index_fields", "=", "None", ")", ":", "query_dict", "=", "query_dict", "or", "{", "}", "for", "query", "in", "query_dict", ":", "self", ".", "setattr", ...
Saves object to DB. Waits till the backend properly indexes the new object. Args: query_dict(dict) : contains keys - values of the model fields meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_field...
[ "Saves", "object", "to", "DB", ".", "Waits", "till", "the", "backend", "properly", "indexes", "the", "new", "object", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L539-L562
zetaops/pyoko
pyoko/model.py
Model.blocking_delete
def blocking_delete(self, meta=None, index_fields=None): """ Deletes and waits till the backend properly update indexes for just deleted object. meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple l...
python
def blocking_delete(self, meta=None, index_fields=None): """ Deletes and waits till the backend properly update indexes for just deleted object. meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple l...
[ "def", "blocking_delete", "(", "self", ",", "meta", "=", "None", ",", "index_fields", "=", "None", ")", ":", "self", ".", "delete", "(", "meta", "=", "meta", ",", "index_fields", "=", "index_fields", ")", "while", "self", ".", "objects", ".", "filter", ...
Deletes and waits till the backend properly update indexes for just deleted object. meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple list for indexing keys in riak (with 'bin' or 'int'). bin is used ...
[ "Deletes", "and", "waits", "till", "the", "backend", "properly", "update", "indexes", "for", "just", "deleted", "object", ".", "meta", "(", "dict", ")", ":", "JSON", "serializable", "meta", "data", "for", "logging", "of", "save", "operation", ".", "{", "lo...
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L564-L575
zetaops/pyoko
pyoko/model.py
Model.delete
def delete(self, dry=False, meta=None, index_fields=None): """ Sets the objects "deleted" field to True and, current time to "deleted_at" fields then saves it to DB. Args: dry (bool): False. Do not execute the actual deletion. Just list what will be deleted as a...
python
def delete(self, dry=False, meta=None, index_fields=None): """ Sets the objects "deleted" field to True and, current time to "deleted_at" fields then saves it to DB. Args: dry (bool): False. Do not execute the actual deletion. Just list what will be deleted as a...
[ "def", "delete", "(", "self", ",", "dry", "=", "False", ",", "meta", "=", "None", ",", "index_fields", "=", "None", ")", ":", "from", "datetime", "import", "datetime", "# TODO: Make sure this works safely (like a sql transaction)", "if", "not", "dry", ":", "self...
Sets the objects "deleted" field to True and, current time to "deleted_at" fields then saves it to DB. Args: dry (bool): False. Do not execute the actual deletion. Just list what will be deleted as a result of relations. meta (dict): JSON serializable meta data for ...
[ "Sets", "the", "objects", "deleted", "field", "to", "True", "and", "current", "time", "to", "deleted_at", "fields", "then", "saves", "it", "to", "DB", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L596-L625
shimpe/pyvectortween
vectortween/ColorAnimation.py
ColorAnimation.__clip
def __clip(val, minimum, maximum): """ :param val: input value :param minimum: min value :param maximum: max value :return: val clipped to range [minimum, maximum] """ if val is None or minimum is None or maximum is None: return None ...
python
def __clip(val, minimum, maximum): """ :param val: input value :param minimum: min value :param maximum: max value :return: val clipped to range [minimum, maximum] """ if val is None or minimum is None or maximum is None: return None ...
[ "def", "__clip", "(", "val", ",", "minimum", ",", "maximum", ")", ":", "if", "val", "is", "None", "or", "minimum", "is", "None", "or", "maximum", "is", "None", ":", "return", "None", "if", "val", "<", "minimum", ":", "return", "minimum", "if", "val",...
:param val: input value :param minimum: min value :param maximum: max value :return: val clipped to range [minimum, maximum]
[ ":", "param", "val", ":", "input", "value", ":", "param", "minimum", ":", "min", "value", ":", "param", "maximum", ":", "max", "value", ":", "return", ":", "val", "clipped", "to", "range", "[", "minimum", "maximum", "]" ]
train
https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/ColorAnimation.py#L45-L59
shimpe/pyvectortween
vectortween/ColorAnimation.py
ColorAnimation.make_frame
def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None): """ :param frame: current frame :param birthframe: frame where animation starts to return something other than None :param startframe: frame where animation starts to evolve :param stopf...
python
def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None): """ :param frame: current frame :param birthframe: frame where animation starts to return something other than None :param startframe: frame where animation starts to evolve :param stopf...
[ "def", "make_frame", "(", "self", ",", "frame", ",", "birthframe", ",", "startframe", ",", "stopframe", ",", "deathframe", ",", "noiseframe", "=", "None", ")", ":", "if", "self", ".", "use_alpha", ":", "return", "(", "self", ".", "__clip", "(", "self", ...
:param frame: current frame :param birthframe: frame where animation starts to return something other than None :param startframe: frame where animation starts to evolve :param stopframe: frame where animation stops evolving :param deathframe: frame where animation starts to return None...
[ ":", "param", "frame", ":", "current", "frame", ":", "param", "birthframe", ":", "frame", "where", "animation", "starts", "to", "return", "something", "other", "than", "None", ":", "param", "startframe", ":", "frame", "where", "animation", "starts", "to", "e...
train
https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/ColorAnimation.py#L62-L79
yatiml/yatiml
yatiml/recognizer.py
Recognizer.__recognize_scalar
def __recognize_scalar(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be a scalar. Args: node: The node to recognize. expected_type: The type it is expected to be. Returns: A list of...
python
def __recognize_scalar(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be a scalar. Args: node: The node to recognize. expected_type: The type it is expected to be. Returns: A list of...
[ "def", "__recognize_scalar", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "expected_type", ":", "Type", ")", "->", "RecResult", ":", "logger", ".", "debug", "(", "'Recognizing as a scalar'", ")", "if", "(", "isinstance", "(", "node", ",", "yaml...
Recognize a node that we expect to be a scalar. Args: node: The node to recognize. expected_type: The type it is expected to be. Returns: A list of recognized types and an error message
[ "Recognize", "a", "node", "that", "we", "expect", "to", "be", "a", "scalar", "." ]
train
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/recognizer.py#L34-L51
yatiml/yatiml
yatiml/recognizer.py
Recognizer.__recognize_list
def __recognize_list(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be a list of some kind. Args: node: The node to recognize. expected_type: List[...something...] Returns expected_typ...
python
def __recognize_list(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be a list of some kind. Args: node: The node to recognize. expected_type: List[...something...] Returns expected_typ...
[ "def", "__recognize_list", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "expected_type", ":", "Type", ")", "->", "RecResult", ":", "logger", ".", "debug", "(", "'Recognizing as a list'", ")", "if", "not", "isinstance", "(", "node", ",", "yaml",...
Recognize a node that we expect to be a list of some kind. Args: node: The node to recognize. expected_type: List[...something...] Returns expected_type and the empty string if it was recognized, [] and an error message otherwise.
[ "Recognize", "a", "node", "that", "we", "expect", "to", "be", "a", "list", "of", "some", "kind", "." ]
train
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/recognizer.py#L53-L82
yatiml/yatiml
yatiml/recognizer.py
Recognizer.__recognize_dict
def __recognize_dict(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be a dict of some kind. Args: node: The node to recognize. expected_type: Dict[str, ...something...] Returns: expect...
python
def __recognize_dict(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be a dict of some kind. Args: node: The node to recognize. expected_type: Dict[str, ...something...] Returns: expect...
[ "def", "__recognize_dict", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "expected_type", ":", "Type", ")", "->", "RecResult", ":", "logger", ".", "debug", "(", "'Recognizing as a dict'", ")", "if", "not", "issubclass", "(", "generic_type_args", "...
Recognize a node that we expect to be a dict of some kind. Args: node: The node to recognize. expected_type: Dict[str, ...something...] Returns: expected_type if it was recognized, [] otherwise.
[ "Recognize", "a", "node", "that", "we", "expect", "to", "be", "a", "dict", "of", "some", "kind", "." ]
train
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/recognizer.py#L84-L114
yatiml/yatiml
yatiml/recognizer.py
Recognizer.__recognize_union
def __recognize_union(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be one of a union of types. Args: node: The node to recognize. expected_type: Union[...something...] Returns: The ...
python
def __recognize_union(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a node that we expect to be one of a union of types. Args: node: The node to recognize. expected_type: Union[...something...] Returns: The ...
[ "def", "__recognize_union", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "expected_type", ":", "Type", ")", "->", "RecResult", ":", "logger", ".", "debug", "(", "'Recognizing as a union'", ")", "recognized_types", "=", "[", "]", "message", "=", ...
Recognize a node that we expect to be one of a union of types. Args: node: The node to recognize. expected_type: Union[...something...] Returns: The specific type that was recognized, multiple, or none.
[ "Recognize", "a", "node", "that", "we", "expect", "to", "be", "one", "of", "a", "union", "of", "types", "." ]
train
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/recognizer.py#L116-L149
yatiml/yatiml
yatiml/recognizer.py
Recognizer.__recognize_user_class
def __recognize_user_class(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a user-defined class in the node. This tries to recognize only exactly the specified class. It \ recurses down into the class's attributes, but not to its \ s...
python
def __recognize_user_class(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a user-defined class in the node. This tries to recognize only exactly the specified class. It \ recurses down into the class's attributes, but not to its \ s...
[ "def", "__recognize_user_class", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "expected_type", ":", "Type", ")", "->", "RecResult", ":", "logger", ".", "debug", "(", "'Recognizing as a user-defined class'", ")", "loc_str", "=", "'{}{}'", ".", "form...
Recognize a user-defined class in the node. This tries to recognize only exactly the specified class. It \ recurses down into the class's attributes, but not to its \ subclasses. See also __recognize_user_classes(). Args: node: The node to recognize. expected_ty...
[ "Recognize", "a", "user", "-", "defined", "class", "in", "the", "node", "." ]
train
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/recognizer.py#L151-L232
yatiml/yatiml
yatiml/recognizer.py
Recognizer.__recognize_user_classes
def __recognize_user_classes(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a user-defined class in the node. This returns a list of classes from the inheritance hierarchy \ headed by expected_type which match the given node and which \ ...
python
def __recognize_user_classes(self, node: yaml.Node, expected_type: Type) -> RecResult: """Recognize a user-defined class in the node. This returns a list of classes from the inheritance hierarchy \ headed by expected_type which match the given node and which \ ...
[ "def", "__recognize_user_classes", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "expected_type", ":", "Type", ")", "->", "RecResult", ":", "# Let the user override with an explicit tag", "if", "node", ".", "tag", "in", "self", ".", "__registered_classe...
Recognize a user-defined class in the node. This returns a list of classes from the inheritance hierarchy \ headed by expected_type which match the given node and which \ do not have a registered derived class that matches the given \ node. So, the returned classes are the most derived ...
[ "Recognize", "a", "user", "-", "defined", "class", "in", "the", "node", "." ]
train
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/recognizer.py#L234-L286
yatiml/yatiml
yatiml/recognizer.py
Recognizer.recognize
def recognize(self, node: yaml.Node, expected_type: Type) -> RecResult: """Figure out how to interpret this node. This is not quite a type check. This function makes a list of \ all types that match the expected type and also the node, and \ returns that list. The goal here is not to te...
python
def recognize(self, node: yaml.Node, expected_type: Type) -> RecResult: """Figure out how to interpret this node. This is not quite a type check. This function makes a list of \ all types that match the expected type and also the node, and \ returns that list. The goal here is not to te...
[ "def", "recognize", "(", "self", ",", "node", ":", "yaml", ".", "Node", ",", "expected_type", ":", "Type", ")", "->", "RecResult", ":", "logger", ".", "debug", "(", "'Recognizing {} as a {}'", ".", "format", "(", "node", ",", "expected_type", ")", ")", "...
Figure out how to interpret this node. This is not quite a type check. This function makes a list of \ all types that match the expected type and also the node, and \ returns that list. The goal here is not to test validity, but \ to determine how to process this node further. ...
[ "Figure", "out", "how", "to", "interpret", "this", "node", "." ]
train
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/recognizer.py#L288-L334
moonso/vcftoolbox
vcftoolbox/cli.py
cli
def cli(ctx, vcf, verbose, outfile, silent): """Simple vcf operations""" # configure root logger to print to STDERR loglevel = LEVELS.get(min(verbose, 3)) configure_stream(level=loglevel) if vcf == '-': handle = get_vcf_handle(fsock=sys.stdin) else: handle = get_vcf_handle(i...
python
def cli(ctx, vcf, verbose, outfile, silent): """Simple vcf operations""" # configure root logger to print to STDERR loglevel = LEVELS.get(min(verbose, 3)) configure_stream(level=loglevel) if vcf == '-': handle = get_vcf_handle(fsock=sys.stdin) else: handle = get_vcf_handle(i...
[ "def", "cli", "(", "ctx", ",", "vcf", ",", "verbose", ",", "outfile", ",", "silent", ")", ":", "# configure root logger to print to STDERR", "loglevel", "=", "LEVELS", ".", "get", "(", "min", "(", "verbose", ",", "3", ")", ")", "configure_stream", "(", "le...
Simple vcf operations
[ "Simple", "vcf", "operations" ]
train
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/cli.py#L33-L58
moonso/vcftoolbox
vcftoolbox/cli.py
delete_info
def delete_info(ctx, info): """Delete a info field from all variants in a vcf""" head = ctx.parent.head vcf_handle = ctx.parent.handle outfile = ctx.parent.outfile silent = ctx.parent.silent if not info: logger.error("No info provided") sys.exit("Please provide a info string...
python
def delete_info(ctx, info): """Delete a info field from all variants in a vcf""" head = ctx.parent.head vcf_handle = ctx.parent.handle outfile = ctx.parent.outfile silent = ctx.parent.silent if not info: logger.error("No info provided") sys.exit("Please provide a info string...
[ "def", "delete_info", "(", "ctx", ",", "info", ")", ":", "head", "=", "ctx", ".", "parent", ".", "head", "vcf_handle", "=", "ctx", ".", "parent", ".", "handle", "outfile", "=", "ctx", ".", "parent", ".", "outfile", "silent", "=", "ctx", ".", "parent"...
Delete a info field from all variants in a vcf
[ "Delete", "a", "info", "field", "from", "all", "variants", "in", "a", "vcf" ]
train
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/cli.py#L66-L88
moonso/vcftoolbox
vcftoolbox/cli.py
variants
def variants(ctx, snpeff): """Print the variants in a vcf""" head = ctx.parent.head vcf_handle = ctx.parent.handle outfile = ctx.parent.outfile silent = ctx.parent.silent print_headers(head, outfile=outfile, silent=silent) for line in vcf_handle: print_variant(variant_line=...
python
def variants(ctx, snpeff): """Print the variants in a vcf""" head = ctx.parent.head vcf_handle = ctx.parent.handle outfile = ctx.parent.outfile silent = ctx.parent.silent print_headers(head, outfile=outfile, silent=silent) for line in vcf_handle: print_variant(variant_line=...
[ "def", "variants", "(", "ctx", ",", "snpeff", ")", ":", "head", "=", "ctx", ".", "parent", ".", "head", "vcf_handle", "=", "ctx", ".", "parent", ".", "handle", "outfile", "=", "ctx", ".", "parent", ".", "outfile", "silent", "=", "ctx", ".", "parent",...
Print the variants in a vcf
[ "Print", "the", "variants", "in", "a", "vcf" ]
train
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/cli.py#L96-L123
moonso/vcftoolbox
vcftoolbox/cli.py
sort
def sort(ctx): """Sort the variants of a vcf file""" head = ctx.parent.head vcf_handle = ctx.parent.handle outfile = ctx.parent.outfile silent = ctx.parent.silent print_headers(head, outfile=outfile, silent=silent) for line in sort_variants(vcf_handle): print_variant(variant_line=l...
python
def sort(ctx): """Sort the variants of a vcf file""" head = ctx.parent.head vcf_handle = ctx.parent.handle outfile = ctx.parent.outfile silent = ctx.parent.silent print_headers(head, outfile=outfile, silent=silent) for line in sort_variants(vcf_handle): print_variant(variant_line=l...
[ "def", "sort", "(", "ctx", ")", ":", "head", "=", "ctx", ".", "parent", ".", "head", "vcf_handle", "=", "ctx", ".", "parent", ".", "handle", "outfile", "=", "ctx", ".", "parent", ".", "outfile", "silent", "=", "ctx", ".", "parent", ".", "silent", "...
Sort the variants of a vcf file
[ "Sort", "the", "variants", "of", "a", "vcf", "file" ]
train
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/cli.py#L127-L137
klen/django-netauth
netauth/backends/openid.py
OpenIDBackend.validate
def validate(self, request, data): """ Validate response from OpenID server. Set identity in case of successfull validation. """ client = consumer.Consumer(request.session, None) try: resp = client.complete(data, request.session['openid_return_to']) e...
python
def validate(self, request, data): """ Validate response from OpenID server. Set identity in case of successfull validation. """ client = consumer.Consumer(request.session, None) try: resp = client.complete(data, request.session['openid_return_to']) e...
[ "def", "validate", "(", "self", ",", "request", ",", "data", ")", ":", "client", "=", "consumer", ".", "Consumer", "(", "request", ".", "session", ",", "None", ")", "try", ":", "resp", "=", "client", ".", "complete", "(", "data", ",", "request", ".",...
Validate response from OpenID server. Set identity in case of successfull validation.
[ "Validate", "response", "from", "OpenID", "server", ".", "Set", "identity", "in", "case", "of", "successfull", "validation", "." ]
train
https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/backends/openid.py#L49-L70
bkad/python-stylus
stylus/__init__.py
Stylus.use
def use(self, plugin, arguments={}): """Add plugin to use during compilation. plugin: Plugin to include. arguments: Dictionary of arguments to pass to the import. """ self.plugins[plugin] = dict(arguments) return self.plugins
python
def use(self, plugin, arguments={}): """Add plugin to use during compilation. plugin: Plugin to include. arguments: Dictionary of arguments to pass to the import. """ self.plugins[plugin] = dict(arguments) return self.plugins
[ "def", "use", "(", "self", ",", "plugin", ",", "arguments", "=", "{", "}", ")", ":", "self", ".", "plugins", "[", "plugin", "]", "=", "dict", "(", "arguments", ")", "return", "self", ".", "plugins" ]
Add plugin to use during compilation. plugin: Plugin to include. arguments: Dictionary of arguments to pass to the import.
[ "Add", "plugin", "to", "use", "during", "compilation", "." ]
train
https://github.com/bkad/python-stylus/blob/3d79145fecd56e6af9fb38d55886c65ce2cac82e/stylus/__init__.py#L31-L38
bkad/python-stylus
stylus/__init__.py
Stylus.compile
def compile(self, source, options={}): """Compile stylus into css source: A string containing the stylus code options: A dictionary of arguments to pass to the compiler Returns a string of css resulting from the compilation """ options = dict(options) if "paths" in options: options["...
python
def compile(self, source, options={}): """Compile stylus into css source: A string containing the stylus code options: A dictionary of arguments to pass to the compiler Returns a string of css resulting from the compilation """ options = dict(options) if "paths" in options: options["...
[ "def", "compile", "(", "self", ",", "source", ",", "options", "=", "{", "}", ")", ":", "options", "=", "dict", "(", "options", ")", "if", "\"paths\"", "in", "options", ":", "options", "[", "\"paths\"", "]", "+=", "self", ".", "paths", "else", ":", ...
Compile stylus into css source: A string containing the stylus code options: A dictionary of arguments to pass to the compiler Returns a string of css resulting from the compilation
[ "Compile", "stylus", "into", "css" ]
train
https://github.com/bkad/python-stylus/blob/3d79145fecd56e6af9fb38d55886c65ce2cac82e/stylus/__init__.py#L40-L57
bkad/python-stylus
stylus/__init__.py
Stylus.context
def context(self): "Internal property that returns the stylus compiler" if self._context is None: with io.open(path.join(path.abspath(path.dirname(__file__)), "compiler.js")) as compiler_file: compiler_source = compiler_file.read() self._context = self.backend.compile(compiler_source) re...
python
def context(self): "Internal property that returns the stylus compiler" if self._context is None: with io.open(path.join(path.abspath(path.dirname(__file__)), "compiler.js")) as compiler_file: compiler_source = compiler_file.read() self._context = self.backend.compile(compiler_source) re...
[ "def", "context", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "with", "io", ".", "open", "(", "path", ".", "join", "(", "path", ".", "abspath", "(", "path", ".", "dirname", "(", "__file__", ")", ")", ",", "\"compiler.js...
Internal property that returns the stylus compiler
[ "Internal", "property", "that", "returns", "the", "stylus", "compiler" ]
train
https://github.com/bkad/python-stylus/blob/3d79145fecd56e6af9fb38d55886c65ce2cac82e/stylus/__init__.py#L62-L68
bkad/python-stylus
stylus/__init__.py
Stylus.backend
def backend(self): "Internal property that returns the Node script running harness" if self._backend is None: with io.open(path.join(path.abspath(path.dirname(__file__)), "runner.js")) as runner_file: runner_source = runner_file.read() self._backend = execjs.ExternalRuntime(name="Node.js (V8...
python
def backend(self): "Internal property that returns the Node script running harness" if self._backend is None: with io.open(path.join(path.abspath(path.dirname(__file__)), "runner.js")) as runner_file: runner_source = runner_file.read() self._backend = execjs.ExternalRuntime(name="Node.js (V8...
[ "def", "backend", "(", "self", ")", ":", "if", "self", ".", "_backend", "is", "None", ":", "with", "io", ".", "open", "(", "path", ".", "join", "(", "path", ".", "abspath", "(", "path", ".", "dirname", "(", "__file__", ")", ")", ",", "\"runner.js\"...
Internal property that returns the Node script running harness
[ "Internal", "property", "that", "returns", "the", "Node", "script", "running", "harness" ]
train
https://github.com/bkad/python-stylus/blob/3d79145fecd56e6af9fb38d55886c65ce2cac82e/stylus/__init__.py#L71-L79
ionelmc/python-cogen
cogen/core/proactors/ctypes_iocp_impl/__init__.py
CTYPES_IOCPProactor.request_generic
def request_generic(self, act, coro, perform, complete): """ Performs an overlapped request (via `perform` callable) and saves the token and the (`overlapped`, `perform`, `complete`) trio. """ overlapped = OVERLAPPED() overlapped.object = act self.add_token...
python
def request_generic(self, act, coro, perform, complete): """ Performs an overlapped request (via `perform` callable) and saves the token and the (`overlapped`, `perform`, `complete`) trio. """ overlapped = OVERLAPPED() overlapped.object = act self.add_token...
[ "def", "request_generic", "(", "self", ",", "act", ",", "coro", ",", "perform", ",", "complete", ")", ":", "overlapped", "=", "OVERLAPPED", "(", ")", "overlapped", ".", "object", "=", "act", "self", ".", "add_token", "(", "act", ",", "coro", ",", "(", ...
Performs an overlapped request (via `perform` callable) and saves the token and the (`overlapped`, `perform`, `complete`) trio.
[ "Performs", "an", "overlapped", "request", "(", "via", "perform", "callable", ")", "and", "saves", "the", "token", "and", "the", "(", "overlapped", "perform", "complete", ")", "trio", "." ]
train
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/ctypes_iocp_impl/__init__.py#L259-L285
ionelmc/python-cogen
cogen/core/proactors/ctypes_iocp_impl/__init__.py
CTYPES_IOCPProactor.run
def run(self, timeout = 0): """ Calls GetQueuedCompletionStatus and handles completion via process_op. """ # same resolution as epoll ptimeout = int( timeout.days * 86400000 + timeout.microseconds / 1000 + timeout.seconds * 100...
python
def run(self, timeout = 0): """ Calls GetQueuedCompletionStatus and handles completion via process_op. """ # same resolution as epoll ptimeout = int( timeout.days * 86400000 + timeout.microseconds / 1000 + timeout.seconds * 100...
[ "def", "run", "(", "self", ",", "timeout", "=", "0", ")", ":", "# same resolution as epoll\r", "ptimeout", "=", "int", "(", "timeout", ".", "days", "*", "86400000", "+", "timeout", ".", "microseconds", "/", "1000", "+", "timeout", ".", "seconds", "*", "1...
Calls GetQueuedCompletionStatus and handles completion via process_op.
[ "Calls", "GetQueuedCompletionStatus", "and", "handles", "completion", "via", "process_op", "." ]
train
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/ctypes_iocp_impl/__init__.py#L347-L426
ibm-watson-data-lab/ibmseti
ibmseti/compamp.py
Compamp.header
def header(self): ''' This returns the first header in the data file ''' if self._header is None: self._header = self._read_half_frame_header(self.data) return self._header
python
def header(self): ''' This returns the first header in the data file ''' if self._header is None: self._header = self._read_half_frame_header(self.data) return self._header
[ "def", "header", "(", "self", ")", ":", "if", "self", ".", "_header", "is", "None", ":", "self", ".", "_header", "=", "self", ".", "_read_half_frame_header", "(", "self", ".", "data", ")", "return", "self", ".", "_header" ]
This returns the first header in the data file
[ "This", "returns", "the", "first", "header", "in", "the", "data", "file" ]
train
https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/compamp.py#L71-L79
ibm-watson-data-lab/ibmseti
ibmseti/compamp.py
Compamp.headers
def headers(self): ''' This returns all headers in the data file. There should be one for each half_frame in the file (typically 129). ''' first_header = self.header() single_compamp_data = np.frombuffer(self.data, dtype=np.int8)\ .reshape((first_header['number_of_half_frames'], first_h...
python
def headers(self): ''' This returns all headers in the data file. There should be one for each half_frame in the file (typically 129). ''' first_header = self.header() single_compamp_data = np.frombuffer(self.data, dtype=np.int8)\ .reshape((first_header['number_of_half_frames'], first_h...
[ "def", "headers", "(", "self", ")", ":", "first_header", "=", "self", ".", "header", "(", ")", "single_compamp_data", "=", "np", ".", "frombuffer", "(", "self", ".", "data", ",", "dtype", "=", "np", ".", "int8", ")", ".", "reshape", "(", "(", "first_...
This returns all headers in the data file. There should be one for each half_frame in the file (typically 129).
[ "This", "returns", "all", "headers", "in", "the", "data", "file", ".", "There", "should", "be", "one", "for", "each", "half_frame", "in", "the", "file", "(", "typically", "129", ")", "." ]
train
https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/compamp.py#L81-L91
ibm-watson-data-lab/ibmseti
ibmseti/compamp.py
Compamp._packed_data
def _packed_data(self): ''' Returns the bit-packed data extracted from the data file. This is not so useful to analyze. Use the complex_data method instead. ''' header = self.header() packed_data = np.frombuffer(self.data, dtype=np.int8)\ .reshape((header['number_of_half_frames'], heade...
python
def _packed_data(self): ''' Returns the bit-packed data extracted from the data file. This is not so useful to analyze. Use the complex_data method instead. ''' header = self.header() packed_data = np.frombuffer(self.data, dtype=np.int8)\ .reshape((header['number_of_half_frames'], heade...
[ "def", "_packed_data", "(", "self", ")", ":", "header", "=", "self", ".", "header", "(", ")", "packed_data", "=", "np", ".", "frombuffer", "(", "self", ".", "data", ",", "dtype", "=", "np", ".", "int8", ")", ".", "reshape", "(", "(", "header", "[",...
Returns the bit-packed data extracted from the data file. This is not so useful to analyze. Use the complex_data method instead.
[ "Returns", "the", "bit", "-", "packed", "data", "extracted", "from", "the", "data", "file", ".", "This", "is", "not", "so", "useful", "to", "analyze", ".", "Use", "the", "complex_data", "method", "instead", "." ]
train
https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/compamp.py#L93-L105
ibm-watson-data-lab/ibmseti
ibmseti/compamp.py
Compamp.complex_data
def complex_data(self): ''' This will cast each byte to an int8 and interpret each byte as 4 bits real values and 4 bits imag values (RRRRIIII). The data are then used to create a 3D numpy array of dtype=complex, which is returned. The shape of the numpy array is N half frames, M subbands, K data ...
python
def complex_data(self): ''' This will cast each byte to an int8 and interpret each byte as 4 bits real values and 4 bits imag values (RRRRIIII). The data are then used to create a 3D numpy array of dtype=complex, which is returned. The shape of the numpy array is N half frames, M subbands, K data ...
[ "def", "complex_data", "(", "self", ")", ":", "#note that since we can only pack into int8 types, we must pad each 4-bit value with 4, 0 bits", "#this effectively multiplies each 4-bit value by 16 when that value is represented as an 8-bit signed integer.", "packed_data", "=", "self", ".", "...
This will cast each byte to an int8 and interpret each byte as 4 bits real values and 4 bits imag values (RRRRIIII). The data are then used to create a 3D numpy array of dtype=complex, which is returned. The shape of the numpy array is N half frames, M subbands, K data points per half frame, where K =...
[ "This", "will", "cast", "each", "byte", "to", "an", "int8", "and", "interpret", "each", "byte", "as", "4", "bits", "real", "values", "and", "4", "bits", "imag", "values", "(", "RRRRIIII", ")", ".", "The", "data", "are", "then", "used", "to", "create", ...
train
https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/compamp.py#L107-L138
ibm-watson-data-lab/ibmseti
ibmseti/compamp.py
SimCompamp.complex_data
def complex_data(self): ''' This unpacks the data into a time-series data, of complex values. Also, any DC offset from the time-series is removed. This is a 1D complex-valued numpy array. ''' cp = np.frombuffer(self.data, dtype='i1').astype(np.float32).view(np.complex64) cp = cp - cp.mean(...
python
def complex_data(self): ''' This unpacks the data into a time-series data, of complex values. Also, any DC offset from the time-series is removed. This is a 1D complex-valued numpy array. ''' cp = np.frombuffer(self.data, dtype='i1').astype(np.float32).view(np.complex64) cp = cp - cp.mean(...
[ "def", "complex_data", "(", "self", ")", ":", "cp", "=", "np", ".", "frombuffer", "(", "self", ".", "data", ",", "dtype", "=", "'i1'", ")", ".", "astype", "(", "np", ".", "float32", ")", ".", "view", "(", "np", ".", "complex64", ")", "cp", "=", ...
This unpacks the data into a time-series data, of complex values. Also, any DC offset from the time-series is removed. This is a 1D complex-valued numpy array.
[ "This", "unpacks", "the", "data", "into", "a", "time", "-", "series", "data", "of", "complex", "values", "." ]
train
https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/compamp.py#L248-L258
ibm-watson-data-lab/ibmseti
ibmseti/compamp.py
SimCompamp._spec_fft
def _spec_fft(self, complex_data): ''' Calculates the DFT of the complex_data along axis = 1. This assumes complex_data is a 2D array. This uses numpy and the code is straight forward np.fft.fftshift( np.fft.fft(complex_data), 1) Note that we automatically shift the FFT frequency bins so that alo...
python
def _spec_fft(self, complex_data): ''' Calculates the DFT of the complex_data along axis = 1. This assumes complex_data is a 2D array. This uses numpy and the code is straight forward np.fft.fftshift( np.fft.fft(complex_data), 1) Note that we automatically shift the FFT frequency bins so that alo...
[ "def", "_spec_fft", "(", "self", ",", "complex_data", ")", ":", "return", "np", ".", "fft", ".", "fftshift", "(", "np", ".", "fft", ".", "fft", "(", "complex_data", ")", ",", "1", ")" ]
Calculates the DFT of the complex_data along axis = 1. This assumes complex_data is a 2D array. This uses numpy and the code is straight forward np.fft.fftshift( np.fft.fft(complex_data), 1) Note that we automatically shift the FFT frequency bins so that along the frequency axis, "negative" frequenc...
[ "Calculates", "the", "DFT", "of", "the", "complex_data", "along", "axis", "=", "1", ".", "This", "assumes", "complex_data", "is", "a", "2D", "array", "." ]
train
https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/compamp.py#L272-L282
ibm-watson-data-lab/ibmseti
ibmseti/compamp.py
SimCompamp.get_spectrogram
def get_spectrogram(self): ''' Transforms the input simulated data and computes a standard-sized spectrogram. If self.sigProc function is not None, the 2D complex-valued time-series data will be processed with that function before the FFT and spectrogram are calculated. ''' return self._spec...
python
def get_spectrogram(self): ''' Transforms the input simulated data and computes a standard-sized spectrogram. If self.sigProc function is not None, the 2D complex-valued time-series data will be processed with that function before the FFT and spectrogram are calculated. ''' return self._spec...
[ "def", "get_spectrogram", "(", "self", ")", ":", "return", "self", ".", "_spec_power", "(", "self", ".", "_spec_fft", "(", "self", ".", "_sigProc", "(", "self", ".", "_reshape", "(", "self", ".", "complex_data", "(", ")", ")", ")", ")", ")" ]
Transforms the input simulated data and computes a standard-sized spectrogram. If self.sigProc function is not None, the 2D complex-valued time-series data will be processed with that function before the FFT and spectrogram are calculated.
[ "Transforms", "the", "input", "simulated", "data", "and", "computes", "a", "standard", "-", "sized", "spectrogram", "." ]
train
https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/compamp.py#L291-L299
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.riak_http_search_query
def riak_http_search_query(self, solr_core, solr_params, count_deleted=False): """ This method is for advanced SOLR queries. Riak HTTP search query endpoint, sends solr_params and query string as a proxy and returns solr reponse. Args: solr_core (str): solr core on w...
python
def riak_http_search_query(self, solr_core, solr_params, count_deleted=False): """ This method is for advanced SOLR queries. Riak HTTP search query endpoint, sends solr_params and query string as a proxy and returns solr reponse. Args: solr_core (str): solr core on w...
[ "def", "riak_http_search_query", "(", "self", ",", "solr_core", ",", "solr_params", ",", "count_deleted", "=", "False", ")", ":", "# append current _solr_query params", "sq", "=", "[", "\"%s%%3A%s\"", "%", "(", "q", "[", "0", "]", ",", "q", "[", "1", "]", ...
This method is for advanced SOLR queries. Riak HTTP search query endpoint, sends solr_params and query string as a proxy and returns solr reponse. Args: solr_core (str): solr core on which query will be executed solr_params (str): solr specific query params,...
[ "This", "method", "is", "for", "advanced", "SOLR", "queries", ".", "Riak", "HTTP", "search", "query", "endpoint", "sends", "solr_params", "and", "query", "string", "as", "a", "proxy", "and", "returns", "solr", "reponse", ".", "Args", ":", "solr_core", "(", ...
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L129-L159
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.distinct_values_of
def distinct_values_of(self, field, count_deleted=False): """ Uses riak http search query endpoint for advanced SOLR queries. Args: field (str): facet field count_deleted (bool): ignore deleted or not Returns: (dict): pairs of field values and numbe...
python
def distinct_values_of(self, field, count_deleted=False): """ Uses riak http search query endpoint for advanced SOLR queries. Args: field (str): facet field count_deleted (bool): ignore deleted or not Returns: (dict): pairs of field values and numbe...
[ "def", "distinct_values_of", "(", "self", ",", "field", ",", "count_deleted", "=", "False", ")", ":", "solr_params", "=", "\"facet=true&facet.field=%s&rows=0\"", "%", "field", "result", "=", "self", ".", "riak_http_search_query", "(", "self", ".", "index_name", ",...
Uses riak http search query endpoint for advanced SOLR queries. Args: field (str): facet field count_deleted (bool): ignore deleted or not Returns: (dict): pairs of field values and number of counts
[ "Uses", "riak", "http", "search", "query", "endpoint", "for", "advanced", "SOLR", "queries", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L161-L180
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._clear
def _clear(self, wait): """ clear outs the all content of current bucket only for development purposes """ i = 0 t1 = time.time() for k in self.bucket.get_keys(): i += 1 self.bucket.get(k).delete() print("\nDELETION TOOK: %s" % roun...
python
def _clear(self, wait): """ clear outs the all content of current bucket only for development purposes """ i = 0 t1 = time.time() for k in self.bucket.get_keys(): i += 1 self.bucket.get(k).delete() print("\nDELETION TOOK: %s" % roun...
[ "def", "_clear", "(", "self", ",", "wait", ")", ":", "i", "=", "0", "t1", "=", "time", ".", "time", "(", ")", "for", "k", "in", "self", ".", "bucket", ".", "get_keys", "(", ")", ":", "i", "+=", "1", "self", ".", "bucket", ".", "get", "(", "...
clear outs the all content of current bucket only for development purposes
[ "clear", "outs", "the", "all", "content", "of", "current", "bucket", "only", "for", "development", "purposes" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L182-L196
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.get_from_solr
def get_from_solr(clone, number, row_size): """ If not start parameter is given, with the given number(0,1,2..) multiplies default row size and determines start parameter. Takes results from solr according to this parameter. For example, if number is 2 and default row size is 1000, takes...
python
def get_from_solr(clone, number, row_size): """ If not start parameter is given, with the given number(0,1,2..) multiplies default row size and determines start parameter. Takes results from solr according to this parameter. For example, if number is 2 and default row size is 1000, takes...
[ "def", "get_from_solr", "(", "clone", ",", "number", ",", "row_size", ")", ":", "start", "=", "number", "*", "clone", ".", "_cfg", "[", "'row_size'", "]", "+", "clone", ".", "_cfg", "[", "'start'", "]", "clone", ".", "_solr_params", ".", "update", "(",...
If not start parameter is given, with the given number(0,1,2..) multiplies default row size and determines start parameter. Takes results from solr according to this parameter. For example, if number is 2 and default row size is 1000, takes results from solr between 2000 and 3000. But if start p...
[ "If", "not", "start", "parameter", "is", "given", "with", "the", "given", "number", "(", "0", "1", "2", "..", ")", "multiplies", "default", "row", "size", "and", "determines", "start", "parameter", ".", "Takes", "results", "from", "solr", "according", "to"...
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L199-L227
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.riak_multi_get
def riak_multi_get(self, key_list_tuple): """ Sends given tuples of list to multiget method and took riak objs' keys and data. For each multiget call, separate pools are used and after execution, pools are stopped. Args: key_list_tuple(list of tuples): [('bucket_type','bucket...
python
def riak_multi_get(self, key_list_tuple): """ Sends given tuples of list to multiget method and took riak objs' keys and data. For each multiget call, separate pools are used and after execution, pools are stopped. Args: key_list_tuple(list of tuples): [('bucket_type','bucket...
[ "def", "riak_multi_get", "(", "self", ",", "key_list_tuple", ")", ":", "pool", "=", "PyokoMG", "(", ")", "objs", "=", "self", ".", "_client", ".", "multiget", "(", "key_list_tuple", ",", "pool", "=", "pool", ")", "pool", ".", "stop", "(", ")", "return"...
Sends given tuples of list to multiget method and took riak objs' keys and data. For each multiget call, separate pools are used and after execution, pools are stopped. Args: key_list_tuple(list of tuples): [('bucket_type','bucket','riak_key')] Ex...
[ "Sends", "given", "tuples", "of", "list", "to", "multiget", "method", "and", "took", "riak", "objs", "keys", "and", "data", ".", "For", "each", "multiget", "call", "separate", "pools", "are", "used", "and", "after", "execution", "pools", "are", "stopped", ...
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L229-L246
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._set_bucket
def _set_bucket(self, type, name): """ prepares bucket, sets index name :param str type: bucket type :param str name: bucket name :return: """ if type: self._cfg['bucket_type'] = type if name: self._cfg['bucket_name'] = name ...
python
def _set_bucket(self, type, name): """ prepares bucket, sets index name :param str type: bucket type :param str name: bucket name :return: """ if type: self._cfg['bucket_type'] = type if name: self._cfg['bucket_name'] = name ...
[ "def", "_set_bucket", "(", "self", ",", "type", ",", "name", ")", ":", "if", "type", ":", "self", ".", "_cfg", "[", "'bucket_type'", "]", "=", "type", "if", "name", ":", "self", ".", "_cfg", "[", "'bucket_name'", "]", "=", "name", "self", ".", "buc...
prepares bucket, sets index name :param str type: bucket type :param str name: bucket name :return:
[ "prepares", "bucket", "sets", "index", "name", ":", "param", "str", "type", ":", "bucket", "type", ":", "param", "str", "name", ":", "bucket", "name", ":", "return", ":" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L327-L341
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._write_version
def _write_version(self, data, model): """ Writes a copy of the objects current state to write-once mirror bucket. Args: data (dict): Model instance's all data for versioning. model (instance): Model instance. Returns: Key of version record. ...
python
def _write_version(self, data, model): """ Writes a copy of the objects current state to write-once mirror bucket. Args: data (dict): Model instance's all data for versioning. model (instance): Model instance. Returns: Key of version record. ...
[ "def", "_write_version", "(", "self", ",", "data", ",", "model", ")", ":", "vdata", "=", "{", "'data'", ":", "data", ",", "'key'", ":", "model", ".", "key", ",", "'model'", ":", "model", ".", "Meta", ".", "bucket_name", ",", "'timestamp'", ":", "time...
Writes a copy of the objects current state to write-once mirror bucket. Args: data (dict): Model instance's all data for versioning. model (instance): Model instance. Returns: Key of version record. key (str): Version_bucket key.
[ "Writes", "a", "copy", "of", "the", "objects", "current", "state", "to", "write", "-", "once", "mirror", "bucket", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L347-L368
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._write_log
def _write_log(self, version_key, meta_data, index_fields): """ Creates a log entry for current object, Args: version_key(str): Version_bucket key from _write_version(). meta_data (dict): JSON serializable meta data for logging of save operation. {'lorem':...
python
def _write_log(self, version_key, meta_data, index_fields): """ Creates a log entry for current object, Args: version_key(str): Version_bucket key from _write_version(). meta_data (dict): JSON serializable meta data for logging of save operation. {'lorem':...
[ "def", "_write_log", "(", "self", ",", "version_key", ",", "meta_data", ",", "index_fields", ")", ":", "meta_data", "=", "meta_data", "or", "{", "}", "meta_data", ".", "update", "(", "{", "'version_key'", ":", "version_key", ",", "'timestamp'", ":", "time", ...
Creates a log entry for current object, Args: version_key(str): Version_bucket key from _write_version(). meta_data (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple list for secondary ...
[ "Creates", "a", "log", "entry", "for", "current", "object", "Args", ":", "version_key", "(", "str", ")", ":", "Version_bucket", "key", "from", "_write_version", "()", ".", "meta_data", "(", "dict", ")", ":", "JSON", "serializable", "meta", "data", "for", "...
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L370-L393
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.save_model
def save_model(self, model, meta_data=None, index_fields=None): """ model (instance): Model instance. meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple list for indexing keys in ri...
python
def save_model(self, model, meta_data=None, index_fields=None): """ model (instance): Model instance. meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple list for indexing keys in ri...
[ "def", "save_model", "(", "self", ",", "model", ",", "meta_data", "=", "None", ",", "index_fields", "=", "None", ")", ":", "# if model:", "# self._model = model", "if", "settings", ".", "DEBUG", ":", "t1", "=", "time", ".", "time", "(", ")", "clean_val...
model (instance): Model instance. meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple list for indexing keys in riak (with 'bin' or 'int'). [('lorem','bin'),('dolar','int')] :ret...
[ "model", "(", "instance", ")", ":", "Model", "instance", ".", "meta", "(", "dict", ")", ":", "JSON", "serializable", "meta", "data", "for", "logging", "of", "save", "operation", ".", "{", "lorem", ":", "ipsum", "dolar", ":", "5", "}", "index_fields", "...
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L412-L470
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.set_to_cache
def set_to_cache(vk): """ Args: vk (tuple): obj data (dict), obj key(str) Return: tuple: value (dict), key (string) """ v, k = vk try: cache.set(k, json.dumps(v), settings.CACHE_EXPIRE_DURATION) except Exception as e: ...
python
def set_to_cache(vk): """ Args: vk (tuple): obj data (dict), obj key(str) Return: tuple: value (dict), key (string) """ v, k = vk try: cache.set(k, json.dumps(v), settings.CACHE_EXPIRE_DURATION) except Exception as e: ...
[ "def", "set_to_cache", "(", "vk", ")", ":", "v", ",", "k", "=", "vk", "try", ":", "cache", ".", "set", "(", "k", ",", "json", ".", "dumps", "(", "v", ")", ",", "settings", ".", "CACHE_EXPIRE_DURATION", ")", "except", "Exception", "as", "e", ":", ...
Args: vk (tuple): obj data (dict), obj key(str) Return: tuple: value (dict), key (string)
[ "Args", ":", "vk", "(", "tuple", ")", ":", "obj", "data", "(", "dict", ")", "obj", "key", "(", "str", ")" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L473-L488
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.get_from_cache
def get_from_cache(key): """ Args: key (str): Return: (dict): from json string """ try: value = cache.get(key) return json.loads(value), key if value else None except Exception as e: # todo should add log.error(...
python
def get_from_cache(key): """ Args: key (str): Return: (dict): from json string """ try: value = cache.get(key) return json.loads(value), key if value else None except Exception as e: # todo should add log.error(...
[ "def", "get_from_cache", "(", "key", ")", ":", "try", ":", "value", "=", "cache", ".", "get", "(", "key", ")", "return", "json", ".", "loads", "(", "value", ")", ",", "key", "if", "value", "else", "None", "except", "Exception", "as", "e", ":", "# t...
Args: key (str): Return: (dict): from json string
[ "Args", ":", "key", "(", "str", ")", ":", "Return", ":", "(", "dict", ")", ":", "from", "json", "string" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L491-L504
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._get_from_riak
def _get_from_riak(self, key): """ Args: key (str): riak key Returns: (tuple): riak obj json data and riak key """ obj = self.bucket.get(key) if obj.exists: return obj.data, obj.key raise ObjectDoesNotExist("%s %s" % (key, se...
python
def _get_from_riak(self, key): """ Args: key (str): riak key Returns: (tuple): riak obj json data and riak key """ obj = self.bucket.get(key) if obj.exists: return obj.data, obj.key raise ObjectDoesNotExist("%s %s" % (key, se...
[ "def", "_get_from_riak", "(", "self", ",", "key", ")", ":", "obj", "=", "self", ".", "bucket", ".", "get", "(", "key", ")", "if", "obj", ".", "exists", ":", "return", "obj", ".", "data", ",", "obj", ".", "key", "raise", "ObjectDoesNotExist", "(", "...
Args: key (str): riak key Returns: (tuple): riak obj json data and riak key
[ "Args", ":", "key", "(", "str", ")", ":", "riak", "key", "Returns", ":", "(", "tuple", ")", ":", "riak", "obj", "json", "data", "and", "riak", "key" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L506-L519
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.count
def count(self): """Counts the number of results that could be accessed with the current parameters. :return: number of objects matches to the query :rtype: int """ # Save the existing rows and start parameters to see how many results were actually expected _rows = self...
python
def count(self): """Counts the number of results that could be accessed with the current parameters. :return: number of objects matches to the query :rtype: int """ # Save the existing rows and start parameters to see how many results were actually expected _rows = self...
[ "def", "count", "(", "self", ")", ":", "# Save the existing rows and start parameters to see how many results were actually expected", "_rows", "=", "self", ".", "_solr_params", ".", "get", "(", "'rows'", ",", "None", ")", "_start", "=", "self", ".", "_solr_params", "...
Counts the number of results that could be accessed with the current parameters. :return: number of objects matches to the query :rtype: int
[ "Counts", "the", "number", "of", "results", "that", "could", "be", "accessed", "with", "the", "current", "parameters", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L558-L588
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.search_on
def search_on(self, *fields, **query): """ Search for query on given fields. Query modifier can be one of these: * exact * contains * startswith * endswith * range * lte * gte Args: \*fields...
python
def search_on(self, *fields, **query): """ Search for query on given fields. Query modifier can be one of these: * exact * contains * startswith * endswith * range * lte * gte Args: \*fields...
[ "def", "search_on", "(", "self", ",", "*", "fields", ",", "*", "*", "query", ")", ":", "search_type", "=", "list", "(", "query", ".", "keys", "(", ")", ")", "[", "0", "]", "parsed_query", "=", "self", ".", "_parse_query_modifier", "(", "search_type", ...
Search for query on given fields. Query modifier can be one of these: * exact * contains * startswith * endswith * range * lte * gte Args: \*fields (str): Field list to be searched on \*\*query:...
[ "Search", "for", "query", "on", "given", "fields", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L590-L617
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.order_by
def order_by(self, *args): """ Applies query ordering. New parameters are appended to current ones, overwriting existing ones. Args: **args: Order by fields names. Defaults to ascending, prepend with hypen (-) for desecending ordering. """ if s...
python
def order_by(self, *args): """ Applies query ordering. New parameters are appended to current ones, overwriting existing ones. Args: **args: Order by fields names. Defaults to ascending, prepend with hypen (-) for desecending ordering. """ if s...
[ "def", "order_by", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "_solr_locked", ":", "raise", "Exception", "(", "\"Query already executed, no changes can be made.\"", "\"%s %s\"", "%", "(", "self", ".", "_solr_query", ",", "self", ".", "_solr_para...
Applies query ordering. New parameters are appended to current ones, overwriting existing ones. Args: **args: Order by fields names. Defaults to ascending, prepend with hypen (-) for desecending ordering.
[ "Applies", "query", "ordering", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L619-L640
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter.set_params
def set_params(self, **params): """ add/update solr query parameters """ if self._solr_locked: raise Exception("Query already executed, no changes can be made." "%s %s" % (self._solr_query, self._solr_params) ) s...
python
def set_params(self, **params): """ add/update solr query parameters """ if self._solr_locked: raise Exception("Query already executed, no changes can be made." "%s %s" % (self._solr_query, self._solr_params) ) s...
[ "def", "set_params", "(", "self", ",", "*", "*", "params", ")", ":", "if", "self", ".", "_solr_locked", ":", "raise", "Exception", "(", "\"Query already executed, no changes can be made.\"", "\"%s %s\"", "%", "(", "self", ".", "_solr_query", ",", "self", ".", ...
add/update solr query parameters
[ "add", "/", "update", "solr", "query", "parameters" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L642-L650
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._escape_query
def _escape_query(self, query, escaped=False): """ Escapes query if it's not already escaped. Args: query: Query value. escaped (bool): expresses if query already escaped or not. Returns: Escaped query value. """ if escaped: ...
python
def _escape_query(self, query, escaped=False): """ Escapes query if it's not already escaped. Args: query: Query value. escaped (bool): expresses if query already escaped or not. Returns: Escaped query value. """ if escaped: ...
[ "def", "_escape_query", "(", "self", ",", "query", ",", "escaped", "=", "False", ")", ":", "if", "escaped", ":", "return", "query", "query", "=", "six", ".", "text_type", "(", "query", ")", "for", "e", "in", "[", "'+'", ",", "'-'", ",", "'&&'", ","...
Escapes query if it's not already escaped. Args: query: Query value. escaped (bool): expresses if query already escaped or not. Returns: Escaped query value.
[ "Escapes", "query", "if", "it", "s", "not", "already", "escaped", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L655-L672
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._parse_query_modifier
def _parse_query_modifier(self, modifier, qval, is_escaped): """ Parses query_value according to query_type Args: modifier (str): Type of query. Exact, contains, lte etc. qval: Value partition of the query. Returns: Parsed query_value. """ ...
python
def _parse_query_modifier(self, modifier, qval, is_escaped): """ Parses query_value according to query_type Args: modifier (str): Type of query. Exact, contains, lte etc. qval: Value partition of the query. Returns: Parsed query_value. """ ...
[ "def", "_parse_query_modifier", "(", "self", ",", "modifier", ",", "qval", ",", "is_escaped", ")", ":", "if", "modifier", "==", "'range'", ":", "if", "not", "qval", "[", "0", "]", ":", "start", "=", "'*'", "elif", "isinstance", "(", "qval", "[", "0", ...
Parses query_value according to query_type Args: modifier (str): Type of query. Exact, contains, lte etc. qval: Value partition of the query. Returns: Parsed query_value.
[ "Parses", "query_value", "according", "to", "query_type" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L674-L730
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._parse_query_key
def _parse_query_key(self, key, val, is_escaped): """ Strips query modifier from key and call's the appropriate value modifier. Args: key (str): Query key val: Query value Returns: Parsed query key and value. """ if key.endswith('__co...
python
def _parse_query_key(self, key, val, is_escaped): """ Strips query modifier from key and call's the appropriate value modifier. Args: key (str): Query key val: Query value Returns: Parsed query key and value. """ if key.endswith('__co...
[ "def", "_parse_query_key", "(", "self", ",", "key", ",", "val", ",", "is_escaped", ")", ":", "if", "key", ".", "endswith", "(", "'__contains'", ")", ":", "key", "=", "key", "[", ":", "-", "10", "]", "val", "=", "self", ".", "_parse_query_modifier", "...
Strips query modifier from key and call's the appropriate value modifier. Args: key (str): Query key val: Query value Returns: Parsed query key and value.
[ "Strips", "query", "modifier", "from", "key", "and", "call", "s", "the", "appropriate", "value", "modifier", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L732-L773
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._compile_query
def _compile_query(self): """ Builds SOLR query and stores it into self.compiled_query """ # https://wiki.apache.org/solr/SolrQuerySyntax # http://lucene.apache.org/core/2_9_4/queryparsersyntax.html query = [] # filtered_query = self._model_class.row_level_access...
python
def _compile_query(self): """ Builds SOLR query and stores it into self.compiled_query """ # https://wiki.apache.org/solr/SolrQuerySyntax # http://lucene.apache.org/core/2_9_4/queryparsersyntax.html query = [] # filtered_query = self._model_class.row_level_access...
[ "def", "_compile_query", "(", "self", ")", ":", "# https://wiki.apache.org/solr/SolrQuerySyntax", "# http://lucene.apache.org/core/2_9_4/queryparsersyntax.html", "query", "=", "[", "]", "# filtered_query = self._model_class.row_level_access(self._current_context, self)", "# if filtered_que...
Builds SOLR query and stores it into self.compiled_query
[ "Builds", "SOLR", "query", "and", "stores", "it", "into", "self", ".", "compiled_query" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L814-L897
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._sort_to_str
def _sort_to_str(self): """ Before exec query, this method transforms sort dict string from {"name": "asc", "timestamp":"desc"} to "name asc, timestamp desc" """ params_list = [] timestamp = "" for k, v in self._solr_params['s...
python
def _sort_to_str(self): """ Before exec query, this method transforms sort dict string from {"name": "asc", "timestamp":"desc"} to "name asc, timestamp desc" """ params_list = [] timestamp = "" for k, v in self._solr_params['s...
[ "def", "_sort_to_str", "(", "self", ")", ":", "params_list", "=", "[", "]", "timestamp", "=", "\"\"", "for", "k", ",", "v", "in", "self", ".", "_solr_params", "[", "'sort'", "]", ".", "items", "(", ")", ":", "if", "k", "!=", "\"timestamp\"", ":", "...
Before exec query, this method transforms sort dict string from {"name": "asc", "timestamp":"desc"} to "name asc, timestamp desc"
[ "Before", "exec", "query", "this", "method", "transforms", "sort", "dict", "string" ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L899-L923
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._process_params
def _process_params(self): """ Adds default row size if it's not given in the query. Converts param values into unicode strings. Returns: Processed self._solr_params dict. """ # transform sort dict into str self._sort_to_str() if 'rows' not i...
python
def _process_params(self): """ Adds default row size if it's not given in the query. Converts param values into unicode strings. Returns: Processed self._solr_params dict. """ # transform sort dict into str self._sort_to_str() if 'rows' not i...
[ "def", "_process_params", "(", "self", ")", ":", "# transform sort dict into str", "self", ".", "_sort_to_str", "(", ")", "if", "'rows'", "not", "in", "self", ".", "_solr_params", ":", "self", ".", "_solr_params", "[", "'rows'", "]", "=", "self", ".", "_cfg"...
Adds default row size if it's not given in the query. Converts param values into unicode strings. Returns: Processed self._solr_params dict.
[ "Adds", "default", "row", "size", "if", "it", "s", "not", "given", "in", "the", "query", ".", "Converts", "param", "values", "into", "unicode", "strings", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L925-L942
zetaops/pyoko
pyoko/db/adapter/db_riak.py
Adapter._exec_query
def _exec_query(self): """ Executes solr query if it hasn't already executed. Returns: Self. """ if not self._solr_locked: if not self.compiled_query: self._compile_query() try: solr_params = self._process_param...
python
def _exec_query(self): """ Executes solr query if it hasn't already executed. Returns: Self. """ if not self._solr_locked: if not self.compiled_query: self._compile_query() try: solr_params = self._process_param...
[ "def", "_exec_query", "(", "self", ")", ":", "if", "not", "self", ".", "_solr_locked", ":", "if", "not", "self", ".", "compiled_query", ":", "self", ".", "_compile_query", "(", ")", "try", ":", "solr_params", "=", "self", ".", "_process_params", "(", ")"...
Executes solr query if it hasn't already executed. Returns: Self.
[ "Executes", "solr", "query", "if", "it", "hasn", "t", "already", "executed", "." ]
train
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L951-L977
StevenMaude/bbc-radio-tracklisting-downloader
cmdline.py
parse_arguments
def parse_arguments(args=sys.argv[1:]): """Parse arguments of script.""" cmd_description = "Download tracklistings for BBC radio shows.\n\n" \ "Saves to a text file, tags audio file or does both.\n" \ "To select output file, filename " \ "must bo...
python
def parse_arguments(args=sys.argv[1:]): """Parse arguments of script.""" cmd_description = "Download tracklistings for BBC radio shows.\n\n" \ "Saves to a text file, tags audio file or does both.\n" \ "To select output file, filename " \ "must bo...
[ "def", "parse_arguments", "(", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "cmd_description", "=", "\"Download tracklistings for BBC radio shows.\\n\\n\"", "\"Saves to a text file, tags audio file or does both.\\n\"", "\"To select output file, filename \"", "...
Parse arguments of script.
[ "Parse", "arguments", "of", "script", "." ]
train
https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/cmdline.py#L8-L36
StevenMaude/bbc-radio-tracklisting-downloader
cmdline.py
main
def main(): """Check arguments are retrieved.""" args = parse_arguments() print(args) print("action" + args.action) print("pid" + args.pid) print("directory" + args.directory) print("fileprefix" + args.fileprefix)
python
def main(): """Check arguments are retrieved.""" args = parse_arguments() print(args) print("action" + args.action) print("pid" + args.pid) print("directory" + args.directory) print("fileprefix" + args.fileprefix)
[ "def", "main", "(", ")", ":", "args", "=", "parse_arguments", "(", ")", "print", "(", "args", ")", "print", "(", "\"action\"", "+", "args", ".", "action", ")", "print", "(", "\"pid\"", "+", "args", ".", "pid", ")", "print", "(", "\"directory\"", "+",...
Check arguments are retrieved.
[ "Check", "arguments", "are", "retrieved", "." ]
train
https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/cmdline.py#L39-L46
klen/django-netauth
netauth/backends/oauth.py
OAuthBackend.begin
def begin(self, request, data): """ Try to get Request Token from OAuth Provider and redirect user to provider's site for approval. """ request = self.get_request( http_url = self.REQUEST_TOKEN_URL, parameters = dict(oauth_callback = self.get_callback(...
python
def begin(self, request, data): """ Try to get Request Token from OAuth Provider and redirect user to provider's site for approval. """ request = self.get_request( http_url = self.REQUEST_TOKEN_URL, parameters = dict(oauth_callback = self.get_callback(...
[ "def", "begin", "(", "self", ",", "request", ",", "data", ")", ":", "request", "=", "self", ".", "get_request", "(", "http_url", "=", "self", ".", "REQUEST_TOKEN_URL", ",", "parameters", "=", "dict", "(", "oauth_callback", "=", "self", ".", "get_callback",...
Try to get Request Token from OAuth Provider and redirect user to provider's site for approval.
[ "Try", "to", "get", "Request", "Token", "from", "OAuth", "Provider", "and", "redirect", "user", "to", "provider", "s", "site", "for", "approval", "." ]
train
https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/backends/oauth.py#L19-L30
ionelmc/python-cogen
cogen/magic/corolets.py
CoroGreenlet.run
def run(self, *args, **kwargs): """This runs in a greenlet""" return_value = self.coro(*args, **kwargs) # i don't like this but greenlets are so dodgy i have no other choice raise StopIteration(return_value)
python
def run(self, *args, **kwargs): """This runs in a greenlet""" return_value = self.coro(*args, **kwargs) # i don't like this but greenlets are so dodgy i have no other choice raise StopIteration(return_value)
[ "def", "run", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return_value", "=", "self", ".", "coro", "(", "*", "args", ",", "*", "*", "kwargs", ")", "# i don't like this but greenlets are so dodgy i have no other choice\r", "raise", "StopI...
This runs in a greenlet
[ "This", "runs", "in", "a", "greenlet" ]
train
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/magic/corolets.py#L32-L37
ionelmc/python-cogen
cogen/magic/corolets.py
CoroletInstance.run_op
def run_op(self, op, sched): """ Handle the operation: * if coro is in STATE_RUNNING, send or throw the given op * if coro is in STATE_NEED_INIT, call the init function and if it doesn't return a generator, set STATE_COMPLETED and set the result to whatever ...
python
def run_op(self, op, sched): """ Handle the operation: * if coro is in STATE_RUNNING, send or throw the given op * if coro is in STATE_NEED_INIT, call the init function and if it doesn't return a generator, set STATE_COMPLETED and set the result to whatever ...
[ "def", "run_op", "(", "self", ",", "op", ",", "sched", ")", ":", "if", "op", "is", "self", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"Running coro %s with itself. Something is fishy.\"", "%", "op", ")", "assert", "self", ".", "state", "<", ...
Handle the operation: * if coro is in STATE_RUNNING, send or throw the given op * if coro is in STATE_NEED_INIT, call the init function and if it doesn't return a generator, set STATE_COMPLETED and set the result to whatever the function returned. * if StopIterat...
[ "Handle", "the", "operation", ":", "*", "if", "coro", "is", "in", "STATE_RUNNING", "send", "or", "throw", "the", "given", "op", "*", "if", "coro", "is", "in", "STATE_NEED_INIT", "call", "the", "init", "function", "and", "if", "it", "doesn", "t", "return"...
train
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/magic/corolets.py#L77-L142
seibert-media/Highton
highton/models/user.py
User.me
def me(cls): """ Returns information about the currently authenticated user. :return: :rtype: User """ return fields.ObjectField(name=cls.ENDPOINT, init_class=cls).decode( cls.element_from_string( cls._get_request(endpoint=cls.ENDPOINT + '/me'...
python
def me(cls): """ Returns information about the currently authenticated user. :return: :rtype: User """ return fields.ObjectField(name=cls.ENDPOINT, init_class=cls).decode( cls.element_from_string( cls._get_request(endpoint=cls.ENDPOINT + '/me'...
[ "def", "me", "(", "cls", ")", ":", "return", "fields", ".", "ObjectField", "(", "name", "=", "cls", ".", "ENDPOINT", ",", "init_class", "=", "cls", ")", ".", "decode", "(", "cls", ".", "element_from_string", "(", "cls", ".", "_get_request", "(", "endpo...
Returns information about the currently authenticated user. :return: :rtype: User
[ "Returns", "information", "about", "the", "currently", "authenticated", "user", "." ]
train
https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/models/user.py#L37-L48
DavidMStraub/ckmutil
ckmutil/ckm.py
ckm_standard
def ckm_standard(t12, t13, t23, delta): r"""CKM matrix in the standard parametrization and standard phase convention. Parameters ---------- - `t12`: CKM angle $\theta_{12}$ in radians - `t13`: CKM angle $\theta_{13}$ in radians - `t23`: CKM angle $\theta_{23}$ in radians - `delta`: CKM...
python
def ckm_standard(t12, t13, t23, delta): r"""CKM matrix in the standard parametrization and standard phase convention. Parameters ---------- - `t12`: CKM angle $\theta_{12}$ in radians - `t13`: CKM angle $\theta_{13}$ in radians - `t23`: CKM angle $\theta_{23}$ in radians - `delta`: CKM...
[ "def", "ckm_standard", "(", "t12", ",", "t13", ",", "t23", ",", "delta", ")", ":", "c12", "=", "cos", "(", "t12", ")", "c13", "=", "cos", "(", "t13", ")", "c23", "=", "cos", "(", "t23", ")", "s12", "=", "sin", "(", "t12", ")", "s13", "=", "...
r"""CKM matrix in the standard parametrization and standard phase convention. Parameters ---------- - `t12`: CKM angle $\theta_{12}$ in radians - `t13`: CKM angle $\theta_{13}$ in radians - `t23`: CKM angle $\theta_{23}$ in radians - `delta`: CKM phase $\delta=\gamma$ in radians
[ "r", "CKM", "matrix", "in", "the", "standard", "parametrization", "and", "standard", "phase", "convention", "." ]
train
https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/ckm.py#L7-L33
DavidMStraub/ckmutil
ckmutil/ckm.py
ckm_wolfenstein
def ckm_wolfenstein(laC, A, rhobar, etabar): r"""CKM matrix in the Wolfenstein parametrization and standard phase convention. This function does not rely on an expansion in the Cabibbo angle but defines, to all orders in $\lambda$, - $\lambda = \sin\theta_{12}$ - $A\lambda^2 = \sin\theta_{23}$...
python
def ckm_wolfenstein(laC, A, rhobar, etabar): r"""CKM matrix in the Wolfenstein parametrization and standard phase convention. This function does not rely on an expansion in the Cabibbo angle but defines, to all orders in $\lambda$, - $\lambda = \sin\theta_{12}$ - $A\lambda^2 = \sin\theta_{23}$...
[ "def", "ckm_wolfenstein", "(", "laC", ",", "A", ",", "rhobar", ",", "etabar", ")", ":", "rho", "=", "rhobar", "/", "(", "1", "-", "laC", "**", "2", "/", "2.", ")", "eta", "=", "etabar", "/", "(", "1", "-", "laC", "**", "2", "/", "2.", ")", ...
r"""CKM matrix in the Wolfenstein parametrization and standard phase convention. This function does not rely on an expansion in the Cabibbo angle but defines, to all orders in $\lambda$, - $\lambda = \sin\theta_{12}$ - $A\lambda^2 = \sin\theta_{23}$ - $A\lambda^3(\rho-i \eta) = \sin\theta_{13}...
[ "r", "CKM", "matrix", "in", "the", "Wolfenstein", "parametrization", "and", "standard", "phase", "convention", "." ]
train
https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/ckm.py#L44-L76
DavidMStraub/ckmutil
ckmutil/ckm.py
ckm_tree
def ckm_tree(Vus, Vub, Vcb, gamma): r"""CKM matrix in the tree parametrization and standard phase convention. In this parametrization, the parameters are directly measured from tree-level $B$ decays. It is thus particularly suited for new physics analyses because the tree-level decays should be dom...
python
def ckm_tree(Vus, Vub, Vcb, gamma): r"""CKM matrix in the tree parametrization and standard phase convention. In this parametrization, the parameters are directly measured from tree-level $B$ decays. It is thus particularly suited for new physics analyses because the tree-level decays should be dom...
[ "def", "ckm_tree", "(", "Vus", ",", "Vub", ",", "Vcb", ",", "gamma", ")", ":", "return", "np", ".", "array", "(", "[", "[", "sqrt", "(", "1", "-", "Vub", "**", "2", ")", "*", "sqrt", "(", "1", "-", "Vus", "**", "2", "/", "(", "1", "-", "V...
r"""CKM matrix in the tree parametrization and standard phase convention. In this parametrization, the parameters are directly measured from tree-level $B$ decays. It is thus particularly suited for new physics analyses because the tree-level decays should be dominated by the Standard Model. This f...
[ "r", "CKM", "matrix", "in", "the", "tree", "parametrization", "and", "standard", "phase", "convention", "." ]
train
https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/ckm.py#L78-L110
ionelmc/python-cogen
cogen/core/util.py
debug
def debug(trace=True, backtrace=1, other=None, output=sys.stderr): """A decorator for debugging purposes. Shows the call arguments, result and instructions as they are runned.""" from pprint import pprint import traceback def debugdeco(func): def tracer(frame, event, arg): ...
python
def debug(trace=True, backtrace=1, other=None, output=sys.stderr): """A decorator for debugging purposes. Shows the call arguments, result and instructions as they are runned.""" from pprint import pprint import traceback def debugdeco(func): def tracer(frame, event, arg): ...
[ "def", "debug", "(", "trace", "=", "True", ",", "backtrace", "=", "1", ",", "other", "=", "None", ",", "output", "=", "sys", ".", "stderr", ")", ":", "from", "pprint", "import", "pprint", "import", "traceback", "def", "debugdeco", "(", "func", ")", "...
A decorator for debugging purposes. Shows the call arguments, result and instructions as they are runned.
[ "A", "decorator", "for", "debugging", "purposes", ".", "Shows", "the", "call", "arguments", "result", "and", "instructions", "as", "they", "are", "runned", "." ]
train
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/util.py#L9-L46
henzk/django-productline
django_productline/context.py
bind_context
def bind_context(context_filename): """ loads context from file and binds to it :param: context_filename absolute path of the context file called by featuredjango.startup.select_product prior to selecting the individual features """ global PRODUCT_CONTEXT if PRODUCT_CONTEXT is None: ...
python
def bind_context(context_filename): """ loads context from file and binds to it :param: context_filename absolute path of the context file called by featuredjango.startup.select_product prior to selecting the individual features """ global PRODUCT_CONTEXT if PRODUCT_CONTEXT is None: ...
[ "def", "bind_context", "(", "context_filename", ")", ":", "global", "PRODUCT_CONTEXT", "if", "PRODUCT_CONTEXT", "is", "None", ":", "with", "open", "(", "context_filename", ")", "as", "contextfile", ":", "try", ":", "context", "=", "json", ".", "loads", "(", ...
loads context from file and binds to it :param: context_filename absolute path of the context file called by featuredjango.startup.select_product prior to selecting the individual features
[ "loads", "context", "from", "file", "and", "binds", "to", "it" ]
train
https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/context.py#L59-L90
moonso/vcftoolbox
vcftoolbox/sort.py
get_chromosome_priority
def get_chromosome_priority(chrom, chrom_dict={}): """ Return the chromosome priority Arguments: chrom (str): The cromosome name from the vcf chrom_dict (dict): A map of chromosome names and theis priority Return: priority (str): The priority for this chromosom """ ...
python
def get_chromosome_priority(chrom, chrom_dict={}): """ Return the chromosome priority Arguments: chrom (str): The cromosome name from the vcf chrom_dict (dict): A map of chromosome names and theis priority Return: priority (str): The priority for this chromosom """ ...
[ "def", "get_chromosome_priority", "(", "chrom", ",", "chrom_dict", "=", "{", "}", ")", ":", "priority", "=", "0", "chrom", "=", "str", "(", "chrom", ")", ".", "lstrip", "(", "'chr'", ")", "if", "chrom_dict", ":", "priority", "=", "chrom_dict", ".", "ge...
Return the chromosome priority Arguments: chrom (str): The cromosome name from the vcf chrom_dict (dict): A map of chromosome names and theis priority Return: priority (str): The priority for this chromosom
[ "Return", "the", "chromosome", "priority", "Arguments", ":", "chrom", "(", "str", ")", ":", "The", "cromosome", "name", "from", "the", "vcf", "chrom_dict", "(", "dict", ")", ":", "A", "map", "of", "chromosome", "names", "and", "theis", "priority", "Return"...
train
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/sort.py#L11-L43
moonso/vcftoolbox
vcftoolbox/sort.py
sort_variants
def sort_variants(vcf_handle): """Sort the variants of a vcf file Args: vcf_handle mode (str): position or rank score Returns: sorted_variants (Iterable): An iterable with sorted variants """ logger.debug("Creating temp file") temp_file =...
python
def sort_variants(vcf_handle): """Sort the variants of a vcf file Args: vcf_handle mode (str): position or rank score Returns: sorted_variants (Iterable): An iterable with sorted variants """ logger.debug("Creating temp file") temp_file =...
[ "def", "sort_variants", "(", "vcf_handle", ")", ":", "logger", ".", "debug", "(", "\"Creating temp file\"", ")", "temp_file", "=", "NamedTemporaryFile", "(", "delete", "=", "False", ")", "temp_file", ".", "close", "(", ")", "logger", ".", "debug", "(", "\"Op...
Sort the variants of a vcf file Args: vcf_handle mode (str): position or rank score Returns: sorted_variants (Iterable): An iterable with sorted variants
[ "Sort", "the", "variants", "of", "a", "vcf", "file", "Args", ":", "vcf_handle", "mode", "(", "str", ")", ":", "position", "or", "rank", "score", "Returns", ":", "sorted_variants", "(", "Iterable", ")", ":", "An", "iterable", "with", "sorted", "variants" ]
train
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/sort.py#L47-L92
moonso/vcftoolbox
vcftoolbox/sort.py
sort_variant_file
def sort_variant_file(infile): """ Sort a modified variant file. Sorting is based on the first column and the POS. Uses unix sort to sort the variants and overwrites the infile. Args: infile : A string that is the path to a file mode : 'chromosome' or 'rank' outfile...
python
def sort_variant_file(infile): """ Sort a modified variant file. Sorting is based on the first column and the POS. Uses unix sort to sort the variants and overwrites the infile. Args: infile : A string that is the path to a file mode : 'chromosome' or 'rank' outfile...
[ "def", "sort_variant_file", "(", "infile", ")", ":", "command", "=", "[", "'sort'", ",", "]", "command", ".", "append", "(", "'-n'", ")", "command", ".", "append", "(", "'-k1'", ")", "command", ".", "append", "(", "'-k3'", ")", "command", "=", "command...
Sort a modified variant file. Sorting is based on the first column and the POS. Uses unix sort to sort the variants and overwrites the infile. Args: infile : A string that is the path to a file mode : 'chromosome' or 'rank' outfile : The path to an outfile where the variant...
[ "Sort", "a", "modified", "variant", "file", ".", "Sorting", "is", "based", "on", "the", "first", "column", "and", "the", "POS", ".", "Uses", "unix", "sort", "to", "sort", "the", "variants", "and", "overwrites", "the", "infile", ".", "Args", ":", "infile"...
train
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/sort.py#L99-L139
justquick/django-native-tags
native_tags/contrib/feeds.py
include_feed
def include_feed(feed_url, *args): """ Parse an RSS or Atom feed and render a given number of its items into HTML. It is **highly** recommended that you use `Django's template fragment caching`_ to cache the output of this tag for a reasonable amount of time (e.g., one hour); polling a feed...
python
def include_feed(feed_url, *args): """ Parse an RSS or Atom feed and render a given number of its items into HTML. It is **highly** recommended that you use `Django's template fragment caching`_ to cache the output of this tag for a reasonable amount of time (e.g., one hour); polling a feed...
[ "def", "include_feed", "(", "feed_url", ",", "*", "args", ")", ":", "feed", "=", "feedparser", ".", "parse", "(", "feed_url", ")", "items", "=", "[", "]", "if", "len", "(", "args", ")", "==", "2", ":", "# num_items, template_name", "num_items", ",", "t...
Parse an RSS or Atom feed and render a given number of its items into HTML. It is **highly** recommended that you use `Django's template fragment caching`_ to cache the output of this tag for a reasonable amount of time (e.g., one hour); polling a feed too often is impolite, wastes bandwidth an...
[ "Parse", "an", "RSS", "or", "Atom", "feed", "and", "render", "a", "given", "number", "of", "its", "items", "into", "HTML", ".", "It", "is", "**", "highly", "**", "recommended", "that", "you", "use", "Django", "s", "template", "fragment", "caching", "_", ...
train
https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/feeds.py#L16-L82
ionelmc/python-cogen
examples/cogen-chat/ChatApp/chatapp/config/middleware.py
make_app
def make_app(global_conf, full_stack=True, **app_conf): """Create a Pylons WSGI application and return it ``global_conf`` The inherited configuration for this application. Normally from the [DEFAULT] section of the Paste ini file. ``full_stack`` Whether or not this applicat...
python
def make_app(global_conf, full_stack=True, **app_conf): """Create a Pylons WSGI application and return it ``global_conf`` The inherited configuration for this application. Normally from the [DEFAULT] section of the Paste ini file. ``full_stack`` Whether or not this applicat...
[ "def", "make_app", "(", "global_conf", ",", "full_stack", "=", "True", ",", "*", "*", "app_conf", ")", ":", "# Configure the Pylons environment\r", "load_environment", "(", "global_conf", ",", "app_conf", ")", "# The Pylons WSGI app\r", "app", "=", "PylonsApp", "(",...
Create a Pylons WSGI application and return it ``global_conf`` The inherited configuration for this application. Normally from the [DEFAULT] section of the Paste ini file. ``full_stack`` Whether or not this application provides a full WSGI stack (by default, meaning it ...
[ "Create", "a", "Pylons", "WSGI", "application", "and", "return", "it", "global_conf", "The", "inherited", "configuration", "for", "this", "application", ".", "Normally", "from", "the", "[", "DEFAULT", "]", "section", "of", "the", "Paste", "ini", "file", ".", ...
train
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-chat/ChatApp/chatapp/config/middleware.py#L15-L75
crypto101/merlyn
merlyn/service.py
Protocol.connectionMade
def connectionMade(self): """Keep a reference to the protocol on the factory, and uses the factory's store to find multiplexed connection factories. Unfortunately, we can't add the protocol by TLS certificate fingerprint, because the TLS handshake won't have completed yet, so ``...
python
def connectionMade(self): """Keep a reference to the protocol on the factory, and uses the factory's store to find multiplexed connection factories. Unfortunately, we can't add the protocol by TLS certificate fingerprint, because the TLS handshake won't have completed yet, so ``...
[ "def", "connectionMade", "(", "self", ")", ":", "self", ".", "factory", ".", "protocols", ".", "add", "(", "self", ")", "self", ".", "_factories", "=", "multiplexing", ".", "FactoryDict", "(", "self", ".", "store", ")", "super", "(", "AMP", ",", "self"...
Keep a reference to the protocol on the factory, and uses the factory's store to find multiplexed connection factories. Unfortunately, we can't add the protocol by TLS certificate fingerprint, because the TLS handshake won't have completed yet, so ``self.transport.getPeerCertificate()``...
[ "Keep", "a", "reference", "to", "the", "protocol", "on", "the", "factory", "and", "uses", "the", "factory", "s", "store", "to", "find", "multiplexed", "connection", "factories", "." ]
train
https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/service.py#L26-L38
crypto101/merlyn
merlyn/service.py
Protocol.connectionLost
def connectionLost(self, reason): """Lose the reference to the protocol on the factory. """ self.factory.protocols.remove(self) super(AMP, self).connectionLost(reason)
python
def connectionLost(self, reason): """Lose the reference to the protocol on the factory. """ self.factory.protocols.remove(self) super(AMP, self).connectionLost(reason)
[ "def", "connectionLost", "(", "self", ",", "reason", ")", ":", "self", ".", "factory", ".", "protocols", ".", "remove", "(", "self", ")", "super", "(", "AMP", ",", "self", ")", ".", "connectionLost", "(", "reason", ")" ]
Lose the reference to the protocol on the factory.
[ "Lose", "the", "reference", "to", "the", "protocol", "on", "the", "factory", "." ]
train
https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/service.py#L41-L46
justquick/django-native-tags
native_tags/contrib/mapreduce.py
do_map
def do_map(func_name, *sequence): """ Return a list of the results of applying the function to the items of the argument sequence(s). Functions may be registered with ``native_tags`` or can be ``builtins`` or from the ``operator`` module If more than one sequence is given, the f...
python
def do_map(func_name, *sequence): """ Return a list of the results of applying the function to the items of the argument sequence(s). Functions may be registered with ``native_tags`` or can be ``builtins`` or from the ``operator`` module If more than one sequence is given, the f...
[ "def", "do_map", "(", "func_name", ",", "*", "sequence", ")", ":", "if", "len", "(", "sequence", ")", "==", "1", ":", "sequence", "=", "sequence", "[", "0", "]", "return", "map", "(", "get_func", "(", "func_name", ",", "False", ")", ",", "sequence", ...
Return a list of the results of applying the function to the items of the argument sequence(s). Functions may be registered with ``native_tags`` or can be ``builtins`` or from the ``operator`` module If more than one sequence is given, the function is called with an argument list consis...
[ "Return", "a", "list", "of", "the", "results", "of", "applying", "the", "function", "to", "the", "items", "of", "the", "argument", "sequence", "(", "s", ")", ".", "Functions", "may", "be", "registered", "with", "native_tags", "or", "can", "be", "builtins",...
train
https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/mapreduce.py#L16-L47
justquick/django-native-tags
native_tags/contrib/mapreduce.py
do_reduce
def do_reduce(func_name, *sequence): """ Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. Functions may be registered with ``native_tags`` or can be ``builtins`` or from the ``operator`` module ...
python
def do_reduce(func_name, *sequence): """ Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. Functions may be registered with ``native_tags`` or can be ``builtins`` or from the ``operator`` module ...
[ "def", "do_reduce", "(", "func_name", ",", "*", "sequence", ")", ":", "if", "len", "(", "sequence", ")", "==", "1", ":", "sequence", "=", "sequence", "[", "0", "]", "return", "reduce", "(", "get_func", "(", "func_name", ")", ",", "sequence", ")" ]
Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. Functions may be registered with ``native_tags`` or can be ``builtins`` or from the ``operator`` module Syntax:: {% reduce [function] [se...
[ "Apply", "a", "function", "of", "two", "arguments", "cumulatively", "to", "the", "items", "of", "a", "sequence", "from", "left", "to", "right", "so", "as", "to", "reduce", "the", "sequence", "to", "a", "single", "value", ".", "Functions", "may", "be", "r...
train
https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/mapreduce.py#L51-L74
SetBased/py-etlt
etlt/writer/SqlLoaderWriter.py
SqlLoaderWriter._write_field
def _write_field(self, value): """ Write a single field to the destination file. :param T value: The value of the field. """ class_name = str(value.__class__) if class_name not in self.handlers: raise ValueError('No handler has been registered for class: {0!s...
python
def _write_field(self, value): """ Write a single field to the destination file. :param T value: The value of the field. """ class_name = str(value.__class__) if class_name not in self.handlers: raise ValueError('No handler has been registered for class: {0!s...
[ "def", "_write_field", "(", "self", ",", "value", ")", ":", "class_name", "=", "str", "(", "value", ".", "__class__", ")", "if", "class_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'No handler has been registered for class: {0!s...
Write a single field to the destination file. :param T value: The value of the field.
[ "Write", "a", "single", "field", "to", "the", "destination", "file", "." ]
train
https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/writer/SqlLoaderWriter.py#L108-L118
seibert-media/Highton
highton/call_mixins/list_note_call_mixin.py
ListNoteCallMixin.list_notes
def list_notes(self, page=0, since=None): """ Get the notes of current object :param page: the page starting at 0 :type since: int :param since: get all notes since a datetime :type since: datetime.datetime :return: the notes :rtype: list """ ...
python
def list_notes(self, page=0, since=None): """ Get the notes of current object :param page: the page starting at 0 :type since: int :param since: get all notes since a datetime :type since: datetime.datetime :return: the notes :rtype: list """ ...
[ "def", "list_notes", "(", "self", ",", "page", "=", "0", ",", "since", "=", "None", ")", ":", "from", "highton", ".", "models", ".", "note", "import", "Note", "params", "=", "{", "'n'", ":", "int", "(", "page", ")", "*", "self", ".", "NOTES_OFFSET"...
Get the notes of current object :param page: the page starting at 0 :type since: int :param since: get all notes since a datetime :type since: datetime.datetime :return: the notes :rtype: list
[ "Get", "the", "notes", "of", "current", "object" ]
train
https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/list_note_call_mixin.py#L14-L40
happyleavesaoc/python-motorparts
motorparts/__init__.py
_login
def _login(session): """Login.""" _LOGGER.info("logging in (no valid cookie found)") session.cookies.clear() resp = session.post(SSO_URL, { 'USER': session.auth.username, 'PASSWORD': session.auth.password, 'TARGET': TARGET_URL }) parsed = BeautifulSoup(resp.text, HTML_PAR...
python
def _login(session): """Login.""" _LOGGER.info("logging in (no valid cookie found)") session.cookies.clear() resp = session.post(SSO_URL, { 'USER': session.auth.username, 'PASSWORD': session.auth.password, 'TARGET': TARGET_URL }) parsed = BeautifulSoup(resp.text, HTML_PAR...
[ "def", "_login", "(", "session", ")", ":", "_LOGGER", ".", "info", "(", "\"logging in (no valid cookie found)\"", ")", "session", ".", "cookies", ".", "clear", "(", ")", "resp", "=", "session", ".", "post", "(", "SSO_URL", ",", "{", "'USER'", ":", "session...
Login.
[ "Login", "." ]
train
https://github.com/happyleavesaoc/python-motorparts/blob/4a6b4dc72dd45524dd64a7a079478bd98c55215c/motorparts/__init__.py#L61-L78
happyleavesaoc/python-motorparts
motorparts/__init__.py
authenticated
def authenticated(function): """Re-authenticate if session expired.""" def wrapped(*args): """Wrap function.""" try: return function(*args) except MoparError: _LOGGER.info("attempted to access page before login") _login(args[0]) return func...
python
def authenticated(function): """Re-authenticate if session expired.""" def wrapped(*args): """Wrap function.""" try: return function(*args) except MoparError: _LOGGER.info("attempted to access page before login") _login(args[0]) return func...
[ "def", "authenticated", "(", "function", ")", ":", "def", "wrapped", "(", "*", "args", ")", ":", "\"\"\"Wrap function.\"\"\"", "try", ":", "return", "function", "(", "*", "args", ")", "except", "MoparError", ":", "_LOGGER", ".", "info", "(", "\"attempted to ...
Re-authenticate if session expired.
[ "Re", "-", "authenticate", "if", "session", "expired", "." ]
train
https://github.com/happyleavesaoc/python-motorparts/blob/4a6b4dc72dd45524dd64a7a079478bd98c55215c/motorparts/__init__.py#L87-L97
happyleavesaoc/python-motorparts
motorparts/__init__.py
token
def token(function): """Attach a CSRF token for POST requests.""" def wrapped(session, *args): """Wrap function.""" resp = session.get(TOKEN_URL).json() session.headers.update({'mopar-csrf-salt': resp['token']}) return function(session, *args) return wrapped
python
def token(function): """Attach a CSRF token for POST requests.""" def wrapped(session, *args): """Wrap function.""" resp = session.get(TOKEN_URL).json() session.headers.update({'mopar-csrf-salt': resp['token']}) return function(session, *args) return wrapped
[ "def", "token", "(", "function", ")", ":", "def", "wrapped", "(", "session", ",", "*", "args", ")", ":", "\"\"\"Wrap function.\"\"\"", "resp", "=", "session", ".", "get", "(", "TOKEN_URL", ")", ".", "json", "(", ")", "session", ".", "headers", ".", "up...
Attach a CSRF token for POST requests.
[ "Attach", "a", "CSRF", "token", "for", "POST", "requests", "." ]
train
https://github.com/happyleavesaoc/python-motorparts/blob/4a6b4dc72dd45524dd64a7a079478bd98c55215c/motorparts/__init__.py#L100-L107
happyleavesaoc/python-motorparts
motorparts/__init__.py
get_profile
def get_profile(session): """Get complete profile.""" try: profile = session.get(PROFILE_URL).json() if 'errorCode' in profile and profile['errorCode'] == '403': raise MoparError("not logged in") return profile except JSONDecodeError: raise MoparError("not logged ...
python
def get_profile(session): """Get complete profile.""" try: profile = session.get(PROFILE_URL).json() if 'errorCode' in profile and profile['errorCode'] == '403': raise MoparError("not logged in") return profile except JSONDecodeError: raise MoparError("not logged ...
[ "def", "get_profile", "(", "session", ")", ":", "try", ":", "profile", "=", "session", ".", "get", "(", "PROFILE_URL", ")", ".", "json", "(", ")", "if", "'errorCode'", "in", "profile", "and", "profile", "[", "'errorCode'", "]", "==", "'403'", ":", "rai...
Get complete profile.
[ "Get", "complete", "profile", "." ]
train
https://github.com/happyleavesaoc/python-motorparts/blob/4a6b4dc72dd45524dd64a7a079478bd98c55215c/motorparts/__init__.py#L111-L119
happyleavesaoc/python-motorparts
motorparts/__init__.py
get_report
def get_report(session, vehicle_index): """Get vehicle health report summary.""" vhr = get_vehicle_health_report(session, vehicle_index) if 'reportCard' not in vhr: raise MoparError("no vhr found") return _traverse_report(vhr['reportCard'])
python
def get_report(session, vehicle_index): """Get vehicle health report summary.""" vhr = get_vehicle_health_report(session, vehicle_index) if 'reportCard' not in vhr: raise MoparError("no vhr found") return _traverse_report(vhr['reportCard'])
[ "def", "get_report", "(", "session", ",", "vehicle_index", ")", ":", "vhr", "=", "get_vehicle_health_report", "(", "session", ",", "vehicle_index", ")", "if", "'reportCard'", "not", "in", "vhr", ":", "raise", "MoparError", "(", "\"no vhr found\"", ")", "return",...
Get vehicle health report summary.
[ "Get", "vehicle", "health", "report", "summary", "." ]
train
https://github.com/happyleavesaoc/python-motorparts/blob/4a6b4dc72dd45524dd64a7a079478bd98c55215c/motorparts/__init__.py#L122-L127