repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
splunk/splunk-sdk-python
splunklib/client.py
Job.cancel
def cancel(self): """Stops the current search and deletes the results cache. :return: The :class:`Job`. """ try: self.post("control", action="cancel") except HTTPError as he: if he.status == 404: # The job has already been cancelled, so ...
python
def cancel(self): """Stops the current search and deletes the results cache. :return: The :class:`Job`. """ try: self.post("control", action="cancel") except HTTPError as he: if he.status == 404: # The job has already been cancelled, so ...
[ "def", "cancel", "(", "self", ")", ":", "try", ":", "self", ".", "post", "(", "\"control\"", ",", "action", "=", "\"cancel\"", ")", "except", "HTTPError", "as", "he", ":", "if", "he", ".", "status", "==", "404", ":", "pass", "else", ":", "raise", "...
Stops the current search and deletes the results cache. :return: The :class:`Job`.
[ "Stops", "the", "current", "search", "and", "deletes", "the", "results", "cache", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2634-L2648
train
splunk/splunk-sdk-python
splunklib/client.py
Job.events
def events(self, **kwargs): """Returns a streaming handle to this job's events. :param kwargs: Additional parameters (optional). For a list of valid parameters, see `GET search/jobs/{search_id}/events <http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_sea...
python
def events(self, **kwargs): """Returns a streaming handle to this job's events. :param kwargs: Additional parameters (optional). For a list of valid parameters, see `GET search/jobs/{search_id}/events <http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_sea...
[ "def", "events", "(", "self", ",", "**", "kwargs", ")", ":", "kwargs", "[", "'segmentation'", "]", "=", "kwargs", ".", "get", "(", "'segmentation'", ",", "'none'", ")", "return", "self", ".", "get", "(", "\"events\"", ",", "**", "kwargs", ")", ".", "...
Returns a streaming handle to this job's events. :param kwargs: Additional parameters (optional). For a list of valid parameters, see `GET search/jobs/{search_id}/events <http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_search.2Fjobs.2F.7Bsearch_id.7D.2Fevents>`...
[ "Returns", "a", "streaming", "handle", "to", "this", "job", "s", "events", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2668-L2680
train
splunk/splunk-sdk-python
splunklib/client.py
Job.is_done
def is_done(self): """Indicates whether this job finished running. :return: ``True`` if the job is done, ``False`` if not. :rtype: ``boolean`` """ if not self.is_ready(): return False done = (self._state.content['isDone'] == '1') return done
python
def is_done(self): """Indicates whether this job finished running. :return: ``True`` if the job is done, ``False`` if not. :rtype: ``boolean`` """ if not self.is_ready(): return False done = (self._state.content['isDone'] == '1') return done
[ "def", "is_done", "(", "self", ")", ":", "if", "not", "self", ".", "is_ready", "(", ")", ":", "return", "False", "done", "=", "(", "self", ".", "_state", ".", "content", "[", "'isDone'", "]", "==", "'1'", ")", "return", "done" ]
Indicates whether this job finished running. :return: ``True`` if the job is done, ``False`` if not. :rtype: ``boolean``
[ "Indicates", "whether", "this", "job", "finished", "running", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2690-L2699
train
splunk/splunk-sdk-python
splunklib/client.py
Job.is_ready
def is_ready(self): """Indicates whether this job is ready for querying. :return: ``True`` if the job is ready, ``False`` if not. :rtype: ``boolean`` """ response = self.get() if response.status == 204: return False self._state = self.read(response) ...
python
def is_ready(self): """Indicates whether this job is ready for querying. :return: ``True`` if the job is ready, ``False`` if not. :rtype: ``boolean`` """ response = self.get() if response.status == 204: return False self._state = self.read(response) ...
[ "def", "is_ready", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", ")", "if", "response", ".", "status", "==", "204", ":", "return", "False", "self", ".", "_state", "=", "self", ".", "read", "(", "response", ")", "ready", "=", "sel...
Indicates whether this job is ready for querying. :return: ``True`` if the job is ready, ``False`` if not. :rtype: ``boolean``
[ "Indicates", "whether", "this", "job", "is", "ready", "for", "querying", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2701-L2713
train
splunk/splunk-sdk-python
splunklib/client.py
Job.preview
def preview(self, **query_params): """Returns a streaming handle to this job's preview search results. Unlike :class:`splunklib.results.ResultsReader`, which requires a job to be finished to return any results, the ``preview`` method returns any results that have been generated ...
python
def preview(self, **query_params): """Returns a streaming handle to this job's preview search results. Unlike :class:`splunklib.results.ResultsReader`, which requires a job to be finished to return any results, the ``preview`` method returns any results that have been generated ...
[ "def", "preview", "(", "self", ",", "**", "query_params", ")", ":", "query_params", "[", "'segmentation'", "]", "=", "query_params", ".", "get", "(", "'segmentation'", ",", "'none'", ")", "return", "self", ".", "get", "(", "\"results_preview\"", ",", "**", ...
Returns a streaming handle to this job's preview search results. Unlike :class:`splunklib.results.ResultsReader`, which requires a job to be finished to return any results, the ``preview`` method returns any results that have been generated so far, whether the job is running or not. The...
[ "Returns", "a", "streaming", "handle", "to", "this", "job", "s", "preview", "search", "results", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2771-L2812
train
splunk/splunk-sdk-python
splunklib/client.py
Jobs.create
def create(self, query, **kwargs): """ Creates a search using a search query and any additional parameters you provide. :param query: The search query. :type query: ``string`` :param kwargs: Additiona parameters (optional). For a list of available parameters, see `Se...
python
def create(self, query, **kwargs): """ Creates a search using a search query and any additional parameters you provide. :param query: The search query. :type query: ``string`` :param kwargs: Additiona parameters (optional). For a list of available parameters, see `Se...
[ "def", "create", "(", "self", ",", "query", ",", "**", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "\"exec_mode\"", ",", "None", ")", "==", "\"oneshot\"", ":", "raise", "TypeError", "(", "\"Cannot specify exec_mode=oneshot; use the oneshot method instead....
Creates a search using a search query and any additional parameters you provide. :param query: The search query. :type query: ``string`` :param kwargs: Additiona parameters (optional). For a list of available parameters, see `Search job parameters <http://dev.spl...
[ "Creates", "a", "search", "using", "a", "search", "query", "and", "any", "additional", "parameters", "you", "provide", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2920-L2938
train
splunk/splunk-sdk-python
splunklib/client.py
Jobs.oneshot
def oneshot(self, query, **params): """Run a oneshot search and returns a streaming handle to the results. The ``InputStream`` object streams XML fragments from the server. To parse this stream into usable Python objects, pass the handle to :class:`splunklib.results.ResultsReader`:: ...
python
def oneshot(self, query, **params): """Run a oneshot search and returns a streaming handle to the results. The ``InputStream`` object streams XML fragments from the server. To parse this stream into usable Python objects, pass the handle to :class:`splunklib.results.ResultsReader`:: ...
[ "def", "oneshot", "(", "self", ",", "query", ",", "**", "params", ")", ":", "if", "\"exec_mode\"", "in", "params", ":", "raise", "TypeError", "(", "\"Cannot specify an exec_mode to oneshot.\"", ")", "params", "[", "'segmentation'", "]", "=", "params", ".", "ge...
Run a oneshot search and returns a streaming handle to the results. The ``InputStream`` object streams XML fragments from the server. To parse this stream into usable Python objects, pass the handle to :class:`splunklib.results.ResultsReader`:: import splunklib.client as client ...
[ "Run", "a", "oneshot", "search", "and", "returns", "a", "streaming", "handle", "to", "the", "results", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2995-L3047
train
splunk/splunk-sdk-python
splunklib/client.py
SavedSearch.dispatch
def dispatch(self, **kwargs): """Runs the saved search and returns the resulting search job. :param `kwargs`: Additional dispatch arguments (optional). For details, see the `POST saved/searches/{name}/dispatch <http://docs.splunk.com/Documentation/Splun...
python
def dispatch(self, **kwargs): """Runs the saved search and returns the resulting search job. :param `kwargs`: Additional dispatch arguments (optional). For details, see the `POST saved/searches/{name}/dispatch <http://docs.splunk.com/Documentation/Splun...
[ "def", "dispatch", "(", "self", ",", "**", "kwargs", ")", ":", "response", "=", "self", ".", "post", "(", "\"dispatch\"", ",", "**", "kwargs", ")", "sid", "=", "_load_sid", "(", "response", ")", "return", "Job", "(", "self", ".", "service", ",", "sid...
Runs the saved search and returns the resulting search job. :param `kwargs`: Additional dispatch arguments (optional). For details, see the `POST saved/searches/{name}/dispatch <http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#POST_saved.2F...
[ "Runs", "the", "saved", "search", "and", "returns", "the", "resulting", "search", "job", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3142-L3154
train
splunk/splunk-sdk-python
splunklib/client.py
SavedSearch.history
def history(self): """Returns a list of search jobs corresponding to this saved search. :return: A list of :class:`Job` objects. """ response = self.get("history") entries = _load_atom_entries(response) if entries is None: return [] jobs = [] for entry in...
python
def history(self): """Returns a list of search jobs corresponding to this saved search. :return: A list of :class:`Job` objects. """ response = self.get("history") entries = _load_atom_entries(response) if entries is None: return [] jobs = [] for entry in...
[ "def", "history", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", "\"history\"", ")", "entries", "=", "_load_atom_entries", "(", "response", ")", "if", "entries", "is", "None", ":", "return", "[", "]", "jobs", "=", "[", "]", "for", "...
Returns a list of search jobs corresponding to this saved search. :return: A list of :class:`Job` objects.
[ "Returns", "a", "list", "of", "search", "jobs", "corresponding", "to", "this", "saved", "search", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3177-L3189
train
splunk/splunk-sdk-python
splunklib/client.py
SavedSearch.update
def update(self, search=None, **kwargs): """Updates the server with any changes you've made to the current saved search along with any additional arguments you specify. :param `search`: The search query (optional). :type search: ``string`` :param `kwargs`: Additional arguments (...
python
def update(self, search=None, **kwargs): """Updates the server with any changes you've made to the current saved search along with any additional arguments you specify. :param `search`: The search query (optional). :type search: ``string`` :param `kwargs`: Additional arguments (...
[ "def", "update", "(", "self", ",", "search", "=", "None", ",", "**", "kwargs", ")", ":", "if", "search", "is", "None", ":", "search", "=", "self", ".", "content", ".", "search", "Entity", ".", "update", "(", "self", ",", "search", "=", "search", ",...
Updates the server with any changes you've made to the current saved search along with any additional arguments you specify. :param `search`: The search query (optional). :type search: ``string`` :param `kwargs`: Additional arguments (optional). For a list of available param...
[ "Updates", "the", "server", "with", "any", "changes", "you", "ve", "made", "to", "the", "current", "saved", "search", "along", "with", "any", "additional", "arguments", "you", "specify", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3191-L3210
train
splunk/splunk-sdk-python
splunklib/client.py
SavedSearch.scheduled_times
def scheduled_times(self, earliest_time='now', latest_time='+1h'): """Returns the times when this search is scheduled to run. By default this method returns the times in the next hour. For different time ranges, set *earliest_time* and *latest_time*. For example, for all times in the la...
python
def scheduled_times(self, earliest_time='now', latest_time='+1h'): """Returns the times when this search is scheduled to run. By default this method returns the times in the next hour. For different time ranges, set *earliest_time* and *latest_time*. For example, for all times in the la...
[ "def", "scheduled_times", "(", "self", ",", "earliest_time", "=", "'now'", ",", "latest_time", "=", "'+1h'", ")", ":", "response", "=", "self", ".", "get", "(", "\"scheduled_times\"", ",", "earliest_time", "=", "earliest_time", ",", "latest_time", "=", "latest...
Returns the times when this search is scheduled to run. By default this method returns the times in the next hour. For different time ranges, set *earliest_time* and *latest_time*. For example, for all times in the last day use "earliest_time=-1d" and "latest_time=now". :param ...
[ "Returns", "the", "times", "when", "this", "search", "is", "scheduled", "to", "run", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3212-L3234
train
splunk/splunk-sdk-python
splunklib/client.py
SavedSearches.create
def create(self, name, search, **kwargs): """ Creates a saved search. :param name: The name for the saved search. :type name: ``string`` :param search: The search query. :type search: ``string`` :param kwargs: Additional arguments (optional). For a list of available ...
python
def create(self, name, search, **kwargs): """ Creates a saved search. :param name: The name for the saved search. :type name: ``string`` :param search: The search query. :type search: ``string`` :param kwargs: Additional arguments (optional). For a list of available ...
[ "def", "create", "(", "self", ",", "name", ",", "search", ",", "**", "kwargs", ")", ":", "return", "Collection", ".", "create", "(", "self", ",", "name", ",", "search", "=", "search", ",", "**", "kwargs", ")" ]
Creates a saved search. :param name: The name for the saved search. :type name: ``string`` :param search: The search query. :type search: ``string`` :param kwargs: Additional arguments (optional). For a list of available parameters, see `Saved search parameters ...
[ "Creates", "a", "saved", "search", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3278-L3292
train
splunk/splunk-sdk-python
splunklib/client.py
User.role_entities
def role_entities(self): """Returns a list of roles assigned to this user. :return: The list of roles. :rtype: ``list`` """ return [self.service.roles[name] for name in self.content.roles]
python
def role_entities(self): """Returns a list of roles assigned to this user. :return: The list of roles. :rtype: ``list`` """ return [self.service.roles[name] for name in self.content.roles]
[ "def", "role_entities", "(", "self", ")", ":", "return", "[", "self", ".", "service", ".", "roles", "[", "name", "]", "for", "name", "in", "self", ".", "content", ".", "roles", "]" ]
Returns a list of roles assigned to this user. :return: The list of roles. :rtype: ``list``
[ "Returns", "a", "list", "of", "roles", "assigned", "to", "this", "user", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3320-L3326
train
splunk/splunk-sdk-python
splunklib/client.py
Role.grant
def grant(self, *capabilities_to_grant): """Grants additional capabilities to this role. :param capabilities_to_grant: Zero or more capabilities to grant this role. For a list of capabilities, see `Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_ o...
python
def grant(self, *capabilities_to_grant): """Grants additional capabilities to this role. :param capabilities_to_grant: Zero or more capabilities to grant this role. For a list of capabilities, see `Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_ o...
[ "def", "grant", "(", "self", ",", "*", "capabilities_to_grant", ")", ":", "possible_capabilities", "=", "self", ".", "service", ".", "capabilities", "for", "capability", "in", "capabilities_to_grant", ":", "if", "capability", "not", "in", "possible_capabilities", ...
Grants additional capabilities to this role. :param capabilities_to_grant: Zero or more capabilities to grant this role. For a list of capabilities, see `Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_ on Splunk Developer Portal. :type capabilitie...
[ "Grants", "additional", "capabilities", "to", "this", "role", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3404-L3426
train
splunk/splunk-sdk-python
splunklib/client.py
Role.revoke
def revoke(self, *capabilities_to_revoke): """Revokes zero or more capabilities from this role. :param capabilities_to_revoke: Zero or more capabilities to grant this role. For a list of capabilities, see `Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_ ...
python
def revoke(self, *capabilities_to_revoke): """Revokes zero or more capabilities from this role. :param capabilities_to_revoke: Zero or more capabilities to grant this role. For a list of capabilities, see `Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_ ...
[ "def", "revoke", "(", "self", ",", "*", "capabilities_to_revoke", ")", ":", "possible_capabilities", "=", "self", ".", "service", ".", "capabilities", "for", "capability", "in", "capabilities_to_revoke", ":", "if", "capability", "not", "in", "possible_capabilities",...
Revokes zero or more capabilities from this role. :param capabilities_to_revoke: Zero or more capabilities to grant this role. For a list of capabilities, see `Capabilities <http://dev.splunk.com/view/SP-CAAAEJ6#capabilities>`_ on Splunk Developer Portal. :type capab...
[ "Revokes", "zero", "or", "more", "capabilities", "from", "this", "role", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3428-L3457
train
splunk/splunk-sdk-python
splunklib/client.py
Roles.create
def create(self, name, **params): """Creates a new role. This function makes two roundtrips to the server, plus at most two more if the ``autologin`` field of :func:`connect` is set to ``True``. :param name: Name for the role. :type name: ``string`` :param param...
python
def create(self, name, **params): """Creates a new role. This function makes two roundtrips to the server, plus at most two more if the ``autologin`` field of :func:`connect` is set to ``True``. :param name: Name for the role. :type name: ``string`` :param param...
[ "def", "create", "(", "self", ",", "name", ",", "**", "params", ")", ":", "if", "not", "isinstance", "(", "name", ",", "six", ".", "string_types", ")", ":", "raise", "ValueError", "(", "\"Invalid role name: %s\"", "%", "str", "(", "name", ")", ")", "na...
Creates a new role. This function makes two roundtrips to the server, plus at most two more if the ``autologin`` field of :func:`connect` is set to ``True``. :param name: Name for the role. :type name: ``string`` :param params: Additional arguments (optional). For a lis...
[ "Creates", "a", "new", "role", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3472-L3510
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollections.create
def create(self, name, indexes = {}, fields = {}, **kwargs): """Creates a KV Store Collection. :param name: name of collection to create :type name: ``string`` :param indexes: dictionary of index definitions :type indexes: ``dict`` :param fields: dictionary of field defi...
python
def create(self, name, indexes = {}, fields = {}, **kwargs): """Creates a KV Store Collection. :param name: name of collection to create :type name: ``string`` :param indexes: dictionary of index definitions :type indexes: ``dict`` :param fields: dictionary of field defi...
[ "def", "create", "(", "self", ",", "name", ",", "indexes", "=", "{", "}", ",", "fields", "=", "{", "}", ",", "**", "kwargs", ")", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "indexes", ")", ":", "if", "isinstance", "(", "v", ...
Creates a KV Store Collection. :param name: name of collection to create :type name: ``string`` :param indexes: dictionary of index definitions :type indexes: ``dict`` :param fields: dictionary of field definitions :type fields: ``dict`` :param kwargs: a dictiona...
[ "Creates", "a", "KV", "Store", "Collection", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3545-L3565
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollection.update_index
def update_index(self, name, value): """Changes the definition of a KV Store index. :param name: name of index to change :type name: ``string`` :param value: new index definition :type value: ``dict`` or ``string`` :return: Result of POST request """ kwa...
python
def update_index(self, name, value): """Changes the definition of a KV Store index. :param name: name of index to change :type name: ``string`` :param value: new index definition :type value: ``dict`` or ``string`` :return: Result of POST request """ kwa...
[ "def", "update_index", "(", "self", ",", "name", ",", "value", ")", ":", "kwargs", "=", "{", "}", "kwargs", "[", "'index.'", "+", "name", "]", "=", "value", "if", "isinstance", "(", "value", ",", "basestring", ")", "else", "json", ".", "dumps", "(", ...
Changes the definition of a KV Store index. :param name: name of index to change :type name: ``string`` :param value: new index definition :type value: ``dict`` or ``string`` :return: Result of POST request
[ "Changes", "the", "definition", "of", "a", "KV", "Store", "index", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3576-L3588
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollection.update_field
def update_field(self, name, value): """Changes the definition of a KV Store field. :param name: name of field to change :type name: ``string`` :param value: new field definition :type value: ``string`` :return: Result of POST request """ kwargs = {} ...
python
def update_field(self, name, value): """Changes the definition of a KV Store field. :param name: name of field to change :type name: ``string`` :param value: new field definition :type value: ``string`` :return: Result of POST request """ kwargs = {} ...
[ "def", "update_field", "(", "self", ",", "name", ",", "value", ")", ":", "kwargs", "=", "{", "}", "kwargs", "[", "'field.'", "+", "name", "]", "=", "value", "return", "self", ".", "post", "(", "**", "kwargs", ")" ]
Changes the definition of a KV Store field. :param name: name of field to change :type name: ``string`` :param value: new field definition :type value: ``string`` :return: Result of POST request
[ "Changes", "the", "definition", "of", "a", "KV", "Store", "field", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3590-L3602
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollectionData.query
def query(self, **query): """ Gets the results of query, with optional parameters sort, limit, skip, and fields. :param query: Optional parameters. Valid options are sort, limit, skip, and fields :type query: ``dict`` :return: Array of documents retrieved by query. :rty...
python
def query(self, **query): """ Gets the results of query, with optional parameters sort, limit, skip, and fields. :param query: Optional parameters. Valid options are sort, limit, skip, and fields :type query: ``dict`` :return: Array of documents retrieved by query. :rty...
[ "def", "query", "(", "self", ",", "**", "query", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_get", "(", "''", ",", "**", "query", ")", ".", "body", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", ")" ]
Gets the results of query, with optional parameters sort, limit, skip, and fields. :param query: Optional parameters. Valid options are sort, limit, skip, and fields :type query: ``dict`` :return: Array of documents retrieved by query. :rtype: ``array``
[ "Gets", "the", "results", "of", "query", "with", "optional", "parameters", "sort", "limit", "skip", "and", "fields", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3626-L3636
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollectionData.query_by_id
def query_by_id(self, id): """ Returns object with _id = id. :param id: Value for ID. If not a string will be coerced to string. :type id: ``string`` :return: Document with id :rtype: ``dict`` """ return json.loads(self._get(UrlEncoded(str(id))).body.rea...
python
def query_by_id(self, id): """ Returns object with _id = id. :param id: Value for ID. If not a string will be coerced to string. :type id: ``string`` :return: Document with id :rtype: ``dict`` """ return json.loads(self._get(UrlEncoded(str(id))).body.rea...
[ "def", "query_by_id", "(", "self", ",", "id", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_get", "(", "UrlEncoded", "(", "str", "(", "id", ")", ")", ")", ".", "body", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", "...
Returns object with _id = id. :param id: Value for ID. If not a string will be coerced to string. :type id: ``string`` :return: Document with id :rtype: ``dict``
[ "Returns", "object", "with", "_id", "=", "id", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3638-L3648
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollectionData.insert
def insert(self, data): """ Inserts item into this collection. An _id field will be generated if not assigned in the data. :param data: Document to insert :type data: ``string`` :return: _id of inserted object :rtype: ``dict`` """ return json.loads(self....
python
def insert(self, data): """ Inserts item into this collection. An _id field will be generated if not assigned in the data. :param data: Document to insert :type data: ``string`` :return: _id of inserted object :rtype: ``dict`` """ return json.loads(self....
[ "def", "insert", "(", "self", ",", "data", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_post", "(", "''", ",", "headers", "=", "KVStoreCollectionData", ".", "JSON_HEADER", ",", "body", "=", "data", ")", ".", "body", ".", "read", "(",...
Inserts item into this collection. An _id field will be generated if not assigned in the data. :param data: Document to insert :type data: ``string`` :return: _id of inserted object :rtype: ``dict``
[ "Inserts", "item", "into", "this", "collection", ".", "An", "_id", "field", "will", "be", "generated", "if", "not", "assigned", "in", "the", "data", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3650-L3660
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollectionData.update
def update(self, id, data): """ Replaces document with _id = id with data. :param id: _id of document to update :type id: ``string`` :param data: the new document to insert :type data: ``string`` :return: id of replaced document :rtype: ``dict`` ...
python
def update(self, id, data): """ Replaces document with _id = id with data. :param id: _id of document to update :type id: ``string`` :param data: the new document to insert :type data: ``string`` :return: id of replaced document :rtype: ``dict`` ...
[ "def", "update", "(", "self", ",", "id", ",", "data", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_post", "(", "UrlEncoded", "(", "str", "(", "id", ")", ")", ",", "headers", "=", "KVStoreCollectionData", ".", "JSON_HEADER", ",", "bod...
Replaces document with _id = id with data. :param id: _id of document to update :type id: ``string`` :param data: the new document to insert :type data: ``string`` :return: id of replaced document :rtype: ``dict``
[ "Replaces", "document", "with", "_id", "=", "id", "with", "data", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3684-L3696
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollectionData.batch_find
def batch_find(self, *dbqueries): """ Returns array of results from queries dbqueries. :param dbqueries: Array of individual queries as dictionaries :type dbqueries: ``array`` of ``dict`` :return: Results of each query :rtype: ``array`` of ``array`` """ ...
python
def batch_find(self, *dbqueries): """ Returns array of results from queries dbqueries. :param dbqueries: Array of individual queries as dictionaries :type dbqueries: ``array`` of ``dict`` :return: Results of each query :rtype: ``array`` of ``array`` """ ...
[ "def", "batch_find", "(", "self", ",", "*", "dbqueries", ")", ":", "if", "len", "(", "dbqueries", ")", "<", "1", ":", "raise", "Exception", "(", "'Must have at least one query.'", ")", "data", "=", "json", ".", "dumps", "(", "dbqueries", ")", "return", "...
Returns array of results from queries dbqueries. :param dbqueries: Array of individual queries as dictionaries :type dbqueries: ``array`` of ``dict`` :return: Results of each query :rtype: ``array`` of ``array``
[ "Returns", "array", "of", "results", "from", "queries", "dbqueries", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3698-L3713
train
splunk/splunk-sdk-python
splunklib/client.py
KVStoreCollectionData.batch_save
def batch_save(self, *documents): """ Inserts or updates every document specified in documents. :param documents: Array of documents to save as dictionaries :type documents: ``array`` of ``dict`` :return: Results of update operation as overall stats :rtype: ``dict`` ...
python
def batch_save(self, *documents): """ Inserts or updates every document specified in documents. :param documents: Array of documents to save as dictionaries :type documents: ``array`` of ``dict`` :return: Results of update operation as overall stats :rtype: ``dict`` ...
[ "def", "batch_save", "(", "self", ",", "*", "documents", ")", ":", "if", "len", "(", "documents", ")", "<", "1", ":", "raise", "Exception", "(", "'Must have at least one document.'", ")", "data", "=", "json", ".", "dumps", "(", "documents", ")", "return", ...
Inserts or updates every document specified in documents. :param documents: Array of documents to save as dictionaries :type documents: ``array`` of ``dict`` :return: Results of update operation as overall stats :rtype: ``dict``
[ "Inserts", "or", "updates", "every", "document", "specified", "in", "documents", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3715-L3730
train
splunk/splunk-sdk-python
setup.py
DistCommand.get_python_files
def get_python_files(files): """Utility function to get .py files from a list""" python_files = [] for file_name in files: if file_name.endswith(".py"): python_files.append(file_name) return python_files
python
def get_python_files(files): """Utility function to get .py files from a list""" python_files = [] for file_name in files: if file_name.endswith(".py"): python_files.append(file_name) return python_files
[ "def", "get_python_files", "(", "files", ")", ":", "python_files", "=", "[", "]", "for", "file_name", "in", "files", ":", "if", "file_name", ".", "endswith", "(", "\".py\"", ")", ":", "python_files", ".", "append", "(", "file_name", ")", "return", "python_...
Utility function to get .py files from a list
[ "Utility", "function", "to", "get", ".", "py", "files", "from", "a", "list" ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/setup.py#L146-L153
train
splunk/splunk-sdk-python
splunklib/binding.py
_parse_cookies
def _parse_cookies(cookie_str, dictionary): """Tries to parse any key-value pairs of cookies in a string, then updates the the dictionary with any key-value pairs found. **Example**:: dictionary = {} _parse_cookies('my=value', dictionary) # Now the following is True dictiona...
python
def _parse_cookies(cookie_str, dictionary): """Tries to parse any key-value pairs of cookies in a string, then updates the the dictionary with any key-value pairs found. **Example**:: dictionary = {} _parse_cookies('my=value', dictionary) # Now the following is True dictiona...
[ "def", "_parse_cookies", "(", "cookie_str", ",", "dictionary", ")", ":", "parsed_cookie", "=", "six", ".", "moves", ".", "http_cookies", ".", "SimpleCookie", "(", "cookie_str", ")", "for", "cookie", "in", "parsed_cookie", ".", "values", "(", ")", ":", "dicti...
Tries to parse any key-value pairs of cookies in a string, then updates the the dictionary with any key-value pairs found. **Example**:: dictionary = {} _parse_cookies('my=value', dictionary) # Now the following is True dictionary['my'] == 'value' :param cookie_str: A strin...
[ "Tries", "to", "parse", "any", "key", "-", "value", "pairs", "of", "cookies", "in", "a", "string", "then", "updates", "the", "the", "dictionary", "with", "any", "key", "-", "value", "pairs", "found", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L78-L95
train
splunk/splunk-sdk-python
splunklib/binding.py
namespace
def namespace(sharing=None, owner=None, app=None, **kwargs): """This function constructs a Splunk namespace. Every Splunk resource belongs to a namespace. The namespace is specified by the pair of values ``owner`` and ``app`` and is governed by a ``sharing`` mode. The possible values for ``sharing`` ar...
python
def namespace(sharing=None, owner=None, app=None, **kwargs): """This function constructs a Splunk namespace. Every Splunk resource belongs to a namespace. The namespace is specified by the pair of values ``owner`` and ``app`` and is governed by a ``sharing`` mode. The possible values for ``sharing`` ar...
[ "def", "namespace", "(", "sharing", "=", "None", ",", "owner", "=", "None", ",", "app", "=", "None", ",", "**", "kwargs", ")", ":", "if", "sharing", "in", "[", "\"system\"", "]", ":", "return", "record", "(", "{", "'sharing'", ":", "sharing", ",", ...
This function constructs a Splunk namespace. Every Splunk resource belongs to a namespace. The namespace is specified by the pair of values ``owner`` and ``app`` and is governed by a ``sharing`` mode. The possible values for ``sharing`` are: "user", "app", "global" and "system", which map to the follow...
[ "This", "function", "constructs", "a", "Splunk", "namespace", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L355-L412
train
splunk/splunk-sdk-python
splunklib/binding.py
Context.request
def request(self, path_segment, method="GET", headers=None, body="", owner=None, app=None, sharing=None): """Issues an arbitrary HTTP request to the REST path segment. This method is named to match ``httplib.request``. This function makes a single round trip to the server. ...
python
def request(self, path_segment, method="GET", headers=None, body="", owner=None, app=None, sharing=None): """Issues an arbitrary HTTP request to the REST path segment. This method is named to match ``httplib.request``. This function makes a single round trip to the server. ...
[ "def", "request", "(", "self", ",", "path_segment", ",", "method", "=", "\"GET\"", ",", "headers", "=", "None", ",", "body", "=", "\"\"", ",", "owner", "=", "None", ",", "app", "=", "None", ",", "sharing", "=", "None", ")", ":", "if", "headers", "i...
Issues an arbitrary HTTP request to the REST path segment. This method is named to match ``httplib.request``. This function makes a single round trip to the server. If *owner*, *app*, and *sharing* are omitted, this method uses the default :class:`Context` namespace. All other keyword ...
[ "Issues", "an", "arbitrary", "HTTP", "request", "to", "the", "REST", "path", "segment", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L757-L824
train
splunk/splunk-sdk-python
splunklib/binding.py
HttpLib.delete
def delete(self, url, headers=None, **kwargs): """Sends a DELETE request to a URL. :param url: The URL. :type url: ``string`` :param headers: A list of pairs specifying the headers for the HTTP response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``...
python
def delete(self, url, headers=None, **kwargs): """Sends a DELETE request to a URL. :param url: The URL. :type url: ``string`` :param headers: A list of pairs specifying the headers for the HTTP response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``...
[ "def", "delete", "(", "self", ",", "url", ",", "headers", "=", "None", ",", "**", "kwargs", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "[", "]", "if", "kwargs", ":", "url", "=", "url", "+", "UrlEncoded", "(", "'?'", "+", "_enco...
Sends a DELETE request to a URL. :param url: The URL. :type url: ``string`` :param headers: A list of pairs specifying the headers for the HTTP response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``). :type headers: ``list`` :param kwargs: ...
[ "Sends", "a", "DELETE", "request", "to", "a", "URL", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1131-L1158
train
splunk/splunk-sdk-python
splunklib/binding.py
HttpLib.get
def get(self, url, headers=None, **kwargs): """Sends a GET request to a URL. :param url: The URL. :type url: ``string`` :param headers: A list of pairs specifying the headers for the HTTP response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``). ...
python
def get(self, url, headers=None, **kwargs): """Sends a GET request to a URL. :param url: The URL. :type url: ``string`` :param headers: A list of pairs specifying the headers for the HTTP response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``). ...
[ "def", "get", "(", "self", ",", "url", ",", "headers", "=", "None", ",", "**", "kwargs", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "[", "]", "if", "kwargs", ":", "url", "=", "url", "+", "UrlEncoded", "(", "'?'", "+", "_encode"...
Sends a GET request to a URL. :param url: The URL. :type url: ``string`` :param headers: A list of pairs specifying the headers for the HTTP response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``). :type headers: ``list`` :param kwargs: Add...
[ "Sends", "a", "GET", "request", "to", "a", "URL", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1160-L1183
train
splunk/splunk-sdk-python
splunklib/binding.py
ResponseReader.peek
def peek(self, size): """Nondestructively retrieves a given number of characters. The next :meth:`read` operation behaves as though this method was never called. :param size: The number of characters to retrieve. :type size: ``integer`` """ c = self.read(size) ...
python
def peek(self, size): """Nondestructively retrieves a given number of characters. The next :meth:`read` operation behaves as though this method was never called. :param size: The number of characters to retrieve. :type size: ``integer`` """ c = self.read(size) ...
[ "def", "peek", "(", "self", ",", "size", ")", ":", "c", "=", "self", ".", "read", "(", "size", ")", "self", ".", "_buffer", "=", "self", ".", "_buffer", "+", "c", "return", "c" ]
Nondestructively retrieves a given number of characters. The next :meth:`read` operation behaves as though this method was never called. :param size: The number of characters to retrieve. :type size: ``integer``
[ "Nondestructively", "retrieves", "a", "given", "number", "of", "characters", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1284-L1295
train
splunk/splunk-sdk-python
splunklib/binding.py
ResponseReader.close
def close(self): """Closes this response.""" if self._connection: self._connection.close() self._response.close()
python
def close(self): """Closes this response.""" if self._connection: self._connection.close() self._response.close()
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_connection", ":", "self", ".", "_connection", ".", "close", "(", ")", "self", ".", "_response", ".", "close", "(", ")" ]
Closes this response.
[ "Closes", "this", "response", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1297-L1301
train
splunk/splunk-sdk-python
splunklib/binding.py
ResponseReader.readinto
def readinto(self, byte_array): """ Read data into a byte array, upto the size of the byte array. :param byte_array: A byte array/memory view to pour bytes into. :type byte_array: ``bytearray`` or ``memoryview`` """ max_size = len(byte_array) data = self.read(max_size) ...
python
def readinto(self, byte_array): """ Read data into a byte array, upto the size of the byte array. :param byte_array: A byte array/memory view to pour bytes into. :type byte_array: ``bytearray`` or ``memoryview`` """ max_size = len(byte_array) data = self.read(max_size) ...
[ "def", "readinto", "(", "self", ",", "byte_array", ")", ":", "max_size", "=", "len", "(", "byte_array", ")", "data", "=", "self", ".", "read", "(", "max_size", ")", "bytes_read", "=", "len", "(", "data", ")", "byte_array", "[", ":", "bytes_read", "]", ...
Read data into a byte array, upto the size of the byte array. :param byte_array: A byte array/memory view to pour bytes into. :type byte_array: ``bytearray`` or ``memoryview``
[ "Read", "data", "into", "a", "byte", "array", "upto", "the", "size", "of", "the", "byte", "array", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/binding.py#L1322-L1333
train
splunk/splunk-sdk-python
splunklib/modularinput/validation_definition.py
ValidationDefinition.parse
def parse(stream): """Creates a ``ValidationDefinition`` from a provided stream containing XML. The XML typically will look like this: ``<items>`` `` <server_host>myHost</server_host>`` `` <server_uri>https://127.0.0.1:8089</server_uri>`` `` <session_key>12310...
python
def parse(stream): """Creates a ``ValidationDefinition`` from a provided stream containing XML. The XML typically will look like this: ``<items>`` `` <server_host>myHost</server_host>`` `` <server_uri>https://127.0.0.1:8089</server_uri>`` `` <session_key>12310...
[ "def", "parse", "(", "stream", ")", ":", "definition", "=", "ValidationDefinition", "(", ")", "root", "=", "ET", ".", "parse", "(", "stream", ")", ".", "getroot", "(", ")", "for", "node", "in", "root", ":", "if", "node", ".", "tag", "==", "\"item\"",...
Creates a ``ValidationDefinition`` from a provided stream containing XML. The XML typically will look like this: ``<items>`` `` <server_host>myHost</server_host>`` `` <server_uri>https://127.0.0.1:8089</server_uri>`` `` <session_key>123102983109283019283</session_key>...
[ "Creates", "a", "ValidationDefinition", "from", "a", "provided", "stream", "containing", "XML", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/modularinput/validation_definition.py#L44-L84
train
splunk/splunk-sdk-python
examples/custom_search/bin/usercount.py
output_results
def output_results(results, mvdelim = '\n', output = sys.stdout): """Given a list of dictionaries, each representing a single result, and an optional list of fields, output those results to stdout for consumption by the Splunk pipeline""" # We collect all the unique field names, as well as # c...
python
def output_results(results, mvdelim = '\n', output = sys.stdout): """Given a list of dictionaries, each representing a single result, and an optional list of fields, output those results to stdout for consumption by the Splunk pipeline""" # We collect all the unique field names, as well as # c...
[ "def", "output_results", "(", "results", ",", "mvdelim", "=", "'\\n'", ",", "output", "=", "sys", ".", "stdout", ")", ":", "fields", "=", "set", "(", ")", "for", "result", "in", "results", ":", "for", "key", "in", "result", ".", "keys", "(", ")", "...
Given a list of dictionaries, each representing a single result, and an optional list of fields, output those results to stdout for consumption by the Splunk pipeline
[ "Given", "a", "list", "of", "dictionaries", "each", "representing", "a", "single", "result", "and", "an", "optional", "list", "of", "fields", "output", "those", "results", "to", "stdout", "for", "consumption", "by", "the", "Splunk", "pipeline" ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/custom_search/bin/usercount.py#L79-L103
train
splunk/splunk-sdk-python
examples/github_forks/github_forks.py
MyScript.validate_input
def validate_input(self, validation_definition): """In this example we are using external validation to verify that the Github repository exists. If validate_input does not raise an Exception, the input is assumed to be valid. Otherwise it prints the exception as an error message when te...
python
def validate_input(self, validation_definition): """In this example we are using external validation to verify that the Github repository exists. If validate_input does not raise an Exception, the input is assumed to be valid. Otherwise it prints the exception as an error message when te...
[ "def", "validate_input", "(", "self", ",", "validation_definition", ")", ":", "owner", "=", "validation_definition", ".", "parameters", "[", "\"owner\"", "]", "repo_name", "=", "validation_definition", ".", "parameters", "[", "\"repo_name\"", "]", "repo_url", "=", ...
In this example we are using external validation to verify that the Github repository exists. If validate_input does not raise an Exception, the input is assumed to be valid. Otherwise it prints the exception as an error message when telling splunkd that the configuration is invalid. Wh...
[ "In", "this", "example", "we", "are", "using", "external", "validation", "to", "verify", "that", "the", "Github", "repository", "exists", ".", "If", "validate_input", "does", "not", "raise", "an", "Exception", "the", "input", "is", "assumed", "to", "be", "va...
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/github_forks/github_forks.py#L73-L107
train
splunk/splunk-sdk-python
splunklib/searchcommands/internals.py
InputHeader.read
def read(self, ifile): """ Reads an input header from an input file. The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the input header is signalled by an empty line or an end-of-file. :param ifile: File-like object that supports ...
python
def read(self, ifile): """ Reads an input header from an input file. The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the input header is signalled by an empty line or an end-of-file. :param ifile: File-like object that supports ...
[ "def", "read", "(", "self", ",", "ifile", ")", ":", "name", ",", "value", "=", "None", ",", "None", "for", "line", "in", "ifile", ":", "if", "line", "==", "'\\n'", ":", "break", "item", "=", "line", ".", "split", "(", "':'", ",", "1", ")", "if"...
Reads an input header from an input file. The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the input header is signalled by an empty line or an end-of-file. :param ifile: File-like object that supports iteration over lines.
[ "Reads", "an", "input", "header", "from", "an", "input", "file", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/searchcommands/internals.py#L352-L376
train
splunk/splunk-sdk-python
splunklib/modularinput/input_definition.py
InputDefinition.parse
def parse(stream): """Parse a stream containing XML into an ``InputDefinition``. :param stream: stream containing XML to parse. :return: definition: an ``InputDefinition`` object. """ definition = InputDefinition() # parse XML from the stream, then get the root node ...
python
def parse(stream): """Parse a stream containing XML into an ``InputDefinition``. :param stream: stream containing XML to parse. :return: definition: an ``InputDefinition`` object. """ definition = InputDefinition() # parse XML from the stream, then get the root node ...
[ "def", "parse", "(", "stream", ")", ":", "definition", "=", "InputDefinition", "(", ")", "root", "=", "ET", ".", "parse", "(", "stream", ")", ".", "getroot", "(", ")", "for", "node", "in", "root", ":", "if", "node", ".", "tag", "==", "\"configuration...
Parse a stream containing XML into an ``InputDefinition``. :param stream: stream containing XML to parse. :return: definition: an ``InputDefinition`` object.
[ "Parse", "a", "stream", "containing", "XML", "into", "an", "InputDefinition", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/modularinput/input_definition.py#L42-L60
train
splunk/splunk-sdk-python
splunklib/searchcommands/environment.py
configure_logging
def configure_logging(logger_name, filename=None): """ Configure logging and return the named logger and the location of the logging configuration file loaded. This function expects a Splunk app directory structure:: <app-root> bin ... default .....
python
def configure_logging(logger_name, filename=None): """ Configure logging and return the named logger and the location of the logging configuration file loaded. This function expects a Splunk app directory structure:: <app-root> bin ... default .....
[ "def", "configure_logging", "(", "logger_name", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "if", "logger_name", "is", "None", ":", "probing_paths", "=", "[", "path", ".", "join", "(", "'local'", ",", "'logging.conf'", ")",...
Configure logging and return the named logger and the location of the logging configuration file loaded. This function expects a Splunk app directory structure:: <app-root> bin ... default ... local ... This function ...
[ "Configure", "logging", "and", "return", "the", "named", "logger", "and", "the", "location", "of", "the", "logging", "configuration", "file", "loaded", "." ]
a245a4eeb93b3621730418008e31715912bcdcd8
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/searchcommands/environment.py#L27-L111
train
kennethreitz/legit
legit/scm.py
SCMRepo.git_exec
def git_exec(self, command, **kwargs): """Execute git commands""" from .cli import verbose_echo command.insert(0, self.git) if kwargs.pop('no_verbose', False): # used when git output isn't helpful to user verbose = False else: verbose = self.verbose ...
python
def git_exec(self, command, **kwargs): """Execute git commands""" from .cli import verbose_echo command.insert(0, self.git) if kwargs.pop('no_verbose', False): # used when git output isn't helpful to user verbose = False else: verbose = self.verbose ...
[ "def", "git_exec", "(", "self", ",", "command", ",", "**", "kwargs", ")", ":", "from", ".", "cli", "import", "verbose_echo", "command", ".", "insert", "(", "0", ",", "self", ".", "git", ")", "if", "kwargs", ".", "pop", "(", "'no_verbose'", ",", "Fals...
Execute git commands
[ "Execute", "git", "commands" ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L47-L65
train
kennethreitz/legit
legit/scm.py
SCMRepo.unstash_index
def unstash_index(self, sync=False, branch=None): """Returns an unstash index if one is available.""" stash_list = self.git_exec(['stash', 'list'], no_verbose=True) if branch is None: branch = self.get_current_branch_name() for stash in stash_list.splitlines(): ...
python
def unstash_index(self, sync=False, branch=None): """Returns an unstash index if one is available.""" stash_list = self.git_exec(['stash', 'list'], no_verbose=True) if branch is None: branch = self.get_current_branch_name() for stash in stash_list.splitlines(): ...
[ "def", "unstash_index", "(", "self", ",", "sync", "=", "False", ",", "branch", "=", "None", ")", ":", "stash_list", "=", "self", ".", "git_exec", "(", "[", "'stash'", ",", "'list'", "]", ",", "no_verbose", "=", "True", ")", "if", "branch", "is", "Non...
Returns an unstash index if one is available.
[ "Returns", "an", "unstash", "index", "if", "one", "is", "available", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L88-L110
train
kennethreitz/legit
legit/scm.py
SCMRepo.unstash_it
def unstash_it(self, sync=False): """ Unstashes changes from current branch for branch sync. Requires prior code setting self.stash_index. """ if self.stash_index is not None: return self.git_exec( ['stash', 'pop', 'stash@{{{0}}}'.format(self.stash_ind...
python
def unstash_it(self, sync=False): """ Unstashes changes from current branch for branch sync. Requires prior code setting self.stash_index. """ if self.stash_index is not None: return self.git_exec( ['stash', 'pop', 'stash@{{{0}}}'.format(self.stash_ind...
[ "def", "unstash_it", "(", "self", ",", "sync", "=", "False", ")", ":", "if", "self", ".", "stash_index", "is", "not", "None", ":", "return", "self", ".", "git_exec", "(", "[", "'stash'", ",", "'pop'", ",", "'stash@{{{0}}}'", ".", "format", "(", "self",...
Unstashes changes from current branch for branch sync. Requires prior code setting self.stash_index.
[ "Unstashes", "changes", "from", "current", "branch", "for", "branch", "sync", ".", "Requires", "prior", "code", "setting", "self", ".", "stash_index", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L118-L125
train
kennethreitz/legit
legit/scm.py
SCMRepo.checkout_branch
def checkout_branch(self, branch): """Checks out given branch.""" _, stdout, stderr = self.git_exec( ['checkout', branch], with_extended_output=True) return '\n'.join([stderr, stdout])
python
def checkout_branch(self, branch): """Checks out given branch.""" _, stdout, stderr = self.git_exec( ['checkout', branch], with_extended_output=True) return '\n'.join([stderr, stdout])
[ "def", "checkout_branch", "(", "self", ",", "branch", ")", ":", "_", ",", "stdout", ",", "stderr", "=", "self", ".", "git_exec", "(", "[", "'checkout'", ",", "branch", "]", ",", "with_extended_output", "=", "True", ")", "return", "'\\n'", ".", "join", ...
Checks out given branch.
[ "Checks", "out", "given", "branch", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L194-L200
train
kennethreitz/legit
legit/scm.py
SCMRepo.unpublish_branch
def unpublish_branch(self, branch): """Unpublishes given branch.""" try: return self.git_exec( ['push', self.remote.name, ':{0}'.format(branch)]) except GitCommandError: _, _, log = self.git_exec( ['fetch', self.remote.name, '--prune'], ...
python
def unpublish_branch(self, branch): """Unpublishes given branch.""" try: return self.git_exec( ['push', self.remote.name, ':{0}'.format(branch)]) except GitCommandError: _, _, log = self.git_exec( ['fetch', self.remote.name, '--prune'], ...
[ "def", "unpublish_branch", "(", "self", ",", "branch", ")", ":", "try", ":", "return", "self", ".", "git_exec", "(", "[", "'push'", ",", "self", ".", "remote", ".", "name", ",", "':{0}'", ".", "format", "(", "branch", ")", "]", ")", "except", "GitCom...
Unpublishes given branch.
[ "Unpublishes", "given", "branch", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L202-L212
train
kennethreitz/legit
legit/scm.py
SCMRepo.undo
def undo(self, hard=False): """Makes last commit not exist""" if not self.fake: return self.repo.git.reset('HEAD^', working_tree=hard) else: click.echo(crayons.red('Faked! >>> git reset {}{}' .format('--hard ' if hard else '', 'HEAD^'))...
python
def undo(self, hard=False): """Makes last commit not exist""" if not self.fake: return self.repo.git.reset('HEAD^', working_tree=hard) else: click.echo(crayons.red('Faked! >>> git reset {}{}' .format('--hard ' if hard else '', 'HEAD^'))...
[ "def", "undo", "(", "self", ",", "hard", "=", "False", ")", ":", "if", "not", "self", ".", "fake", ":", "return", "self", ".", "repo", ".", "git", ".", "reset", "(", "'HEAD^'", ",", "working_tree", "=", "hard", ")", "else", ":", "click", ".", "ec...
Makes last commit not exist
[ "Makes", "last", "commit", "not", "exist" ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L220-L228
train
kennethreitz/legit
legit/scm.py
SCMRepo.get_branches
def get_branches(self, local=True, remote_branches=True): """Returns a list of local and remote branches.""" if not self.repo.remotes: remote_branches = False branches = [] if remote_branches: # Remote refs. try: for b in self.remot...
python
def get_branches(self, local=True, remote_branches=True): """Returns a list of local and remote branches.""" if not self.repo.remotes: remote_branches = False branches = [] if remote_branches: # Remote refs. try: for b in self.remot...
[ "def", "get_branches", "(", "self", ",", "local", "=", "True", ",", "remote_branches", "=", "True", ")", ":", "if", "not", "self", ".", "repo", ".", "remotes", ":", "remote_branches", "=", "False", "branches", "=", "[", "]", "if", "remote_branches", ":",...
Returns a list of local and remote branches.
[ "Returns", "a", "list", "of", "local", "and", "remote", "branches", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L289-L318
train
kennethreitz/legit
legit/scm.py
SCMRepo.display_available_branches
def display_available_branches(self): """Displays available branches.""" if not self.repo.remotes: remote_branches = False else: remote_branches = True branches = self.get_branches(local=True, remote_branches=remote_branches) if not branches: ...
python
def display_available_branches(self): """Displays available branches.""" if not self.repo.remotes: remote_branches = False else: remote_branches = True branches = self.get_branches(local=True, remote_branches=remote_branches) if not branches: ...
[ "def", "display_available_branches", "(", "self", ")", ":", "if", "not", "self", ".", "repo", ".", "remotes", ":", "remote_branches", "=", "False", "else", ":", "remote_branches", "=", "True", "branches", "=", "self", ".", "get_branches", "(", "local", "=", ...
Displays available branches.
[ "Displays", "available", "branches", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/scm.py#L326-L356
train
kennethreitz/legit
legit/utils.py
status_log
def status_log(func, message, *args, **kwargs): """Emits header message, executes a callable, and echoes the return strings.""" click.echo(message) log = func(*args, **kwargs) if log: out = [] for line in log.split('\n'): if not line.startswith('#'): out.ap...
python
def status_log(func, message, *args, **kwargs): """Emits header message, executes a callable, and echoes the return strings.""" click.echo(message) log = func(*args, **kwargs) if log: out = [] for line in log.split('\n'): if not line.startswith('#'): out.ap...
[ "def", "status_log", "(", "func", ",", "message", ",", "*", "args", ",", "**", "kwargs", ")", ":", "click", ".", "echo", "(", "message", ")", "log", "=", "func", "(", "*", "args", ",", "**", "kwargs", ")", "if", "log", ":", "out", "=", "[", "]"...
Emits header message, executes a callable, and echoes the return strings.
[ "Emits", "header", "message", "executes", "a", "callable", "and", "echoes", "the", "return", "strings", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/utils.py#L8-L20
train
kennethreitz/legit
legit/utils.py
verbose_echo
def verbose_echo(str, verbose=False, fake=False): """Selectively output ``str``, with special formatting if ``fake`` is True""" verbose = fake or verbose if verbose: color = crayons.green prefix = '' if fake: color = crayons.red prefix = 'Faked!' clic...
python
def verbose_echo(str, verbose=False, fake=False): """Selectively output ``str``, with special formatting if ``fake`` is True""" verbose = fake or verbose if verbose: color = crayons.green prefix = '' if fake: color = crayons.red prefix = 'Faked!' clic...
[ "def", "verbose_echo", "(", "str", ",", "verbose", "=", "False", ",", "fake", "=", "False", ")", ":", "verbose", "=", "fake", "or", "verbose", "if", "verbose", ":", "color", "=", "crayons", ".", "green", "prefix", "=", "''", "if", "fake", ":", "color...
Selectively output ``str``, with special formatting if ``fake`` is True
[ "Selectively", "output", "str", "with", "special", "formatting", "if", "fake", "is", "True" ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/utils.py#L23-L33
train
kennethreitz/legit
legit/utils.py
output_aliases
def output_aliases(aliases): """Display git aliases""" for alias in aliases: cmd = '!legit ' + alias click.echo(columns([colored.yellow('git ' + alias), 20], [cmd, None]))
python
def output_aliases(aliases): """Display git aliases""" for alias in aliases: cmd = '!legit ' + alias click.echo(columns([colored.yellow('git ' + alias), 20], [cmd, None]))
[ "def", "output_aliases", "(", "aliases", ")", ":", "for", "alias", "in", "aliases", ":", "cmd", "=", "'!legit '", "+", "alias", "click", ".", "echo", "(", "columns", "(", "[", "colored", ".", "yellow", "(", "'git '", "+", "alias", ")", ",", "20", "]"...
Display git aliases
[ "Display", "git", "aliases" ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/utils.py#L36-L40
train
kennethreitz/legit
legit/cli.py
cli
def cli(ctx, verbose, fake, install, uninstall, config): """legit command line interface""" # Create a repo object and remember it as as the context object. From # this point onwards other commands can refer to it by using the # @pass_scm decorator. ctx.obj = SCMRepo() ctx.obj.fake = fake c...
python
def cli(ctx, verbose, fake, install, uninstall, config): """legit command line interface""" # Create a repo object and remember it as as the context object. From # this point onwards other commands can refer to it by using the # @pass_scm decorator. ctx.obj = SCMRepo() ctx.obj.fake = fake c...
[ "def", "cli", "(", "ctx", ",", "verbose", ",", "fake", ",", "install", ",", "uninstall", ",", "config", ")", ":", "ctx", ".", "obj", "=", "SCMRepo", "(", ")", "ctx", ".", "obj", ".", "fake", "=", "fake", "ctx", ".", "obj", ".", "verbose", "=", ...
legit command line interface
[ "legit", "command", "line", "interface" ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L82-L103
train
kennethreitz/legit
legit/cli.py
switch
def switch(scm, to_branch, verbose, fake): """Switches from one branch to another, safely stashing and restoring local changes. """ scm.fake = fake scm.verbose = fake or verbose scm.repo_check() if to_branch is None: scm.display_available_branches() raise click.BadArgumentUsage...
python
def switch(scm, to_branch, verbose, fake): """Switches from one branch to another, safely stashing and restoring local changes. """ scm.fake = fake scm.verbose = fake or verbose scm.repo_check() if to_branch is None: scm.display_available_branches() raise click.BadArgumentUsage...
[ "def", "switch", "(", "scm", ",", "to_branch", ",", "verbose", ",", "fake", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", ")", "if", "to_branch", "is", "None", ":", "s...
Switches from one branch to another, safely stashing and restoring local changes.
[ "Switches", "from", "one", "branch", "to", "another", "safely", "stashing", "and", "restoring", "local", "changes", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L111-L126
train
kennethreitz/legit
legit/cli.py
sync
def sync(ctx, scm, to_branch, verbose, fake): """Stashes unstaged changes, Fetches remote data, Performs smart pull+merge, Pushes local commits up, and Unstashes changes. Defaults to current branch. """ scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) ...
python
def sync(ctx, scm, to_branch, verbose, fake): """Stashes unstaged changes, Fetches remote data, Performs smart pull+merge, Pushes local commits up, and Unstashes changes. Defaults to current branch. """ scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) ...
[ "def", "sync", "(", "ctx", ",", "scm", ",", "to_branch", ",", "verbose", ",", "fake", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", "require_remote", "=", "True", ")", ...
Stashes unstaged changes, Fetches remote data, Performs smart pull+merge, Pushes local commits up, and Unstashes changes. Defaults to current branch.
[ "Stashes", "unstaged", "changes", "Fetches", "remote", "data", "Performs", "smart", "pull", "+", "merge", "Pushes", "local", "commits", "up", "and", "Unstashes", "changes", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L135-L173
train
kennethreitz/legit
legit/cli.py
publish
def publish(scm, to_branch, verbose, fake): """Pushes an unpublished branch to a remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(to_branch) if not branch: branch = scm.get_current_branch_name() ...
python
def publish(scm, to_branch, verbose, fake): """Pushes an unpublished branch to a remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(to_branch) if not branch: branch = scm.get_current_branch_name() ...
[ "def", "publish", "(", "scm", ",", "to_branch", ",", "verbose", ",", "fake", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", "require_remote", "=", "True", ")", "branch", ...
Pushes an unpublished branch to a remote repository.
[ "Pushes", "an", "unpublished", "branch", "to", "a", "remote", "repository", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L181-L207
train
kennethreitz/legit
legit/cli.py
unpublish
def unpublish(scm, published_branch, verbose, fake): """Removes a published branch from the remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(published_branch) if not branch: scm.display_available_bra...
python
def unpublish(scm, published_branch, verbose, fake): """Removes a published branch from the remote repository.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check(require_remote=True) branch = scm.fuzzy_match_branch(published_branch) if not branch: scm.display_available_bra...
[ "def", "unpublish", "(", "scm", ",", "published_branch", ",", "verbose", ",", "fake", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", "require_remote", "=", "True", ")", "br...
Removes a published branch from the remote repository.
[ "Removes", "a", "published", "branch", "from", "the", "remote", "repository", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L215-L235
train
kennethreitz/legit
legit/cli.py
undo
def undo(scm, verbose, fake, hard): """Removes the last commit from history.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check() status_log(scm.undo, 'Last commit removed from history.', hard)
python
def undo(scm, verbose, fake, hard): """Removes the last commit from history.""" scm.fake = fake scm.verbose = fake or verbose scm.repo_check() status_log(scm.undo, 'Last commit removed from history.', hard)
[ "def", "undo", "(", "scm", ",", "verbose", ",", "fake", ",", "hard", ")", ":", "scm", ".", "fake", "=", "fake", "scm", ".", "verbose", "=", "fake", "or", "verbose", "scm", ".", "repo_check", "(", ")", "status_log", "(", "scm", ".", "undo", ",", "...
Removes the last commit from history.
[ "Removes", "the", "last", "commit", "from", "history", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L243-L250
train
kennethreitz/legit
legit/cli.py
do_install
def do_install(ctx, verbose, fake): """Installs legit git aliases.""" click.echo('The following git aliases will be installed:\n') aliases = cli.list_commands(ctx) output_aliases(aliases) if click.confirm('\n{}Install aliases above?'.format('FAKE ' if fake else ''), default=fake): for alias...
python
def do_install(ctx, verbose, fake): """Installs legit git aliases.""" click.echo('The following git aliases will be installed:\n') aliases = cli.list_commands(ctx) output_aliases(aliases) if click.confirm('\n{}Install aliases above?'.format('FAKE ' if fake else ''), default=fake): for alias...
[ "def", "do_install", "(", "ctx", ",", "verbose", ",", "fake", ")", ":", "click", ".", "echo", "(", "'The following git aliases will be installed:\\n'", ")", "aliases", "=", "cli", ".", "list_commands", "(", "ctx", ")", "output_aliases", "(", "aliases", ")", "i...
Installs legit git aliases.
[ "Installs", "legit", "git", "aliases", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L262-L278
train
kennethreitz/legit
legit/cli.py
do_uninstall
def do_uninstall(ctx, verbose, fake): """Uninstalls legit git aliases, including deprecated legit sub-commands.""" aliases = cli.list_commands(ctx) # Add deprecated aliases aliases.extend(['graft', 'harvest', 'sprout', 'resync', 'settings', 'install', 'uninstall']) for alias in aliases: syst...
python
def do_uninstall(ctx, verbose, fake): """Uninstalls legit git aliases, including deprecated legit sub-commands.""" aliases = cli.list_commands(ctx) # Add deprecated aliases aliases.extend(['graft', 'harvest', 'sprout', 'resync', 'settings', 'install', 'uninstall']) for alias in aliases: syst...
[ "def", "do_uninstall", "(", "ctx", ",", "verbose", ",", "fake", ")", ":", "aliases", "=", "cli", ".", "list_commands", "(", "ctx", ")", "aliases", ".", "extend", "(", "[", "'graft'", ",", "'harvest'", ",", "'sprout'", ",", "'resync'", ",", "'settings'", ...
Uninstalls legit git aliases, including deprecated legit sub-commands.
[ "Uninstalls", "legit", "git", "aliases", "including", "deprecated", "legit", "sub", "-", "commands", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L281-L293
train
kennethreitz/legit
legit/cli.py
do_edit_settings
def do_edit_settings(fake): """Opens legit settings in editor.""" path = resources.user.open('config.ini').name click.echo('Legit Settings:\n') for (option, _, description) in legit_settings.config_defaults: click.echo(columns([crayons.yellow(option), 25], [description, None])) click.echo...
python
def do_edit_settings(fake): """Opens legit settings in editor.""" path = resources.user.open('config.ini').name click.echo('Legit Settings:\n') for (option, _, description) in legit_settings.config_defaults: click.echo(columns([crayons.yellow(option), 25], [description, None])) click.echo...
[ "def", "do_edit_settings", "(", "fake", ")", ":", "path", "=", "resources", ".", "user", ".", "open", "(", "'config.ini'", ")", ".", "name", "click", ".", "echo", "(", "'Legit Settings:\\n'", ")", "for", "(", "option", ",", "_", ",", "description", ")", ...
Opens legit settings in editor.
[ "Opens", "legit", "settings", "in", "editor", "." ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L296-L310
train
kennethreitz/legit
legit/cli.py
LegitGroup.get_command
def get_command(self, ctx, cmd_name): """Override to handle command aliases""" rv = click.Group.get_command(self, ctx, cmd_name) if rv is not None: return rv cmd_name = self.command_aliases.get(cmd_name, "") return click.Group.get_command(self, ctx, cmd_name)
python
def get_command(self, ctx, cmd_name): """Override to handle command aliases""" rv = click.Group.get_command(self, ctx, cmd_name) if rv is not None: return rv cmd_name = self.command_aliases.get(cmd_name, "") return click.Group.get_command(self, ctx, cmd_name)
[ "def", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", ":", "rv", "=", "click", ".", "Group", ".", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", "if", "rv", "is", "not", "None", ":", "return", "rv", "cmd_name", "=", "s...
Override to handle command aliases
[ "Override", "to", "handle", "command", "aliases" ]
699802c5be665bd358456a940953b5c1d8672754
https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L42-L48
train
nschloe/meshio
meshio/cli.py
_get_parser
def _get_parser(): """Parse input options.""" import argparse parser = argparse.ArgumentParser(description=("Convert between mesh formats.")) parser.add_argument("infile", type=str, help="mesh file to be read from") parser.add_argument( "--input-format", "-i", type=str, ...
python
def _get_parser(): """Parse input options.""" import argparse parser = argparse.ArgumentParser(description=("Convert between mesh formats.")) parser.add_argument("infile", type=str, help="mesh file to be read from") parser.add_argument( "--input-format", "-i", type=str, ...
[ "def", "_get_parser", "(", ")", ":", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "(", "\"Convert between mesh formats.\"", ")", ")", "parser", ".", "add_argument", "(", "\"infile\"", ",", "type", "=", "str", ...
Parse input options.
[ "Parse", "input", "options", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/cli.py#L43-L93
train
nschloe/meshio
meshio/msh_io/main.py
_read_header
def _read_header(f): """Read the mesh format block specified as version(ASCII double; currently 4.1) file-type(ASCII int; 0 for ASCII mode, 1 for binary mode) data-size(ASCII int; sizeof(size_t)) < int with value one; only in binary mode, to detect endianness > though here the ver...
python
def _read_header(f): """Read the mesh format block specified as version(ASCII double; currently 4.1) file-type(ASCII int; 0 for ASCII mode, 1 for binary mode) data-size(ASCII int; sizeof(size_t)) < int with value one; only in binary mode, to detect endianness > though here the ver...
[ "def", "_read_header", "(", "f", ")", ":", "line", "=", "f", ".", "readline", "(", ")", ".", "decode", "(", "\"utf-8\"", ")", "str_list", "=", "list", "(", "filter", "(", "None", ",", "line", ".", "split", "(", ")", ")", ")", "fmt_version", "=", ...
Read the mesh format block specified as version(ASCII double; currently 4.1) file-type(ASCII int; 0 for ASCII mode, 1 for binary mode) data-size(ASCII int; sizeof(size_t)) < int with value one; only in binary mode, to detect endianness > though here the version is left as str
[ "Read", "the", "mesh", "format", "block" ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/msh_io/main.py#L48-L81
train
nschloe/meshio
meshio/msh_io/main.py
write
def write(filename, mesh, fmt_version, write_binary=True): """Writes a Gmsh msh file. """ try: writer = _writers[fmt_version] except KeyError: try: writer = _writers[fmt_version.split(".")[0]] except KeyError: raise ValueError( "Need mesh f...
python
def write(filename, mesh, fmt_version, write_binary=True): """Writes a Gmsh msh file. """ try: writer = _writers[fmt_version] except KeyError: try: writer = _writers[fmt_version.split(".")[0]] except KeyError: raise ValueError( "Need mesh f...
[ "def", "write", "(", "filename", ",", "mesh", ",", "fmt_version", ",", "write_binary", "=", "True", ")", ":", "try", ":", "writer", "=", "_writers", "[", "fmt_version", "]", "except", "KeyError", ":", "try", ":", "writer", "=", "_writers", "[", "fmt_vers...
Writes a Gmsh msh file.
[ "Writes", "a", "Gmsh", "msh", "file", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/msh_io/main.py#L84-L99
train
nschloe/meshio
meshio/helpers.py
write
def write(filename, mesh, file_format=None, **kwargs): """Writes mesh together with data to a file. :params filename: File to write to. :type filename: str :params point_data: Named additional point data to write to the file. :type point_data: dict """ if not file_format: # deduce ...
python
def write(filename, mesh, file_format=None, **kwargs): """Writes mesh together with data to a file. :params filename: File to write to. :type filename: str :params point_data: Named additional point data to write to the file. :type point_data: dict """ if not file_format: # deduce ...
[ "def", "write", "(", "filename", ",", "mesh", ",", "file_format", "=", "None", ",", "**", "kwargs", ")", ":", "if", "not", "file_format", ":", "file_format", "=", "_filetype_from_filename", "(", "filename", ")", "for", "key", ",", "value", "in", "mesh", ...
Writes mesh together with data to a file. :params filename: File to write to. :type filename: str :params point_data: Named additional point data to write to the file. :type point_data: dict
[ "Writes", "mesh", "together", "with", "data", "to", "a", "file", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/helpers.py#L193-L227
train
nschloe/meshio
meshio/medit_io.py
_ItemReader.next_items
def next_items(self, n): """Returns the next n items. Throws StopIteration when there is not enough data to return n items. """ items = [] while len(items) < n: if self._line_ptr >= len(self._line): # Load the next line. line = next(se...
python
def next_items(self, n): """Returns the next n items. Throws StopIteration when there is not enough data to return n items. """ items = [] while len(items) < n: if self._line_ptr >= len(self._line): # Load the next line. line = next(se...
[ "def", "next_items", "(", "self", ",", "n", ")", ":", "items", "=", "[", "]", "while", "len", "(", "items", ")", "<", "n", ":", "if", "self", ".", "_line_ptr", ">=", "len", "(", "self", ".", "_line", ")", ":", "line", "=", "next", "(", "self", ...
Returns the next n items. Throws StopIteration when there is not enough data to return n items.
[ "Returns", "the", "next", "n", "items", "." ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/medit_io.py#L35-L53
train
nschloe/meshio
meshio/abaqus_io.py
get_param_map
def get_param_map(word, required_keys=None): """ get the optional arguments on a line Example ------- >>> iline = 0 >>> word = 'elset,instance=dummy2,generate' >>> params = get_param_map(iline, word, required_keys=['instance']) params = { 'elset' : None, 'instance' : 'du...
python
def get_param_map(word, required_keys=None): """ get the optional arguments on a line Example ------- >>> iline = 0 >>> word = 'elset,instance=dummy2,generate' >>> params = get_param_map(iline, word, required_keys=['instance']) params = { 'elset' : None, 'instance' : 'du...
[ "def", "get_param_map", "(", "word", ",", "required_keys", "=", "None", ")", ":", "if", "required_keys", "is", "None", ":", "required_keys", "=", "[", "]", "words", "=", "word", ".", "split", "(", "\",\"", ")", "param_map", "=", "{", "}", "for", "wordi...
get the optional arguments on a line Example ------- >>> iline = 0 >>> word = 'elset,instance=dummy2,generate' >>> params = get_param_map(iline, word, required_keys=['instance']) params = { 'elset' : None, 'instance' : 'dummy2, 'generate' : None, }
[ "get", "the", "optional", "arguments", "on", "a", "line" ]
cb78285962b573fb46a4f3f54276206d922bdbcb
https://github.com/nschloe/meshio/blob/cb78285962b573fb46a4f3f54276206d922bdbcb/meshio/abaqus_io.py#L193-L229
train
spulec/moto
moto/ssm/models.py
SimpleSystemManagerBackend.get_parameters_by_path
def get_parameters_by_path(self, path, with_decryption, recursive, filters=None): """Implement the get-parameters-by-path-API in the backend.""" result = [] # path could be with or without a trailing /. we handle this # difference here. path = path.rstrip('/') + '/' for p...
python
def get_parameters_by_path(self, path, with_decryption, recursive, filters=None): """Implement the get-parameters-by-path-API in the backend.""" result = [] # path could be with or without a trailing /. we handle this # difference here. path = path.rstrip('/') + '/' for p...
[ "def", "get_parameters_by_path", "(", "self", ",", "path", ",", "with_decryption", ",", "recursive", ",", "filters", "=", "None", ")", ":", "result", "=", "[", "]", "path", "=", "path", ".", "rstrip", "(", "'/'", ")", "+", "'/'", "for", "param", "in", ...
Implement the get-parameters-by-path-API in the backend.
[ "Implement", "the", "get", "-", "parameters", "-", "by", "-", "path", "-", "API", "in", "the", "backend", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ssm/models.py#L255-L270
train
spulec/moto
moto/ssm/models.py
SimpleSystemManagerBackend._match_filters
def _match_filters(parameter, filters=None): """Return True if the given parameter matches all the filters""" for filter_obj in (filters or []): key = filter_obj['Key'] option = filter_obj.get('Option', 'Equals') values = filter_obj.get('Values', []) what...
python
def _match_filters(parameter, filters=None): """Return True if the given parameter matches all the filters""" for filter_obj in (filters or []): key = filter_obj['Key'] option = filter_obj.get('Option', 'Equals') values = filter_obj.get('Values', []) what...
[ "def", "_match_filters", "(", "parameter", ",", "filters", "=", "None", ")", ":", "for", "filter_obj", "in", "(", "filters", "or", "[", "]", ")", ":", "key", "=", "filter_obj", "[", "'Key'", "]", "option", "=", "filter_obj", ".", "get", "(", "'Option'"...
Return True if the given parameter matches all the filters
[ "Return", "True", "if", "the", "given", "parameter", "matches", "all", "the", "filters" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ssm/models.py#L273-L293
train
spulec/moto
scripts/scaffold.py
initialize_service
def initialize_service(service, operation, api_protocol): """create lib and test dirs if not exist """ lib_dir = get_lib_dir(service) test_dir = get_test_dir(service) print_progress('Initializing service', service, 'green') client = boto3.client(service) service_class = client.__class__.__...
python
def initialize_service(service, operation, api_protocol): """create lib and test dirs if not exist """ lib_dir = get_lib_dir(service) test_dir = get_test_dir(service) print_progress('Initializing service', service, 'green') client = boto3.client(service) service_class = client.__class__.__...
[ "def", "initialize_service", "(", "service", ",", "operation", ",", "api_protocol", ")", ":", "lib_dir", "=", "get_lib_dir", "(", "service", ")", "test_dir", "=", "get_test_dir", "(", "service", ")", "print_progress", "(", "'Initializing service'", ",", "service",...
create lib and test dirs if not exist
[ "create", "lib", "and", "test", "dirs", "if", "not", "exist" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/scripts/scaffold.py#L167-L216
train
spulec/moto
scripts/scaffold.py
get_response_query_template
def get_response_query_template(service, operation): """refers to definition of API in botocore, and autogenerates template Assume that response format is xml when protocol is query You can see example of elbv2 from link below. https://github.com/boto/botocore/blob/develop/botocore/data/elbv2/2015-12...
python
def get_response_query_template(service, operation): """refers to definition of API in botocore, and autogenerates template Assume that response format is xml when protocol is query You can see example of elbv2 from link below. https://github.com/boto/botocore/blob/develop/botocore/data/elbv2/2015-12...
[ "def", "get_response_query_template", "(", "service", ",", "operation", ")", ":", "client", "=", "boto3", ".", "client", "(", "service", ")", "aws_operation_name", "=", "to_upper_camel_case", "(", "operation", ")", "op_model", "=", "client", ".", "_service_model",...
refers to definition of API in botocore, and autogenerates template Assume that response format is xml when protocol is query You can see example of elbv2 from link below. https://github.com/boto/botocore/blob/develop/botocore/data/elbv2/2015-12-01/service-2.json
[ "refers", "to", "definition", "of", "API", "in", "botocore", "and", "autogenerates", "template", "Assume", "that", "response", "format", "is", "xml", "when", "protocol", "is", "query" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/scripts/scaffold.py#L324-L382
train
spulec/moto
moto/core/utils.py
camelcase_to_underscores
def camelcase_to_underscores(argument): ''' Converts a camelcase param like theNewAttribute to the equivalent python underscore variable like the_new_attribute''' result = '' prev_char_title = True if not argument: return argument for index, char in enumerate(argument): try: ...
python
def camelcase_to_underscores(argument): ''' Converts a camelcase param like theNewAttribute to the equivalent python underscore variable like the_new_attribute''' result = '' prev_char_title = True if not argument: return argument for index, char in enumerate(argument): try: ...
[ "def", "camelcase_to_underscores", "(", "argument", ")", ":", "result", "=", "''", "prev_char_title", "=", "True", "if", "not", "argument", ":", "return", "argument", "for", "index", ",", "char", "in", "enumerate", "(", "argument", ")", ":", "try", ":", "n...
Converts a camelcase param like theNewAttribute to the equivalent python underscore variable like the_new_attribute
[ "Converts", "a", "camelcase", "param", "like", "theNewAttribute", "to", "the", "equivalent", "python", "underscore", "variable", "like", "the_new_attribute" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/utils.py#L17-L40
train
spulec/moto
moto/core/utils.py
underscores_to_camelcase
def underscores_to_camelcase(argument): ''' Converts a camelcase param like the_new_attribute to the equivalent camelcase version like theNewAttribute. Note that the first letter is NOT capitalized by this function ''' result = '' previous_was_underscore = False for char in argument: if ...
python
def underscores_to_camelcase(argument): ''' Converts a camelcase param like the_new_attribute to the equivalent camelcase version like theNewAttribute. Note that the first letter is NOT capitalized by this function ''' result = '' previous_was_underscore = False for char in argument: if ...
[ "def", "underscores_to_camelcase", "(", "argument", ")", ":", "result", "=", "''", "previous_was_underscore", "=", "False", "for", "char", "in", "argument", ":", "if", "char", "!=", "'_'", ":", "if", "previous_was_underscore", ":", "result", "+=", "char", ".",...
Converts a camelcase param like the_new_attribute to the equivalent camelcase version like theNewAttribute. Note that the first letter is NOT capitalized by this function
[ "Converts", "a", "camelcase", "param", "like", "the_new_attribute", "to", "the", "equivalent", "camelcase", "version", "like", "theNewAttribute", ".", "Note", "that", "the", "first", "letter", "is", "NOT", "capitalized", "by", "this", "function" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/utils.py#L43-L56
train
spulec/moto
moto/core/utils.py
convert_regex_to_flask_path
def convert_regex_to_flask_path(url_path): """ Converts a regex matching url to one that can be used with flask """ for token in ["$"]: url_path = url_path.replace(token, "") def caller(reg): match_name, match_pattern = reg.groups() return '<regex("{0}"):{1}>'.format(match_p...
python
def convert_regex_to_flask_path(url_path): """ Converts a regex matching url to one that can be used with flask """ for token in ["$"]: url_path = url_path.replace(token, "") def caller(reg): match_name, match_pattern = reg.groups() return '<regex("{0}"):{1}>'.format(match_p...
[ "def", "convert_regex_to_flask_path", "(", "url_path", ")", ":", "for", "token", "in", "[", "\"$\"", "]", ":", "url_path", "=", "url_path", ".", "replace", "(", "token", ",", "\"\"", ")", "def", "caller", "(", "reg", ")", ":", "match_name", ",", "match_p...
Converts a regex matching url to one that can be used with flask
[ "Converts", "a", "regex", "matching", "url", "to", "one", "that", "can", "be", "used", "with", "flask" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/utils.py#L80-L96
train
spulec/moto
moto/emr/responses.py
generate_boto3_response
def generate_boto3_response(operation): """The decorator to convert an XML response to JSON, if the request is determined to be from boto3. Pass the API action as a parameter. """ def _boto3_request(method): @wraps(method) def f(self, *args, **kwargs): rendered = method(self...
python
def generate_boto3_response(operation): """The decorator to convert an XML response to JSON, if the request is determined to be from boto3. Pass the API action as a parameter. """ def _boto3_request(method): @wraps(method) def f(self, *args, **kwargs): rendered = method(self...
[ "def", "generate_boto3_response", "(", "operation", ")", ":", "def", "_boto3_request", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "f", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "rendered", "=", "method", "(", ...
The decorator to convert an XML response to JSON, if the request is determined to be from boto3. Pass the API action as a parameter.
[ "The", "decorator", "to", "convert", "an", "XML", "response", "to", "JSON", "if", "the", "request", "is", "determined", "to", "be", "from", "boto3", ".", "Pass", "the", "API", "action", "as", "a", "parameter", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/emr/responses.py#L18-L37
train
spulec/moto
moto/ecr/models.py
ECRBackend.describe_repositories
def describe_repositories(self, registry_id=None, repository_names=None): """ maxResults and nextToken not implemented """ if repository_names: for repository_name in repository_names: if repository_name not in self.repositories: raise Repo...
python
def describe_repositories(self, registry_id=None, repository_names=None): """ maxResults and nextToken not implemented """ if repository_names: for repository_name in repository_names: if repository_name not in self.repositories: raise Repo...
[ "def", "describe_repositories", "(", "self", ",", "registry_id", "=", "None", ",", "repository_names", "=", "None", ")", ":", "if", "repository_names", ":", "for", "repository_name", "in", "repository_names", ":", "if", "repository_name", "not", "in", "self", "....
maxResults and nextToken not implemented
[ "maxResults", "and", "nextToken", "not", "implemented" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ecr/models.py#L174-L195
train
spulec/moto
moto/ecr/models.py
ECRBackend.list_images
def list_images(self, repository_name, registry_id=None): """ maxResults and filtering not implemented """ repository = None found = False if repository_name in self.repositories: repository = self.repositories[repository_name] if registry_id: ...
python
def list_images(self, repository_name, registry_id=None): """ maxResults and filtering not implemented """ repository = None found = False if repository_name in self.repositories: repository = self.repositories[repository_name] if registry_id: ...
[ "def", "list_images", "(", "self", ",", "repository_name", ",", "registry_id", "=", "None", ")", ":", "repository", "=", "None", "found", "=", "False", "if", "repository_name", "in", "self", ".", "repositories", ":", "repository", "=", "self", ".", "reposito...
maxResults and filtering not implemented
[ "maxResults", "and", "filtering", "not", "implemented" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ecr/models.py#L208-L228
train
spulec/moto
moto/packages/httpretty/core.py
httprettified
def httprettified(test): "A decorator tests that use HTTPretty" def decorate_class(klass): for attr in dir(klass): if not attr.startswith('test_'): continue attr_value = getattr(klass, attr) if not hasattr(attr_value, "__call__"): cont...
python
def httprettified(test): "A decorator tests that use HTTPretty" def decorate_class(klass): for attr in dir(klass): if not attr.startswith('test_'): continue attr_value = getattr(klass, attr) if not hasattr(attr_value, "__call__"): cont...
[ "def", "httprettified", "(", "test", ")", ":", "\"A decorator tests that use HTTPretty\"", "def", "decorate_class", "(", "klass", ")", ":", "for", "attr", "in", "dir", "(", "klass", ")", ":", "if", "not", "attr", ".", "startswith", "(", "'test_'", ")", ":", ...
A decorator tests that use HTTPretty
[ "A", "decorator", "tests", "that", "use", "HTTPretty" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/core.py#L1089-L1116
train
spulec/moto
moto/packages/httpretty/core.py
URIMatcher.get_next_entry
def get_next_entry(self, method, info, request): """Cycle through available responses, but only once. Any subsequent requests will receive the last response""" if method not in self.current_entries: self.current_entries[method] = 0 # restrict selection to entries that match...
python
def get_next_entry(self, method, info, request): """Cycle through available responses, but only once. Any subsequent requests will receive the last response""" if method not in self.current_entries: self.current_entries[method] = 0 # restrict selection to entries that match...
[ "def", "get_next_entry", "(", "self", ",", "method", ",", "info", ",", "request", ")", ":", "if", "method", "not", "in", "self", ".", "current_entries", ":", "self", ".", "current_entries", "[", "method", "]", "=", "0", "entries_for_method", "=", "[", "e...
Cycle through available responses, but only once. Any subsequent requests will receive the last response
[ "Cycle", "through", "available", "responses", "but", "only", "once", ".", "Any", "subsequent", "requests", "will", "receive", "the", "last", "response" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/core.py#L809-L837
train
spulec/moto
moto/xray/mock_client.py
mock_xray_client
def mock_xray_client(f): """ Mocks the X-Ray sdk by pwning its evil singleton with our methods The X-Ray SDK has normally been imported and `patched()` called long before we start mocking. This means the Context() will be very unhappy if an env var isnt present, so we set that, save the old context...
python
def mock_xray_client(f): """ Mocks the X-Ray sdk by pwning its evil singleton with our methods The X-Ray SDK has normally been imported and `patched()` called long before we start mocking. This means the Context() will be very unhappy if an env var isnt present, so we set that, save the old context...
[ "def", "mock_xray_client", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "_wrapped", "(", "*", "args", ",", "**", "kwargs", ")", ":", "print", "(", "\"Starting X-Ray Patch\"", ")", "old_xray_context_var", "=", "os", ".", "environ", ".", "get", ...
Mocks the X-Ray sdk by pwning its evil singleton with our methods The X-Ray SDK has normally been imported and `patched()` called long before we start mocking. This means the Context() will be very unhappy if an env var isnt present, so we set that, save the old context, then supply our new context. We...
[ "Mocks", "the", "X", "-", "Ray", "sdk", "by", "pwning", "its", "evil", "singleton", "with", "our", "methods" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/xray/mock_client.py#L32-L65
train
spulec/moto
moto/iot/models.py
FakeCertificate.to_description_dict
def to_description_dict(self): """ You might need keys below in some situation - caCertificateId - previousOwnedBy """ return { 'certificateArn': self.arn, 'certificateId': self.certificate_id, 'status': self.status, 'ce...
python
def to_description_dict(self): """ You might need keys below in some situation - caCertificateId - previousOwnedBy """ return { 'certificateArn': self.arn, 'certificateId': self.certificate_id, 'status': self.status, 'ce...
[ "def", "to_description_dict", "(", "self", ")", ":", "return", "{", "'certificateArn'", ":", "self", ".", "arn", ",", "'certificateId'", ":", "self", ".", "certificate_id", ",", "'status'", ":", "self", ".", "status", ",", "'certificatePem'", ":", "self", "....
You might need keys below in some situation - caCertificateId - previousOwnedBy
[ "You", "might", "need", "keys", "below", "in", "some", "situation", "-", "caCertificateId", "-", "previousOwnedBy" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iot/models.py#L122-L137
train
spulec/moto
moto/opsworks/models.py
OpsworkInstance.start
def start(self): """ create an ec2 reservation if one doesn't already exist and call start_instance. Update instance attributes to the newly created instance attributes """ if self.instance is None: reservation = self.ec2_backend.add_instances( ...
python
def start(self): """ create an ec2 reservation if one doesn't already exist and call start_instance. Update instance attributes to the newly created instance attributes """ if self.instance is None: reservation = self.ec2_backend.add_instances( ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "instance", "is", "None", ":", "reservation", "=", "self", ".", "ec2_backend", ".", "add_instances", "(", "image_id", "=", "self", ".", "ami_id", ",", "count", "=", "1", ",", "user_data", "=", ...
create an ec2 reservation if one doesn't already exist and call start_instance. Update instance attributes to the newly created instance attributes
[ "create", "an", "ec2", "reservation", "if", "one", "doesn", "t", "already", "exist", "and", "call", "start_instance", ".", "Update", "instance", "attributes", "to", "the", "newly", "created", "instance", "attributes" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/opsworks/models.py#L84-L116
train
spulec/moto
moto/core/responses.py
flatten_json_request_body
def flatten_json_request_body(prefix, dict_body, spec): """Convert a JSON request body into query params.""" if len(spec) == 1 and 'type' in spec: return {prefix: to_str(dict_body, spec)} flat = {} for key, value in dict_body.items(): node_type = spec[key]['type'] if node_type =...
python
def flatten_json_request_body(prefix, dict_body, spec): """Convert a JSON request body into query params.""" if len(spec) == 1 and 'type' in spec: return {prefix: to_str(dict_body, spec)} flat = {} for key, value in dict_body.items(): node_type = spec[key]['type'] if node_type =...
[ "def", "flatten_json_request_body", "(", "prefix", ",", "dict_body", ",", "spec", ")", ":", "if", "len", "(", "spec", ")", "==", "1", "and", "'type'", "in", "spec", ":", "return", "{", "prefix", ":", "to_str", "(", "dict_body", ",", "spec", ")", "}", ...
Convert a JSON request body into query params.
[ "Convert", "a", "JSON", "request", "body", "into", "query", "params", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/responses.py#L751-L776
train
spulec/moto
moto/core/responses.py
xml_to_json_response
def xml_to_json_response(service_spec, operation, xml, result_node=None): """Convert rendered XML response to JSON for use with boto3.""" def transform(value, spec): """Apply transformations to make the output JSON comply with the expected form. This function applies: (1) Type cast t...
python
def xml_to_json_response(service_spec, operation, xml, result_node=None): """Convert rendered XML response to JSON for use with boto3.""" def transform(value, spec): """Apply transformations to make the output JSON comply with the expected form. This function applies: (1) Type cast t...
[ "def", "xml_to_json_response", "(", "service_spec", ",", "operation", ",", "xml", ",", "result_node", "=", "None", ")", ":", "def", "transform", "(", "value", ",", "spec", ")", ":", "if", "len", "(", "spec", ")", "==", "1", ":", "return", "from_str", "...
Convert rendered XML response to JSON for use with boto3.
[ "Convert", "rendered", "XML", "response", "to", "JSON", "for", "use", "with", "boto3", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/responses.py#L779-L852
train
spulec/moto
moto/core/responses.py
BaseResponse.get_current_user
def get_current_user(self): """ Returns the access key id used in this request as the current user id """ if 'Authorization' in self.headers: match = self.access_key_regex.search(self.headers['Authorization']) if match: return match.group(1) ...
python
def get_current_user(self): """ Returns the access key id used in this request as the current user id """ if 'Authorization' in self.headers: match = self.access_key_regex.search(self.headers['Authorization']) if match: return match.group(1) ...
[ "def", "get_current_user", "(", "self", ")", ":", "if", "'Authorization'", "in", "self", ".", "headers", ":", "match", "=", "self", ".", "access_key_regex", ".", "search", "(", "self", ".", "headers", "[", "'Authorization'", "]", ")", "if", "match", ":", ...
Returns the access key id used in this request as the current user id
[ "Returns", "the", "access", "key", "id", "used", "in", "this", "request", "as", "the", "current", "user", "id" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/responses.py#L183-L196
train
spulec/moto
moto/kms/models.py
KmsBackend.delete_alias
def delete_alias(self, alias_name): """Delete the alias.""" for aliases in self.key_to_aliases.values(): if alias_name in aliases: aliases.remove(alias_name)
python
def delete_alias(self, alias_name): """Delete the alias.""" for aliases in self.key_to_aliases.values(): if alias_name in aliases: aliases.remove(alias_name)
[ "def", "delete_alias", "(", "self", ",", "alias_name", ")", ":", "for", "aliases", "in", "self", ".", "key_to_aliases", ".", "values", "(", ")", ":", "if", "alias_name", "in", "aliases", ":", "aliases", ".", "remove", "(", "alias_name", ")" ]
Delete the alias.
[ "Delete", "the", "alias", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/kms/models.py#L132-L136
train
spulec/moto
moto/dynamodb/models.py
DynamoType.compare
def compare(self, range_comparison, range_objs): """ Compares this type against comparison filters """ range_values = [obj.value for obj in range_objs] comparison_func = get_comparison_func(range_comparison) return comparison_func(self.value, *range_values)
python
def compare(self, range_comparison, range_objs): """ Compares this type against comparison filters """ range_values = [obj.value for obj in range_objs] comparison_func = get_comparison_func(range_comparison) return comparison_func(self.value, *range_values)
[ "def", "compare", "(", "self", ",", "range_comparison", ",", "range_objs", ")", ":", "range_values", "=", "[", "obj", ".", "value", "for", "obj", "in", "range_objs", "]", "comparison_func", "=", "get_comparison_func", "(", "range_comparison", ")", "return", "c...
Compares this type against comparison filters
[ "Compares", "this", "type", "against", "comparison", "filters" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/dynamodb/models.py#L47-L53
train
spulec/moto
moto/cognitoidp/models.py
paginate
def paginate(limit, start_arg="next_token", limit_arg="max_results"): """Returns a limited result list, and an offset into list of remaining items Takes the next_token, and max_results kwargs given to a function and handles the slicing of the results. The kwarg `next_token` is the offset into the list ...
python
def paginate(limit, start_arg="next_token", limit_arg="max_results"): """Returns a limited result list, and an offset into list of remaining items Takes the next_token, and max_results kwargs given to a function and handles the slicing of the results. The kwarg `next_token` is the offset into the list ...
[ "def", "paginate", "(", "limit", ",", "start_arg", "=", "\"next_token\"", ",", "limit_arg", "=", "\"max_results\"", ")", ":", "default_start", "=", "0", "def", "outer_wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def",...
Returns a limited result list, and an offset into list of remaining items Takes the next_token, and max_results kwargs given to a function and handles the slicing of the results. The kwarg `next_token` is the offset into the list to begin slicing from. `max_results` is the size of the result required ...
[ "Returns", "a", "limited", "result", "list", "and", "an", "offset", "into", "list", "of", "remaining", "items" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/cognitoidp/models.py#L24-L54
train
spulec/moto
moto/core/models.py
CallbackResponse._url_matches
def _url_matches(self, url, other, match_querystring=False): ''' Need to override this so we can fix querystrings breaking regex matching ''' if not match_querystring: other = other.split('?', 1)[0] if responses._is_string(url): if responses._has_unicode(...
python
def _url_matches(self, url, other, match_querystring=False): ''' Need to override this so we can fix querystrings breaking regex matching ''' if not match_querystring: other = other.split('?', 1)[0] if responses._is_string(url): if responses._has_unicode(...
[ "def", "_url_matches", "(", "self", ",", "url", ",", "other", ",", "match_querystring", "=", "False", ")", ":", "if", "not", "match_querystring", ":", "other", "=", "other", ".", "split", "(", "'?'", ",", "1", ")", "[", "0", "]", "if", "responses", "...
Need to override this so we can fix querystrings breaking regex matching
[ "Need", "to", "override", "this", "so", "we", "can", "fix", "querystrings", "breaking", "regex", "matching" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L175-L191
train
spulec/moto
moto/core/models.py
BaseBackend.urls
def urls(self): """ A dictionary of the urls to be mocked with this service and the handlers that should be called in their place """ url_bases = self._url_module.url_bases unformatted_paths = self._url_module.url_paths urls = {} for url_base in url_bases...
python
def urls(self): """ A dictionary of the urls to be mocked with this service and the handlers that should be called in their place """ url_bases = self._url_module.url_bases unformatted_paths = self._url_module.url_paths urls = {} for url_base in url_bases...
[ "def", "urls", "(", "self", ")", ":", "url_bases", "=", "self", ".", "_url_module", ".", "url_bases", "unformatted_paths", "=", "self", ".", "_url_module", ".", "url_paths", "urls", "=", "{", "}", "for", "url_base", "in", "url_bases", ":", "for", "url_path...
A dictionary of the urls to be mocked with this service and the handlers that should be called in their place
[ "A", "dictionary", "of", "the", "urls", "to", "be", "mocked", "with", "this", "service", "and", "the", "handlers", "that", "should", "be", "called", "in", "their", "place" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L484-L498
train
spulec/moto
moto/core/models.py
BaseBackend.url_paths
def url_paths(self): """ A dictionary of the paths of the urls to be mocked with this service and the handlers that should be called in their place """ unformatted_paths = self._url_module.url_paths paths = {} for unformatted_path, handler in unformatted_paths.it...
python
def url_paths(self): """ A dictionary of the paths of the urls to be mocked with this service and the handlers that should be called in their place """ unformatted_paths = self._url_module.url_paths paths = {} for unformatted_path, handler in unformatted_paths.it...
[ "def", "url_paths", "(", "self", ")", ":", "unformatted_paths", "=", "self", ".", "_url_module", ".", "url_paths", "paths", "=", "{", "}", "for", "unformatted_path", ",", "handler", "in", "unformatted_paths", ".", "items", "(", ")", ":", "path", "=", "unfo...
A dictionary of the paths of the urls to be mocked with this service and the handlers that should be called in their place
[ "A", "dictionary", "of", "the", "paths", "of", "the", "urls", "to", "be", "mocked", "with", "this", "service", "and", "the", "handlers", "that", "should", "be", "called", "in", "their", "place" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L501-L513
train
spulec/moto
moto/core/models.py
BaseBackend.flask_paths
def flask_paths(self): """ The url paths that will be used for the flask server """ paths = {} for url_path, handler in self.url_paths.items(): url_path = convert_regex_to_flask_path(url_path) paths[url_path] = handler return paths
python
def flask_paths(self): """ The url paths that will be used for the flask server """ paths = {} for url_path, handler in self.url_paths.items(): url_path = convert_regex_to_flask_path(url_path) paths[url_path] = handler return paths
[ "def", "flask_paths", "(", "self", ")", ":", "paths", "=", "{", "}", "for", "url_path", ",", "handler", "in", "self", ".", "url_paths", ".", "items", "(", ")", ":", "url_path", "=", "convert_regex_to_flask_path", "(", "url_path", ")", "paths", "[", "url_...
The url paths that will be used for the flask server
[ "The", "url", "paths", "that", "will", "be", "used", "for", "the", "flask", "server" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/core/models.py#L523-L532
train
spulec/moto
moto/cloudformation/utils.py
yaml_tag_constructor
def yaml_tag_constructor(loader, tag, node): """convert shorthand intrinsic function to full name """ def _f(loader, tag, node): if tag == '!GetAtt': return node.value.split('.') elif type(node) == yaml.SequenceNode: return loader.construct_sequence(node) else...
python
def yaml_tag_constructor(loader, tag, node): """convert shorthand intrinsic function to full name """ def _f(loader, tag, node): if tag == '!GetAtt': return node.value.split('.') elif type(node) == yaml.SequenceNode: return loader.construct_sequence(node) else...
[ "def", "yaml_tag_constructor", "(", "loader", ",", "tag", ",", "node", ")", ":", "def", "_f", "(", "loader", ",", "tag", ",", "node", ")", ":", "if", "tag", "==", "'!GetAtt'", ":", "return", "node", ".", "value", ".", "split", "(", "'.'", ")", "eli...
convert shorthand intrinsic function to full name
[ "convert", "shorthand", "intrinsic", "function", "to", "full", "name" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/cloudformation/utils.py#L36-L52
train
spulec/moto
moto/dynamodb/responses.py
DynamoHandler.get_endpoint_name
def get_endpoint_name(self, headers): """Parses request headers and extracts part od the X-Amz-Target that corresponds to a method of DynamoHandler ie: X-Amz-Target: DynamoDB_20111205.ListTables -> ListTables """ # Headers are case-insensitive. Probably a better way to do this. ...
python
def get_endpoint_name(self, headers): """Parses request headers and extracts part od the X-Amz-Target that corresponds to a method of DynamoHandler ie: X-Amz-Target: DynamoDB_20111205.ListTables -> ListTables """ # Headers are case-insensitive. Probably a better way to do this. ...
[ "def", "get_endpoint_name", "(", "self", ",", "headers", ")", ":", "match", "=", "headers", ".", "get", "(", "'x-amz-target'", ")", "or", "headers", ".", "get", "(", "'X-Amz-Target'", ")", "if", "match", ":", "return", "match", ".", "split", "(", "\".\""...
Parses request headers and extracts part od the X-Amz-Target that corresponds to a method of DynamoHandler ie: X-Amz-Target: DynamoDB_20111205.ListTables -> ListTables
[ "Parses", "request", "headers", "and", "extracts", "part", "od", "the", "X", "-", "Amz", "-", "Target", "that", "corresponds", "to", "a", "method", "of", "DynamoHandler" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/dynamodb/responses.py#L12-L21
train
spulec/moto
moto/ec2/models.py
InstanceBackend.get_reservations_by_instance_ids
def get_reservations_by_instance_ids(self, instance_ids, filters=None): """ Go through all of the reservations and filter to only return those associated with the given instance_ids. """ reservations = [] for reservation in self.all_reservations(): reservation_instanc...
python
def get_reservations_by_instance_ids(self, instance_ids, filters=None): """ Go through all of the reservations and filter to only return those associated with the given instance_ids. """ reservations = [] for reservation in self.all_reservations(): reservation_instanc...
[ "def", "get_reservations_by_instance_ids", "(", "self", ",", "instance_ids", ",", "filters", "=", "None", ")", ":", "reservations", "=", "[", "]", "for", "reservation", "in", "self", ".", "all_reservations", "(", ")", ":", "reservation_instance_ids", "=", "[", ...
Go through all of the reservations and filter to only return those associated with the given instance_ids.
[ "Go", "through", "all", "of", "the", "reservations", "and", "filter", "to", "only", "return", "those", "associated", "with", "the", "given", "instance_ids", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ec2/models.py#L829-L851
train
spulec/moto
moto/ecs/models.py
EC2ContainerServiceBackend.list_task_definitions
def list_task_definitions(self): """ Filtering not implemented """ task_arns = [] for task_definition_list in self.task_definitions.values(): task_arns.extend( [task_definition.arn for task_definition in task_definition_list]) return task_arns
python
def list_task_definitions(self): """ Filtering not implemented """ task_arns = [] for task_definition_list in self.task_definitions.values(): task_arns.extend( [task_definition.arn for task_definition in task_definition_list]) return task_arns
[ "def", "list_task_definitions", "(", "self", ")", ":", "task_arns", "=", "[", "]", "for", "task_definition_list", "in", "self", ".", "task_definitions", ".", "values", "(", ")", ":", "task_arns", ".", "extend", "(", "[", "task_definition", ".", "arn", "for",...
Filtering not implemented
[ "Filtering", "not", "implemented" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/ecs/models.py#L481-L489
train
spulec/moto
moto/iotdata/models.py
FakeShadow.create_from_previous_version
def create_from_previous_version(cls, previous_shadow, payload): """ set None to payload when you want to delete shadow """ version, previous_payload = (previous_shadow.version + 1, previous_shadow.to_dict(include_delta=False)) if previous_shadow else (1, {}) if payload is None:...
python
def create_from_previous_version(cls, previous_shadow, payload): """ set None to payload when you want to delete shadow """ version, previous_payload = (previous_shadow.version + 1, previous_shadow.to_dict(include_delta=False)) if previous_shadow else (1, {}) if payload is None:...
[ "def", "create_from_previous_version", "(", "cls", ",", "previous_shadow", ",", "payload", ")", ":", "version", ",", "previous_payload", "=", "(", "previous_shadow", ".", "version", "+", "1", ",", "previous_shadow", ".", "to_dict", "(", "include_delta", "=", "Fa...
set None to payload when you want to delete shadow
[ "set", "None", "to", "payload", "when", "you", "want", "to", "delete", "shadow" ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iotdata/models.py#L30-L52
train
spulec/moto
moto/iotdata/models.py
FakeShadow.to_dict
def to_dict(self, include_delta=True): """returning nothing except for just top-level keys for now. """ if self.deleted: return { 'timestamp': self.timestamp, 'version': self.version } delta = self.parse_payload(self.desired, self.r...
python
def to_dict(self, include_delta=True): """returning nothing except for just top-level keys for now. """ if self.deleted: return { 'timestamp': self.timestamp, 'version': self.version } delta = self.parse_payload(self.desired, self.r...
[ "def", "to_dict", "(", "self", ",", "include_delta", "=", "True", ")", ":", "if", "self", ".", "deleted", ":", "return", "{", "'timestamp'", ":", "self", ".", "timestamp", ",", "'version'", ":", "self", ".", "version", "}", "delta", "=", "self", ".", ...
returning nothing except for just top-level keys for now.
[ "returning", "nothing", "except", "for", "just", "top", "-", "level", "keys", "for", "now", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iotdata/models.py#L102-L130
train
spulec/moto
moto/iotdata/models.py
IoTDataPlaneBackend.delete_thing_shadow
def delete_thing_shadow(self, thing_name): """after deleting, get_thing_shadow will raise ResourceNotFound. But version of the shadow keep increasing... """ thing = iot_backends[self.region_name].describe_thing(thing_name) if thing.thing_shadow is None: raise Resource...
python
def delete_thing_shadow(self, thing_name): """after deleting, get_thing_shadow will raise ResourceNotFound. But version of the shadow keep increasing... """ thing = iot_backends[self.region_name].describe_thing(thing_name) if thing.thing_shadow is None: raise Resource...
[ "def", "delete_thing_shadow", "(", "self", ",", "thing_name", ")", ":", "thing", "=", "iot_backends", "[", "self", ".", "region_name", "]", ".", "describe_thing", "(", "thing_name", ")", "if", "thing", ".", "thing_shadow", "is", "None", ":", "raise", "Resour...
after deleting, get_thing_shadow will raise ResourceNotFound. But version of the shadow keep increasing...
[ "after", "deleting", "get_thing_shadow", "will", "raise", "ResourceNotFound", ".", "But", "version", "of", "the", "shadow", "keep", "increasing", "..." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iotdata/models.py#L175-L185
train
spulec/moto
moto/acm/models.py
AWSCertificateManagerBackend._get_arn_from_idempotency_token
def _get_arn_from_idempotency_token(self, token): """ If token doesnt exist, return None, later it will be set with an expiry and arn. If token expiry has passed, delete entry and return None Else return ARN :param token: String token :return: None or ARN ...
python
def _get_arn_from_idempotency_token(self, token): """ If token doesnt exist, return None, later it will be set with an expiry and arn. If token expiry has passed, delete entry and return None Else return ARN :param token: String token :return: None or ARN ...
[ "def", "_get_arn_from_idempotency_token", "(", "self", ",", "token", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "if", "token", "in", "self", ".", "_idempotency_tokens", ":", "if", "self", ".", "_idempotency_tokens", "[", "token"...
If token doesnt exist, return None, later it will be set with an expiry and arn. If token expiry has passed, delete entry and return None Else return ARN :param token: String token :return: None or ARN
[ "If", "token", "doesnt", "exist", "return", "None", "later", "it", "will", "be", "set", "with", "an", "expiry", "and", "arn", "." ]
4a286c4bc288933bb023396e2784a6fdbb966bc9
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/acm/models.py#L287-L308
train