repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
indico/indico-plugins
livesync/indico_livesync/models/queue.py
LiveSyncQueueEntry.object
def object(self): """Return the changed object.""" if self.type == EntryType.category: return self.category elif self.type == EntryType.event: return self.event elif self.type == EntryType.session: return self.session elif self.type == EntryTyp...
python
def object(self): """Return the changed object.""" if self.type == EntryType.category: return self.category elif self.type == EntryType.event: return self.event elif self.type == EntryType.session: return self.session elif self.type == EntryTyp...
[ "def", "object", "(", "self", ")", ":", "if", "self", ".", "type", "==", "EntryType", ".", "category", ":", "return", "self", ".", "category", "elif", "self", ".", "type", "==", "EntryType", ".", "event", ":", "return", "self", ".", "event", "elif", ...
Return the changed object.
[ "Return", "the", "changed", "object", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/models/queue.py#L213-L224
indico/indico-plugins
livesync/indico_livesync/models/queue.py
LiveSyncQueueEntry.object_ref
def object_ref(self): """Return the reference of the changed object.""" return ImmutableDict(type=self.type, category_id=self.category_id, event_id=self.event_id, session_id=self.session_id, contrib_id=self.contrib_id, subcontrib_id=self.subcontrib_id)
python
def object_ref(self): """Return the reference of the changed object.""" return ImmutableDict(type=self.type, category_id=self.category_id, event_id=self.event_id, session_id=self.session_id, contrib_id=self.contrib_id, subcontrib_id=self.subcontrib_id)
[ "def", "object_ref", "(", "self", ")", ":", "return", "ImmutableDict", "(", "type", "=", "self", ".", "type", ",", "category_id", "=", "self", ".", "category_id", ",", "event_id", "=", "self", ".", "event_id", ",", "session_id", "=", "self", ".", "sessio...
Return the reference of the changed object.
[ "Return", "the", "reference", "of", "the", "changed", "object", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/models/queue.py#L227-L230
indico/indico-plugins
livesync/indico_livesync/models/queue.py
LiveSyncQueueEntry.create
def create(cls, changes, ref, excluded_categories=set()): """Create a new change in all queues. :param changes: the change types, an iterable containing :class:`ChangeType` :param ref: the object reference (returned by `obj_ref`) of the changed ob...
python
def create(cls, changes, ref, excluded_categories=set()): """Create a new change in all queues. :param changes: the change types, an iterable containing :class:`ChangeType` :param ref: the object reference (returned by `obj_ref`) of the changed ob...
[ "def", "create", "(", "cls", ",", "changes", ",", "ref", ",", "excluded_categories", "=", "set", "(", ")", ")", ":", "ref", "=", "dict", "(", "ref", ")", "obj", "=", "obj_deref", "(", "ref", ")", "if", "isinstance", "(", "obj", ",", "Category", ")"...
Create a new change in all queues. :param changes: the change types, an iterable containing :class:`ChangeType` :param ref: the object reference (returned by `obj_ref`) of the changed object :param excluded_categories: set of categories (IDs) whos...
[ "Create", "a", "new", "change", "in", "all", "queues", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/models/queue.py#L238-L271
sbg/sevenbridges-python
sevenbridges/models/async_jobs.py
AsyncJob.get_file_copy_job
def get_file_copy_job(cls, id, api=None): """ Retrieve file copy async job :param id: Async job identifier :param api: Api instance :return: """ id = Transform.to_async_job(id) api = api if api else cls._API async_job = api.get( url=cl...
python
def get_file_copy_job(cls, id, api=None): """ Retrieve file copy async job :param id: Async job identifier :param api: Api instance :return: """ id = Transform.to_async_job(id) api = api if api else cls._API async_job = api.get( url=cl...
[ "def", "get_file_copy_job", "(", "cls", ",", "id", ",", "api", "=", "None", ")", ":", "id", "=", "Transform", ".", "to_async_job", "(", "id", ")", "api", "=", "api", "if", "api", "else", "cls", ".", "_API", "async_job", "=", "api", ".", "get", "(",...
Retrieve file copy async job :param id: Async job identifier :param api: Api instance :return:
[ "Retrieve", "file", "copy", "async", "job", ":", "param", "id", ":", "Async", "job", "identifier", ":", "param", "api", ":", "Api", "instance", ":", "return", ":" ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/async_jobs.py#L72-L85
sbg/sevenbridges-python
sevenbridges/models/async_jobs.py
AsyncJob.get_result
def get_result(self, api=None): """ Get async job result in bulk format :return: List of AsyncFileBulkRecord objects """ api = api or self._API if not self.result: return [] return AsyncFileBulkRecord.parse_records( result=self.result, ...
python
def get_result(self, api=None): """ Get async job result in bulk format :return: List of AsyncFileBulkRecord objects """ api = api or self._API if not self.result: return [] return AsyncFileBulkRecord.parse_records( result=self.result, ...
[ "def", "get_result", "(", "self", ",", "api", "=", "None", ")", ":", "api", "=", "api", "or", "self", ".", "_API", "if", "not", "self", ".", "result", ":", "return", "[", "]", "return", "AsyncFileBulkRecord", ".", "parse_records", "(", "result", "=", ...
Get async job result in bulk format :return: List of AsyncFileBulkRecord objects
[ "Get", "async", "job", "result", "in", "bulk", "format", ":", "return", ":", "List", "of", "AsyncFileBulkRecord", "objects" ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/async_jobs.py#L102-L113
sbg/sevenbridges-python
sevenbridges/models/async_jobs.py
AsyncJob.list_file_jobs
def list_file_jobs(cls, offset=None, limit=None, api=None): """Query ( List ) async jobs :param offset: Pagination offset :param limit: Pagination limit :param api: Api instance :return: Collection object """ api = api or cls._API return super(AsyncJob, cl...
python
def list_file_jobs(cls, offset=None, limit=None, api=None): """Query ( List ) async jobs :param offset: Pagination offset :param limit: Pagination limit :param api: Api instance :return: Collection object """ api = api or cls._API return super(AsyncJob, cl...
[ "def", "list_file_jobs", "(", "cls", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "api", "=", "None", ")", ":", "api", "=", "api", "or", "cls", ".", "_API", "return", "super", "(", "AsyncJob", ",", "cls", ")", ".", "_query", "(", "...
Query ( List ) async jobs :param offset: Pagination offset :param limit: Pagination limit :param api: Api instance :return: Collection object
[ "Query", "(", "List", ")", "async", "jobs", ":", "param", "offset", ":", "Pagination", "offset", ":", "param", "limit", ":", "Pagination", "limit", ":", "param", "api", ":", "Api", "instance", ":", "return", ":", "Collection", "object" ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/async_jobs.py#L116-L129
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
decompose_code
def decompose_code(code): """ Decomposes a MARC "code" into tag, ind1, ind2, subcode """ code = "%-6s" % code ind1 = code[3:4] if ind1 == " ": ind1 = "_" ind2 = code[4:5] if ind2 == " ": ind2 = "_" subcode = code[5:6] if subcode == " ": subcode = None return (code[0:3], ind1,...
python
def decompose_code(code): """ Decomposes a MARC "code" into tag, ind1, ind2, subcode """ code = "%-6s" % code ind1 = code[3:4] if ind1 == " ": ind1 = "_" ind2 = code[4:5] if ind2 == " ": ind2 = "_" subcode = code[5:6] if subcode == " ": subcode = None return (code[0:3], ind1,...
[ "def", "decompose_code", "(", "code", ")", ":", "code", "=", "\"%-6s\"", "%", "code", "ind1", "=", "code", "[", "3", ":", "4", "]", "if", "ind1", "==", "\" \"", ":", "ind1", "=", "\"_\"", "ind2", "=", "code", "[", "4", ":", "5", "]", "if", "ind...
Decomposes a MARC "code" into tag, ind1, ind2, subcode
[ "Decomposes", "a", "MARC", "code", "into", "tag", "ind1", "ind2", "subcode" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L642-L653
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector._init_browser
def _init_browser(self): """ Ovveride this method with the appropriate way to prepare a logged in browser. """ self.browser = mechanize.Browser() self.browser.set_handle_robots(False) self.browser.open(self.server_url + "/youraccount/login") self.browser.s...
python
def _init_browser(self): """ Ovveride this method with the appropriate way to prepare a logged in browser. """ self.browser = mechanize.Browser() self.browser.set_handle_robots(False) self.browser.open(self.server_url + "/youraccount/login") self.browser.s...
[ "def", "_init_browser", "(", "self", ")", ":", "self", ".", "browser", "=", "mechanize", ".", "Browser", "(", ")", "self", ".", "browser", ".", "set_handle_robots", "(", "False", ")", "self", ".", "browser", ".", "open", "(", "self", ".", "server_url", ...
Ovveride this method with the appropriate way to prepare a logged in browser.
[ "Ovveride", "this", "method", "with", "the", "appropriate", "way", "to", "prepare", "a", "logged", "in", "browser", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L193-L211
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.search
def search(self, read_cache=True, **kwparams): """ Returns records corresponding to the given search query. See docstring of invenio.legacy.search_engine.perform_request_search() for an overview of available parameters. @raise InvenioConnectorAuthError: if authentication fails ...
python
def search(self, read_cache=True, **kwparams): """ Returns records corresponding to the given search query. See docstring of invenio.legacy.search_engine.perform_request_search() for an overview of available parameters. @raise InvenioConnectorAuthError: if authentication fails ...
[ "def", "search", "(", "self", ",", "read_cache", "=", "True", ",", "*", "*", "kwparams", ")", ":", "parse_results", "=", "False", "of", "=", "kwparams", ".", "get", "(", "'of'", ",", "\"\"", ")", "if", "of", "==", "\"\"", ":", "parse_results", "=", ...
Returns records corresponding to the given search query. See docstring of invenio.legacy.search_engine.perform_request_search() for an overview of available parameters. @raise InvenioConnectorAuthError: if authentication fails
[ "Returns", "records", "corresponding", "to", "the", "given", "search", "query", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L218-L292
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.search_with_retry
def search_with_retry(self, sleeptime=3.0, retrycount=3, **params): """ This function performs a search given a dictionary of search(..) parameters. It accounts for server timeouts as necessary and will retry some number of times. @param sleeptime: number of seconds to sleep bet...
python
def search_with_retry(self, sleeptime=3.0, retrycount=3, **params): """ This function performs a search given a dictionary of search(..) parameters. It accounts for server timeouts as necessary and will retry some number of times. @param sleeptime: number of seconds to sleep bet...
[ "def", "search_with_retry", "(", "self", ",", "sleeptime", "=", "3.0", ",", "retrycount", "=", "3", ",", "*", "*", "params", ")", ":", "results", "=", "[", "]", "count", "=", "0", "while", "count", "<", "retrycount", ":", "try", ":", "results", "=", ...
This function performs a search given a dictionary of search(..) parameters. It accounts for server timeouts as necessary and will retry some number of times. @param sleeptime: number of seconds to sleep between retries @type sleeptime: float @param retrycount: number of times ...
[ "This", "function", "performs", "a", "search", "given", "a", "dictionary", "of", "search", "(", "..", ")", "parameters", ".", "It", "accounts", "for", "server", "timeouts", "as", "necessary", "and", "will", "retry", "some", "number", "of", "times", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L294-L324
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.get_records_from_basket
def get_records_from_basket(self, bskid, group_basket=False, read_cache=True): """ Returns the records from the (public) basket with given bskid """ if bskid not in self.cached_baskets or not read_cache: if self.user: if group_basket: group...
python
def get_records_from_basket(self, bskid, group_basket=False, read_cache=True): """ Returns the records from the (public) basket with given bskid """ if bskid not in self.cached_baskets or not read_cache: if self.user: if group_basket: group...
[ "def", "get_records_from_basket", "(", "self", ",", "bskid", ",", "group_basket", "=", "False", ",", "read_cache", "=", "True", ")", ":", "if", "bskid", "not", "in", "self", ".", "cached_baskets", "or", "not", "read_cache", ":", "if", "self", ".", "user", ...
Returns the records from the (public) basket with given bskid
[ "Returns", "the", "records", "from", "the", "(", "public", ")", "basket", "with", "given", "bskid" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L338-L358
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.get_record
def get_record(self, recid, read_cache=True): """ Returns the record with given recid """ if recid in self.cached_records or not read_cache: return self.cached_records[recid] else: return self.search(p="recid:" + str(recid))
python
def get_record(self, recid, read_cache=True): """ Returns the record with given recid """ if recid in self.cached_records or not read_cache: return self.cached_records[recid] else: return self.search(p="recid:" + str(recid))
[ "def", "get_record", "(", "self", ",", "recid", ",", "read_cache", "=", "True", ")", ":", "if", "recid", "in", "self", ".", "cached_records", "or", "not", "read_cache", ":", "return", "self", ".", "cached_records", "[", "recid", "]", "else", ":", "return...
Returns the record with given recid
[ "Returns", "the", "record", "with", "given", "recid" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L360-L367
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.upload_marcxml
def upload_marcxml(self, marcxml, mode): """ Uploads a record to the server Parameters: marcxml - *str* the XML to upload. mode - *str* the mode to use for the upload. "-i" insert new records "-r" replace existing records ...
python
def upload_marcxml(self, marcxml, mode): """ Uploads a record to the server Parameters: marcxml - *str* the XML to upload. mode - *str* the mode to use for the upload. "-i" insert new records "-r" replace existing records ...
[ "def", "upload_marcxml", "(", "self", ",", "marcxml", ",", "mode", ")", ":", "if", "mode", "not", "in", "[", "\"-i\"", ",", "\"-r\"", ",", "\"-c\"", ",", "\"-a\"", ",", "\"-ir\"", "]", ":", "raise", "NameError", ",", "\"Incorrect mode \"", "+", "str", ...
Uploads a record to the server Parameters: marcxml - *str* the XML to upload. mode - *str* the mode to use for the upload. "-i" insert new records "-r" replace existing records "-c" correct fields of records ...
[ "Uploads", "a", "record", "to", "the", "server" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L369-L400
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector._parse_results
def _parse_results(self, results, cached_records): """ Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory) """ parser = xml...
python
def _parse_results(self, results, cached_records): """ Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory) """ parser = xml...
[ "def", "_parse_results", "(", "self", ",", "results", ",", "cached_records", ")", ":", "parser", "=", "xml", ".", "sax", ".", "make_parser", "(", ")", "handler", "=", "RecordsHandler", "(", "cached_records", ")", "parser", ".", "setContentHandler", "(", "han...
Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory)
[ "Parses", "the", "given", "results", "(", "in", "MARCXML", "format", ")", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L402-L414
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector._validate_server_url
def _validate_server_url(self): """Validates self.server_url""" try: request = requests.head(self.server_url) if request.status_code >= 400: raise InvenioConnectorServerError( "Unexpected status code '%d' accessing URL: %s" ...
python
def _validate_server_url(self): """Validates self.server_url""" try: request = requests.head(self.server_url) if request.status_code >= 400: raise InvenioConnectorServerError( "Unexpected status code '%d' accessing URL: %s" ...
[ "def", "_validate_server_url", "(", "self", ")", ":", "try", ":", "request", "=", "requests", ".", "head", "(", "self", ".", "server_url", ")", "if", "request", ".", "status_code", ">=", "400", ":", "raise", "InvenioConnectorServerError", "(", "\"Unexpected st...
Validates self.server_url
[ "Validates", "self", ".", "server_url" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L416-L438
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricDownloads._get_cumulative_results
def _get_cumulative_results(self, results): """ Returns a dictionary of {'total': x, 'unique': y} for the date range. """ hits = {'total': 0, 'unique': 0} day_hits = list(hits[0] for hits in results.values() if hits) for metrics in day_hits: hits['tot...
python
def _get_cumulative_results(self, results): """ Returns a dictionary of {'total': x, 'unique': y} for the date range. """ hits = {'total': 0, 'unique': 0} day_hits = list(hits[0] for hits in results.values() if hits) for metrics in day_hits: hits['tot...
[ "def", "_get_cumulative_results", "(", "self", ",", "results", ")", ":", "hits", "=", "{", "'total'", ":", "0", ",", "'unique'", ":", "0", "}", "day_hits", "=", "list", "(", "hits", "[", "0", "]", "for", "hits", "in", "results", ".", "values", "(", ...
Returns a dictionary of {'total': x, 'unique': y} for the date range.
[ "Returns", "a", "dictionary", "of", "{", "total", ":", "x", "unique", ":", "y", "}", "for", "the", "date", "range", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L69-L81
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricReferrers.get_result
def get_result(self): """Perform the call and return a list of referrers""" result = get_json_from_remote_server(self.call) referrers = list(result) for referrer in referrers: referrer['sum_visit_length'] = stringify_seconds(referrer['sum_visit_length']) return sorted...
python
def get_result(self): """Perform the call and return a list of referrers""" result = get_json_from_remote_server(self.call) referrers = list(result) for referrer in referrers: referrer['sum_visit_length'] = stringify_seconds(referrer['sum_visit_length']) return sorted...
[ "def", "get_result", "(", "self", ")", ":", "result", "=", "get_json_from_remote_server", "(", "self", ".", "call", ")", "referrers", "=", "list", "(", "result", ")", "for", "referrer", "in", "referrers", ":", "referrer", "[", "'sum_visit_length'", "]", "=",...
Perform the call and return a list of referrers
[ "Perform", "the", "call", "and", "return", "a", "list", "of", "referrers" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L89-L95
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricVisitDuration.get_result
def get_result(self): """Perform the call and return a string with the time in hh:mm:ss""" result = get_json_from_remote_server(self.call) seconds = self._get_average_duration(result) if result else 0 return stringify_seconds(seconds)
python
def get_result(self): """Perform the call and return a string with the time in hh:mm:ss""" result = get_json_from_remote_server(self.call) seconds = self._get_average_duration(result) if result else 0 return stringify_seconds(seconds)
[ "def", "get_result", "(", "self", ")", ":", "result", "=", "get_json_from_remote_server", "(", "self", ".", "call", ")", "seconds", "=", "self", ".", "_get_average_duration", "(", "result", ")", "if", "result", "else", "0", "return", "stringify_seconds", "(", ...
Perform the call and return a string with the time in hh:mm:ss
[ "Perform", "the", "call", "and", "return", "a", "string", "with", "the", "time", "in", "hh", ":", "mm", ":", "ss" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L113-L117
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricPeakDateAndVisitors.get_result
def get_result(self): """Perform the call and return the peak date and how many users""" result = get_json_from_remote_server(self.call) if result: date, value = max(result.iteritems(), key=itemgetter(1)) return {'date': date, 'users': value} else: ret...
python
def get_result(self): """Perform the call and return the peak date and how many users""" result = get_json_from_remote_server(self.call) if result: date, value = max(result.iteritems(), key=itemgetter(1)) return {'date': date, 'users': value} else: ret...
[ "def", "get_result", "(", "self", ")", ":", "result", "=", "get_json_from_remote_server", "(", "self", ".", "call", ")", "if", "result", ":", "date", ",", "value", "=", "max", "(", "result", ".", "iteritems", "(", ")", ",", "key", "=", "itemgetter", "(...
Perform the call and return the peak date and how many users
[ "Perform", "the", "call", "and", "return", "the", "peak", "date", "and", "how", "many", "users" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L135-L142
indico/indico-plugins
piwik/indico_piwik/piwik.py
PiwikRequest.call
def call(self, default_response=None, **query_params): """Perform a query to the Piwik server and return the response. :param default_response: Return value in case the query fails :param query_params: Dictionary with the parameters of the query """ query_url = self.get_query_ur...
python
def call(self, default_response=None, **query_params): """Perform a query to the Piwik server and return the response. :param default_response: Return value in case the query fails :param query_params: Dictionary with the parameters of the query """ query_url = self.get_query_ur...
[ "def", "call", "(", "self", ",", "default_response", "=", "None", ",", "*", "*", "query_params", ")", ":", "query_url", "=", "self", ".", "get_query_url", "(", "*", "*", "query_params", ")", "return", "self", ".", "_perform_call", "(", "query_url", ",", ...
Perform a query to the Piwik server and return the response. :param default_response: Return value in case the query fails :param query_params: Dictionary with the parameters of the query
[ "Perform", "a", "query", "to", "the", "Piwik", "server", "and", "return", "the", "response", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/piwik.py#L45-L52
indico/indico-plugins
piwik/indico_piwik/piwik.py
PiwikRequest.get_query
def get_query(self, query_params=None): """Return a query string""" if query_params is None: query_params = {} query = '' query_params['idSite'] = self.site_id if self.api_token is not None: query_params['token_auth'] = self.api_token for key, valu...
python
def get_query(self, query_params=None): """Return a query string""" if query_params is None: query_params = {} query = '' query_params['idSite'] = self.site_id if self.api_token is not None: query_params['token_auth'] = self.api_token for key, valu...
[ "def", "get_query", "(", "self", ",", "query_params", "=", "None", ")", ":", "if", "query_params", "is", "None", ":", "query_params", "=", "{", "}", "query", "=", "''", "query_params", "[", "'idSite'", "]", "=", "self", ".", "site_id", "if", "self", "....
Return a query string
[ "Return", "a", "query", "string" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/piwik.py#L54-L66
indico/indico-plugins
piwik/indico_piwik/piwik.py
PiwikRequest._perform_call
def _perform_call(self, query_url, default_response=None, timeout=10): """Returns the raw results from the API""" try: response = requests.get(query_url, timeout=timeout) except socket.timeout: current_plugin.logger.warning("Timeout contacting Piwik server") r...
python
def _perform_call(self, query_url, default_response=None, timeout=10): """Returns the raw results from the API""" try: response = requests.get(query_url, timeout=timeout) except socket.timeout: current_plugin.logger.warning("Timeout contacting Piwik server") r...
[ "def", "_perform_call", "(", "self", ",", "query_url", ",", "default_response", "=", "None", ",", "timeout", "=", "10", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "query_url", ",", "timeout", "=", "timeout", ")", "except", "socke...
Returns the raw results from the API
[ "Returns", "the", "raw", "results", "from", "the", "API" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/piwik.py#L72-L82
indico/indico-plugins
livesync/indico_livesync/uploader.py
Uploader.run
def run(self, records): """Runs the batch upload :param records: an iterable containing queue entries """ self_name = type(self).__name__ for i, batch in enumerate(grouper(records, self.BATCH_SIZE, skip_missing=True), 1): self.logger.info('%s processing batch %d', se...
python
def run(self, records): """Runs the batch upload :param records: an iterable containing queue entries """ self_name = type(self).__name__ for i, batch in enumerate(grouper(records, self.BATCH_SIZE, skip_missing=True), 1): self.logger.info('%s processing batch %d', se...
[ "def", "run", "(", "self", ",", "records", ")", ":", "self_name", "=", "type", "(", "self", ")", ".", "__name__", "for", "i", ",", "batch", "in", "enumerate", "(", "grouper", "(", "records", ",", "self", ".", "BATCH_SIZE", ",", "skip_missing", "=", "...
Runs the batch upload :param records: an iterable containing queue entries
[ "Runs", "the", "batch", "upload" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/uploader.py#L37-L55
indico/indico-plugins
livesync/indico_livesync/uploader.py
Uploader.run_initial
def run_initial(self, events): """Runs the initial batch upload :param events: an iterable containing events """ self_name = type(self).__name__ for i, batch in enumerate(grouper(events, self.INITIAL_BATCH_SIZE, skip_missing=True), 1): self.logger.debug('%s processin...
python
def run_initial(self, events): """Runs the initial batch upload :param events: an iterable containing events """ self_name = type(self).__name__ for i, batch in enumerate(grouper(events, self.INITIAL_BATCH_SIZE, skip_missing=True), 1): self.logger.debug('%s processin...
[ "def", "run_initial", "(", "self", ",", "events", ")", ":", "self_name", "=", "type", "(", "self", ")", ".", "__name__", "for", "i", ",", "batch", "in", "enumerate", "(", "grouper", "(", "events", ",", "self", ".", "INITIAL_BATCH_SIZE", ",", "skip_missin...
Runs the initial batch upload :param events: an iterable containing events
[ "Runs", "the", "initial", "batch", "upload" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/uploader.py#L57-L69
indico/indico-plugins
livesync/indico_livesync/uploader.py
Uploader.processed_records
def processed_records(self, records): """Executed after successfully uploading a batch of records from the queue. :param records: a list of queue entries """ for record in records: self.logger.debug('Marking as processed: %s', record) record.processed = True ...
python
def processed_records(self, records): """Executed after successfully uploading a batch of records from the queue. :param records: a list of queue entries """ for record in records: self.logger.debug('Marking as processed: %s', record) record.processed = True ...
[ "def", "processed_records", "(", "self", ",", "records", ")", ":", "for", "record", "in", "records", ":", "self", ".", "logger", ".", "debug", "(", "'Marking as processed: %s'", ",", "record", ")", "record", ".", "processed", "=", "True", "db", ".", "sessi...
Executed after successfully uploading a batch of records from the queue. :param records: a list of queue entries
[ "Executed", "after", "successfully", "uploading", "a", "batch", "of", "records", "from", "the", "queue", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/uploader.py#L80-L88
indico/indico-plugins
storage_s3/indico_storage_s3/migrate.py
cli
def cli(): """Migrate data to S3. Use the `copy` subcommand to copy data to S3. This can be done safely while Indico is running. At the end it will show you what you need to add to your `indico.conf`. Once you updated your config with the new storage backends, you can use the `apply` subcomman...
python
def cli(): """Migrate data to S3. Use the `copy` subcommand to copy data to S3. This can be done safely while Indico is running. At the end it will show you what you need to add to your `indico.conf`. Once you updated your config with the new storage backends, you can use the `apply` subcomman...
[ "def", "cli", "(", ")", ":", "if", "config", ".", "DB_LOG", ":", "click", ".", "secho", "(", "'Warning: The database logger is currently enabled (DB_LOG = True).\\n'", "'This will slow down the migration. Unless you database is very small, please disable it.'", ",", "fg", "=", ...
Migrate data to S3. Use the `copy` subcommand to copy data to S3. This can be done safely while Indico is running. At the end it will show you what you need to add to your `indico.conf`. Once you updated your config with the new storage backends, you can use the `apply` subcommand to update your d...
[ "Migrate", "data", "to", "S3", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/storage_s3/indico_storage_s3/migrate.py#L385-L403
indico/indico-plugins
storage_s3/indico_storage_s3/migrate.py
copy
def copy(source_backend_names, bucket_names, static_bucket_name, s3_endpoint, s3_profile, s3_bucket_policy_file, rclone, output): """Copy files to S3. This command copies files to S3 and records the necessary database changes in a JSONL file. Multiple bucket names can be specified; in that ca...
python
def copy(source_backend_names, bucket_names, static_bucket_name, s3_endpoint, s3_profile, s3_bucket_policy_file, rclone, output): """Copy files to S3. This command copies files to S3 and records the necessary database changes in a JSONL file. Multiple bucket names can be specified; in that ca...
[ "def", "copy", "(", "source_backend_names", ",", "bucket_names", ",", "static_bucket_name", ",", "s3_endpoint", ",", "s3_profile", ",", "s3_bucket_policy_file", ",", "rclone", ",", "output", ")", ":", "bucket_names", "=", "[", "tuple", "(", "x", ".", "split", ...
Copy files to S3. This command copies files to S3 and records the necessary database changes in a JSONL file. Multiple bucket names can be specified; in that case the bucket name can change based on the year a file was created in. The last bucket name will be the default, while any other bucket na...
[ "Copy", "files", "to", "S3", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/storage_s3/indico_storage_s3/migrate.py#L421-L491
Kane610/deconz
pydeconz/__init__.py
DeconzSession.start
def start(self) -> None: """Connect websocket to deCONZ.""" if self.config: self.websocket = self.ws_client( self.loop, self.session, self.host, self.config.websocketport, self.async_session_handler) self.websocket.start() else: ...
python
def start(self) -> None: """Connect websocket to deCONZ.""" if self.config: self.websocket = self.ws_client( self.loop, self.session, self.host, self.config.websocketport, self.async_session_handler) self.websocket.start() else: ...
[ "def", "start", "(", "self", ")", "->", "None", ":", "if", "self", ".", "config", ":", "self", ".", "websocket", "=", "self", ".", "ws_client", "(", "self", ".", "loop", ",", "self", ".", "session", ",", "self", ".", "host", ",", "self", ".", "co...
Connect websocket to deCONZ.
[ "Connect", "websocket", "to", "deCONZ", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L38-L46
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_load_parameters
async def async_load_parameters(self) -> bool: """Load deCONZ parameters. Returns lists of indices of which devices was added. """ data = await self.async_get_state('') _LOGGER.debug(pformat(data)) config = data.get('config', {}) groups = data.get('groups', {})...
python
async def async_load_parameters(self) -> bool: """Load deCONZ parameters. Returns lists of indices of which devices was added. """ data = await self.async_get_state('') _LOGGER.debug(pformat(data)) config = data.get('config', {}) groups = data.get('groups', {})...
[ "async", "def", "async_load_parameters", "(", "self", ")", "->", "bool", ":", "data", "=", "await", "self", ".", "async_get_state", "(", "''", ")", "_LOGGER", ".", "debug", "(", "pformat", "(", "data", ")", ")", "config", "=", "data", ".", "get", "(", ...
Load deCONZ parameters. Returns lists of indices of which devices was added.
[ "Load", "deCONZ", "parameters", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L54-L101
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_put_state
async def async_put_state(self, field: str, data: dict) -> dict: """Set state of object in deCONZ. Field is a string representing a specific device in deCONZ e.g. field='/lights/1/state'. Data is a json object with what data you want to alter e.g. data={'on': True}. See ...
python
async def async_put_state(self, field: str, data: dict) -> dict: """Set state of object in deCONZ. Field is a string representing a specific device in deCONZ e.g. field='/lights/1/state'. Data is a json object with what data you want to alter e.g. data={'on': True}. See ...
[ "async", "def", "async_put_state", "(", "self", ",", "field", ":", "str", ",", "data", ":", "dict", ")", "->", "dict", ":", "session", "=", "self", ".", "session", ".", "put", "url", "=", "self", ".", "api_url", "+", "field", "jsondata", "=", "json",...
Set state of object in deCONZ. Field is a string representing a specific device in deCONZ e.g. field='/lights/1/state'. Data is a json object with what data you want to alter e.g. data={'on': True}. See Dresden Elektroniks REST API documentation for details: http://dresd...
[ "Set", "state", "of", "object", "in", "deCONZ", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L103-L117
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_get_state
async def async_get_state(self, field: str) -> dict: """Get state of object in deCONZ. Field is a string representing an API endpoint or lower e.g. field='/lights'. See Dresden Elektroniks REST API documentation for details: http://dresden-elektronik.github.io/deconz-rest-doc/re...
python
async def async_get_state(self, field: str) -> dict: """Get state of object in deCONZ. Field is a string representing an API endpoint or lower e.g. field='/lights'. See Dresden Elektroniks REST API documentation for details: http://dresden-elektronik.github.io/deconz-rest-doc/re...
[ "async", "def", "async_get_state", "(", "self", ",", "field", ":", "str", ")", "->", "dict", ":", "session", "=", "self", ".", "session", ".", "get", "url", "=", "self", ".", "api_url", "+", "field", "response_dict", "=", "await", "async_request", "(", ...
Get state of object in deCONZ. Field is a string representing an API endpoint or lower e.g. field='/lights'. See Dresden Elektroniks REST API documentation for details: http://dresden-elektronik.github.io/deconz-rest-doc/rest/
[ "Get", "state", "of", "object", "in", "deCONZ", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L119-L130
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_session_handler
def async_session_handler(self, signal: str) -> None: """Signalling from websocket. data - new data available for processing. state - network state has changed. """ if signal == 'data': self.async_event_handler(self.websocket.data) elif signal == 'state...
python
def async_session_handler(self, signal: str) -> None: """Signalling from websocket. data - new data available for processing. state - network state has changed. """ if signal == 'data': self.async_event_handler(self.websocket.data) elif signal == 'state...
[ "def", "async_session_handler", "(", "self", ",", "signal", ":", "str", ")", "->", "None", ":", "if", "signal", "==", "'data'", ":", "self", ".", "async_event_handler", "(", "self", ".", "websocket", ".", "data", ")", "elif", "signal", "==", "'state'", "...
Signalling from websocket. data - new data available for processing. state - network state has changed.
[ "Signalling", "from", "websocket", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L132-L143
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_event_handler
def async_event_handler(self, event: dict) -> None: """Receive event from websocket and identifies where the event belong. { "t": "event", "e": "changed", "r": "sensors", "id": "12", "state": { "buttonevent": 2002 } } """ ...
python
def async_event_handler(self, event: dict) -> None: """Receive event from websocket and identifies where the event belong. { "t": "event", "e": "changed", "r": "sensors", "id": "12", "state": { "buttonevent": 2002 } } """ ...
[ "def", "async_event_handler", "(", "self", ",", "event", ":", "dict", ")", "->", "None", ":", "if", "event", "[", "'e'", "]", "==", "'added'", ":", "if", "event", "[", "'r'", "]", "==", "'lights'", "and", "event", "[", "'id'", "]", "not", "in", "se...
Receive event from websocket and identifies where the event belong. { "t": "event", "e": "changed", "r": "sensors", "id": "12", "state": { "buttonevent": 2002 } }
[ "Receive", "event", "from", "websocket", "and", "identifies", "where", "the", "event", "belong", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L145-L198
Kane610/deconz
pydeconz/__init__.py
DeconzSession.update_group_color
def update_group_color(self, lights: list) -> None: """Update group colors based on light states. deCONZ group updates don't contain any information about the current state of the lights in the group. This method updates the color properties of the group to the current color of the ligh...
python
def update_group_color(self, lights: list) -> None: """Update group colors based on light states. deCONZ group updates don't contain any information about the current state of the lights in the group. This method updates the color properties of the group to the current color of the ligh...
[ "def", "update_group_color", "(", "self", ",", "lights", ":", "list", ")", "->", "None", ":", "for", "group", "in", "self", ".", "groups", ".", "values", "(", ")", ":", "# Skip group if there are no common light ids.", "if", "not", "any", "(", "{", "*", "l...
Update group colors based on light states. deCONZ group updates don't contain any information about the current state of the lights in the group. This method updates the color properties of the group to the current color of the lights in the group. For groups where the lights h...
[ "Update", "group", "colors", "based", "on", "light", "states", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L200-L225
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.submit_export
def submit_export(cls, file, volume, location, properties=None, overwrite=False, copy_only=False, api=None): """ Submit new export job. :param file: File to be exported. :param volume: Volume identifier. :param location: Volume location. :param prop...
python
def submit_export(cls, file, volume, location, properties=None, overwrite=False, copy_only=False, api=None): """ Submit new export job. :param file: File to be exported. :param volume: Volume identifier. :param location: Volume location. :param prop...
[ "def", "submit_export", "(", "cls", ",", "file", ",", "volume", ",", "location", ",", "properties", "=", "None", ",", "overwrite", "=", "False", ",", "copy_only", "=", "False", ",", "api", "=", "None", ")", ":", "data", "=", "{", "}", "params", "=", ...
Submit new export job. :param file: File to be exported. :param volume: Volume identifier. :param location: Volume location. :param properties: Properties dictionary. :param overwrite: If true it will overwrite file if exists :param copy_only: If true files are kept on Se...
[ "Submit", "new", "export", "job", ".", ":", "param", "file", ":", "File", "to", "be", "exported", ".", ":", "param", "volume", ":", "Volume", "identifier", ".", ":", "param", "location", ":", "Volume", "location", ".", ":", "param", "properties", ":", ...
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L74-L122
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.query
def query(cls, volume=None, state=None, offset=None, limit=None, api=None): """ Query (List) exports. :param volume: Optional volume identifier. :param state: Optional import sate. :param api: Api instance. :return: Collection object. """ ap...
python
def query(cls, volume=None, state=None, offset=None, limit=None, api=None): """ Query (List) exports. :param volume: Optional volume identifier. :param state: Optional import sate. :param api: Api instance. :return: Collection object. """ ap...
[ "def", "query", "(", "cls", ",", "volume", "=", "None", ",", "state", "=", "None", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "api", "=", "None", ")", ":", "api", "=", "api", "or", "cls", ".", "_API", "if", "volume", ":", "volu...
Query (List) exports. :param volume: Optional volume identifier. :param state: Optional import sate. :param api: Api instance. :return: Collection object.
[ "Query", "(", "List", ")", "exports", ".", ":", "param", "volume", ":", "Optional", "volume", "identifier", ".", ":", "param", "state", ":", "Optional", "import", "sate", ".", ":", "param", "api", ":", "Api", "instance", ".", ":", "return", ":", "Colle...
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L125-L143
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.bulk_get
def bulk_get(cls, exports, api=None): """ Retrieve exports in bulk. :param exports: Exports to be retrieved. :param api: Api instance. :return: list of ExportBulkRecord objects. """ api = api or cls._API export_ids = [Transform.to_export(export) for export...
python
def bulk_get(cls, exports, api=None): """ Retrieve exports in bulk. :param exports: Exports to be retrieved. :param api: Api instance. :return: list of ExportBulkRecord objects. """ api = api or cls._API export_ids = [Transform.to_export(export) for export...
[ "def", "bulk_get", "(", "cls", ",", "exports", ",", "api", "=", "None", ")", ":", "api", "=", "api", "or", "cls", ".", "_API", "export_ids", "=", "[", "Transform", ".", "to_export", "(", "export", ")", "for", "export", "in", "exports", "]", "data", ...
Retrieve exports in bulk. :param exports: Exports to be retrieved. :param api: Api instance. :return: list of ExportBulkRecord objects.
[ "Retrieve", "exports", "in", "bulk", ".", ":", "param", "exports", ":", "Exports", "to", "be", "retrieved", ".", ":", "param", "api", ":", "Api", "instance", ".", ":", "return", ":", "list", "of", "ExportBulkRecord", "objects", "." ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L146-L158
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.bulk_submit
def bulk_submit(cls, exports, copy_only=False, api=None): """ Create exports in bulk. :param exports: Exports to be submitted in bulk. :param copy_only: If true files are kept on SevenBridges bucket. :param api: Api instance. :return: list of ExportBulkRecord objects. ...
python
def bulk_submit(cls, exports, copy_only=False, api=None): """ Create exports in bulk. :param exports: Exports to be submitted in bulk. :param copy_only: If true files are kept on SevenBridges bucket. :param api: Api instance. :return: list of ExportBulkRecord objects. ...
[ "def", "bulk_submit", "(", "cls", ",", "exports", ",", "copy_only", "=", "False", ",", "api", "=", "None", ")", ":", "if", "not", "exports", ":", "raise", "SbgError", "(", "'Exports are required'", ")", "api", "=", "api", "or", "cls", ".", "_API", "ite...
Create exports in bulk. :param exports: Exports to be submitted in bulk. :param copy_only: If true files are kept on SevenBridges bucket. :param api: Api instance. :return: list of ExportBulkRecord objects.
[ "Create", "exports", "in", "bulk", ".", ":", "param", "exports", ":", "Exports", "to", "be", "submitted", "in", "bulk", ".", ":", "param", "copy_only", ":", "If", "true", "files", "are", "kept", "on", "SevenBridges", "bucket", ".", ":", "param", "api", ...
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L161-L202
sbg/sevenbridges-python
sevenbridges/models/division.py
Division.query
def query(cls, offset=None, limit=None, api=None): """ Query (List) divisions. :param offset: Pagination offset. :param limit: Pagination limit. :param api: Api instance. :return: Collection object. """ api = api if api else cls._API return super(...
python
def query(cls, offset=None, limit=None, api=None): """ Query (List) divisions. :param offset: Pagination offset. :param limit: Pagination limit. :param api: Api instance. :return: Collection object. """ api = api if api else cls._API return super(...
[ "def", "query", "(", "cls", ",", "offset", "=", "None", ",", "limit", "=", "None", ",", "api", "=", "None", ")", ":", "api", "=", "api", "if", "api", "else", "cls", ".", "_API", "return", "super", "(", "Division", ",", "cls", ")", ".", "_query", ...
Query (List) divisions. :param offset: Pagination offset. :param limit: Pagination limit. :param api: Api instance. :return: Collection object.
[ "Query", "(", "List", ")", "divisions", "." ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/division.py#L34-L47
Kane610/deconz
pydeconz/utils.py
async_get_api_key
async def async_get_api_key(session, host, port, username=None, password=None, **kwargs): """Get a new API key for devicetype.""" url = 'http://{host}:{port}/api'.format(host=host, port=str(port)) auth = None if username and password: auth = aiohttp.BasicAuth(username, password=password) d...
python
async def async_get_api_key(session, host, port, username=None, password=None, **kwargs): """Get a new API key for devicetype.""" url = 'http://{host}:{port}/api'.format(host=host, port=str(port)) auth = None if username and password: auth = aiohttp.BasicAuth(username, password=password) d...
[ "async", "def", "async_get_api_key", "(", "session", ",", "host", ",", "port", ",", "username", "=", "None", ",", "password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "'http://{host}:{port}/api'", ".", "format", "(", "host", "=", "host...
Get a new API key for devicetype.
[ "Get", "a", "new", "API", "key", "for", "devicetype", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L14-L27
Kane610/deconz
pydeconz/utils.py
async_delete_api_key
async def async_delete_api_key(session, host, port, api_key): """Delete API key from deCONZ.""" url = 'http://{host}:{port}/api/{api_key}/config/whitelist/{api_key}'.format( host=host, port=str(port), api_key=api_key) response = await async_request(session.delete, url) _LOGGER.info(response)
python
async def async_delete_api_key(session, host, port, api_key): """Delete API key from deCONZ.""" url = 'http://{host}:{port}/api/{api_key}/config/whitelist/{api_key}'.format( host=host, port=str(port), api_key=api_key) response = await async_request(session.delete, url) _LOGGER.info(response)
[ "async", "def", "async_delete_api_key", "(", "session", ",", "host", ",", "port", ",", "api_key", ")", ":", "url", "=", "'http://{host}:{port}/api/{api_key}/config/whitelist/{api_key}'", ".", "format", "(", "host", "=", "host", ",", "port", "=", "str", "(", "por...
Delete API key from deCONZ.
[ "Delete", "API", "key", "from", "deCONZ", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L30-L37
Kane610/deconz
pydeconz/utils.py
async_delete_all_keys
async def async_delete_all_keys(session, host, port, api_key, api_keys=[]): """Delete all API keys except for the ones provided to the method.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) api_keys.append(api_key) for key in...
python
async def async_delete_all_keys(session, host, port, api_key, api_keys=[]): """Delete all API keys except for the ones provided to the method.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) api_keys.append(api_key) for key in...
[ "async", "def", "async_delete_all_keys", "(", "session", ",", "host", ",", "port", ",", "api_key", ",", "api_keys", "=", "[", "]", ")", ":", "url", "=", "'http://{}:{}/api/{}/config'", ".", "format", "(", "host", ",", "str", "(", "port", ")", ",", "api_k...
Delete all API keys except for the ones provided to the method.
[ "Delete", "all", "API", "keys", "except", "for", "the", "ones", "provided", "to", "the", "method", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L40-L49
Kane610/deconz
pydeconz/utils.py
async_get_bridgeid
async def async_get_bridgeid(session, host, port, api_key, **kwargs): """Get bridge id for bridge.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) bridgeid = response['bridgeid'] _LOGGER.info("Bridge id: %s", bridgeid) ret...
python
async def async_get_bridgeid(session, host, port, api_key, **kwargs): """Get bridge id for bridge.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) bridgeid = response['bridgeid'] _LOGGER.info("Bridge id: %s", bridgeid) ret...
[ "async", "def", "async_get_bridgeid", "(", "session", ",", "host", ",", "port", ",", "api_key", ",", "*", "*", "kwargs", ")", ":", "url", "=", "'http://{}:{}/api/{}/config'", ".", "format", "(", "host", ",", "str", "(", "port", ")", ",", "api_key", ")", ...
Get bridge id for bridge.
[ "Get", "bridge", "id", "for", "bridge", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L52-L60
Kane610/deconz
pydeconz/utils.py
async_discovery
async def async_discovery(session): """Find bridges allowing gateway discovery.""" bridges = [] response = await async_request(session.get, URL_DISCOVER) if not response: _LOGGER.info("No discoverable bridges available.") return bridges for bridge in response: bridges.appen...
python
async def async_discovery(session): """Find bridges allowing gateway discovery.""" bridges = [] response = await async_request(session.get, URL_DISCOVER) if not response: _LOGGER.info("No discoverable bridges available.") return bridges for bridge in response: bridges.appen...
[ "async", "def", "async_discovery", "(", "session", ")", ":", "bridges", "=", "[", "]", "response", "=", "await", "async_request", "(", "session", ".", "get", ",", "URL_DISCOVER", ")", "if", "not", "response", ":", "_LOGGER", ".", "info", "(", "\"No discove...
Find bridges allowing gateway discovery.
[ "Find", "bridges", "allowing", "gateway", "discovery", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L63-L79
Kane610/deconz
pydeconz/utils.py
async_request
async def async_request(session, url, **kwargs): """Do a web request and manage response.""" _LOGGER.debug("Sending %s to %s", kwargs, url) try: res = await session(url, **kwargs) if res.content_type != 'application/json': raise ResponseError( "Invalid content t...
python
async def async_request(session, url, **kwargs): """Do a web request and manage response.""" _LOGGER.debug("Sending %s to %s", kwargs, url) try: res = await session(url, **kwargs) if res.content_type != 'application/json': raise ResponseError( "Invalid content t...
[ "async", "def", "async_request", "(", "session", ",", "url", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Sending %s to %s\"", ",", "kwargs", ",", "url", ")", "try", ":", "res", "=", "await", "session", "(", "url", ",", "*", "*...
Do a web request and manage response.
[ "Do", "a", "web", "request", "and", "manage", "response", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L82-L103
Kane610/deconz
pydeconz/websocket.py
AIOWSClient.running
async def running(self): """Start websocket connection.""" url = 'http://{}:{}'.format(self.host, self.port) try: async with self.session.ws_connect(url) as ws: self.state = STATE_RUNNING async for msg in ws: if self.state == STATE_...
python
async def running(self): """Start websocket connection.""" url = 'http://{}:{}'.format(self.host, self.port) try: async with self.session.ws_connect(url) as ws: self.state = STATE_RUNNING async for msg in ws: if self.state == STATE_...
[ "async", "def", "running", "(", "self", ")", ":", "url", "=", "'http://{}:{}'", ".", "format", "(", "self", ".", "host", ",", "self", ".", "port", ")", "try", ":", "async", "with", "self", ".", "session", ".", "ws_connect", "(", "url", ")", "as", "...
Start websocket connection.
[ "Start", "websocket", "connection", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L56-L82
Kane610/deconz
pydeconz/websocket.py
AIOWSClient.retry
def retry(self): """Retry to connect to deCONZ.""" self.state = STATE_STARTING self.loop.call_later(RETRY_TIMER, self.start) _LOGGER.debug('Reconnecting to deCONZ in %i.', RETRY_TIMER)
python
def retry(self): """Retry to connect to deCONZ.""" self.state = STATE_STARTING self.loop.call_later(RETRY_TIMER, self.start) _LOGGER.debug('Reconnecting to deCONZ in %i.', RETRY_TIMER)
[ "def", "retry", "(", "self", ")", ":", "self", ".", "state", "=", "STATE_STARTING", "self", ".", "loop", ".", "call_later", "(", "RETRY_TIMER", ",", "self", ".", "start", ")", "_LOGGER", ".", "debug", "(", "'Reconnecting to deCONZ in %i.'", ",", "RETRY_TIMER...
Retry to connect to deCONZ.
[ "Retry", "to", "connect", "to", "deCONZ", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L88-L92
Kane610/deconz
pydeconz/websocket.py
WSClient.start
def start(self): """Start websocket connection.""" if self.state != STATE_RUNNING: conn = self.loop.create_connection( lambda: self, self.host, self.port) task = self.loop.create_task(conn) task.add_done_callback(self.init_done) self.state ...
python
def start(self): """Start websocket connection.""" if self.state != STATE_RUNNING: conn = self.loop.create_connection( lambda: self, self.host, self.port) task = self.loop.create_task(conn) task.add_done_callback(self.init_done) self.state ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "state", "!=", "STATE_RUNNING", ":", "conn", "=", "self", ".", "loop", ".", "create_connection", "(", "lambda", ":", "self", ",", "self", ".", "host", ",", "self", ".", "port", ")", "task", ...
Start websocket connection.
[ "Start", "websocket", "connection", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L109-L116
Kane610/deconz
pydeconz/websocket.py
WSClient.init_done
def init_done(self, fut): """Server ready. If we get OSError during init the device is not available. """ try: if fut.exception(): fut.result() except OSError as err: _LOGGER.debug('Got exception %s', err) self.retry()
python
def init_done(self, fut): """Server ready. If we get OSError during init the device is not available. """ try: if fut.exception(): fut.result() except OSError as err: _LOGGER.debug('Got exception %s', err) self.retry()
[ "def", "init_done", "(", "self", ",", "fut", ")", ":", "try", ":", "if", "fut", ".", "exception", "(", ")", ":", "fut", ".", "result", "(", ")", "except", "OSError", "as", "err", ":", "_LOGGER", ".", "debug", "(", "'Got exception %s'", ",", "err", ...
Server ready. If we get OSError during init the device is not available.
[ "Server", "ready", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L118-L128
Kane610/deconz
pydeconz/websocket.py
WSClient.stop
def stop(self): """Close websocket connection.""" self.state = STATE_STOPPED if self.transport: self.transport.close()
python
def stop(self): """Close websocket connection.""" self.state = STATE_STOPPED if self.transport: self.transport.close()
[ "def", "stop", "(", "self", ")", ":", "self", ".", "state", "=", "STATE_STOPPED", "if", "self", ".", "transport", ":", "self", ".", "transport", ".", "close", "(", ")" ]
Close websocket connection.
[ "Close", "websocket", "connection", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L146-L150
Kane610/deconz
pydeconz/websocket.py
WSClient.connection_made
def connection_made(self, transport): """Do the websocket handshake. According to https://tools.ietf.org/html/rfc6455 """ randomness = os.urandom(16) key = base64encode(randomness).decode('utf-8').strip() self.transport = transport message = "GET / HTTP/1.1\r\n" ...
python
def connection_made(self, transport): """Do the websocket handshake. According to https://tools.ietf.org/html/rfc6455 """ randomness = os.urandom(16) key = base64encode(randomness).decode('utf-8').strip() self.transport = transport message = "GET / HTTP/1.1\r\n" ...
[ "def", "connection_made", "(", "self", ",", "transport", ")", ":", "randomness", "=", "os", ".", "urandom", "(", "16", ")", "key", "=", "base64encode", "(", "randomness", ")", ".", "decode", "(", "'utf-8'", ")", ".", "strip", "(", ")", "self", ".", "...
Do the websocket handshake. According to https://tools.ietf.org/html/rfc6455
[ "Do", "the", "websocket", "handshake", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L157-L174
Kane610/deconz
pydeconz/websocket.py
WSClient.data_received
def data_received(self, data): """Data received over websocket. First received data will allways be handshake accepting connection. We need to check how big the header is so we can send event data as a proper json object. """ if self.state == STATE_STARTING: ...
python
def data_received(self, data): """Data received over websocket. First received data will allways be handshake accepting connection. We need to check how big the header is so we can send event data as a proper json object. """ if self.state == STATE_STARTING: ...
[ "def", "data_received", "(", "self", ",", "data", ")", ":", "if", "self", ".", "state", "==", "STATE_STARTING", ":", "self", ".", "state", "=", "STATE_RUNNING", "_LOGGER", ".", "debug", "(", "'Websocket handshake: %s'", ",", "data", ".", "decode", "(", ")"...
Data received over websocket. First received data will allways be handshake accepting connection. We need to check how big the header is so we can send event data as a proper json object.
[ "Data", "received", "over", "websocket", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L176-L194
Kane610/deconz
pydeconz/websocket.py
WSClient.connection_lost
def connection_lost(self, exc): """Happen when device closes connection or stop() has been called.""" if self.state == STATE_RUNNING: _LOGGER.warning('Lost connection to deCONZ') self.retry()
python
def connection_lost(self, exc): """Happen when device closes connection or stop() has been called.""" if self.state == STATE_RUNNING: _LOGGER.warning('Lost connection to deCONZ') self.retry()
[ "def", "connection_lost", "(", "self", ",", "exc", ")", ":", "if", "self", ".", "state", "==", "STATE_RUNNING", ":", "_LOGGER", ".", "warning", "(", "'Lost connection to deCONZ'", ")", "self", ".", "retry", "(", ")" ]
Happen when device closes connection or stop() has been called.
[ "Happen", "when", "device", "closes", "connection", "or", "stop", "()", "has", "been", "called", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L196-L200
Kane610/deconz
pydeconz/websocket.py
WSClient.get_payload
def get_payload(self, data): """Parse length of payload and return it.""" start = 2 length = ord(data[1:2]) if length == 126: # Payload information are an extra 2 bytes. start = 4 length, = unpack(">H", data[2:4]) elif length == 127: ...
python
def get_payload(self, data): """Parse length of payload and return it.""" start = 2 length = ord(data[1:2]) if length == 126: # Payload information are an extra 2 bytes. start = 4 length, = unpack(">H", data[2:4]) elif length == 127: ...
[ "def", "get_payload", "(", "self", ",", "data", ")", ":", "start", "=", "2", "length", "=", "ord", "(", "data", "[", "1", ":", "2", "]", ")", "if", "length", "==", "126", ":", "# Payload information are an extra 2 bytes.", "start", "=", "4", "length", ...
Parse length of payload and return it.
[ "Parse", "length", "of", "payload", "and", "return", "it", "." ]
train
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L202-L217
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/task.py
find_old_vidyo_rooms
def find_old_vidyo_rooms(max_room_event_age): """Finds all Vidyo rooms that are: - linked to no events - linked only to events whose start date precedes today - max_room_event_age days """ recently_used = (db.session.query(VCRoom.id) .filter(VCRoom.type == 'vidyo', ...
python
def find_old_vidyo_rooms(max_room_event_age): """Finds all Vidyo rooms that are: - linked to no events - linked only to events whose start date precedes today - max_room_event_age days """ recently_used = (db.session.query(VCRoom.id) .filter(VCRoom.type == 'vidyo', ...
[ "def", "find_old_vidyo_rooms", "(", "max_room_event_age", ")", ":", "recently_used", "=", "(", "db", ".", "session", ".", "query", "(", "VCRoom", ".", "id", ")", ".", "filter", "(", "VCRoom", ".", "type", "==", "'vidyo'", ",", "Event", ".", "end_dt", ">"...
Finds all Vidyo rooms that are: - linked to no events - linked only to events whose start date precedes today - max_room_event_age days
[ "Finds", "all", "Vidyo", "rooms", "that", "are", ":", "-", "linked", "to", "no", "events", "-", "linked", "only", "to", "events", "whose", "start", "date", "precedes", "today", "-", "max_room_event_age", "days" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/task.py#L35-L48
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/task.py
notify_owner
def notify_owner(plugin, vc_room): """Notifies about the deletion of a Vidyo room from the Vidyo server.""" user = vc_room.vidyo_extension.owned_by_user tpl = get_plugin_template_module('emails/remote_deleted.html', plugin=plugin, vc_room=vc_room, event=None, vc_room_eve...
python
def notify_owner(plugin, vc_room): """Notifies about the deletion of a Vidyo room from the Vidyo server.""" user = vc_room.vidyo_extension.owned_by_user tpl = get_plugin_template_module('emails/remote_deleted.html', plugin=plugin, vc_room=vc_room, event=None, vc_room_eve...
[ "def", "notify_owner", "(", "plugin", ",", "vc_room", ")", ":", "user", "=", "vc_room", ".", "vidyo_extension", ".", "owned_by_user", "tpl", "=", "get_plugin_template_module", "(", "'emails/remote_deleted.html'", ",", "plugin", "=", "plugin", ",", "vc_room", "=", ...
Notifies about the deletion of a Vidyo room from the Vidyo server.
[ "Notifies", "about", "the", "deletion", "of", "a", "Vidyo", "room", "from", "the", "Vidyo", "server", "." ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/task.py#L51-L56
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/cli.py
rooms
def rooms(status=None): """Lists all Vidyo rooms""" room_query = VCRoom.find(type='vidyo') table_data = [['ID', 'Name', 'Status', 'Vidyo ID', 'Extension']] if status: room_query = room_query.filter(VCRoom.status == VCRoomStatus.get(status)) for room in room_query: table_data.appen...
python
def rooms(status=None): """Lists all Vidyo rooms""" room_query = VCRoom.find(type='vidyo') table_data = [['ID', 'Name', 'Status', 'Vidyo ID', 'Extension']] if status: room_query = room_query.filter(VCRoom.status == VCRoomStatus.get(status)) for room in room_query: table_data.appen...
[ "def", "rooms", "(", "status", "=", "None", ")", ":", "room_query", "=", "VCRoom", ".", "find", "(", "type", "=", "'vidyo'", ")", "table_data", "=", "[", "[", "'ID'", ",", "'Name'", ",", "'Status'", ",", "'Vidyo ID'", ",", "'Extension'", "]", "]", "i...
Lists all Vidyo rooms
[ "Lists", "all", "Vidyo", "rooms" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/cli.py#L33-L49
sbg/sevenbridges-python
sevenbridges/http/client.py
config_vars
def config_vars(profiles, advance_access): """ Utility method to fetch config vars using ini section profile :param profiles: profile name. :param advance_access: advance_access flag. :return: """ for profile in profiles: try: config = Config(profile, advance_access=advan...
python
def config_vars(profiles, advance_access): """ Utility method to fetch config vars using ini section profile :param profiles: profile name. :param advance_access: advance_access flag. :return: """ for profile in profiles: try: config = Config(profile, advance_access=advan...
[ "def", "config_vars", "(", "profiles", ",", "advance_access", ")", ":", "for", "profile", "in", "profiles", ":", "try", ":", "config", "=", "Config", "(", "profile", ",", "advance_access", "=", "advance_access", ")", "url", "=", "config", ".", "api_endpoint"...
Utility method to fetch config vars using ini section profile :param profiles: profile name. :param advance_access: advance_access flag. :return:
[ "Utility", "method", "to", "fetch", "config", "vars", "using", "ini", "section", "profile", ":", "param", "profiles", ":", "profile", "name", ".", ":", "param", "advance_access", ":", "advance_access", "flag", ".", ":", "return", ":" ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/http/client.py#L63-L80
sbg/sevenbridges-python
sevenbridges/http/client.py
RequestSession.send
def send(self, request, **kwargs): """Send prepared request :param request: Prepared request to be sent :param kwargs: request keyword arguments :return: Request response """ if len(request.url) > self.MAX_URL_LENGTH: raise URITooLong( message=...
python
def send(self, request, **kwargs): """Send prepared request :param request: Prepared request to be sent :param kwargs: request keyword arguments :return: Request response """ if len(request.url) > self.MAX_URL_LENGTH: raise URITooLong( message=...
[ "def", "send", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "request", ".", "url", ")", ">", "self", ".", "MAX_URL_LENGTH", ":", "raise", "URITooLong", "(", "message", "=", "(", "'Request url too large, '", "'likely t...
Send prepared request :param request: Prepared request to be sent :param kwargs: request keyword arguments :return: Request response
[ "Send", "prepared", "request", ":", "param", "request", ":", "Prepared", "request", "to", "be", "sent", ":", "param", "kwargs", ":", "request", "keyword", "arguments", ":", "return", ":", "Request", "response" ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/http/client.py#L35-L48
indico/indico-plugins
search/indico_search/util.py
render_engine_or_search_template
def render_engine_or_search_template(template_name, **context): """Renders a template from the engine plugin or the search plugin If the template is available in the engine plugin, it's taken from there, otherwise the template from this plugin is used. :param template_name: name of the template :p...
python
def render_engine_or_search_template(template_name, **context): """Renders a template from the engine plugin or the search plugin If the template is available in the engine plugin, it's taken from there, otherwise the template from this plugin is used. :param template_name: name of the template :p...
[ "def", "render_engine_or_search_template", "(", "template_name", ",", "*", "*", "context", ")", ":", "from", "indico_search", ".", "plugin", "import", "SearchPlugin", "assert", "current_plugin", "==", "SearchPlugin", ".", "instance", "templates", "=", "(", "'{}:{}'"...
Renders a template from the engine plugin or the search plugin If the template is available in the engine plugin, it's taken from there, otherwise the template from this plugin is used. :param template_name: name of the template :param context: the variables that should be available in the ...
[ "Renders", "a", "template", "from", "the", "engine", "plugin", "or", "the", "search", "plugin" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/search/indico_search/util.py#L22-L37
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
iter_user_identities
def iter_user_identities(user): """Iterates over all existing user identities that can be used with Vidyo""" from indico_vc_vidyo.plugin import VidyoPlugin providers = authenticators_re.split(VidyoPlugin.settings.get('authenticators')) done = set() for provider in providers: for _, identifie...
python
def iter_user_identities(user): """Iterates over all existing user identities that can be used with Vidyo""" from indico_vc_vidyo.plugin import VidyoPlugin providers = authenticators_re.split(VidyoPlugin.settings.get('authenticators')) done = set() for provider in providers: for _, identifie...
[ "def", "iter_user_identities", "(", "user", ")", ":", "from", "indico_vc_vidyo", ".", "plugin", "import", "VidyoPlugin", "providers", "=", "authenticators_re", ".", "split", "(", "VidyoPlugin", ".", "settings", ".", "get", "(", "'authenticators'", ")", ")", "don...
Iterates over all existing user identities that can be used with Vidyo
[ "Iterates", "over", "all", "existing", "user", "identities", "that", "can", "be", "used", "with", "Vidyo" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L32-L42
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
get_user_from_identifier
def get_user_from_identifier(settings, identifier): """Get an actual User object from an identifier""" providers = list(auth.strip() for auth in settings.get('authenticators').split(',')) identities = Identity.find_all(Identity.provider.in_(providers), Identity.identifier == identifier) if identities: ...
python
def get_user_from_identifier(settings, identifier): """Get an actual User object from an identifier""" providers = list(auth.strip() for auth in settings.get('authenticators').split(',')) identities = Identity.find_all(Identity.provider.in_(providers), Identity.identifier == identifier) if identities: ...
[ "def", "get_user_from_identifier", "(", "settings", ",", "identifier", ")", ":", "providers", "=", "list", "(", "auth", ".", "strip", "(", ")", "for", "auth", "in", "settings", ".", "get", "(", "'authenticators'", ")", ".", "split", "(", "','", ")", ")",...
Get an actual User object from an identifier
[ "Get", "an", "actual", "User", "object", "from", "an", "identifier" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L45-L65
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
iter_extensions
def iter_extensions(prefix, event_id): """Return extension (prefix + event_id) with an optional suffix which is incremented step by step in case of collision """ extension = '{prefix}{event_id}'.format(prefix=prefix, event_id=event_id) yield extension suffix = 1 while True: yield ...
python
def iter_extensions(prefix, event_id): """Return extension (prefix + event_id) with an optional suffix which is incremented step by step in case of collision """ extension = '{prefix}{event_id}'.format(prefix=prefix, event_id=event_id) yield extension suffix = 1 while True: yield ...
[ "def", "iter_extensions", "(", "prefix", ",", "event_id", ")", ":", "extension", "=", "'{prefix}{event_id}'", ".", "format", "(", "prefix", "=", "prefix", ",", "event_id", "=", "event_id", ")", "yield", "extension", "suffix", "=", "1", "while", "True", ":", ...
Return extension (prefix + event_id) with an optional suffix which is incremented step by step in case of collision
[ "Return", "extension", "(", "prefix", "+", "event_id", ")", "with", "an", "optional", "suffix", "which", "is", "incremented", "step", "by", "step", "in", "case", "of", "collision" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L68-L77
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
update_room_from_obj
def update_room_from_obj(settings, vc_room, room_obj): """Updates a VCRoom DB object using a SOAP room object returned by the API""" vc_room.name = room_obj.name if room_obj.ownerName != vc_room.data['owner_identity']: owner = get_user_from_identifier(settings, room_obj.ownerName) or User.get_system...
python
def update_room_from_obj(settings, vc_room, room_obj): """Updates a VCRoom DB object using a SOAP room object returned by the API""" vc_room.name = room_obj.name if room_obj.ownerName != vc_room.data['owner_identity']: owner = get_user_from_identifier(settings, room_obj.ownerName) or User.get_system...
[ "def", "update_room_from_obj", "(", "settings", ",", "vc_room", ",", "room_obj", ")", ":", "vc_room", ".", "name", "=", "room_obj", ".", "name", "if", "room_obj", ".", "ownerName", "!=", "vc_room", ".", "data", "[", "'owner_identity'", "]", ":", "owner", "...
Updates a VCRoom DB object using a SOAP room object returned by the API
[ "Updates", "a", "VCRoom", "DB", "object", "using", "a", "SOAP", "room", "object", "returned", "by", "the", "API" ]
train
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L80-L95
sbg/sevenbridges-python
sevenbridges/models/endpoints.py
Endpoints.get
def get(cls, api=None, **kwargs): """ Get api links. :param api: Api instance. :return: Endpoints object. """ api = api if api else cls._API extra = { 'resource': cls.__name__, 'query': {} } logger.info('Getting resources', ...
python
def get(cls, api=None, **kwargs): """ Get api links. :param api: Api instance. :return: Endpoints object. """ api = api if api else cls._API extra = { 'resource': cls.__name__, 'query': {} } logger.info('Getting resources', ...
[ "def", "get", "(", "cls", ",", "api", "=", "None", ",", "*", "*", "kwargs", ")", ":", "api", "=", "api", "if", "api", "else", "cls", ".", "_API", "extra", "=", "{", "'resource'", ":", "cls", ".", "__name__", ",", "'query'", ":", "{", "}", "}", ...
Get api links. :param api: Api instance. :return: Endpoints object.
[ "Get", "api", "links", ".", ":", "param", "api", ":", "Api", "instance", ".", ":", "return", ":", "Endpoints", "object", "." ]
train
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/endpoints.py#L30-L43
CygnusNetworks/pypureomapi
pypureomapi.py
parse_chain
def parse_chain(*args): """Creates a new parser that executes the passed parsers (args) with the previous results and yields a tuple of the results. >>> list(parse_chain(lambda: (None, 1), lambda one: (None, 2))) [None, None, (1, 2)] @param args: parsers @returns: parser """ items = [] for parser in args: ...
python
def parse_chain(*args): """Creates a new parser that executes the passed parsers (args) with the previous results and yields a tuple of the results. >>> list(parse_chain(lambda: (None, 1), lambda one: (None, 2))) [None, None, (1, 2)] @param args: parsers @returns: parser """ items = [] for parser in args: ...
[ "def", "parse_chain", "(", "*", "args", ")", ":", "items", "=", "[", "]", "for", "parser", "in", "args", ":", "for", "element", "in", "parser", "(", "*", "items", ")", ":", "# pylint:disable=star-args", "if", "element", "is", "None", ":", "yield", "Non...
Creates a new parser that executes the passed parsers (args) with the previous results and yields a tuple of the results. >>> list(parse_chain(lambda: (None, 1), lambda one: (None, 2))) [None, None, (1, 2)] @param args: parsers @returns: parser
[ "Creates", "a", "new", "parser", "that", "executes", "the", "passed", "parsers", "(", "args", ")", "with", "the", "previous", "results", "and", "yields", "a", "tuple", "of", "the", "results", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L567-L585
CygnusNetworks/pypureomapi
pypureomapi.py
pack_ip
def pack_ip(ipstr): """Converts an ip address given in dotted notation to a four byte string in network byte order. >>> len(pack_ip("127.0.0.1")) 4 >>> pack_ip("foo") Traceback (most recent call last): ... ValueError: given ip address has an invalid number of dots @type ipstr: str @rtype: bytes @raises Val...
python
def pack_ip(ipstr): """Converts an ip address given in dotted notation to a four byte string in network byte order. >>> len(pack_ip("127.0.0.1")) 4 >>> pack_ip("foo") Traceback (most recent call last): ... ValueError: given ip address has an invalid number of dots @type ipstr: str @rtype: bytes @raises Val...
[ "def", "pack_ip", "(", "ipstr", ")", ":", "if", "not", "isinstance", "(", "ipstr", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\"given ip address is not a string\"", ")", "parts", "=", "ipstr", ".", "split", "(", "'.'", ")", "if", "len", "(",...
Converts an ip address given in dotted notation to a four byte string in network byte order. >>> len(pack_ip("127.0.0.1")) 4 >>> pack_ip("foo") Traceback (most recent call last): ... ValueError: given ip address has an invalid number of dots @type ipstr: str @rtype: bytes @raises ValueError: for badly forma...
[ "Converts", "an", "ip", "address", "given", "in", "dotted", "notation", "to", "a", "four", "byte", "string", "in", "network", "byte", "order", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L724-L745
CygnusNetworks/pypureomapi
pypureomapi.py
unpack_ip
def unpack_ip(fourbytes): """Converts an ip address given in a four byte string in network byte order to a string in dotted notation. >>> unpack_ip(b"dead") '100.101.97.100' >>> unpack_ip(b"alive") Traceback (most recent call last): ... ValueError: given buffer is not exactly four bytes long @type fourbytes:...
python
def unpack_ip(fourbytes): """Converts an ip address given in a four byte string in network byte order to a string in dotted notation. >>> unpack_ip(b"dead") '100.101.97.100' >>> unpack_ip(b"alive") Traceback (most recent call last): ... ValueError: given buffer is not exactly four bytes long @type fourbytes:...
[ "def", "unpack_ip", "(", "fourbytes", ")", ":", "if", "not", "isinstance", "(", "fourbytes", ",", "bytes", ")", ":", "raise", "ValueError", "(", "\"given buffer is not a string\"", ")", "if", "len", "(", "fourbytes", ")", "!=", "4", ":", "raise", "ValueError...
Converts an ip address given in a four byte string in network byte order to a string in dotted notation. >>> unpack_ip(b"dead") '100.101.97.100' >>> unpack_ip(b"alive") Traceback (most recent call last): ... ValueError: given buffer is not exactly four bytes long @type fourbytes: bytes @rtype: str @raises V...
[ "Converts", "an", "ip", "address", "given", "in", "a", "four", "byte", "string", "in", "network", "byte", "order", "to", "a", "string", "in", "dotted", "notation", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L751-L770
CygnusNetworks/pypureomapi
pypureomapi.py
pack_mac
def pack_mac(macstr): """Converts a mac address given in colon delimited notation to a six byte string in network byte order. >>> pack_mac("30:31:32:33:34:35") == b'012345' True >>> pack_mac("bad") Traceback (most recent call last): ... ValueError: given mac addresses has an invalid number of colons @type m...
python
def pack_mac(macstr): """Converts a mac address given in colon delimited notation to a six byte string in network byte order. >>> pack_mac("30:31:32:33:34:35") == b'012345' True >>> pack_mac("bad") Traceback (most recent call last): ... ValueError: given mac addresses has an invalid number of colons @type m...
[ "def", "pack_mac", "(", "macstr", ")", ":", "if", "not", "isinstance", "(", "macstr", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\"given mac addresses is not a string\"", ")", "parts", "=", "macstr", ".", "split", "(", "\":\"", ")", "if", "len...
Converts a mac address given in colon delimited notation to a six byte string in network byte order. >>> pack_mac("30:31:32:33:34:35") == b'012345' True >>> pack_mac("bad") Traceback (most recent call last): ... ValueError: given mac addresses has an invalid number of colons @type macstr: str @rtype: bytes ...
[ "Converts", "a", "mac", "address", "given", "in", "colon", "delimited", "notation", "to", "a", "six", "byte", "string", "in", "network", "byte", "order", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L776-L798
CygnusNetworks/pypureomapi
pypureomapi.py
unpack_mac
def unpack_mac(sixbytes): """Converts a mac address given in a six byte string in network byte order to a string in colon delimited notation. >>> unpack_mac(b"012345") '30:31:32:33:34:35' >>> unpack_mac(b"bad") Traceback (most recent call last): ... ValueError: given buffer is not exactly six bytes long @typ...
python
def unpack_mac(sixbytes): """Converts a mac address given in a six byte string in network byte order to a string in colon delimited notation. >>> unpack_mac(b"012345") '30:31:32:33:34:35' >>> unpack_mac(b"bad") Traceback (most recent call last): ... ValueError: given buffer is not exactly six bytes long @typ...
[ "def", "unpack_mac", "(", "sixbytes", ")", ":", "if", "not", "isinstance", "(", "sixbytes", ",", "bytes", ")", ":", "raise", "ValueError", "(", "\"given buffer is not a string\"", ")", "if", "len", "(", "sixbytes", ")", "!=", "6", ":", "raise", "ValueError",...
Converts a mac address given in a six byte string in network byte order to a string in colon delimited notation. >>> unpack_mac(b"012345") '30:31:32:33:34:35' >>> unpack_mac(b"bad") Traceback (most recent call last): ... ValueError: given buffer is not exactly six bytes long @type sixbytes: bytes @rtype: str...
[ "Converts", "a", "mac", "address", "given", "in", "a", "six", "byte", "string", "in", "network", "byte", "order", "to", "a", "string", "in", "colon", "delimited", "notation", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L804-L823
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add
def add(self, data): """ >>> ob = OutBuffer().add(OutBuffer.sizelimit * b"x") >>> ob.add(b"y") # doctest: +ELLIPSIS Traceback (most recent call last): ... OmapiSizeLimitError: ... @type data: bytes @returns: self @raises OmapiSizeLimitError: """ if len(self) + len(data) > self.sizelimit: raise...
python
def add(self, data): """ >>> ob = OutBuffer().add(OutBuffer.sizelimit * b"x") >>> ob.add(b"y") # doctest: +ELLIPSIS Traceback (most recent call last): ... OmapiSizeLimitError: ... @type data: bytes @returns: self @raises OmapiSizeLimitError: """ if len(self) + len(data) > self.sizelimit: raise...
[ "def", "add", "(", "self", ",", "data", ")", ":", "if", "len", "(", "self", ")", "+", "len", "(", "data", ")", ">", "self", ".", "sizelimit", ":", "raise", "OmapiSizeLimitError", "(", ")", "self", ".", "buff", ".", "write", "(", "data", ")", "ret...
>>> ob = OutBuffer().add(OutBuffer.sizelimit * b"x") >>> ob.add(b"y") # doctest: +ELLIPSIS Traceback (most recent call last): ... OmapiSizeLimitError: ... @type data: bytes @returns: self @raises OmapiSizeLimitError:
[ ">>>", "ob", "=", "OutBuffer", "()", ".", "add", "(", "OutBuffer", ".", "sizelimit", "*", "b", "x", ")", ">>>", "ob", ".", "add", "(", "b", "y", ")", "#", "doctest", ":", "+", "ELLIPSIS", "Traceback", "(", "most", "recent", "call", "last", ")", "...
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L131-L146
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add_net32string
def add_net32string(self, string): """ >>> r = b'\\x00\\x00\\x00\\x01x' >>> OutBuffer().add_net32string(b"x").getvalue() == r True @type string: bytes @param string: maximum length must fit in a 32bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 32): raise Valu...
python
def add_net32string(self, string): """ >>> r = b'\\x00\\x00\\x00\\x01x' >>> OutBuffer().add_net32string(b"x").getvalue() == r True @type string: bytes @param string: maximum length must fit in a 32bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 32): raise Valu...
[ "def", "add_net32string", "(", "self", ",", "string", ")", ":", "if", "len", "(", "string", ")", ">=", "(", "1", "<<", "32", ")", ":", "raise", "ValueError", "(", "\"string too long\"", ")", "return", "self", ".", "add_net32int", "(", "len", "(", "stri...
>>> r = b'\\x00\\x00\\x00\\x01x' >>> OutBuffer().add_net32string(b"x").getvalue() == r True @type string: bytes @param string: maximum length must fit in a 32bit integer @returns: self @raises OmapiSizeLimitError:
[ ">>>", "r", "=", "b", "\\\\", "x00", "\\\\", "x00", "\\\\", "x00", "\\\\", "x01x", ">>>", "OutBuffer", "()", ".", "add_net32string", "(", "b", "x", ")", ".", "getvalue", "()", "==", "r", "True" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L170-L183
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add_net16string
def add_net16string(self, string): """ >>> OutBuffer().add_net16string(b"x").getvalue() == b'\\x00\\x01x' True @type string: bytes @param string: maximum length must fit in a 16bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 16): raise ValueError("string too lon...
python
def add_net16string(self, string): """ >>> OutBuffer().add_net16string(b"x").getvalue() == b'\\x00\\x01x' True @type string: bytes @param string: maximum length must fit in a 16bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 16): raise ValueError("string too lon...
[ "def", "add_net16string", "(", "self", ",", "string", ")", ":", "if", "len", "(", "string", ")", ">=", "(", "1", "<<", "16", ")", ":", "raise", "ValueError", "(", "\"string too long\"", ")", "return", "self", ".", "add_net16int", "(", "len", "(", "stri...
>>> OutBuffer().add_net16string(b"x").getvalue() == b'\\x00\\x01x' True @type string: bytes @param string: maximum length must fit in a 16bit integer @returns: self @raises OmapiSizeLimitError:
[ ">>>", "OutBuffer", "()", ".", "add_net16string", "(", "b", "x", ")", ".", "getvalue", "()", "==", "b", "\\\\", "x00", "\\\\", "x01x", "True" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L185-L197
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add_bindict
def add_bindict(self, items): """ >>> r = b'\\x00\\x03foo\\x00\\x00\\x00\\x03bar\\x00\\x00' >>> OutBuffer().add_bindict({b"foo": b"bar"}).getvalue() == r True @type items: [(bytes, bytes)] or {bytes: bytes} @returns: self @raises OmapiSizeLimitError: """ if not isinstance(items, list): items = ite...
python
def add_bindict(self, items): """ >>> r = b'\\x00\\x03foo\\x00\\x00\\x00\\x03bar\\x00\\x00' >>> OutBuffer().add_bindict({b"foo": b"bar"}).getvalue() == r True @type items: [(bytes, bytes)] or {bytes: bytes} @returns: self @raises OmapiSizeLimitError: """ if not isinstance(items, list): items = ite...
[ "def", "add_bindict", "(", "self", ",", "items", ")", ":", "if", "not", "isinstance", "(", "items", ",", "list", ")", ":", "items", "=", "items", ".", "items", "(", ")", "for", "key", ",", "value", "in", "items", ":", "self", ".", "add_net16string", ...
>>> r = b'\\x00\\x03foo\\x00\\x00\\x00\\x03bar\\x00\\x00' >>> OutBuffer().add_bindict({b"foo": b"bar"}).getvalue() == r True @type items: [(bytes, bytes)] or {bytes: bytes} @returns: self @raises OmapiSizeLimitError:
[ ">>>", "r", "=", "b", "\\\\", "x00", "\\\\", "x03foo", "\\\\", "x00", "\\\\", "x00", "\\\\", "x00", "\\\\", "x03bar", "\\\\", "x00", "\\\\", "x00", ">>>", "OutBuffer", "()", ".", "add_bindict", "(", "{", "b", "foo", ":", "b", "bar", "}", ")", ".", ...
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L199-L213
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.consume
def consume(self, length): """ >>> OutBuffer().add(b"spam").consume(2).getvalue() == b"am" True @type length: int @returns: self """ self.buff = io.BytesIO(self.getvalue()[length:]) return self
python
def consume(self, length): """ >>> OutBuffer().add(b"spam").consume(2).getvalue() == b"am" True @type length: int @returns: self """ self.buff = io.BytesIO(self.getvalue()[length:]) return self
[ "def", "consume", "(", "self", ",", "length", ")", ":", "self", ".", "buff", "=", "io", ".", "BytesIO", "(", "self", ".", "getvalue", "(", ")", "[", "length", ":", "]", ")", "return", "self" ]
>>> OutBuffer().add(b"spam").consume(2).getvalue() == b"am" True @type length: int @returns: self
[ ">>>", "OutBuffer", "()", ".", "add", "(", "b", "spam", ")", ".", "consume", "(", "2", ")", ".", "getvalue", "()", "==", "b", "am", "True" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L224-L233
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiStartupMessage.validate
def validate(self): """Checks whether this OmapiStartupMessage matches the implementation. @raises OmapiError: """ if self.implemented_protocol_version != self.protocol_version: raise OmapiError("protocol mismatch") if self.implemented_header_size != self.header_size: raise OmapiError("header size misma...
python
def validate(self): """Checks whether this OmapiStartupMessage matches the implementation. @raises OmapiError: """ if self.implemented_protocol_version != self.protocol_version: raise OmapiError("protocol mismatch") if self.implemented_header_size != self.header_size: raise OmapiError("header size misma...
[ "def", "validate", "(", "self", ")", ":", "if", "self", ".", "implemented_protocol_version", "!=", "self", ".", "protocol_version", ":", "raise", "OmapiError", "(", "\"protocol mismatch\"", ")", "if", "self", ".", "implemented_header_size", "!=", "self", ".", "h...
Checks whether this OmapiStartupMessage matches the implementation. @raises OmapiError:
[ "Checks", "whether", "this", "OmapiStartupMessage", "matches", "the", "implementation", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L263-L270
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiStartupMessage.serialize
def serialize(self, outbuffer): """Serialize this OmapiStartupMessage to the given outbuffer. @type outbuffer: OutBuffer """ outbuffer.add_net32int(self.protocol_version) outbuffer.add_net32int(self.header_size)
python
def serialize(self, outbuffer): """Serialize this OmapiStartupMessage to the given outbuffer. @type outbuffer: OutBuffer """ outbuffer.add_net32int(self.protocol_version) outbuffer.add_net32int(self.header_size)
[ "def", "serialize", "(", "self", ",", "outbuffer", ")", ":", "outbuffer", ".", "add_net32int", "(", "self", ".", "protocol_version", ")", "outbuffer", ".", "add_net32int", "(", "self", ".", "header_size", ")" ]
Serialize this OmapiStartupMessage to the given outbuffer. @type outbuffer: OutBuffer
[ "Serialize", "this", "OmapiStartupMessage", "to", "the", "given", "outbuffer", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L280-L285
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiHMACMD5Authenticator.sign
def sign(self, message): """ >>> authlen = OmapiHMACMD5Authenticator.authlen >>> len(OmapiHMACMD5Authenticator(b"foo", 16*b"x").sign(b"baz")) == authlen True @type message: bytes @rtype: bytes @returns: a signature of length self.authlen """ return hmac.HMAC(self.key, message, digestmod=hashlib.md5)....
python
def sign(self, message): """ >>> authlen = OmapiHMACMD5Authenticator.authlen >>> len(OmapiHMACMD5Authenticator(b"foo", 16*b"x").sign(b"baz")) == authlen True @type message: bytes @rtype: bytes @returns: a signature of length self.authlen """ return hmac.HMAC(self.key, message, digestmod=hashlib.md5)....
[ "def", "sign", "(", "self", ",", "message", ")", ":", "return", "hmac", ".", "HMAC", "(", "self", ".", "key", ",", "message", ",", "digestmod", "=", "hashlib", ".", "md5", ")", ".", "digest", "(", ")" ]
>>> authlen = OmapiHMACMD5Authenticator.authlen >>> len(OmapiHMACMD5Authenticator(b"foo", 16*b"x").sign(b"baz")) == authlen True @type message: bytes @rtype: bytes @returns: a signature of length self.authlen
[ ">>>", "authlen", "=", "OmapiHMACMD5Authenticator", ".", "authlen", ">>>", "len", "(", "OmapiHMACMD5Authenticator", "(", "b", "foo", "16", "*", "b", "x", ")", ".", "sign", "(", "b", "baz", "))", "==", "authlen", "True" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L361-L371
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.as_string
def as_string(self, forsigning=False): """ >>> len(OmapiMessage().as_string(True)) >= 24 True @type forsigning: bool @rtype: bytes @raises OmapiSizeLimitError: """ ret = OutBuffer() self.serialize(ret, forsigning) return ret.getvalue()
python
def as_string(self, forsigning=False): """ >>> len(OmapiMessage().as_string(True)) >= 24 True @type forsigning: bool @rtype: bytes @raises OmapiSizeLimitError: """ ret = OutBuffer() self.serialize(ret, forsigning) return ret.getvalue()
[ "def", "as_string", "(", "self", ",", "forsigning", "=", "False", ")", ":", "ret", "=", "OutBuffer", "(", ")", "self", ".", "serialize", "(", "ret", ",", "forsigning", ")", "return", "ret", ".", "getvalue", "(", ")" ]
>>> len(OmapiMessage().as_string(True)) >= 24 True @type forsigning: bool @rtype: bytes @raises OmapiSizeLimitError:
[ ">>>", "len", "(", "OmapiMessage", "()", ".", "as_string", "(", "True", "))", ">", "=", "24", "True" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L449-L460
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.sign
def sign(self, authenticator): """Sign this OMAPI message. @type authenticator: OmapiAuthenticatorBase """ self.authid = authenticator.authid self.signature = b"\0" * authenticator.authlen # provide authlen self.signature = authenticator.sign(self.as_string(forsigning=True)) assert len(self.signature) ==...
python
def sign(self, authenticator): """Sign this OMAPI message. @type authenticator: OmapiAuthenticatorBase """ self.authid = authenticator.authid self.signature = b"\0" * authenticator.authlen # provide authlen self.signature = authenticator.sign(self.as_string(forsigning=True)) assert len(self.signature) ==...
[ "def", "sign", "(", "self", ",", "authenticator", ")", ":", "self", ".", "authid", "=", "authenticator", ".", "authid", "self", ".", "signature", "=", "b\"\\0\"", "*", "authenticator", ".", "authlen", "# provide authlen", "self", ".", "signature", "=", "auth...
Sign this OMAPI message. @type authenticator: OmapiAuthenticatorBase
[ "Sign", "this", "OMAPI", "message", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L462-L469
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.verify
def verify(self, authenticators): """Verify this OMAPI message. >>> a1 = OmapiHMACMD5Authenticator(b"egg", b"spam") >>> a2 = OmapiHMACMD5Authenticator(b"egg", b"tomatoes") >>> a1.authid = a2.authid = 5 >>> m = OmapiMessage.open(b"host") >>> m.verify({a1.authid: a1}) False >>> m.sign(a1) >>> m.verify(...
python
def verify(self, authenticators): """Verify this OMAPI message. >>> a1 = OmapiHMACMD5Authenticator(b"egg", b"spam") >>> a2 = OmapiHMACMD5Authenticator(b"egg", b"tomatoes") >>> a1.authid = a2.authid = 5 >>> m = OmapiMessage.open(b"host") >>> m.verify({a1.authid: a1}) False >>> m.sign(a1) >>> m.verify(...
[ "def", "verify", "(", "self", ",", "authenticators", ")", ":", "try", ":", "return", "authenticators", "[", "self", ".", "authid", "]", ".", "sign", "(", "self", ".", "as_string", "(", "forsigning", "=", "True", ")", ")", "==", "self", ".", "signature"...
Verify this OMAPI message. >>> a1 = OmapiHMACMD5Authenticator(b"egg", b"spam") >>> a2 = OmapiHMACMD5Authenticator(b"egg", b"tomatoes") >>> a1.authid = a2.authid = 5 >>> m = OmapiMessage.open(b"host") >>> m.verify({a1.authid: a1}) False >>> m.sign(a1) >>> m.verify({a1.authid: a1}) True >>> m.sign(a2...
[ "Verify", "this", "OMAPI", "message", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L471-L493
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.open
def open(cls, typename): """Create an OMAPI open message with given typename. @type typename: bytes @rtype: OmapiMessage """ return cls(opcode=OMAPI_OP_OPEN, message=[(b"type", typename)], tid=-1)
python
def open(cls, typename): """Create an OMAPI open message with given typename. @type typename: bytes @rtype: OmapiMessage """ return cls(opcode=OMAPI_OP_OPEN, message=[(b"type", typename)], tid=-1)
[ "def", "open", "(", "cls", ",", "typename", ")", ":", "return", "cls", "(", "opcode", "=", "OMAPI_OP_OPEN", ",", "message", "=", "[", "(", "b\"type\"", ",", "typename", ")", "]", ",", "tid", "=", "-", "1", ")" ]
Create an OMAPI open message with given typename. @type typename: bytes @rtype: OmapiMessage
[ "Create", "an", "OMAPI", "open", "message", "with", "given", "typename", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L496-L501
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_net16string
def parse_net16string(self): """ >>> next(InBuffer(b"\\0\\x03eggs").parse_net16string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net16int, self.parse_fixedbuffer))
python
def parse_net16string(self): """ >>> next(InBuffer(b"\\0\\x03eggs").parse_net16string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net16int, self.parse_fixedbuffer))
[ "def", "parse_net16string", "(", "self", ")", ":", "return", "parse_map", "(", "operator", ".", "itemgetter", "(", "1", ")", ",", "parse_chain", "(", "self", ".", "parse_net16int", ",", "self", ".", "parse_fixedbuffer", ")", ")" ]
>>> next(InBuffer(b"\\0\\x03eggs").parse_net16string()) == b'egg' True
[ ">>>", "next", "(", "InBuffer", "(", "b", "\\\\", "0", "\\\\", "x03eggs", ")", ".", "parse_net16string", "()", ")", "==", "b", "egg", "True" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L645-L650
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_net32string
def parse_net32string(self): """ >>> next(InBuffer(b"\\0\\0\\0\\x03eggs").parse_net32string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net32int, self.parse_fixedbuffer))
python
def parse_net32string(self): """ >>> next(InBuffer(b"\\0\\0\\0\\x03eggs").parse_net32string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net32int, self.parse_fixedbuffer))
[ "def", "parse_net32string", "(", "self", ")", ":", "return", "parse_map", "(", "operator", ".", "itemgetter", "(", "1", ")", ",", "parse_chain", "(", "self", ".", "parse_net32int", ",", "self", ".", "parse_fixedbuffer", ")", ")" ]
>>> next(InBuffer(b"\\0\\0\\0\\x03eggs").parse_net32string()) == b'egg' True
[ ">>>", "next", "(", "InBuffer", "(", "b", "\\\\", "0", "\\\\", "0", "\\\\", "0", "\\\\", "x03eggs", ")", ".", "parse_net32string", "()", ")", "==", "b", "egg", "True" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L652-L657
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_bindict
def parse_bindict(self): """ >>> d = b"\\0\\x01a\\0\\0\\0\\x01b\\0\\0spam" >>> next(InBuffer(d).parse_bindict()) == [(b'a', b'b')] True """ entries = [] try: while True: for key in self.parse_net16string(): if key is None: yield None elif not key: raise StopIteration() el...
python
def parse_bindict(self): """ >>> d = b"\\0\\x01a\\0\\0\\0\\x01b\\0\\0spam" >>> next(InBuffer(d).parse_bindict()) == [(b'a', b'b')] True """ entries = [] try: while True: for key in self.parse_net16string(): if key is None: yield None elif not key: raise StopIteration() el...
[ "def", "parse_bindict", "(", "self", ")", ":", "entries", "=", "[", "]", "try", ":", "while", "True", ":", "for", "key", "in", "self", ".", "parse_net16string", "(", ")", ":", "if", "key", "is", "None", ":", "yield", "None", "elif", "not", "key", "...
>>> d = b"\\0\\x01a\\0\\0\\0\\x01b\\0\\0spam" >>> next(InBuffer(d).parse_bindict()) == [(b'a', b'b')] True
[ ">>>", "d", "=", "b", "\\\\", "0", "\\\\", "x01a", "\\\\", "0", "\\\\", "0", "\\\\", "0", "\\\\", "x01b", "\\\\", "0", "\\\\", "0spam", ">>>", "next", "(", "InBuffer", "(", "d", ")", ".", "parse_bindict", "()", ")", "==", "[", "(", "b", "a", "b...
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L659-L684
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_startup_message
def parse_startup_message(self): """results in an OmapiStartupMessage >>> d = b"\\0\\0\\0\\x64\\0\\0\\0\\x18" >>> next(InBuffer(d).parse_startup_message()).validate() """ return parse_map(lambda args: OmapiStartupMessage(*args), parse_chain(self.parse_net32int, lambda _: self.parse_net32int()))
python
def parse_startup_message(self): """results in an OmapiStartupMessage >>> d = b"\\0\\0\\0\\x64\\0\\0\\0\\x18" >>> next(InBuffer(d).parse_startup_message()).validate() """ return parse_map(lambda args: OmapiStartupMessage(*args), parse_chain(self.parse_net32int, lambda _: self.parse_net32int()))
[ "def", "parse_startup_message", "(", "self", ")", ":", "return", "parse_map", "(", "lambda", "args", ":", "OmapiStartupMessage", "(", "*", "args", ")", ",", "parse_chain", "(", "self", ".", "parse_net32int", ",", "lambda", "_", ":", "self", ".", "parse_net32...
results in an OmapiStartupMessage >>> d = b"\\0\\0\\0\\x64\\0\\0\\0\\x18" >>> next(InBuffer(d).parse_startup_message()).validate()
[ "results", "in", "an", "OmapiStartupMessage" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L686-L692
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_message
def parse_message(self): """results in an OmapiMessage""" parser = parse_chain(self.parse_net32int, # authid lambda *_: self.parse_net32int(), # authlen lambda *_: self.parse_net32int(), # opcode lambda *_: self.parse_net32int(), # handle lambda *_: self.parse_net32int(), # tid ...
python
def parse_message(self): """results in an OmapiMessage""" parser = parse_chain(self.parse_net32int, # authid lambda *_: self.parse_net32int(), # authlen lambda *_: self.parse_net32int(), # opcode lambda *_: self.parse_net32int(), # handle lambda *_: self.parse_net32int(), # tid ...
[ "def", "parse_message", "(", "self", ")", ":", "parser", "=", "parse_chain", "(", "self", ".", "parse_net32int", ",", "# authid", "lambda", "*", "_", ":", "self", ".", "parse_net32int", "(", ")", ",", "# authlen", "lambda", "*", "_", ":", "self", ".", ...
results in an OmapiMessage
[ "results", "in", "an", "OmapiMessage" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L694-L706
CygnusNetworks/pypureomapi
pypureomapi.py
TCPClientTransport.fill_inbuffer
def fill_inbuffer(self): """Read bytes from the connection and hand them to the protocol. @raises OmapiError: @raises socket.error: """ if not self.connection: raise OmapiError("not connected") try: data = self.connection.recv(2048) except socket.error: self.close() raise if not data: sel...
python
def fill_inbuffer(self): """Read bytes from the connection and hand them to the protocol. @raises OmapiError: @raises socket.error: """ if not self.connection: raise OmapiError("not connected") try: data = self.connection.recv(2048) except socket.error: self.close() raise if not data: sel...
[ "def", "fill_inbuffer", "(", "self", ")", ":", "if", "not", "self", ".", "connection", ":", "raise", "OmapiError", "(", "\"not connected\"", ")", "try", ":", "data", "=", "self", ".", "connection", ".", "recv", "(", "2048", ")", "except", "socket", ".", ...
Read bytes from the connection and hand them to the protocol. @raises OmapiError: @raises socket.error:
[ "Read", "bytes", "from", "the", "connection", "and", "hand", "them", "to", "the", "protocol", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L849-L868
CygnusNetworks/pypureomapi
pypureomapi.py
TCPClientTransport.write
def write(self, data): """Send all of data to the connection. @type data: bytes @raises socket.error: """ try: self.connection.sendall(data) except socket.error: self.close() raise
python
def write(self, data): """Send all of data to the connection. @type data: bytes @raises socket.error: """ try: self.connection.sendall(data) except socket.error: self.close() raise
[ "def", "write", "(", "self", ",", "data", ")", ":", "try", ":", "self", ".", "connection", ".", "sendall", "(", "data", ")", "except", "socket", ".", "error", ":", "self", ".", "close", "(", ")", "raise" ]
Send all of data to the connection. @type data: bytes @raises socket.error:
[ "Send", "all", "of", "data", "to", "the", "connection", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L870-L880
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiProtocol.send_message
def send_message(self, message, sign=True): """Send the given message to the connection. @type message: OmapiMessage @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ if sign: message.sign(self.authenticators[self.defauth]) logger.debug("sending %s", L...
python
def send_message(self, message, sign=True): """Send the given message to the connection. @type message: OmapiMessage @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ if sign: message.sign(self.authenticators[self.defauth]) logger.debug("sending %s", L...
[ "def", "send_message", "(", "self", ",", "message", ",", "sign", "=", "True", ")", ":", "if", "sign", ":", "message", ".", "sign", "(", "self", ".", "authenticators", "[", "self", ".", "defauth", "]", ")", "logger", ".", "debug", "(", "\"sending %s\"",...
Send the given message to the connection. @type message: OmapiMessage @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error:
[ "Send", "the", "given", "message", "to", "the", "connection", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L937-L948
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.receive_message
def receive_message(self): """Read the next message from the connection. @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ while not self.recv_message_queue: self.transport.fill_inbuffer() message = self.recv_message_queue.pop(0) assert message is not None if not message.verify(sel...
python
def receive_message(self): """Read the next message from the connection. @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ while not self.recv_message_queue: self.transport.fill_inbuffer() message = self.recv_message_queue.pop(0) assert message is not None if not message.verify(sel...
[ "def", "receive_message", "(", "self", ")", ":", "while", "not", "self", ".", "recv_message_queue", ":", "self", ".", "transport", ".", "fill_inbuffer", "(", ")", "message", "=", "self", ".", "recv_message_queue", ".", "pop", "(", "0", ")", "assert", "mess...
Read the next message from the connection. @rtype: OmapiMessage @raises OmapiError: @raises socket.error:
[ "Read", "the", "next", "message", "from", "the", "connection", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1005-L1018
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.receive_response
def receive_response(self, message, insecure=False): """Read the response for the given message. @type message: OmapiMessage @type insecure: bool @param insecure: avoid an OmapiError about a wrong authenticator @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ response = self.receive_...
python
def receive_response(self, message, insecure=False): """Read the response for the given message. @type message: OmapiMessage @type insecure: bool @param insecure: avoid an OmapiError about a wrong authenticator @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ response = self.receive_...
[ "def", "receive_response", "(", "self", ",", "message", ",", "insecure", "=", "False", ")", ":", "response", "=", "self", ".", "receive_message", "(", ")", "if", "not", "response", ".", "is_response", "(", "message", ")", ":", "raise", "OmapiError", "(", ...
Read the response for the given message. @type message: OmapiMessage @type insecure: bool @param insecure: avoid an OmapiError about a wrong authenticator @rtype: OmapiMessage @raises OmapiError: @raises socket.error:
[ "Read", "the", "response", "for", "the", "given", "message", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1020-L1035
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.send_message
def send_message(self, message, sign=True): """Sends the given message to the connection. @type message: OmapiMessage @type sign: bool @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ self.check_connected() self.protocol.send_message(message, sign)
python
def send_message(self, message, sign=True): """Sends the given message to the connection. @type message: OmapiMessage @type sign: bool @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ self.check_connected() self.protocol.send_message(message, sign)
[ "def", "send_message", "(", "self", ",", "message", ",", "sign", "=", "True", ")", ":", "self", ".", "check_connected", "(", ")", "self", ".", "protocol", ".", "send_message", "(", "message", ",", "sign", ")" ]
Sends the given message to the connection. @type message: OmapiMessage @type sign: bool @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error:
[ "Sends", "the", "given", "message", "to", "the", "connection", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1037-L1046
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_ip_host
def lookup_ip_host(self, mac): """Lookup a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but objects lacks a ip ...
python
def lookup_ip_host(self, mac): """Lookup a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but objects lacks a ip ...
[ "def", "lookup_ip_host", "(", "self", ",", "mac", ")", ":", "res", "=", "self", ".", "lookup_by_host", "(", "mac", "=", "mac", ")", "try", ":", "return", "res", "[", "\"ip-address\"", "]", "except", "KeyError", ":", "raise", "OmapiErrorAttributeNotFound", ...
Lookup a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but objects lacks a ip @raises socket.error:
[ "Lookup", "a", "host", "object", "with", "with", "given", "mac", "address", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1077-L1091
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_ip
def lookup_ip(self, mac): """Look for a lease object with given mac address and return the assigned ip address. @type mac: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound...
python
def lookup_ip(self, mac): """Look for a lease object with given mac address and return the assigned ip address. @type mac: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound...
[ "def", "lookup_ip", "(", "self", ",", "mac", ")", ":", "res", "=", "self", ".", "lookup_by_lease", "(", "mac", "=", "mac", ")", "try", ":", "return", "res", "[", "\"ip-address\"", "]", "except", "KeyError", ":", "raise", "OmapiErrorAttributeNotFound", "(",...
Look for a lease object with given mac address and return the assigned ip address. @type mac: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but ...
[ "Look", "for", "a", "lease", "object", "with", "given", "mac", "address", "and", "return", "the", "assigned", "ip", "address", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1093-L1109
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_mac
def lookup_mac(self, ip): """Look up a lease object with given ip address and return the associated mac address. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip could be found @raises OmapiErrorAttributeNotFound:...
python
def lookup_mac(self, ip): """Look up a lease object with given ip address and return the associated mac address. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip could be found @raises OmapiErrorAttributeNotFound:...
[ "def", "lookup_mac", "(", "self", ",", "ip", ")", ":", "res", "=", "self", ".", "lookup_by_lease", "(", "ip", "=", "ip", ")", "try", ":", "return", "res", "[", "\"hardware-address\"", "]", "except", "KeyError", ":", "raise", "OmapiErrorAttributeNotFound", ...
Look up a lease object with given ip address and return the associated mac address. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but o...
[ "Look", "up", "a", "lease", "object", "with", "given", "ip", "address", "and", "return", "the", "associated", "mac", "address", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1111-L1127
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_host
def lookup_host(self, name): """Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFou...
python
def lookup_host(self, name): """Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFou...
[ "def", "lookup_host", "(", "self", ",", "name", ")", ":", "res", "=", "self", ".", "lookup_by_host", "(", "name", "=", "name", ")", "try", ":", "return", "dict", "(", "ip", "=", "res", "[", "\"ip-address\"", "]", ",", "mac", "=", "res", "[", "\"har...
Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but o...
[ "Look", "for", "a", "host", "object", "with", "given", "name", "and", "return", "the", "name", "mac", "and", "ip", "address" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1129-L1145
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_host_host
def lookup_host_host(self, mac): """Look for a host object with given mac address and return the name, mac, and ip address @type mac: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given mac address could be found @raises OmapiErr...
python
def lookup_host_host(self, mac): """Look for a host object with given mac address and return the name, mac, and ip address @type mac: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given mac address could be found @raises OmapiErr...
[ "def", "lookup_host_host", "(", "self", ",", "mac", ")", ":", "res", "=", "self", ".", "lookup_by_host", "(", "mac", "=", "mac", ")", "try", ":", "return", "dict", "(", "ip", "=", "res", "[", "\"ip-address\"", "]", ",", "mac", "=", "res", "[", "\"h...
Look for a host object with given mac address and return the name, mac, and ip address @type mac: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given mac address could be found @raises OmapiErrorAttributeNotFound: if lease could be...
[ "Look", "for", "a", "host", "object", "with", "given", "mac", "address", "and", "return", "the", "name", "mac", "and", "ip", "address" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1147-L1163
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_hostname
def lookup_hostname(self, ip): """Look up a lease object with given ip address and return the associated client hostname. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip address could be found @raises OmapiErrorAtt...
python
def lookup_hostname(self, ip): """Look up a lease object with given ip address and return the associated client hostname. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip address could be found @raises OmapiErrorAtt...
[ "def", "lookup_hostname", "(", "self", ",", "ip", ")", ":", "res", "=", "self", ".", "lookup_by_lease", "(", "ip", "=", "ip", ")", "if", "\"client-hostname\"", "not", "in", "res", ":", "raise", "OmapiErrorAttributeNotFound", "(", ")", "return", "res", "[",...
Look up a lease object with given ip address and return the associated client hostname. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip address could be found @raises OmapiErrorAttributeNotFound: if lease could be fo...
[ "Look", "up", "a", "lease", "object", "with", "given", "ip", "address", "and", "return", "the", "associated", "client", "hostname", "." ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1165-L1179
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.__lookup
def __lookup(self, ltype, **kwargs): """Generic Lookup function @type ltype: str @type rvalues: list @type ip: str @type mac: str @type name: str @rtype: dict or str (if len(rvalues) == 1) or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given n...
python
def __lookup(self, ltype, **kwargs): """Generic Lookup function @type ltype: str @type rvalues: list @type ip: str @type mac: str @type name: str @rtype: dict or str (if len(rvalues) == 1) or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given n...
[ "def", "__lookup", "(", "self", ",", "ltype", ",", "*", "*", "kwargs", ")", ":", "ltype_utf", "=", "ltype", ".", "encode", "(", "\"utf-8\"", ")", "assert", "ltype_utf", "in", "[", "b\"host\"", ",", "b\"lease\"", "]", "msg", "=", "OmapiMessage", ".", "o...
Generic Lookup function @type ltype: str @type rvalues: list @type ip: str @type mac: str @type name: str @rtype: dict or str (if len(rvalues) == 1) or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found or the object lacks...
[ "Generic", "Lookup", "function" ]
train
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1187-L1238