repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
mozilla/elasticutils
elasticutils/__init__.py
_boosted_value
def _boosted_value(name, action, key, value, boost): """Boost a value if we should in _process_queries""" if boost is not None: # Note: Most queries use 'value' for the key name except # Match queries which use 'query'. So we have to do some # switcheroo for that. value_key = 'qu...
python
def _boosted_value(name, action, key, value, boost): """Boost a value if we should in _process_queries""" if boost is not None: # Note: Most queries use 'value' for the key name except # Match queries which use 'query'. So we have to do some # switcheroo for that. value_key = 'qu...
[ "def", "_boosted_value", "(", "name", ",", "action", ",", "key", ",", "value", ",", "boost", ")", ":", "if", "boost", "is", "not", "None", ":", "# Note: Most queries use 'value' for the key name except", "# Match queries which use 'query'. So we have to do some", "# switc...
Boost a value if we should in _process_queries
[ "Boost", "a", "value", "if", "we", "should", "in", "_process_queries" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L397-L405
train
mozilla/elasticutils
elasticutils/__init__.py
decorate_with_metadata
def decorate_with_metadata(obj, result): """Return obj decorated with es_meta object""" # Create es_meta object with Elasticsearch metadata about this # search result obj.es_meta = Metadata( # Elasticsearch id id=result.get('_id', 0), # Source data source=result.get('_sou...
python
def decorate_with_metadata(obj, result): """Return obj decorated with es_meta object""" # Create es_meta object with Elasticsearch metadata about this # search result obj.es_meta = Metadata( # Elasticsearch id id=result.get('_id', 0), # Source data source=result.get('_sou...
[ "def", "decorate_with_metadata", "(", "obj", ",", "result", ")", ":", "# Create es_meta object with Elasticsearch metadata about this", "# search result", "obj", ".", "es_meta", "=", "Metadata", "(", "# Elasticsearch id", "id", "=", "result", ".", "get", "(", "'_id'", ...
Return obj decorated with es_meta object
[ "Return", "obj", "decorated", "with", "es_meta", "object" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1918-L1938
train
mozilla/elasticutils
elasticutils/__init__.py
F._combine
def _combine(self, other, conn='and'): """ OR and AND will create a new F, with the filters from both F objects combined with the connector `conn`. """ f = F() self_filters = copy.deepcopy(self.filters) other_filters = copy.deepcopy(other.filters) if not...
python
def _combine(self, other, conn='and'): """ OR and AND will create a new F, with the filters from both F objects combined with the connector `conn`. """ f = F() self_filters = copy.deepcopy(self.filters) other_filters = copy.deepcopy(other.filters) if not...
[ "def", "_combine", "(", "self", ",", "other", ",", "conn", "=", "'and'", ")", ":", "f", "=", "F", "(", ")", "self_filters", "=", "copy", ".", "deepcopy", "(", "self", ".", "filters", ")", "other_filters", "=", "copy", ".", "deepcopy", "(", "other", ...
OR and AND will create a new F, with the filters from both F objects combined with the connector `conn`.
[ "OR", "and", "AND", "will", "create", "a", "new", "F", "with", "the", "filters", "from", "both", "F", "objects", "combined", "with", "the", "connector", "conn", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L277-L300
train
mozilla/elasticutils
elasticutils/__init__.py
PythonMixin.to_python
def to_python(self, obj): """Converts strings in a data structure to Python types It converts datetime-ish things to Python datetimes. Override if you want something different. :arg obj: Python datastructure :returns: Python datastructure with strings converted to ...
python
def to_python(self, obj): """Converts strings in a data structure to Python types It converts datetime-ish things to Python datetimes. Override if you want something different. :arg obj: Python datastructure :returns: Python datastructure with strings converted to ...
[ "def", "to_python", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "string_types", ")", ":", "if", "len", "(", "obj", ")", "==", "26", ":", "try", ":", "return", "datetime", ".", "strptime", "(", "obj", ",", "'%Y-%m-%dT%H:%M:...
Converts strings in a data structure to Python types It converts datetime-ish things to Python datetimes. Override if you want something different. :arg obj: Python datastructure :returns: Python datastructure with strings converted to Python types .. Note:: ...
[ "Converts", "strings", "in", "a", "data", "structure", "to", "Python", "types" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L410-L451
train
mozilla/elasticutils
elasticutils/__init__.py
S.query
def query(self, *queries, **kw): """ Return a new S instance with query args combined with existing set in a must boolean query. :arg queries: instances of Q :arg kw: queries in the form of ``field__action=value`` There are three special flags you can use: * ``...
python
def query(self, *queries, **kw): """ Return a new S instance with query args combined with existing set in a must boolean query. :arg queries: instances of Q :arg kw: queries in the form of ``field__action=value`` There are three special flags you can use: * ``...
[ "def", "query", "(", "self", ",", "*", "queries", ",", "*", "*", "kw", ")", ":", "q", "=", "Q", "(", ")", "for", "query", "in", "queries", ":", "q", "+=", "query", "if", "'or_'", "in", "kw", ":", "# Backwards compatibile with pre-0.7 version.", "or_que...
Return a new S instance with query args combined with existing set in a must boolean query. :arg queries: instances of Q :arg kw: queries in the form of ``field__action=value`` There are three special flags you can use: * ``must=True``: Specifies that the queries and kw querie...
[ "Return", "a", "new", "S", "instance", "with", "query", "args", "combined", "with", "existing", "set", "in", "a", "must", "boolean", "query", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L694-L759
train
mozilla/elasticutils
elasticutils/__init__.py
S.filter
def filter(self, *filters, **kw): """ Return a new S instance with filter args combined with existing set with AND. :arg filters: this will be instances of F :arg kw: this will be in the form of ``field__action=value`` Examples: >>> s = S().filter(foo='bar') ...
python
def filter(self, *filters, **kw): """ Return a new S instance with filter args combined with existing set with AND. :arg filters: this will be instances of F :arg kw: this will be in the form of ``field__action=value`` Examples: >>> s = S().filter(foo='bar') ...
[ "def", "filter", "(", "self", ",", "*", "filters", ",", "*", "*", "kw", ")", ":", "items", "=", "kw", ".", "items", "(", ")", "if", "six", ".", "PY3", ":", "items", "=", "list", "(", "items", ")", "return", "self", ".", "_clone", "(", "next_ste...
Return a new S instance with filter args combined with existing set with AND. :arg filters: this will be instances of F :arg kw: this will be in the form of ``field__action=value`` Examples: >>> s = S().filter(foo='bar') >>> s = S().filter(F(foo='bar')) >>> s =...
[ "Return", "a", "new", "S", "instance", "with", "filter", "args", "combined", "with", "existing", "set", "with", "AND", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L782-L817
train
mozilla/elasticutils
elasticutils/__init__.py
S.boost
def boost(self, **kw): """ Return a new S instance with field boosts. ElasticUtils allows you to specify query-time field boosts with ``.boost()``. It takes a set of arguments where the keys are either field names or field name + ``__`` + field action. Examples:: ...
python
def boost(self, **kw): """ Return a new S instance with field boosts. ElasticUtils allows you to specify query-time field boosts with ``.boost()``. It takes a set of arguments where the keys are either field names or field name + ``__`` + field action. Examples:: ...
[ "def", "boost", "(", "self", ",", "*", "*", "kw", ")", ":", "new", "=", "self", ".", "_clone", "(", ")", "new", ".", "field_boosts", ".", "update", "(", "kw", ")", "return", "new" ]
Return a new S instance with field boosts. ElasticUtils allows you to specify query-time field boosts with ``.boost()``. It takes a set of arguments where the keys are either field names or field name + ``__`` + field action. Examples:: q = (S().query(title='taco trucks', ...
[ "Return", "a", "new", "S", "instance", "with", "field", "boosts", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L839-L897
train
mozilla/elasticutils
elasticutils/__init__.py
S.demote
def demote(self, amount_, *queries, **kw): """ Returns a new S instance with boosting query and demotion. You can demote documents that match query criteria:: q = (S().query(title='trucks') .demote(0.5, description__match='gross')) q = (S().query(ti...
python
def demote(self, amount_, *queries, **kw): """ Returns a new S instance with boosting query and demotion. You can demote documents that match query criteria:: q = (S().query(title='trucks') .demote(0.5, description__match='gross')) q = (S().query(ti...
[ "def", "demote", "(", "self", ",", "amount_", ",", "*", "queries", ",", "*", "*", "kw", ")", ":", "q", "=", "Q", "(", ")", "for", "query", "in", "queries", ":", "q", "+=", "query", "q", "+=", "Q", "(", "*", "*", "kw", ")", "return", "self", ...
Returns a new S instance with boosting query and demotion. You can demote documents that match query criteria:: q = (S().query(title='trucks') .demote(0.5, description__match='gross')) q = (S().query(title='trucks') .demote(0.5, Q(description__m...
[ "Returns", "a", "new", "S", "instance", "with", "boosting", "query", "and", "demotion", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L899-L928
train
mozilla/elasticutils
elasticutils/__init__.py
S.facet_raw
def facet_raw(self, **kw): """ Return a new S instance with raw facet args combined with existing set. """ items = kw.items() if six.PY3: items = list(items) return self._clone(next_step=('facet_raw', items))
python
def facet_raw(self, **kw): """ Return a new S instance with raw facet args combined with existing set. """ items = kw.items() if six.PY3: items = list(items) return self._clone(next_step=('facet_raw', items))
[ "def", "facet_raw", "(", "self", ",", "*", "*", "kw", ")", ":", "items", "=", "kw", ".", "items", "(", ")", "if", "six", ".", "PY3", ":", "items", "=", "list", "(", "items", ")", "return", "self", ".", "_clone", "(", "next_step", "=", "(", "'fa...
Return a new S instance with raw facet args combined with existing set.
[ "Return", "a", "new", "S", "instance", "with", "raw", "facet", "args", "combined", "with", "existing", "set", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L944-L952
train
mozilla/elasticutils
elasticutils/__init__.py
S.suggest
def suggest(self, name, term, **kwargs): """Set suggestion options. :arg name: The name to use for the suggestions. :arg term: The term to suggest similar looking terms for. Additional keyword options: * ``field`` -- The field to base suggestions upon, defaults to _all ...
python
def suggest(self, name, term, **kwargs): """Set suggestion options. :arg name: The name to use for the suggestions. :arg term: The term to suggest similar looking terms for. Additional keyword options: * ``field`` -- The field to base suggestions upon, defaults to _all ...
[ "def", "suggest", "(", "self", ",", "name", ",", "term", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_clone", "(", "next_step", "=", "(", "'suggest'", ",", "(", "name", ",", "term", ",", "kwargs", ")", ")", ")" ]
Set suggestion options. :arg name: The name to use for the suggestions. :arg term: The term to suggest similar looking terms for. Additional keyword options: * ``field`` -- The field to base suggestions upon, defaults to _all Results will have a ``_suggestions`` property cont...
[ "Set", "suggestion", "options", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1019-L1039
train
mozilla/elasticutils
elasticutils/__init__.py
S.extra
def extra(self, **kw): """ Return a new S instance with extra args combined with existing set. """ new = self._clone() actions = ['values_list', 'values_dict', 'order_by', 'query', 'filter', 'facet'] for key, vals in kw.items(): asse...
python
def extra(self, **kw): """ Return a new S instance with extra args combined with existing set. """ new = self._clone() actions = ['values_list', 'values_dict', 'order_by', 'query', 'filter', 'facet'] for key, vals in kw.items(): asse...
[ "def", "extra", "(", "self", ",", "*", "*", "kw", ")", ":", "new", "=", "self", ".", "_clone", "(", ")", "actions", "=", "[", "'values_list'", ",", "'values_dict'", ",", "'order_by'", ",", "'query'", ",", "'filter'", ",", "'facet'", "]", "for", "key"...
Return a new S instance with extra args combined with existing set.
[ "Return", "a", "new", "S", "instance", "with", "extra", "args", "combined", "with", "existing", "set", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1041-L1055
train
mozilla/elasticutils
elasticutils/__init__.py
S.build_search
def build_search(self): """Builds the Elasticsearch search body represented by this S. Loop over self.steps to build the search body that will be sent to Elasticsearch. This returns a Python dict. If you want the JSON that actually gets sent, then pass the return value through ...
python
def build_search(self): """Builds the Elasticsearch search body represented by this S. Loop over self.steps to build the search body that will be sent to Elasticsearch. This returns a Python dict. If you want the JSON that actually gets sent, then pass the return value through ...
[ "def", "build_search", "(", "self", ")", ":", "filters", "=", "[", "]", "filters_raw", "=", "None", "queries", "=", "[", "]", "query_raw", "=", "None", "sort", "=", "[", "]", "dict_fields", "=", "set", "(", ")", "list_fields", "=", "set", "(", ")", ...
Builds the Elasticsearch search body represented by this S. Loop over self.steps to build the search body that will be sent to Elasticsearch. This returns a Python dict. If you want the JSON that actually gets sent, then pass the return value through :py:func:`elasticutils.utils.to_jso...
[ "Builds", "the", "Elasticsearch", "search", "body", "represented", "by", "this", "S", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1067-L1227
train
mozilla/elasticutils
elasticutils/__init__.py
S._build_highlight
def _build_highlight(self, fields, options): """Return the portion of the query that controls highlighting.""" ret = {'fields': dict((f, {}) for f in fields), 'order': 'score'} ret.update(options) return ret
python
def _build_highlight(self, fields, options): """Return the portion of the query that controls highlighting.""" ret = {'fields': dict((f, {}) for f in fields), 'order': 'score'} ret.update(options) return ret
[ "def", "_build_highlight", "(", "self", ",", "fields", ",", "options", ")", ":", "ret", "=", "{", "'fields'", ":", "dict", "(", "(", "f", ",", "{", "}", ")", "for", "f", "in", "fields", ")", ",", "'order'", ":", "'score'", "}", "ret", ".", "updat...
Return the portion of the query that controls highlighting.
[ "Return", "the", "portion", "of", "the", "query", "that", "controls", "highlighting", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1229-L1234
train
mozilla/elasticutils
elasticutils/__init__.py
S._process_filters
def _process_filters(self, filters): """Takes a list of filters and returns ES JSON API :arg filters: list of F, (key, val) tuples, or dicts :returns: list of ES JSON API filters """ rv = [] for f in filters: if isinstance(f, F): if f.filter...
python
def _process_filters(self, filters): """Takes a list of filters and returns ES JSON API :arg filters: list of F, (key, val) tuples, or dicts :returns: list of ES JSON API filters """ rv = [] for f in filters: if isinstance(f, F): if f.filter...
[ "def", "_process_filters", "(", "self", ",", "filters", ")", ":", "rv", "=", "[", "]", "for", "f", "in", "filters", ":", "if", "isinstance", "(", "f", ",", "F", ")", ":", "if", "f", ".", "filters", ":", "rv", ".", "extend", "(", "self", ".", "_...
Takes a list of filters and returns ES JSON API :arg filters: list of F, (key, val) tuples, or dicts :returns: list of ES JSON API filters
[ "Takes", "a", "list", "of", "filters", "and", "returns", "ES", "JSON", "API" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1236-L1318
train
mozilla/elasticutils
elasticutils/__init__.py
S._process_query
def _process_query(self, query): """Takes a key/val pair and returns the Elasticsearch code for it""" key, val = query field_name, field_action = split_field_action(key) # Boost by name__action overrides boost by name. boost = self.field_boosts.get(key) if boost is None:...
python
def _process_query(self, query): """Takes a key/val pair and returns the Elasticsearch code for it""" key, val = query field_name, field_action = split_field_action(key) # Boost by name__action overrides boost by name. boost = self.field_boosts.get(key) if boost is None:...
[ "def", "_process_query", "(", "self", ",", "query", ")", ":", "key", ",", "val", "=", "query", "field_name", ",", "field_action", "=", "split_field_action", "(", "key", ")", "# Boost by name__action overrides boost by name.", "boost", "=", "self", ".", "field_boos...
Takes a key/val pair and returns the Elasticsearch code for it
[ "Takes", "a", "key", "/", "val", "pair", "and", "returns", "the", "Elasticsearch", "code", "for", "it" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1320-L1371
train
mozilla/elasticutils
elasticutils/__init__.py
S._process_queries
def _process_queries(self, queries): """Takes a list of queries and returns query clause value :arg queries: list of Q instances :returns: dict which is the query clause value """ # First, let's mush everything into a single Q. Then we can # parse that into bits. ...
python
def _process_queries(self, queries): """Takes a list of queries and returns query clause value :arg queries: list of Q instances :returns: dict which is the query clause value """ # First, let's mush everything into a single Q. Then we can # parse that into bits. ...
[ "def", "_process_queries", "(", "self", ",", "queries", ")", ":", "# First, let's mush everything into a single Q. Then we can", "# parse that into bits.", "new_q", "=", "Q", "(", ")", "for", "query", "in", "queries", ":", "new_q", "+=", "query", "# Now we have a single...
Takes a list of queries and returns query clause value :arg queries: list of Q instances :returns: dict which is the query clause value
[ "Takes", "a", "list", "of", "queries", "and", "returns", "query", "clause", "value" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1373-L1411
train
mozilla/elasticutils
elasticutils/__init__.py
S._do_search
def _do_search(self): """ Perform the search, then convert that raw format into a SearchResults instance and return it. """ if self._results_cache is None: response = self.raw() ResultsClass = self.get_results_class() results = self.to_python(r...
python
def _do_search(self): """ Perform the search, then convert that raw format into a SearchResults instance and return it. """ if self._results_cache is None: response = self.raw() ResultsClass = self.get_results_class() results = self.to_python(r...
[ "def", "_do_search", "(", "self", ")", ":", "if", "self", ".", "_results_cache", "is", "None", ":", "response", "=", "self", ".", "raw", "(", ")", "ResultsClass", "=", "self", ".", "get_results_class", "(", ")", "results", "=", "self", ".", "to_python", ...
Perform the search, then convert that raw format into a SearchResults instance and return it.
[ "Perform", "the", "search", "then", "convert", "that", "raw", "format", "into", "a", "SearchResults", "instance", "and", "return", "it", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1426-L1437
train
mozilla/elasticutils
elasticutils/__init__.py
S.get_es
def get_es(self, default_builder=get_es): """Returns the Elasticsearch object to use. :arg default_builder: The function that takes a bunch of arguments and generates a elasticsearch Elasticsearch object. .. Note:: If you desire special behavior regarding bu...
python
def get_es(self, default_builder=get_es): """Returns the Elasticsearch object to use. :arg default_builder: The function that takes a bunch of arguments and generates a elasticsearch Elasticsearch object. .. Note:: If you desire special behavior regarding bu...
[ "def", "get_es", "(", "self", ",", "default_builder", "=", "get_es", ")", ":", "# .es() calls are incremental, so we go through them all and", "# update bits that are specified.", "args", "=", "{", "}", "for", "action", ",", "value", "in", "self", ".", "steps", ":", ...
Returns the Elasticsearch object to use. :arg default_builder: The function that takes a bunch of arguments and generates a elasticsearch Elasticsearch object. .. Note:: If you desire special behavior regarding building the Elasticsearch object for this S...
[ "Returns", "the", "Elasticsearch", "object", "to", "use", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1439-L1462
train
mozilla/elasticutils
elasticutils/__init__.py
S.get_indexes
def get_indexes(self, default_indexes=DEFAULT_INDEXES): """Returns the list of indexes to act on.""" for action, value in reversed(self.steps): if action == 'indexes': return list(value) if self.type is not None: indexes = self.type.get_index() ...
python
def get_indexes(self, default_indexes=DEFAULT_INDEXES): """Returns the list of indexes to act on.""" for action, value in reversed(self.steps): if action == 'indexes': return list(value) if self.type is not None: indexes = self.type.get_index() ...
[ "def", "get_indexes", "(", "self", ",", "default_indexes", "=", "DEFAULT_INDEXES", ")", ":", "for", "action", ",", "value", "in", "reversed", "(", "self", ".", "steps", ")", ":", "if", "action", "==", "'indexes'", ":", "return", "list", "(", "value", ")"...
Returns the list of indexes to act on.
[ "Returns", "the", "list", "of", "indexes", "to", "act", "on", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1464-L1476
train
mozilla/elasticutils
elasticutils/__init__.py
S.get_doctypes
def get_doctypes(self, default_doctypes=DEFAULT_DOCTYPES): """Returns the list of doctypes to use.""" for action, value in reversed(self.steps): if action == 'doctypes': return list(value) if self.type is not None: return [self.type.get_mapping_type_name(...
python
def get_doctypes(self, default_doctypes=DEFAULT_DOCTYPES): """Returns the list of doctypes to use.""" for action, value in reversed(self.steps): if action == 'doctypes': return list(value) if self.type is not None: return [self.type.get_mapping_type_name(...
[ "def", "get_doctypes", "(", "self", ",", "default_doctypes", "=", "DEFAULT_DOCTYPES", ")", ":", "for", "action", ",", "value", "in", "reversed", "(", "self", ".", "steps", ")", ":", "if", "action", "==", "'doctypes'", ":", "return", "list", "(", "value", ...
Returns the list of doctypes to use.
[ "Returns", "the", "list", "of", "doctypes", "to", "use", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1478-L1487
train
mozilla/elasticutils
elasticutils/__init__.py
S.raw
def raw(self): """ Build query and passes to Elasticsearch, then returns the raw format returned. """ qs = self.build_search() es = self.get_es() index = self.get_indexes() doc_type = self.get_doctypes() if doc_type and not index: rai...
python
def raw(self): """ Build query and passes to Elasticsearch, then returns the raw format returned. """ qs = self.build_search() es = self.get_es() index = self.get_indexes() doc_type = self.get_doctypes() if doc_type and not index: rai...
[ "def", "raw", "(", "self", ")", ":", "qs", "=", "self", ".", "build_search", "(", ")", "es", "=", "self", ".", "get_es", "(", ")", "index", "=", "self", ".", "get_indexes", "(", ")", "doc_type", "=", "self", ".", "get_doctypes", "(", ")", "if", "...
Build query and passes to Elasticsearch, then returns the raw format returned.
[ "Build", "query", "and", "passes", "to", "Elasticsearch", "then", "returns", "the", "raw", "format", "returned", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1489-L1514
train
mozilla/elasticutils
elasticutils/__init__.py
MLT.get_es
def get_es(self): """Returns an `Elasticsearch`. * If there's an s, then it returns that `Elasticsearch`. * If the es was provided in the constructor, then it returns that `Elasticsearch`. * Otherwise, it creates a new `Elasticsearch` and returns that. Overr...
python
def get_es(self): """Returns an `Elasticsearch`. * If there's an s, then it returns that `Elasticsearch`. * If the es was provided in the constructor, then it returns that `Elasticsearch`. * Otherwise, it creates a new `Elasticsearch` and returns that. Overr...
[ "def", "get_es", "(", "self", ")", ":", "if", "self", ".", "s", ":", "return", "self", ".", "s", ".", "get_es", "(", ")", "return", "self", ".", "es", "or", "get_es", "(", ")" ]
Returns an `Elasticsearch`. * If there's an s, then it returns that `Elasticsearch`. * If the es was provided in the constructor, then it returns that `Elasticsearch`. * Otherwise, it creates a new `Elasticsearch` and returns that. Override this if that behavior isn...
[ "Returns", "an", "Elasticsearch", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1721-L1736
train
mozilla/elasticutils
elasticutils/__init__.py
MLT.raw
def raw(self): """ Build query and passes to `Elasticsearch`, then returns the raw format returned. """ es = self.get_es() params = dict(self.query_params) mlt_fields = self.mlt_fields or params.pop('mlt_fields', []) body = self.s.build_search() if self....
python
def raw(self): """ Build query and passes to `Elasticsearch`, then returns the raw format returned. """ es = self.get_es() params = dict(self.query_params) mlt_fields = self.mlt_fields or params.pop('mlt_fields', []) body = self.s.build_search() if self....
[ "def", "raw", "(", "self", ")", ":", "es", "=", "self", ".", "get_es", "(", ")", "params", "=", "dict", "(", "self", ".", "query_params", ")", "mlt_fields", "=", "self", ".", "mlt_fields", "or", "params", ".", "pop", "(", "'mlt_fields'", ",", "[", ...
Build query and passes to `Elasticsearch`, then returns the raw format returned.
[ "Build", "query", "and", "passes", "to", "Elasticsearch", "then", "returns", "the", "raw", "format", "returned", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1738-L1756
train
mozilla/elasticutils
elasticutils/__init__.py
MLT._do_search
def _do_search(self): """ Perform the mlt call, then convert that raw format into a SearchResults instance and return it. """ if self._results_cache is None: response = self.raw() results = self.to_python(response.get('hits', {}).get('hits', [])) ...
python
def _do_search(self): """ Perform the mlt call, then convert that raw format into a SearchResults instance and return it. """ if self._results_cache is None: response = self.raw() results = self.to_python(response.get('hits', {}).get('hits', [])) ...
[ "def", "_do_search", "(", "self", ")", ":", "if", "self", ".", "_results_cache", "is", "None", ":", "response", "=", "self", ".", "raw", "(", ")", "results", "=", "self", ".", "to_python", "(", "response", ".", "get", "(", "'hits'", ",", "{", "}", ...
Perform the mlt call, then convert that raw format into a SearchResults instance and return it.
[ "Perform", "the", "mlt", "call", "then", "convert", "that", "raw", "format", "into", "a", "SearchResults", "instance", "and", "return", "it", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1758-L1768
train
mozilla/elasticutils
elasticutils/__init__.py
Indexable.index
def index(cls, document, id_=None, overwrite_existing=True, es=None, index=None): """Adds or updates a document to the index :arg document: Python dict of key/value pairs representing the document .. Note:: This must be serializable into JSON. ...
python
def index(cls, document, id_=None, overwrite_existing=True, es=None, index=None): """Adds or updates a document to the index :arg document: Python dict of key/value pairs representing the document .. Note:: This must be serializable into JSON. ...
[ "def", "index", "(", "cls", ",", "document", ",", "id_", "=", "None", ",", "overwrite_existing", "=", "True", ",", "es", "=", "None", ",", "index", "=", "None", ")", ":", "if", "es", "is", "None", ":", "es", "=", "cls", ".", "get_es", "(", ")", ...
Adds or updates a document to the index :arg document: Python dict of key/value pairs representing the document .. Note:: This must be serializable into JSON. :arg id_: the id of the document .. Note:: If you don't provide an ``id_`...
[ "Adds", "or", "updates", "a", "document", "to", "the", "index" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L2182-L2227
train
mozilla/elasticutils
elasticutils/__init__.py
Indexable.bulk_index
def bulk_index(cls, documents, id_field='id', es=None, index=None): """Adds or updates a batch of documents. :arg documents: List of Python dicts representing individual documents to be added to the index .. Note:: This must be serializable into JSON. :...
python
def bulk_index(cls, documents, id_field='id', es=None, index=None): """Adds or updates a batch of documents. :arg documents: List of Python dicts representing individual documents to be added to the index .. Note:: This must be serializable into JSON. :...
[ "def", "bulk_index", "(", "cls", ",", "documents", ",", "id_field", "=", "'id'", ",", "es", "=", "None", ",", "index", "=", "None", ")", ":", "if", "es", "is", "None", ":", "es", "=", "cls", ".", "get_es", "(", ")", "if", "index", "is", "None", ...
Adds or updates a batch of documents. :arg documents: List of Python dicts representing individual documents to be added to the index .. Note:: This must be serializable into JSON. :arg id_field: The name of the field to use as the document id. This...
[ "Adds", "or", "updates", "a", "batch", "of", "documents", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L2230-L2270
train
mozilla/elasticutils
elasticutils/__init__.py
Indexable.unindex
def unindex(cls, id_, es=None, index=None): """Removes a particular item from the search index. :arg id_: The Elasticsearch id for the document to remove from the index. :arg es: The `Elasticsearch` to use. If you don't specify an `Elasticsearch`, it'll use `cls.get_es(...
python
def unindex(cls, id_, es=None, index=None): """Removes a particular item from the search index. :arg id_: The Elasticsearch id for the document to remove from the index. :arg es: The `Elasticsearch` to use. If you don't specify an `Elasticsearch`, it'll use `cls.get_es(...
[ "def", "unindex", "(", "cls", ",", "id_", ",", "es", "=", "None", ",", "index", "=", "None", ")", ":", "if", "es", "is", "None", ":", "es", "=", "cls", ".", "get_es", "(", ")", "if", "index", "is", "None", ":", "index", "=", "cls", ".", "get_...
Removes a particular item from the search index. :arg id_: The Elasticsearch id for the document to remove from the index. :arg es: The `Elasticsearch` to use. If you don't specify an `Elasticsearch`, it'll use `cls.get_es()`. :arg index: The name of the index to use. ...
[ "Removes", "a", "particular", "item", "from", "the", "search", "index", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L2273-L2292
train
mozilla/elasticutils
elasticutils/__init__.py
Indexable.refresh_index
def refresh_index(cls, es=None, index=None): """Refreshes the index. Elasticsearch will update the index periodically automatically. If you need to see the documents you just indexed in your search results right now, you should call `refresh_index` as soon as you're done indexin...
python
def refresh_index(cls, es=None, index=None): """Refreshes the index. Elasticsearch will update the index periodically automatically. If you need to see the documents you just indexed in your search results right now, you should call `refresh_index` as soon as you're done indexin...
[ "def", "refresh_index", "(", "cls", ",", "es", "=", "None", ",", "index", "=", "None", ")", ":", "if", "es", "is", "None", ":", "es", "=", "cls", ".", "get_es", "(", ")", "if", "index", "is", "None", ":", "index", "=", "cls", ".", "get_index", ...
Refreshes the index. Elasticsearch will update the index periodically automatically. If you need to see the documents you just indexed in your search results right now, you should call `refresh_index` as soon as you're done indexing. This is particularly helpful for unit tests. ...
[ "Refreshes", "the", "index", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L2295-L2317
train
mozilla/elasticutils
elasticutils/monkeypatch.py
monkeypatch_es
def monkeypatch_es(): """Monkey patch for elasticsearch-py 1.0+ to make it work with ES 0.90 1. tweaks elasticsearch.client.bulk to normalize return status codes .. Note:: We can nix this whe we drop support for ES 0.90. """ if _monkeypatched_es: return def normalize_bulk_ret...
python
def monkeypatch_es(): """Monkey patch for elasticsearch-py 1.0+ to make it work with ES 0.90 1. tweaks elasticsearch.client.bulk to normalize return status codes .. Note:: We can nix this whe we drop support for ES 0.90. """ if _monkeypatched_es: return def normalize_bulk_ret...
[ "def", "monkeypatch_es", "(", ")", ":", "if", "_monkeypatched_es", ":", "return", "def", "normalize_bulk_return", "(", "fun", ")", ":", "\"\"\"Set's \"ok\" based on \"status\" if \"status\" exists\"\"\"", "@", "wraps", "(", "fun", ")", "def", "_fixed_bulk", "(", "self...
Monkey patch for elasticsearch-py 1.0+ to make it work with ES 0.90 1. tweaks elasticsearch.client.bulk to normalize return status codes .. Note:: We can nix this whe we drop support for ES 0.90.
[ "Monkey", "patch", "for", "elasticsearch", "-", "py", "1", ".", "0", "+", "to", "make", "it", "work", "with", "ES", "0", ".", "90" ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/monkeypatch.py#L9-L40
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/views.py
EntriesView.get_context_data
def get_context_data(self, **kwargs): """ Returns view context dictionary. :rtype: dict. """ kwargs.update({ 'entries': Entry.objects.get_for_tag( self.kwargs.get('slug', 0) ) }) return super(EntriesView, self).get_context...
python
def get_context_data(self, **kwargs): """ Returns view context dictionary. :rtype: dict. """ kwargs.update({ 'entries': Entry.objects.get_for_tag( self.kwargs.get('slug', 0) ) }) return super(EntriesView, self).get_context...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "'entries'", ":", "Entry", ".", "objects", ".", "get_for_tag", "(", "self", ".", "kwargs", ".", "get", "(", "'slug'", ",", "0", ")", ")", ...
Returns view context dictionary. :rtype: dict.
[ "Returns", "view", "context", "dictionary", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/views.py#L28-L40
train
jaraco/keyrings.alt
keyrings/alt/file_base.py
Keyring.get_password
def get_password(self, service, username): """ Read the password from the file. """ assoc = self._generate_assoc(service, username) service = escape_for_ini(service) username = escape_for_ini(username) # load the passwords from the file config = configpar...
python
def get_password(self, service, username): """ Read the password from the file. """ assoc = self._generate_assoc(service, username) service = escape_for_ini(service) username = escape_for_ini(username) # load the passwords from the file config = configpar...
[ "def", "get_password", "(", "self", ",", "service", ",", "username", ")", ":", "assoc", "=", "self", ".", "_generate_assoc", "(", "service", ",", "username", ")", "service", "=", "escape_for_ini", "(", "service", ")", "username", "=", "escape_for_ini", "(", ...
Read the password from the file.
[ "Read", "the", "password", "from", "the", "file", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file_base.py#L96-L123
train
jaraco/keyrings.alt
keyrings/alt/file_base.py
Keyring.set_password
def set_password(self, service, username, password): """Write the password in the file. """ if not username: # https://github.com/jaraco/keyrings.alt/issues/21 raise ValueError("Username cannot be blank.") if not isinstance(password, string_types): rai...
python
def set_password(self, service, username, password): """Write the password in the file. """ if not username: # https://github.com/jaraco/keyrings.alt/issues/21 raise ValueError("Username cannot be blank.") if not isinstance(password, string_types): rai...
[ "def", "set_password", "(", "self", ",", "service", ",", "username", ",", "password", ")", ":", "if", "not", "username", ":", "# https://github.com/jaraco/keyrings.alt/issues/21", "raise", "ValueError", "(", "\"Username cannot be blank.\"", ")", "if", "not", "isinstan...
Write the password in the file.
[ "Write", "the", "password", "in", "the", "file", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file_base.py#L125-L139
train
jaraco/keyrings.alt
keyrings/alt/file_base.py
Keyring._ensure_file_path
def _ensure_file_path(self): """ Ensure the storage path exists. If it doesn't, create it with "go-rwx" permissions. """ storage_root = os.path.dirname(self.file_path) needs_storage_root = storage_root and not os.path.isdir(storage_root) if needs_storage_root: # ...
python
def _ensure_file_path(self): """ Ensure the storage path exists. If it doesn't, create it with "go-rwx" permissions. """ storage_root = os.path.dirname(self.file_path) needs_storage_root = storage_root and not os.path.isdir(storage_root) if needs_storage_root: # ...
[ "def", "_ensure_file_path", "(", "self", ")", ":", "storage_root", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "file_path", ")", "needs_storage_root", "=", "storage_root", "and", "not", "os", ".", "path", ".", "isdir", "(", "storage_root", ")...
Ensure the storage path exists. If it doesn't, create it with "go-rwx" permissions.
[ "Ensure", "the", "storage", "path", "exists", ".", "If", "it", "doesn", "t", "create", "it", "with", "go", "-", "rwx", "permissions", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file_base.py#L167-L181
train
jaraco/keyrings.alt
keyrings/alt/file_base.py
Keyring.delete_password
def delete_password(self, service, username): """Delete the password for the username of the service. """ service = escape_for_ini(service) username = escape_for_ini(username) config = configparser.RawConfigParser() if os.path.exists(self.file_path): config.re...
python
def delete_password(self, service, username): """Delete the password for the username of the service. """ service = escape_for_ini(service) username = escape_for_ini(username) config = configparser.RawConfigParser() if os.path.exists(self.file_path): config.re...
[ "def", "delete_password", "(", "self", ",", "service", ",", "username", ")", ":", "service", "=", "escape_for_ini", "(", "service", ")", "username", "=", "escape_for_ini", "(", "username", ")", "config", "=", "configparser", ".", "RawConfigParser", "(", ")", ...
Delete the password for the username of the service.
[ "Delete", "the", "password", "for", "the", "username", "of", "the", "service", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file_base.py#L183-L198
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/apps.py
WagtailRelationsAppConfig.applicable_models
def applicable_models(self): """ Returns a list of model classes that subclass Page and include a "tags" field. :rtype: list. """ Page = apps.get_model('wagtailcore', 'Page') applicable = [] for model in apps.get_models(): ...
python
def applicable_models(self): """ Returns a list of model classes that subclass Page and include a "tags" field. :rtype: list. """ Page = apps.get_model('wagtailcore', 'Page') applicable = [] for model in apps.get_models(): ...
[ "def", "applicable_models", "(", "self", ")", ":", "Page", "=", "apps", ".", "get_model", "(", "'wagtailcore'", ",", "'Page'", ")", "applicable", "=", "[", "]", "for", "model", "in", "apps", ".", "get_models", "(", ")", ":", "meta", "=", "getattr", "("...
Returns a list of model classes that subclass Page and include a "tags" field. :rtype: list.
[ "Returns", "a", "list", "of", "model", "classes", "that", "subclass", "Page", "and", "include", "a", "tags", "field", ".", ":", "rtype", ":", "list", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/apps.py#L17-L34
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/apps.py
WagtailRelationsAppConfig.add_relationship_panels
def add_relationship_panels(self): """ Add edit handler that includes "related" panels to applicable model classes that don't explicitly define their own edit handler. """ from wagtailplus.utils.edit_handlers import add_panel_to_edit_handler from wagtailplus.wagtail...
python
def add_relationship_panels(self): """ Add edit handler that includes "related" panels to applicable model classes that don't explicitly define their own edit handler. """ from wagtailplus.utils.edit_handlers import add_panel_to_edit_handler from wagtailplus.wagtail...
[ "def", "add_relationship_panels", "(", "self", ")", ":", "from", "wagtailplus", ".", "utils", ".", "edit_handlers", "import", "add_panel_to_edit_handler", "from", "wagtailplus", ".", "wagtailrelations", ".", "edit_handlers", "import", "RelatedPanel", "for", "model", "...
Add edit handler that includes "related" panels to applicable model classes that don't explicitly define their own edit handler.
[ "Add", "edit", "handler", "that", "includes", "related", "panels", "to", "applicable", "model", "classes", "that", "don", "t", "explicitly", "define", "their", "own", "edit", "handler", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/apps.py#L36-L45
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/apps.py
WagtailRelationsAppConfig.add_relationship_methods
def add_relationship_methods(self): """ Adds relationship methods to applicable model classes. """ Entry = apps.get_model('wagtailrelations', 'Entry') @cached_property def related(instance): return instance.get_related() @cached_property ...
python
def add_relationship_methods(self): """ Adds relationship methods to applicable model classes. """ Entry = apps.get_model('wagtailrelations', 'Entry') @cached_property def related(instance): return instance.get_related() @cached_property ...
[ "def", "add_relationship_methods", "(", "self", ")", ":", "Entry", "=", "apps", ".", "get_model", "(", "'wagtailrelations'", ",", "'Entry'", ")", "@", "cached_property", "def", "related", "(", "instance", ")", ":", "return", "instance", ".", "get_related", "("...
Adds relationship methods to applicable model classes.
[ "Adds", "relationship", "methods", "to", "applicable", "model", "classes", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/apps.py#L47-L104
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/apps.py
WagtailRelationsAppConfig.ready
def ready(self): """ Finalizes application configuration. """ import wagtailplus.wagtailrelations.signals.handlers self.add_relationship_panels() self.add_relationship_methods() super(WagtailRelationsAppConfig, self).ready()
python
def ready(self): """ Finalizes application configuration. """ import wagtailplus.wagtailrelations.signals.handlers self.add_relationship_panels() self.add_relationship_methods() super(WagtailRelationsAppConfig, self).ready()
[ "def", "ready", "(", "self", ")", ":", "import", "wagtailplus", ".", "wagtailrelations", ".", "signals", ".", "handlers", "self", ".", "add_relationship_panels", "(", ")", "self", ".", "add_relationship_methods", "(", ")", "super", "(", "WagtailRelationsAppConfig"...
Finalizes application configuration.
[ "Finalizes", "application", "configuration", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/apps.py#L106-L114
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/apps.py
WagtailRollbacksAppConfig.applicable_models
def applicable_models(self): """ Returns a list of model classes that subclass Page. :rtype: list. """ Page = apps.get_model('wagtailcore', 'Page') applicable = [] for model in apps.get_models(): if issubclass(model, Page): ...
python
def applicable_models(self): """ Returns a list of model classes that subclass Page. :rtype: list. """ Page = apps.get_model('wagtailcore', 'Page') applicable = [] for model in apps.get_models(): if issubclass(model, Page): ...
[ "def", "applicable_models", "(", "self", ")", ":", "Page", "=", "apps", ".", "get_model", "(", "'wagtailcore'", ",", "'Page'", ")", "applicable", "=", "[", "]", "for", "model", "in", "apps", ".", "get_models", "(", ")", ":", "if", "issubclass", "(", "m...
Returns a list of model classes that subclass Page. :rtype: list.
[ "Returns", "a", "list", "of", "model", "classes", "that", "subclass", "Page", ".", ":", "rtype", ":", "list", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/apps.py#L20-L33
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/apps.py
WagtailRollbacksAppConfig.add_rollback_panels
def add_rollback_panels(self): """ Adds rollback panel to applicable model class's edit handlers. """ from wagtailplus.utils.edit_handlers import add_panel_to_edit_handler from wagtailplus.wagtailrollbacks.edit_handlers import HistoryPanel for model in self.applic...
python
def add_rollback_panels(self): """ Adds rollback panel to applicable model class's edit handlers. """ from wagtailplus.utils.edit_handlers import add_panel_to_edit_handler from wagtailplus.wagtailrollbacks.edit_handlers import HistoryPanel for model in self.applic...
[ "def", "add_rollback_panels", "(", "self", ")", ":", "from", "wagtailplus", ".", "utils", ".", "edit_handlers", "import", "add_panel_to_edit_handler", "from", "wagtailplus", ".", "wagtailrollbacks", ".", "edit_handlers", "import", "HistoryPanel", "for", "model", "in",...
Adds rollback panel to applicable model class's edit handlers.
[ "Adds", "rollback", "panel", "to", "applicable", "model", "class", "s", "edit", "handlers", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/apps.py#L35-L43
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/apps.py
WagtailRollbacksAppConfig.add_rollback_methods
def add_rollback_methods(): """ Adds rollback methods to applicable model classes. """ # Modified Page.save_revision method. def page_rollback(instance, revision_id, user=None, submitted_for_moderation=False, approved_go_live_at=None, changed=True): old_revision...
python
def add_rollback_methods(): """ Adds rollback methods to applicable model classes. """ # Modified Page.save_revision method. def page_rollback(instance, revision_id, user=None, submitted_for_moderation=False, approved_go_live_at=None, changed=True): old_revision...
[ "def", "add_rollback_methods", "(", ")", ":", "# Modified Page.save_revision method.\r", "def", "page_rollback", "(", "instance", ",", "revision_id", ",", "user", "=", "None", ",", "submitted_for_moderation", "=", "False", ",", "approved_go_live_at", "=", "None", ",",...
Adds rollback methods to applicable model classes.
[ "Adds", "rollback", "methods", "to", "applicable", "model", "classes", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/apps.py#L46-L90
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/apps.py
WagtailRollbacksAppConfig.ready
def ready(self): """ Finalizes application configuration. """ self.add_rollback_panels() self.add_rollback_methods() super(WagtailRollbacksAppConfig, self).ready()
python
def ready(self): """ Finalizes application configuration. """ self.add_rollback_panels() self.add_rollback_methods() super(WagtailRollbacksAppConfig, self).ready()
[ "def", "ready", "(", "self", ")", ":", "self", ".", "add_rollback_panels", "(", ")", "self", ".", "add_rollback_methods", "(", ")", "super", "(", "WagtailRollbacksAppConfig", ",", "self", ")", ".", "ready", "(", ")" ]
Finalizes application configuration.
[ "Finalizes", "application", "configuration", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/apps.py#L92-L98
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py
get_related
def get_related(page): """ Returns list of related Entry instances for specified page. :param page: the page instance. :rtype: list. """ related = [] entry = Entry.get_for_model(page) if entry: related = entry.related return related
python
def get_related(page): """ Returns list of related Entry instances for specified page. :param page: the page instance. :rtype: list. """ related = [] entry = Entry.get_for_model(page) if entry: related = entry.related return related
[ "def", "get_related", "(", "page", ")", ":", "related", "=", "[", "]", "entry", "=", "Entry", ".", "get_for_model", "(", "page", ")", "if", "entry", ":", "related", "=", "entry", ".", "related", "return", "related" ]
Returns list of related Entry instances for specified page. :param page: the page instance. :rtype: list.
[ "Returns", "list", "of", "related", "Entry", "instances", "for", "specified", "page", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py#L17-L30
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py
get_related_entry_admin_url
def get_related_entry_admin_url(entry): """ Returns admin URL for specified entry instance. :param entry: the entry instance. :return: str. """ namespaces = { Document: 'wagtaildocs:edit', Link: 'wagtaillinks:edit', Page: 'wagtailadmin_pages:edit', } ...
python
def get_related_entry_admin_url(entry): """ Returns admin URL for specified entry instance. :param entry: the entry instance. :return: str. """ namespaces = { Document: 'wagtaildocs:edit', Link: 'wagtaillinks:edit', Page: 'wagtailadmin_pages:edit', } ...
[ "def", "get_related_entry_admin_url", "(", "entry", ")", ":", "namespaces", "=", "{", "Document", ":", "'wagtaildocs:edit'", ",", "Link", ":", "'wagtaillinks:edit'", ",", "Page", ":", "'wagtailadmin_pages:edit'", ",", "}", "for", "cls", ",", "url", "in", "namesp...
Returns admin URL for specified entry instance. :param entry: the entry instance. :return: str.
[ "Returns", "admin", "URL", "for", "specified", "entry", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py#L33-L50
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py
get_related_with_scores
def get_related_with_scores(page): """ Returns list of related tuples (Entry instance, score) for specified page. :param page: the page instance. :rtype: list. """ related = [] entry = Entry.get_for_model(page) if entry: related = entry.related_with_scores return rel...
python
def get_related_with_scores(page): """ Returns list of related tuples (Entry instance, score) for specified page. :param page: the page instance. :rtype: list. """ related = [] entry = Entry.get_for_model(page) if entry: related = entry.related_with_scores return rel...
[ "def", "get_related_with_scores", "(", "page", ")", ":", "related", "=", "[", "]", "entry", "=", "Entry", ".", "get_for_model", "(", "page", ")", "if", "entry", ":", "related", "=", "entry", ".", "related_with_scores", "return", "related" ]
Returns list of related tuples (Entry instance, score) for specified page. :param page: the page instance. :rtype: list.
[ "Returns", "list", "of", "related", "tuples", "(", "Entry", "instance", "score", ")", "for", "specified", "page", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py#L53-L67
train
jaraco/keyrings.alt
keyrings/alt/multi.py
MultipartKeyringWrapper.get_password
def get_password(self, service, username): """Get password of the username for the service """ init_part = self._keyring.get_password(service, username) if init_part: parts = [init_part] i = 1 while True: next_part = self._keyring.get_p...
python
def get_password(self, service, username): """Get password of the username for the service """ init_part = self._keyring.get_password(service, username) if init_part: parts = [init_part] i = 1 while True: next_part = self._keyring.get_p...
[ "def", "get_password", "(", "self", ",", "service", ",", "username", ")", ":", "init_part", "=", "self", ".", "_keyring", ".", "get_password", "(", "service", ",", "username", ")", "if", "init_part", ":", "parts", "=", "[", "init_part", "]", "i", "=", ...
Get password of the username for the service
[ "Get", "password", "of", "the", "username", "for", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/multi.py#L24-L41
train
jaraco/keyrings.alt
keyrings/alt/multi.py
MultipartKeyringWrapper.set_password
def set_password(self, service, username, password): """Set password for the username of the service """ segments = range(0, len(password), self._max_password_size) password_parts = [ password[i:i + self._max_password_size] for i in segments] for i, password_part in e...
python
def set_password(self, service, username, password): """Set password for the username of the service """ segments = range(0, len(password), self._max_password_size) password_parts = [ password[i:i + self._max_password_size] for i in segments] for i, password_part in e...
[ "def", "set_password", "(", "self", ",", "service", ",", "username", ",", "password", ")", ":", "segments", "=", "range", "(", "0", ",", "len", "(", "password", ")", ",", "self", ".", "_max_password_size", ")", "password_parts", "=", "[", "password", "["...
Set password for the username of the service
[ "Set", "password", "for", "the", "username", "of", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/multi.py#L43-L53
train
rfosterslo/wagtailplus
wagtailplus/wagtaillinks/rich_text.py
LinkHandler.expand_db_attributes
def expand_db_attributes(attrs, for_editor): """ Given a dictionary of attributes, find the corresponding link instance and return its HTML representation. :param attrs: dictionary of link attributes. :param for_editor: whether or not HTML is for editor. :rtype: str. ...
python
def expand_db_attributes(attrs, for_editor): """ Given a dictionary of attributes, find the corresponding link instance and return its HTML representation. :param attrs: dictionary of link attributes. :param for_editor: whether or not HTML is for editor. :rtype: str. ...
[ "def", "expand_db_attributes", "(", "attrs", ",", "for_editor", ")", ":", "try", ":", "editor_attrs", "=", "''", "link", "=", "Link", ".", "objects", ".", "get", "(", "id", "=", "attrs", "[", "'id'", "]", ")", "if", "for_editor", ":", "editor_attrs", "...
Given a dictionary of attributes, find the corresponding link instance and return its HTML representation. :param attrs: dictionary of link attributes. :param for_editor: whether or not HTML is for editor. :rtype: str.
[ "Given", "a", "dictionary", "of", "attributes", "find", "the", "corresponding", "link", "instance", "and", "return", "its", "HTML", "representation", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtaillinks/rich_text.py#L28-L52
train
jaraco/keyrings.alt
keyrings/alt/keyczar.py
BaseCrypter.crypter
def crypter(self): """The actual keyczar crypter""" if not hasattr(self, '_crypter'): # initialise the Keyczar keysets if not self.keyset_location: raise ValueError('No encrypted keyset location!') reader = keyczar.readers.CreateReader(self.keyset_loca...
python
def crypter(self): """The actual keyczar crypter""" if not hasattr(self, '_crypter'): # initialise the Keyczar keysets if not self.keyset_location: raise ValueError('No encrypted keyset location!') reader = keyczar.readers.CreateReader(self.keyset_loca...
[ "def", "crypter", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_crypter'", ")", ":", "# initialise the Keyczar keysets", "if", "not", "self", ".", "keyset_location", ":", "raise", "ValueError", "(", "'No encrypted keyset location!'", ")", "...
The actual keyczar crypter
[ "The", "actual", "keyczar", "crypter" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/keyczar.py#L39-L52
train
mozilla/elasticutils
elasticutils/contrib/django/tasks.py
index_objects
def index_objects(mapping_type, ids, chunk_size=100, es=None, index=None): """Index documents of a specified mapping type. This allows for asynchronous indexing. If a mapping_type extends Indexable, you can add a ``post_save`` hook for the model that it's based on like this:: @receiver(dbsign...
python
def index_objects(mapping_type, ids, chunk_size=100, es=None, index=None): """Index documents of a specified mapping type. This allows for asynchronous indexing. If a mapping_type extends Indexable, you can add a ``post_save`` hook for the model that it's based on like this:: @receiver(dbsign...
[ "def", "index_objects", "(", "mapping_type", ",", "ids", ",", "chunk_size", "=", "100", ",", "es", "=", "None", ",", "index", "=", "None", ")", ":", "if", "settings", ".", "ES_DISABLED", ":", "return", "log", ".", "debug", "(", "'Indexing objects {0}-{1}. ...
Index documents of a specified mapping type. This allows for asynchronous indexing. If a mapping_type extends Indexable, you can add a ``post_save`` hook for the model that it's based on like this:: @receiver(dbsignals.post_save, sender=MyModel) def update_in_index(sender, instance, **kw)...
[ "Index", "documents", "of", "a", "specified", "mapping", "type", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/contrib/django/tasks.py#L13-L65
train
mozilla/elasticutils
elasticutils/contrib/django/tasks.py
unindex_objects
def unindex_objects(mapping_type, ids, es=None, index=None): """Remove documents of a specified mapping_type from the index. This allows for asynchronous deleting. If a mapping_type extends Indexable, you can add a ``pre_delete`` hook for the model that it's based on like this:: @receiver(dbs...
python
def unindex_objects(mapping_type, ids, es=None, index=None): """Remove documents of a specified mapping_type from the index. This allows for asynchronous deleting. If a mapping_type extends Indexable, you can add a ``pre_delete`` hook for the model that it's based on like this:: @receiver(dbs...
[ "def", "unindex_objects", "(", "mapping_type", ",", "ids", ",", "es", "=", "None", ",", "index", "=", "None", ")", ":", "if", "settings", ".", "ES_DISABLED", ":", "return", "for", "id_", "in", "ids", ":", "mapping_type", ".", "unindex", "(", "id_", ","...
Remove documents of a specified mapping_type from the index. This allows for asynchronous deleting. If a mapping_type extends Indexable, you can add a ``pre_delete`` hook for the model that it's based on like this:: @receiver(dbsignals.pre_delete, sender=MyModel) def remove_from_index(sen...
[ "Remove", "documents", "of", "a", "specified", "mapping_type", "from", "the", "index", "." ]
b880cc5d51fb1079b0581255ec664c1ec934656e
https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/contrib/django/tasks.py#L69-L93
train
rfosterslo/wagtailplus
wagtailplus/wagtaillinks/views/chooser.py
LinkChooser.get_json
def get_json(self, link): """ Returns specified link instance as JSON. :param link: the link instance. :rtype: JSON. """ return json.dumps({ 'id': link.id, 'title': link.title, 'url': link.get_absolute_url(), ...
python
def get_json(self, link): """ Returns specified link instance as JSON. :param link: the link instance. :rtype: JSON. """ return json.dumps({ 'id': link.id, 'title': link.title, 'url': link.get_absolute_url(), ...
[ "def", "get_json", "(", "self", ",", "link", ")", ":", "return", "json", ".", "dumps", "(", "{", "'id'", ":", "link", ".", "id", ",", "'title'", ":", "link", ".", "title", ",", "'url'", ":", "link", ".", "get_absolute_url", "(", ")", ",", "'edit_li...
Returns specified link instance as JSON. :param link: the link instance. :rtype: JSON.
[ "Returns", "specified", "link", "instance", "as", "JSON", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtaillinks/views/chooser.py#L14-L29
train
jaraco/keyrings.alt
keyrings/alt/file.py
Encrypted._create_cipher
def _create_cipher(self, password, salt, IV): """ Create the cipher object to encrypt or decrypt a payload. """ from Crypto.Protocol.KDF import PBKDF2 from Crypto.Cipher import AES pw = PBKDF2(password, salt, dkLen=self.block_size) return AES.new(pw[:self.block_si...
python
def _create_cipher(self, password, salt, IV): """ Create the cipher object to encrypt or decrypt a payload. """ from Crypto.Protocol.KDF import PBKDF2 from Crypto.Cipher import AES pw = PBKDF2(password, salt, dkLen=self.block_size) return AES.new(pw[:self.block_si...
[ "def", "_create_cipher", "(", "self", ",", "password", ",", "salt", ",", "IV", ")", ":", "from", "Crypto", ".", "Protocol", ".", "KDF", "import", "PBKDF2", "from", "Crypto", ".", "Cipher", "import", "AES", "pw", "=", "PBKDF2", "(", "password", ",", "sa...
Create the cipher object to encrypt or decrypt a payload.
[ "Create", "the", "cipher", "object", "to", "encrypt", "or", "decrypt", "a", "payload", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file.py#L47-L54
train
jaraco/keyrings.alt
keyrings/alt/file.py
EncryptedKeyring._init_file
def _init_file(self): """ Initialize a new password file and set the reference password. """ self.keyring_key = self._get_new_password() # set a reference password, used to check that the password provided # matches for subsequent checks. self.set_password('keyri...
python
def _init_file(self): """ Initialize a new password file and set the reference password. """ self.keyring_key = self._get_new_password() # set a reference password, used to check that the password provided # matches for subsequent checks. self.set_password('keyri...
[ "def", "_init_file", "(", "self", ")", ":", "self", ".", "keyring_key", "=", "self", ".", "_get_new_password", "(", ")", "# set a reference password, used to check that the password provided", "# matches for subsequent checks.", "self", ".", "set_password", "(", "'keyring-...
Initialize a new password file and set the reference password.
[ "Initialize", "a", "new", "password", "file", "and", "set", "the", "reference", "password", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file.py#L101-L116
train
jaraco/keyrings.alt
keyrings/alt/file.py
EncryptedKeyring._check_file
def _check_file(self): """ Check if the file exists and has the expected password reference. """ if not os.path.exists(self.file_path): return False self._migrate() config = configparser.RawConfigParser() config.read(self.file_path) try: ...
python
def _check_file(self): """ Check if the file exists and has the expected password reference. """ if not os.path.exists(self.file_path): return False self._migrate() config = configparser.RawConfigParser() config.read(self.file_path) try: ...
[ "def", "_check_file", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "file_path", ")", ":", "return", "False", "self", ".", "_migrate", "(", ")", "config", "=", "configparser", ".", "RawConfigParser", "(", ")", ...
Check if the file exists and has the expected password reference.
[ "Check", "if", "the", "file", "exists", "and", "has", "the", "expected", "password", "reference", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file.py#L118-L139
train
jaraco/keyrings.alt
keyrings/alt/file.py
EncryptedKeyring._check_version
def _check_version(self, config): """ check for a valid version an existing scheme implies an existing version as well return True, if version is valid, and False otherwise """ try: self.file_version = config.get( escape_for_ini('keyring-setti...
python
def _check_version(self, config): """ check for a valid version an existing scheme implies an existing version as well return True, if version is valid, and False otherwise """ try: self.file_version = config.get( escape_for_ini('keyring-setti...
[ "def", "_check_version", "(", "self", ",", "config", ")", ":", "try", ":", "self", ".", "file_version", "=", "config", ".", "get", "(", "escape_for_ini", "(", "'keyring-setting'", ")", ",", "escape_for_ini", "(", "'version'", ")", ",", ")", "except", "(", ...
check for a valid version an existing scheme implies an existing version as well return True, if version is valid, and False otherwise
[ "check", "for", "a", "valid", "version", "an", "existing", "scheme", "implies", "an", "existing", "version", "as", "well" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file.py#L164-L178
train
jaraco/keyrings.alt
keyrings/alt/file.py
EncryptedKeyring._unlock
def _unlock(self): """ Unlock this keyring by getting the password for the keyring from the user. """ self.keyring_key = getpass.getpass( 'Please enter password for encrypted keyring: ') try: ref_pw = self.get_password('keyring-setting', 'password ...
python
def _unlock(self): """ Unlock this keyring by getting the password for the keyring from the user. """ self.keyring_key = getpass.getpass( 'Please enter password for encrypted keyring: ') try: ref_pw = self.get_password('keyring-setting', 'password ...
[ "def", "_unlock", "(", "self", ")", ":", "self", ".", "keyring_key", "=", "getpass", ".", "getpass", "(", "'Please enter password for encrypted keyring: '", ")", "try", ":", "ref_pw", "=", "self", ".", "get_password", "(", "'keyring-setting'", ",", "'password refe...
Unlock this keyring by getting the password for the keyring from the user.
[ "Unlock", "this", "keyring", "by", "getting", "the", "password", "for", "the", "keyring", "from", "the", "user", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file.py#L180-L192
train
jaraco/keyrings.alt
keyrings/alt/escape.py
_escape_char
def _escape_char(c): "Single char escape. Return the char, escaped if not already legal" if isinstance(c, int): c = _unichr(c) return c if c in LEGAL_CHARS else ESCAPE_FMT % ord(c)
python
def _escape_char(c): "Single char escape. Return the char, escaped if not already legal" if isinstance(c, int): c = _unichr(c) return c if c in LEGAL_CHARS else ESCAPE_FMT % ord(c)
[ "def", "_escape_char", "(", "c", ")", ":", "if", "isinstance", "(", "c", ",", "int", ")", ":", "c", "=", "_unichr", "(", "c", ")", "return", "c", "if", "c", "in", "LEGAL_CHARS", "else", "ESCAPE_FMT", "%", "ord", "(", "c", ")" ]
Single char escape. Return the char, escaped if not already legal
[ "Single", "char", "escape", ".", "Return", "the", "char", "escaped", "if", "not", "already", "legal" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/escape.py#L25-L29
train
jaraco/keyrings.alt
keyrings/alt/escape.py
unescape
def unescape(value): """ Inverse of escape. """ pattern = ESCAPE_FMT.replace('%02X', '(?P<code>[0-9A-Fa-f]{2})') # the pattern must be bytes to operate on bytes pattern_bytes = pattern.encode('ascii') re_esc = re.compile(pattern_bytes) return re_esc.sub(_unescape_code, value.encode('asci...
python
def unescape(value): """ Inverse of escape. """ pattern = ESCAPE_FMT.replace('%02X', '(?P<code>[0-9A-Fa-f]{2})') # the pattern must be bytes to operate on bytes pattern_bytes = pattern.encode('ascii') re_esc = re.compile(pattern_bytes) return re_esc.sub(_unescape_code, value.encode('asci...
[ "def", "unescape", "(", "value", ")", ":", "pattern", "=", "ESCAPE_FMT", ".", "replace", "(", "'%02X'", ",", "'(?P<code>[0-9A-Fa-f]{2})'", ")", "# the pattern must be bytes to operate on bytes", "pattern_bytes", "=", "pattern", ".", "encode", "(", "'ascii'", ")", "r...
Inverse of escape.
[ "Inverse", "of", "escape", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/escape.py#L45-L53
train
jaraco/keyrings.alt
keyrings/alt/Gnome.py
Keyring._find_passwords
def _find_passwords(self, service, username, deleting=False): """Get password of the username for the service """ passwords = [] service = self._safe_string(service) username = self._safe_string(username) for attrs_tuple in (('username', 'service'), ('user', 'domain')): ...
python
def _find_passwords(self, service, username, deleting=False): """Get password of the username for the service """ passwords = [] service = self._safe_string(service) username = self._safe_string(username) for attrs_tuple in (('username', 'service'), ('user', 'domain')): ...
[ "def", "_find_passwords", "(", "self", ",", "service", ",", "username", ",", "deleting", "=", "False", ")", ":", "passwords", "=", "[", "]", "service", "=", "self", ".", "_safe_string", "(", "service", ")", "username", "=", "self", ".", "_safe_string", "...
Get password of the username for the service
[ "Get", "password", "of", "the", "username", "for", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Gnome.py#L39-L61
train
jaraco/keyrings.alt
keyrings/alt/Gnome.py
Keyring.get_password
def get_password(self, service, username): """Get password of the username for the service """ items = self._find_passwords(service, username) if not items: return None secret = items[0].secret return ( secret if isinstance(secret, six...
python
def get_password(self, service, username): """Get password of the username for the service """ items = self._find_passwords(service, username) if not items: return None secret = items[0].secret return ( secret if isinstance(secret, six...
[ "def", "get_password", "(", "self", ",", "service", ",", "username", ")", ":", "items", "=", "self", ".", "_find_passwords", "(", "service", ",", "username", ")", "if", "not", "items", ":", "return", "None", "secret", "=", "items", "[", "0", "]", ".", ...
Get password of the username for the service
[ "Get", "password", "of", "the", "username", "for", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Gnome.py#L63-L75
train
jaraco/keyrings.alt
keyrings/alt/Gnome.py
Keyring.set_password
def set_password(self, service, username, password): """Set password for the username of the service """ service = self._safe_string(service) username = self._safe_string(username) password = self._safe_string(password) attrs = GnomeKeyring.Attribute.list_new() Gn...
python
def set_password(self, service, username, password): """Set password for the username of the service """ service = self._safe_string(service) username = self._safe_string(username) password = self._safe_string(password) attrs = GnomeKeyring.Attribute.list_new() Gn...
[ "def", "set_password", "(", "self", ",", "service", ",", "username", ",", "password", ")", ":", "service", "=", "self", ".", "_safe_string", "(", "service", ")", "username", "=", "self", ".", "_safe_string", "(", "username", ")", "password", "=", "self", ...
Set password for the username of the service
[ "Set", "password", "for", "the", "username", "of", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Gnome.py#L77-L96
train
jaraco/keyrings.alt
keyrings/alt/Gnome.py
Keyring.delete_password
def delete_password(self, service, username): """Delete the password for the username of the service. """ items = self._find_passwords(service, username, deleting=True) if not items: raise PasswordDeleteError("Password not found") for current in items: res...
python
def delete_password(self, service, username): """Delete the password for the username of the service. """ items = self._find_passwords(service, username, deleting=True) if not items: raise PasswordDeleteError("Password not found") for current in items: res...
[ "def", "delete_password", "(", "self", ",", "service", ",", "username", ")", ":", "items", "=", "self", ".", "_find_passwords", "(", "service", ",", "username", ",", "deleting", "=", "True", ")", "if", "not", "items", ":", "raise", "PasswordDeleteError", "...
Delete the password for the username of the service.
[ "Delete", "the", "password", "for", "the", "username", "of", "the", "service", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Gnome.py#L98-L110
train
jaraco/keyrings.alt
keyrings/alt/Gnome.py
Keyring._safe_string
def _safe_string(self, source, encoding='utf-8'): """Convert unicode to string as gnomekeyring barfs on unicode""" if not isinstance(source, str): return source.encode(encoding) return str(source)
python
def _safe_string(self, source, encoding='utf-8'): """Convert unicode to string as gnomekeyring barfs on unicode""" if not isinstance(source, str): return source.encode(encoding) return str(source)
[ "def", "_safe_string", "(", "self", ",", "source", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "not", "isinstance", "(", "source", ",", "str", ")", ":", "return", "source", ".", "encode", "(", "encoding", ")", "return", "str", "(", "source", ")" ]
Convert unicode to string as gnomekeyring barfs on unicode
[ "Convert", "unicode", "to", "string", "as", "gnomekeyring", "barfs", "on", "unicode" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Gnome.py#L112-L116
train
rfosterslo/wagtailplus
wagtailplus/wagtaillinks/views/links.py
CreateView.get_context_data
def get_context_data(self, **kwargs): """ Returns context dictionary for view. :rtype: dict. """ kwargs.update({ 'view': self, 'email_form': EmailLinkForm(), 'external_form': ExternalLinkForm(), 'type_email': ...
python
def get_context_data(self, **kwargs): """ Returns context dictionary for view. :rtype: dict. """ kwargs.update({ 'view': self, 'email_form': EmailLinkForm(), 'external_form': ExternalLinkForm(), 'type_email': ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "'view'", ":", "self", ",", "'email_form'", ":", "EmailLinkForm", "(", ")", ",", "'external_form'", ":", "ExternalLinkForm", "(", ")", ",", "'ty...
Returns context dictionary for view. :rtype: dict.
[ "Returns", "context", "dictionary", "for", "view", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtaillinks/views/links.py#L26-L49
train
rfosterslo/wagtailplus
wagtailplus/wagtaillinks/views/links.py
CreateView.post
def post(self, request, *args, **kwargs): """ Returns POST response. :param request: the request instance. :rtype: django.http.HttpResponse. """ form = None link_type = int(request.POST.get('link_type', 0)) if link_type == Link.LINK_TYPE_EMAIL: ...
python
def post(self, request, *args, **kwargs): """ Returns POST response. :param request: the request instance. :rtype: django.http.HttpResponse. """ form = None link_type = int(request.POST.get('link_type', 0)) if link_type == Link.LINK_TYPE_EMAIL: ...
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "form", "=", "None", "link_type", "=", "int", "(", "request", ".", "POST", ".", "get", "(", "'link_type'", ",", "0", ")", ")", "if", "link_type", "==...
Returns POST response. :param request: the request instance. :rtype: django.http.HttpResponse.
[ "Returns", "POST", "response", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtaillinks/views/links.py#L57-L78
train
rfosterslo/wagtailplus
wagtailplus/wagtaillinks/views/links.py
UpdateView.get_form_class
def get_form_class(self): """ Returns form class to use in the view. :rtype: django.forms.ModelForm. """ if self.object.link_type == Link.LINK_TYPE_EMAIL: return EmailLinkForm elif self.object.link_type == Link.LINK_TYPE_EXTERNAL: return ExternalL...
python
def get_form_class(self): """ Returns form class to use in the view. :rtype: django.forms.ModelForm. """ if self.object.link_type == Link.LINK_TYPE_EMAIL: return EmailLinkForm elif self.object.link_type == Link.LINK_TYPE_EXTERNAL: return ExternalL...
[ "def", "get_form_class", "(", "self", ")", ":", "if", "self", ".", "object", ".", "link_type", "==", "Link", ".", "LINK_TYPE_EMAIL", ":", "return", "EmailLinkForm", "elif", "self", ".", "object", ".", "link_type", "==", "Link", ".", "LINK_TYPE_EXTERNAL", ":"...
Returns form class to use in the view. :rtype: django.forms.ModelForm.
[ "Returns", "form", "class", "to", "use", "in", "the", "view", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtaillinks/views/links.py#L84-L95
train
jaraco/keyrings.alt
keyrings/alt/Windows.py
RegistryKeyring.get_password
def get_password(self, service, username): """Get password of the username for the service """ try: # fetch the password key = self._key_for_service(service) hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key) password_saved = winreg.QueryValueEx(...
python
def get_password(self, service, username): """Get password of the username for the service """ try: # fetch the password key = self._key_for_service(service) hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key) password_saved = winreg.QueryValueEx(...
[ "def", "get_password", "(", "self", ",", "service", ",", "username", ")", ":", "try", ":", "# fetch the password", "key", "=", "self", ".", "_key_for_service", "(", "service", ")", "hkey", "=", "winreg", ".", "OpenKey", "(", "winreg", ".", "HKEY_CURRENT_USER...
Get password of the username for the service
[ "Get", "password", "of", "the", "username", "for", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Windows.py#L86-L101
train
jaraco/keyrings.alt
keyrings/alt/Windows.py
RegistryKeyring.set_password
def set_password(self, service, username, password): """Write the password to the registry """ # encrypt the password password_encrypted = _win_crypto.encrypt(password.encode('utf-8')) # encode with base64 password_base64 = base64.encodestring(password_encrypted) ...
python
def set_password(self, service, username, password): """Write the password to the registry """ # encrypt the password password_encrypted = _win_crypto.encrypt(password.encode('utf-8')) # encode with base64 password_base64 = base64.encodestring(password_encrypted) ...
[ "def", "set_password", "(", "self", ",", "service", ",", "username", ",", "password", ")", ":", "# encrypt the password", "password_encrypted", "=", "_win_crypto", ".", "encrypt", "(", "password", ".", "encode", "(", "'utf-8'", ")", ")", "# encode with base64", ...
Write the password to the registry
[ "Write", "the", "password", "to", "the", "registry" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Windows.py#L103-L116
train
jaraco/keyrings.alt
keyrings/alt/Windows.py
RegistryKeyring.delete_password
def delete_password(self, service, username): """Delete the password for the username of the service. """ try: key_name = self._key_for_service(service) hkey = winreg.OpenKey( winreg.HKEY_CURRENT_USER, key_name, 0, winreg.KEY_ALL_ACCESS) ...
python
def delete_password(self, service, username): """Delete the password for the username of the service. """ try: key_name = self._key_for_service(service) hkey = winreg.OpenKey( winreg.HKEY_CURRENT_USER, key_name, 0, winreg.KEY_ALL_ACCESS) ...
[ "def", "delete_password", "(", "self", ",", "service", ",", "username", ")", ":", "try", ":", "key_name", "=", "self", ".", "_key_for_service", "(", "service", ")", "hkey", "=", "winreg", ".", "OpenKey", "(", "winreg", ".", "HKEY_CURRENT_USER", ",", "key_n...
Delete the password for the username of the service.
[ "Delete", "the", "password", "for", "the", "username", "of", "the", "service", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Windows.py#L118-L131
train
jaraco/keyrings.alt
keyrings/alt/pyfs.py
BasicKeyring.encrypt
def encrypt(self, password): """Encrypt the password. """ if not password or not self._crypter: return password or b'' return self._crypter.encrypt(password)
python
def encrypt(self, password): """Encrypt the password. """ if not password or not self._crypter: return password or b'' return self._crypter.encrypt(password)
[ "def", "encrypt", "(", "self", ",", "password", ")", ":", "if", "not", "password", "or", "not", "self", ".", "_crypter", ":", "return", "password", "or", "b''", "return", "self", ".", "_crypter", ".", "encrypt", "(", "password", ")" ]
Encrypt the password.
[ "Encrypt", "the", "password", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/pyfs.py#L71-L76
train
jaraco/keyrings.alt
keyrings/alt/pyfs.py
BasicKeyring.decrypt
def decrypt(self, password_encrypted): """Decrypt the password. """ if not password_encrypted or not self._crypter: return password_encrypted or b'' return self._crypter.decrypt(password_encrypted)
python
def decrypt(self, password_encrypted): """Decrypt the password. """ if not password_encrypted or not self._crypter: return password_encrypted or b'' return self._crypter.decrypt(password_encrypted)
[ "def", "decrypt", "(", "self", ",", "password_encrypted", ")", ":", "if", "not", "password_encrypted", "or", "not", "self", ".", "_crypter", ":", "return", "password_encrypted", "or", "b''", "return", "self", ".", "_crypter", ".", "decrypt", "(", "password_enc...
Decrypt the password.
[ "Decrypt", "the", "password", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/pyfs.py#L78-L83
train
jaraco/keyrings.alt
keyrings/alt/pyfs.py
BasicKeyring._open
def _open(self, mode='r'): """Open the password file in the specified mode """ open_file = None writeable = 'w' in mode or 'a' in mode or '+' in mode try: # NOTE: currently the MemOpener does not split off any filename # which causes errors on close(...
python
def _open(self, mode='r'): """Open the password file in the specified mode """ open_file = None writeable = 'w' in mode or 'a' in mode or '+' in mode try: # NOTE: currently the MemOpener does not split off any filename # which causes errors on close(...
[ "def", "_open", "(", "self", ",", "mode", "=", "'r'", ")", ":", "open_file", "=", "None", "writeable", "=", "'w'", "in", "mode", "or", "'a'", "in", "mode", "or", "'+'", "in", "mode", "try", ":", "# NOTE: currently the MemOpener does not split off any filename"...
Open the password file in the specified mode
[ "Open", "the", "password", "file", "in", "the", "specified", "mode" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/pyfs.py#L85-L158
train
jaraco/keyrings.alt
keyrings/alt/pyfs.py
BasicKeyring.config
def config(self): """load the passwords from the config file """ if not hasattr(self, '_config'): raw_config = configparser.RawConfigParser() f = self._open() if f: raw_config.readfp(f) f.close() self._config = raw_c...
python
def config(self): """load the passwords from the config file """ if not hasattr(self, '_config'): raw_config = configparser.RawConfigParser() f = self._open() if f: raw_config.readfp(f) f.close() self._config = raw_c...
[ "def", "config", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_config'", ")", ":", "raw_config", "=", "configparser", ".", "RawConfigParser", "(", ")", "f", "=", "self", ".", "_open", "(", ")", "if", "f", ":", "raw_config", ".",...
load the passwords from the config file
[ "load", "the", "passwords", "from", "the", "config", "file" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/pyfs.py#L161-L171
train
jaraco/keyrings.alt
keyrings/alt/pyfs.py
BasicKeyring.get_password
def get_password(self, service, username): """Read the password from the file. """ service = escape_for_ini(service) username = escape_for_ini(username) # fetch the password try: password_base64 = self.config.get(service, username).encode() # deco...
python
def get_password(self, service, username): """Read the password from the file. """ service = escape_for_ini(service) username = escape_for_ini(username) # fetch the password try: password_base64 = self.config.get(service, username).encode() # deco...
[ "def", "get_password", "(", "self", ",", "service", ",", "username", ")", ":", "service", "=", "escape_for_ini", "(", "service", ")", "username", "=", "escape_for_ini", "(", "username", ")", "# fetch the password", "try", ":", "password_base64", "=", "self", "...
Read the password from the file.
[ "Read", "the", "password", "from", "the", "file", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/pyfs.py#L173-L188
train
jaraco/keyrings.alt
keyrings/alt/pyfs.py
BasicKeyring.set_password
def set_password(self, service, username, password): """Write the password in the file. """ service = escape_for_ini(service) username = escape_for_ini(username) # encrypt the password password = password or '' password_encrypted = self.encrypt(password.encode('u...
python
def set_password(self, service, username, password): """Write the password in the file. """ service = escape_for_ini(service) username = escape_for_ini(username) # encrypt the password password = password or '' password_encrypted = self.encrypt(password.encode('u...
[ "def", "set_password", "(", "self", ",", "service", ",", "username", ",", "password", ")", ":", "service", "=", "escape_for_ini", "(", "service", ")", "username", "=", "escape_for_ini", "(", "username", ")", "# encrypt the password", "password", "=", "password",...
Write the password in the file.
[ "Write", "the", "password", "in", "the", "file", "." ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/pyfs.py#L190-L208
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/models.py
LiveEntryCategoryManager.get_queryset
def get_queryset(self): """ Returns queryset limited to categories with live Entry instances. :rtype: django.db.models.query.QuerySet. """ queryset = super(LiveEntryCategoryManager, self).get_queryset() return queryset.filter(tag__in=[ entry_tag.tag ...
python
def get_queryset(self): """ Returns queryset limited to categories with live Entry instances. :rtype: django.db.models.query.QuerySet. """ queryset = super(LiveEntryCategoryManager, self).get_queryset() return queryset.filter(tag__in=[ entry_tag.tag ...
[ "def", "get_queryset", "(", "self", ")", ":", "queryset", "=", "super", "(", "LiveEntryCategoryManager", ",", "self", ")", ".", "get_queryset", "(", ")", "return", "queryset", ".", "filter", "(", "tag__in", "=", "[", "entry_tag", ".", "tag", "for", "entry_...
Returns queryset limited to categories with live Entry instances. :rtype: django.db.models.query.QuerySet.
[ "Returns", "queryset", "limited", "to", "categories", "with", "live", "Entry", "instances", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/models.py#L33-L44
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/models.py
EntryManager.get_for_model
def get_for_model(self, model): """ Returns tuple (Entry instance, created) for specified model instance. :rtype: wagtailplus.wagtailrelations.models.Entry. """ return self.get_or_create( content_type = ContentType.objects.get_for_model(model), ...
python
def get_for_model(self, model): """ Returns tuple (Entry instance, created) for specified model instance. :rtype: wagtailplus.wagtailrelations.models.Entry. """ return self.get_or_create( content_type = ContentType.objects.get_for_model(model), ...
[ "def", "get_for_model", "(", "self", ",", "model", ")", ":", "return", "self", ".", "get_or_create", "(", "content_type", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "model", ")", ",", "object_id", "=", "model", ".", "pk", ")" ]
Returns tuple (Entry instance, created) for specified model instance. :rtype: wagtailplus.wagtailrelations.models.Entry.
[ "Returns", "tuple", "(", "Entry", "instance", "created", ")", "for", "specified", "model", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/models.py#L120-L130
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/models.py
EntryManager.get_for_tag
def get_for_tag(self, tag): """ Returns queryset of Entry instances assigned to specified tag, which can be a PK value, a slug value, or a Tag instance. :param tag: tag PK, slug, or instance. :rtype: django.db.models.query.QuerySet. """ tag_filter = {'tag': tag} ...
python
def get_for_tag(self, tag): """ Returns queryset of Entry instances assigned to specified tag, which can be a PK value, a slug value, or a Tag instance. :param tag: tag PK, slug, or instance. :rtype: django.db.models.query.QuerySet. """ tag_filter = {'tag': tag} ...
[ "def", "get_for_tag", "(", "self", ",", "tag", ")", ":", "tag_filter", "=", "{", "'tag'", ":", "tag", "}", "if", "isinstance", "(", "tag", ",", "six", ".", "integer_types", ")", ":", "tag_filter", "=", "{", "'tag_id'", ":", "tag", "}", "elif", "isins...
Returns queryset of Entry instances assigned to specified tag, which can be a PK value, a slug value, or a Tag instance. :param tag: tag PK, slug, or instance. :rtype: django.db.models.query.QuerySet.
[ "Returns", "queryset", "of", "Entry", "instances", "assigned", "to", "specified", "tag", "which", "can", "be", "a", "PK", "value", "a", "slug", "value", "or", "a", "Tag", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/models.py#L132-L151
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/models.py
EntryTagManager.for_category
def for_category(self, category, live_only=False): """ Returns queryset of EntryTag instances for specified category. :param category: the Category instance. :param live_only: flag to include only "live" entries. :rtype: django.db.models.query.QuerySet. """ filte...
python
def for_category(self, category, live_only=False): """ Returns queryset of EntryTag instances for specified category. :param category: the Category instance. :param live_only: flag to include only "live" entries. :rtype: django.db.models.query.QuerySet. """ filte...
[ "def", "for_category", "(", "self", ",", "category", ",", "live_only", "=", "False", ")", ":", "filters", "=", "{", "'tag'", ":", "category", ".", "tag", "}", "if", "live_only", ":", "filters", ".", "update", "(", "{", "'entry__live'", ":", "True", "}"...
Returns queryset of EntryTag instances for specified category. :param category: the Category instance. :param live_only: flag to include only "live" entries. :rtype: django.db.models.query.QuerySet.
[ "Returns", "queryset", "of", "EntryTag", "instances", "for", "specified", "category", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/models.py#L343-L356
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/models.py
EntryTagManager.related_to
def related_to(self, entry, live_only=False): """ Returns queryset of Entry instances related to specified Entry instance. :param entry: the Entry instance. :param live_only: flag to include only "live" entries. :rtype: django.db.models.query.QuerySet. """ ...
python
def related_to(self, entry, live_only=False): """ Returns queryset of Entry instances related to specified Entry instance. :param entry: the Entry instance. :param live_only: flag to include only "live" entries. :rtype: django.db.models.query.QuerySet. """ ...
[ "def", "related_to", "(", "self", ",", "entry", ",", "live_only", "=", "False", ")", ":", "filters", "=", "{", "'tag__in'", ":", "entry", ".", "tags", "}", "if", "live_only", ":", "filters", ".", "update", "(", "{", "'entry__live'", ":", "True", "}", ...
Returns queryset of Entry instances related to specified Entry instance. :param entry: the Entry instance. :param live_only: flag to include only "live" entries. :rtype: django.db.models.query.QuerySet.
[ "Returns", "queryset", "of", "Entry", "instances", "related", "to", "specified", "Entry", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/models.py#L365-L379
train
rfosterslo/wagtailplus
wagtailplus/utils/views/chooser.py
chosen_view_factory
def chosen_view_factory(chooser_cls): """ Returns a ChosenView class that extends specified chooser class. :param chooser_cls: the class to extend. :rtype: class. """ class ChosenView(chooser_cls): #noinspection PyUnusedLocal def get(self, request, *args, **kwargs): ...
python
def chosen_view_factory(chooser_cls): """ Returns a ChosenView class that extends specified chooser class. :param chooser_cls: the class to extend. :rtype: class. """ class ChosenView(chooser_cls): #noinspection PyUnusedLocal def get(self, request, *args, **kwargs): ...
[ "def", "chosen_view_factory", "(", "chooser_cls", ")", ":", "class", "ChosenView", "(", "chooser_cls", ")", ":", "#noinspection PyUnusedLocal", "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n ...
Returns a ChosenView class that extends specified chooser class. :param chooser_cls: the class to extend. :rtype: class.
[ "Returns", "a", "ChosenView", "class", "that", "extends", "specified", "chooser", "class", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/utils/views/chooser.py#L163-L215
train
rfosterslo/wagtailplus
wagtailplus/utils/views/chooser.py
ChooserView.form_invalid
def form_invalid(self, form): """ Processes an invalid form submittal. :param form: the form instance. :rtype: django.http.HttpResponse. """ context = self.get_context_data(form=form) #noinspection PyUnresolvedReferences return render_modal_workflow( ...
python
def form_invalid(self, form): """ Processes an invalid form submittal. :param form: the form instance. :rtype: django.http.HttpResponse. """ context = self.get_context_data(form=form) #noinspection PyUnresolvedReferences return render_modal_workflow( ...
[ "def", "form_invalid", "(", "self", ",", "form", ")", ":", "context", "=", "self", ".", "get_context_data", "(", "form", "=", "form", ")", "#noinspection PyUnresolvedReferences", "return", "render_modal_workflow", "(", "self", ".", "request", ",", "'{0}/chooser.ht...
Processes an invalid form submittal. :param form: the form instance. :rtype: django.http.HttpResponse.
[ "Processes", "an", "invalid", "form", "submittal", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/utils/views/chooser.py#L20-L35
train
rfosterslo/wagtailplus
wagtailplus/utils/views/chooser.py
ChooserView.form_valid
def form_valid(self, form): """ Processes a valid form submittal. :param form: the form instance. :rtype: django.http.HttpResponse. """ #noinspection PyAttributeOutsideInit self.object = form.save() # Index the link. for backend in get_search_bac...
python
def form_valid(self, form): """ Processes a valid form submittal. :param form: the form instance. :rtype: django.http.HttpResponse. """ #noinspection PyAttributeOutsideInit self.object = form.save() # Index the link. for backend in get_search_bac...
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "#noinspection PyAttributeOutsideInit", "self", ".", "object", "=", "form", ".", "save", "(", ")", "# Index the link.", "for", "backend", "in", "get_search_backends", "(", ")", ":", "backend", ".", "add"...
Processes a valid form submittal. :param form: the form instance. :rtype: django.http.HttpResponse.
[ "Processes", "a", "valid", "form", "submittal", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/utils/views/chooser.py#L37-L57
train
rfosterslo/wagtailplus
wagtailplus/utils/views/chooser.py
ChooserView.get
def get(self, request, *args, **kwargs): """ Returns GET response. :param request: the request instance. :rtype: django.http.HttpResponse. """ #noinspection PyAttributeOutsideInit self.object_list = self.get_queryset() context = self.get_co...
python
def get(self, request, *args, **kwargs): """ Returns GET response. :param request: the request instance. :rtype: django.http.HttpResponse. """ #noinspection PyAttributeOutsideInit self.object_list = self.get_queryset() context = self.get_co...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#noinspection PyAttributeOutsideInit", "self", ".", "object_list", "=", "self", ".", "get_queryset", "(", ")", "context", "=", "self", ".", "get_context_data", ...
Returns GET response. :param request: the request instance. :rtype: django.http.HttpResponse.
[ "Returns", "GET", "response", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/utils/views/chooser.py#L59-L85
train
rfosterslo/wagtailplus
wagtailplus/utils/views/chooser.py
ChooserView.get_form_kwargs
def get_form_kwargs(self): """ Returns the keyword arguments for instantiating the form. :rtype: dict. """ kwargs = { 'initial': self.get_initial(), 'prefix': self.get_prefix(), } #noinspection PyUnresolvedReferences if self.re...
python
def get_form_kwargs(self): """ Returns the keyword arguments for instantiating the form. :rtype: dict. """ kwargs = { 'initial': self.get_initial(), 'prefix': self.get_prefix(), } #noinspection PyUnresolvedReferences if self.re...
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "{", "'initial'", ":", "self", ".", "get_initial", "(", ")", ",", "'prefix'", ":", "self", ".", "get_prefix", "(", ")", ",", "}", "#noinspection PyUnresolvedReferences", "if", "self", ".", "re...
Returns the keyword arguments for instantiating the form. :rtype: dict.
[ "Returns", "the", "keyword", "arguments", "for", "instantiating", "the", "form", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/utils/views/chooser.py#L106-L128
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/signals/handlers.py
create_entry_tag
def create_entry_tag(sender, instance, created, **kwargs): """ Creates EntryTag for Entry corresponding to specified ItemBase instance. :param sender: the sending ItemBase class. :param instance: the ItemBase instance. """ from ..models import ( Entry, EntryTag ) en...
python
def create_entry_tag(sender, instance, created, **kwargs): """ Creates EntryTag for Entry corresponding to specified ItemBase instance. :param sender: the sending ItemBase class. :param instance: the ItemBase instance. """ from ..models import ( Entry, EntryTag ) en...
[ "def", "create_entry_tag", "(", "sender", ",", "instance", ",", "created", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "models", "import", "(", "Entry", ",", "EntryTag", ")", "entry", "=", "Entry", ".", "objects", ".", "get_for_model", "(", "i...
Creates EntryTag for Entry corresponding to specified ItemBase instance. :param sender: the sending ItemBase class. :param instance: the ItemBase instance.
[ "Creates", "EntryTag", "for", "Entry", "corresponding", "to", "specified", "ItemBase", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/signals/handlers.py#L11-L28
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/signals/handlers.py
delete_entry_tag
def delete_entry_tag(sender, instance, **kwargs): """ Deletes EntryTag for Entry corresponding to specified TaggedItemBase instance. :param sender: the sending TaggedItemBase class. :param instance: the TaggedItemBase instance. """ from ..models import ( Entry, EntryTag ...
python
def delete_entry_tag(sender, instance, **kwargs): """ Deletes EntryTag for Entry corresponding to specified TaggedItemBase instance. :param sender: the sending TaggedItemBase class. :param instance: the TaggedItemBase instance. """ from ..models import ( Entry, EntryTag ...
[ "def", "delete_entry_tag", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "models", "import", "(", "Entry", ",", "EntryTag", ")", "entry", "=", "Entry", ".", "objects", ".", "get_for_model", "(", "instance", ".", "...
Deletes EntryTag for Entry corresponding to specified TaggedItemBase instance. :param sender: the sending TaggedItemBase class. :param instance: the TaggedItemBase instance.
[ "Deletes", "EntryTag", "for", "Entry", "corresponding", "to", "specified", "TaggedItemBase", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/signals/handlers.py#L31-L47
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/signals/handlers.py
delete_entry
def delete_entry(sender, instance, **kwargs): """ Deletes Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being deleted. """ from ..models import Entry Entry.objects.get_for_model(instance)[0].delete()
python
def delete_entry(sender, instance, **kwargs): """ Deletes Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being deleted. """ from ..models import Entry Entry.objects.get_for_model(instance)[0].delete()
[ "def", "delete_entry", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "models", "import", "Entry", "Entry", ".", "objects", ".", "get_for_model", "(", "instance", ")", "[", "0", "]", ".", "delete", "(", ")" ]
Deletes Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being deleted.
[ "Deletes", "Entry", "instance", "corresponding", "to", "specified", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/signals/handlers.py#L50-L59
train
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/signals/handlers.py
update_entry_attributes
def update_entry_attributes(sender, instance, **kwargs): """ Updates attributes for Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being saved. """ from ..models import Entry entry = Entry.objects.get_for_model(instan...
python
def update_entry_attributes(sender, instance, **kwargs): """ Updates attributes for Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being saved. """ from ..models import Entry entry = Entry.objects.get_for_model(instan...
[ "def", "update_entry_attributes", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "models", "import", "Entry", "entry", "=", "Entry", ".", "objects", ".", "get_for_model", "(", "instance", ")", "[", "0", "]", "default...
Updates attributes for Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being saved.
[ "Updates", "attributes", "for", "Entry", "instance", "corresponding", "to", "specified", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/signals/handlers.py#L62-L79
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/views.py
get_revisions
def get_revisions(page, page_num=1): """ Returns paginated queryset of PageRevision instances for specified Page instance. :param page: the page instance. :param page_num: the pagination page number. :rtype: django.db.models.query.QuerySet. """ revisions = page.revisions.order_by('-cr...
python
def get_revisions(page, page_num=1): """ Returns paginated queryset of PageRevision instances for specified Page instance. :param page: the page instance. :param page_num: the pagination page number. :rtype: django.db.models.query.QuerySet. """ revisions = page.revisions.order_by('-cr...
[ "def", "get_revisions", "(", "page", ",", "page_num", "=", "1", ")", ":", "revisions", "=", "page", ".", "revisions", ".", "order_by", "(", "'-created_at'", ")", "current", "=", "page", ".", "get_latest_revision", "(", ")", "if", "current", ":", "revisions...
Returns paginated queryset of PageRevision instances for specified Page instance. :param page: the page instance. :param page_num: the pagination page number. :rtype: django.db.models.query.QuerySet.
[ "Returns", "paginated", "queryset", "of", "PageRevision", "instances", "for", "specified", "Page", "instance", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/views.py#L27-L51
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/views.py
page_revisions
def page_revisions(request, page_id, template_name='wagtailrollbacks/edit_handlers/revisions.html'): """ Returns GET response for specified page revisions. :param request: the request instance. :param page_id: the page ID. :param template_name: the template name. :rtype: django.http.HttpRespons...
python
def page_revisions(request, page_id, template_name='wagtailrollbacks/edit_handlers/revisions.html'): """ Returns GET response for specified page revisions. :param request: the request instance. :param page_id: the page ID. :param template_name: the template name. :rtype: django.http.HttpRespons...
[ "def", "page_revisions", "(", "request", ",", "page_id", ",", "template_name", "=", "'wagtailrollbacks/edit_handlers/revisions.html'", ")", ":", "page", "=", "get_object_or_404", "(", "Page", ",", "pk", "=", "page_id", ")", "page_perms", "=", "page", ".", "permiss...
Returns GET response for specified page revisions. :param request: the request instance. :param page_id: the page ID. :param template_name: the template name. :rtype: django.http.HttpResponse.
[ "Returns", "GET", "response", "for", "specified", "page", "revisions", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/views.py#L53-L79
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/views.py
preview_page_version
def preview_page_version(request, revision_id): """ Returns GET response for specified page preview. :param request: the request instance. :param reversion_pk: the page revision ID. :rtype: django.http.HttpResponse. """ revision = get_object_or_404(PageRevision, pk=revision_id) if not ...
python
def preview_page_version(request, revision_id): """ Returns GET response for specified page preview. :param request: the request instance. :param reversion_pk: the page revision ID. :rtype: django.http.HttpResponse. """ revision = get_object_or_404(PageRevision, pk=revision_id) if not ...
[ "def", "preview_page_version", "(", "request", ",", "revision_id", ")", ":", "revision", "=", "get_object_or_404", "(", "PageRevision", ",", "pk", "=", "revision_id", ")", "if", "not", "revision", ".", "page", ".", "permissions_for_user", "(", "request", ".", ...
Returns GET response for specified page preview. :param request: the request instance. :param reversion_pk: the page revision ID. :rtype: django.http.HttpResponse.
[ "Returns", "GET", "response", "for", "specified", "page", "preview", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/views.py#L81-L97
train
rfosterslo/wagtailplus
wagtailplus/wagtailrollbacks/views.py
confirm_page_reversion
def confirm_page_reversion(request, revision_id, template_name='wagtailrollbacks/pages/confirm_reversion.html'): """ Handles page reversion process (GET and POST). :param request: the request instance. :param revision_id: the page revision ID. :param template_name: the template name. :rtype: dj...
python
def confirm_page_reversion(request, revision_id, template_name='wagtailrollbacks/pages/confirm_reversion.html'): """ Handles page reversion process (GET and POST). :param request: the request instance. :param revision_id: the page revision ID. :param template_name: the template name. :rtype: dj...
[ "def", "confirm_page_reversion", "(", "request", ",", "revision_id", ",", "template_name", "=", "'wagtailrollbacks/pages/confirm_reversion.html'", ")", ":", "revision", "=", "get_object_or_404", "(", "PageRevision", ",", "pk", "=", "revision_id", ")", "page", "=", "re...
Handles page reversion process (GET and POST). :param request: the request instance. :param revision_id: the page revision ID. :param template_name: the template name. :rtype: django.http.HttpResponse.
[ "Handles", "page", "reversion", "process", "(", "GET", "and", "POST", ")", "." ]
22cac857175d8a6f77e470751831c14a92ccd768
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrollbacks/views.py#L99-L176
train
jaraco/keyrings.alt
keyrings/alt/Google.py
DocsKeyring.get_password
def get_password(self, service, username): """Get password of the username for the service """ result = self._get_entry(self._keyring, service, username) if result: result = self._decrypt(result) return result
python
def get_password(self, service, username): """Get password of the username for the service """ result = self._get_entry(self._keyring, service, username) if result: result = self._decrypt(result) return result
[ "def", "get_password", "(", "self", ",", "service", ",", "username", ")", ":", "result", "=", "self", ".", "_get_entry", "(", "self", ".", "_keyring", ",", "service", ",", "username", ")", "if", "result", ":", "result", "=", "self", ".", "_decrypt", "(...
Get password of the username for the service
[ "Get", "password", "of", "the", "username", "for", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Google.py#L85-L91
train
jaraco/keyrings.alt
keyrings/alt/Google.py
DocsKeyring.set_password
def set_password(self, service, username, password): """Set password for the username of the service """ password = self._encrypt(password or '') keyring_working_copy = copy.deepcopy(self._keyring) service_entries = keyring_working_copy.get(service) if not service_entries...
python
def set_password(self, service, username, password): """Set password for the username of the service """ password = self._encrypt(password or '') keyring_working_copy = copy.deepcopy(self._keyring) service_entries = keyring_working_copy.get(service) if not service_entries...
[ "def", "set_password", "(", "self", ",", "service", ",", "username", ",", "password", ")", ":", "password", "=", "self", ".", "_encrypt", "(", "password", "or", "''", ")", "keyring_working_copy", "=", "copy", ".", "deepcopy", "(", "self", ".", "_keyring", ...
Set password for the username of the service
[ "Set", "password", "for", "the", "username", "of", "the", "service" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Google.py#L93-L137
train
jaraco/keyrings.alt
keyrings/alt/Google.py
DocsKeyring._save_keyring
def _save_keyring(self, keyring_dict): """Helper to actually write the keyring to Google""" import gdata result = self.OK file_contents = base64.urlsafe_b64encode(pickle.dumps(keyring_dict)) try: if self.docs_entry: extra_headers = {'Content-Type': 'te...
python
def _save_keyring(self, keyring_dict): """Helper to actually write the keyring to Google""" import gdata result = self.OK file_contents = base64.urlsafe_b64encode(pickle.dumps(keyring_dict)) try: if self.docs_entry: extra_headers = {'Content-Type': 'te...
[ "def", "_save_keyring", "(", "self", ",", "keyring_dict", ")", ":", "import", "gdata", "result", "=", "self", ".", "OK", "file_contents", "=", "base64", ".", "urlsafe_b64encode", "(", "pickle", ".", "dumps", "(", "keyring_dict", ")", ")", "try", ":", "if",...
Helper to actually write the keyring to Google
[ "Helper", "to", "actually", "write", "the", "keyring", "to", "Google" ]
5b71223d12bf9ac6abd05b1b395f1efccb5ea660
https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/Google.py#L247-L306
train
Boudewijn26/gTTS-token
gtts_token/gtts_token.py
Token.calculate_token
def calculate_token(self, text, seed=None): """ Calculate the request token (`tk`) of a string :param text: str The text to calculate a token for :param seed: str The seed to use. By default this is the number of hours since epoch """ if seed is None: seed = self._ge...
python
def calculate_token(self, text, seed=None): """ Calculate the request token (`tk`) of a string :param text: str The text to calculate a token for :param seed: str The seed to use. By default this is the number of hours since epoch """ if seed is None: seed = self._ge...
[ "def", "calculate_token", "(", "self", ",", "text", ",", "seed", "=", "None", ")", ":", "if", "seed", "is", "None", ":", "seed", "=", "self", ".", "_get_token_key", "(", ")", "[", "first_seed", ",", "second_seed", "]", "=", "seed", ".", "split", "(",...
Calculate the request token (`tk`) of a string :param text: str The text to calculate a token for :param seed: str The seed to use. By default this is the number of hours since epoch
[ "Calculate", "the", "request", "token", "(", "tk", ")", "of", "a", "string", ":", "param", "text", ":", "str", "The", "text", "to", "calculate", "a", "token", "for", ":", "param", "seed", ":", "str", "The", "seed", "to", "use", ".", "By", "default", ...
9a1bb569bcce1ec091bfd9586dd54f9c879e7d3c
https://github.com/Boudewijn26/gTTS-token/blob/9a1bb569bcce1ec091bfd9586dd54f9c879e7d3c/gtts_token/gtts_token.py#L21-L49
train
paddycarey/dweepy
dweepy/api.py
_request
def _request(method, url, session=None, **kwargs): """Make HTTP request, raising an exception if it fails. """ url = BASE_URL + url if session: request_func = getattr(session, method) else: request_func = getattr(requests, method) response = request_func(url, **kwargs) # rai...
python
def _request(method, url, session=None, **kwargs): """Make HTTP request, raising an exception if it fails. """ url = BASE_URL + url if session: request_func = getattr(session, method) else: request_func = getattr(requests, method) response = request_func(url, **kwargs) # rai...
[ "def", "_request", "(", "method", ",", "url", ",", "session", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "BASE_URL", "+", "url", "if", "session", ":", "request_func", "=", "getattr", "(", "session", ",", "method", ")", "else", ":", ...
Make HTTP request, raising an exception if it fails.
[ "Make", "HTTP", "request", "raising", "an", "exception", "if", "it", "fails", "." ]
1eb69de4a20c929c57be2a21e2aa39ae9a0ae298
https://github.com/paddycarey/dweepy/blob/1eb69de4a20c929c57be2a21e2aa39ae9a0ae298/dweepy/api.py#L29-L45
train
paddycarey/dweepy
dweepy/api.py
_send_dweet
def _send_dweet(payload, url, params=None, session=None): """Send a dweet to dweet.io """ data = json.dumps(payload) headers = {'Content-type': 'application/json'} return _request('post', url, data=data, headers=headers, params=params, session=session)
python
def _send_dweet(payload, url, params=None, session=None): """Send a dweet to dweet.io """ data = json.dumps(payload) headers = {'Content-type': 'application/json'} return _request('post', url, data=data, headers=headers, params=params, session=session)
[ "def", "_send_dweet", "(", "payload", ",", "url", ",", "params", "=", "None", ",", "session", "=", "None", ")", ":", "data", "=", "json", ".", "dumps", "(", "payload", ")", "headers", "=", "{", "'Content-type'", ":", "'application/json'", "}", "return", ...
Send a dweet to dweet.io
[ "Send", "a", "dweet", "to", "dweet", ".", "io" ]
1eb69de4a20c929c57be2a21e2aa39ae9a0ae298
https://github.com/paddycarey/dweepy/blob/1eb69de4a20c929c57be2a21e2aa39ae9a0ae298/dweepy/api.py#L48-L53
train