partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
ZipExtFile.read
Read and return up to n bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached..
ofs/local/zipfile.py
def read(self, n=-1): """Read and return up to n bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached.. """ buf = b'' while n < 0 or n is None or n > len(buf): data = self.read1(n) if len(data) == 0: ...
def read(self, n=-1): """Read and return up to n bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached.. """ buf = b'' while n < 0 or n is None or n > len(buf): data = self.read1(n) if len(data) == 0: ...
[ "Read", "and", "return", "up", "to", "n", "bytes", ".", "If", "the", "argument", "is", "omitted", "None", "or", "negative", "data", "is", "read", "and", "returned", "until", "EOF", "is", "reached", ".." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipfile.py#L563-L576
[ "def", "read", "(", "self", ",", "n", "=", "-", "1", ")", ":", "buf", "=", "b''", "while", "n", "<", "0", "or", "n", "is", "None", "or", "n", ">", "len", "(", "buf", ")", ":", "data", "=", "self", ".", "read1", "(", "n", ")", "if", "len",...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZipFile._RealGetContents
Read in the table of contents for the ZIP file.
ofs/local/zipfile.py
def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp endrec = _EndRecData(fp) if not endrec: raise BadZipfile("File is not a zip file") if self.debug > 1: print(endrec) size_cd = endrec[_ECD_SIZE] ...
def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp endrec = _EndRecData(fp) if not endrec: raise BadZipfile("File is not a zip file") if self.debug > 1: print(endrec) size_cd = endrec[_ECD_SIZE] ...
[ "Read", "in", "the", "table", "of", "contents", "for", "the", "ZIP", "file", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipfile.py#L724-L785
[ "def", "_RealGetContents", "(", "self", ")", ":", "fp", "=", "self", ".", "fp", "endrec", "=", "_EndRecData", "(", "fp", ")", "if", "not", "endrec", ":", "raise", "BadZipfile", "(", "\"File is not a zip file\"", ")", "if", "self", ".", "debug", ">", "1",...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZipFile.open
Return file-like object for 'name'.
ofs/local/zipfile.py
def open(self, name, mode="r", pwd=None): """Return file-like object for 'name'.""" if mode not in ("r", "U", "rU"): raise RuntimeError('open() requires mode "r", "U", or "rU"') if not self.fp: raise RuntimeError( "Attempt to read ZIP archive that was alre...
def open(self, name, mode="r", pwd=None): """Return file-like object for 'name'.""" if mode not in ("r", "U", "rU"): raise RuntimeError('open() requires mode "r", "U", or "rU"') if not self.fp: raise RuntimeError( "Attempt to read ZIP archive that was alre...
[ "Return", "file", "-", "like", "object", "for", "name", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipfile.py#L837-L906
[ "def", "open", "(", "self", ",", "name", ",", "mode", "=", "\"r\"", ",", "pwd", "=", "None", ")", ":", "if", "mode", "not", "in", "(", "\"r\"", ",", "\"U\"", ",", "\"rU\"", ")", ":", "raise", "RuntimeError", "(", "'open() requires mode \"r\", \"U\", or \...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZipFile.remove
Remove a member from the archive.
ofs/local/zipfile.py
def remove(self, member): """Remove a member from the archive.""" # Make sure we have an info object if isinstance(member, ZipInfo): # 'member' is already an info object zinfo = member else: # Get info object for name zinfo = self.getinfo(m...
def remove(self, member): """Remove a member from the archive.""" # Make sure we have an info object if isinstance(member, ZipInfo): # 'member' is already an info object zinfo = member else: # Get info object for name zinfo = self.getinfo(m...
[ "Remove", "a", "member", "from", "the", "archive", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipfile.py#L1118-L1146
[ "def", "remove", "(", "self", ",", "member", ")", ":", "# Make sure we have an info object", "if", "isinstance", "(", "member", ",", "ZipInfo", ")", ":", "# 'member' is already an info object", "zinfo", "=", "member", "else", ":", "# Get info object for name", "zinfo"...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
PyZipFile._get_codename
Return (filename, archivename) for the path. Given a module name path, return the correct file path and archive name, compiling if necessary. For example, given /python/lib/string, return (/python/lib/string.pyc, string).
ofs/local/zipfile.py
def _get_codename(self, pathname, basename): """Return (filename, archivename) for the path. Given a module name path, return the correct file path and archive name, compiling if necessary. For example, given /python/lib/string, return (/python/lib/string.pyc, string). """ ...
def _get_codename(self, pathname, basename): """Return (filename, archivename) for the path. Given a module name path, return the correct file path and archive name, compiling if necessary. For example, given /python/lib/string, return (/python/lib/string.pyc, string). """ ...
[ "Return", "(", "filename", "archivename", ")", "for", "the", "path", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipfile.py#L1334-L1362
[ "def", "_get_codename", "(", "self", ",", "pathname", ",", "basename", ")", ":", "file_py", "=", "pathname", "+", "\".py\"", "file_pyc", "=", "pathname", "+", "\".pyc\"", "file_pyo", "=", "pathname", "+", "\".pyo\"", "if", "os", ".", "path", ".", "isfile",...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
import_class
Imports the class for the given class name.
batch_requests/settings.py
def import_class(class_path): ''' Imports the class for the given class name. ''' module_name, class_name = class_path.rsplit(".", 1) module = import_module(module_name) claz = getattr(module, class_name) return claz
def import_class(class_path): ''' Imports the class for the given class name. ''' module_name, class_name = class_path.rsplit(".", 1) module = import_module(module_name) claz = getattr(module, class_name) return claz
[ "Imports", "the", "class", "for", "the", "given", "class", "name", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/settings.py#L27-L34
[ "def", "import_class", "(", "class_path", ")", ":", "module_name", ",", "class_name", "=", "class_path", ".", "rsplit", "(", "\".\"", ",", "1", ")", "module", "=", "import_module", "(", "module_name", ")", "claz", "=", "getattr", "(", "module", ",", "class...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
BatchRequestSettings._executor
Creating an ExecutorPool is a costly operation. Executor needs to be instantiated only once.
batch_requests/settings.py
def _executor(self): ''' Creating an ExecutorPool is a costly operation. Executor needs to be instantiated only once. ''' if self.EXECUTE_PARALLEL is False: executor_path = "batch_requests.concurrent.executor.SequentialExecutor" executor_class = import_class(e...
def _executor(self): ''' Creating an ExecutorPool is a costly operation. Executor needs to be instantiated only once. ''' if self.EXECUTE_PARALLEL is False: executor_path = "batch_requests.concurrent.executor.SequentialExecutor" executor_class = import_class(e...
[ "Creating", "an", "ExecutorPool", "is", "a", "costly", "operation", ".", "Executor", "needs", "to", "be", "instantiated", "only", "once", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/settings.py#L48-L59
[ "def", "_executor", "(", "self", ")", ":", "if", "self", ".", "EXECUTE_PARALLEL", "is", "False", ":", "executor_path", "=", "\"batch_requests.concurrent.executor.SequentialExecutor\"", "executor_class", "=", "import_class", "(", "executor_path", ")", "return", "executor...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
OFS.make_label
this borrows too much from the internals of ofs maybe expose different parts of the api?
ofs/command.py
def make_label(self, path): """ this borrows too much from the internals of ofs maybe expose different parts of the api? """ from datetime import datetime from StringIO import StringIO path = path.lstrip("/") bucket, label = path.split("/", 1) buc...
def make_label(self, path): """ this borrows too much from the internals of ofs maybe expose different parts of the api? """ from datetime import datetime from StringIO import StringIO path = path.lstrip("/") bucket, label = path.split("/", 1) buc...
[ "this", "borrows", "too", "much", "from", "the", "internals", "of", "ofs", "maybe", "expose", "different", "parts", "of", "the", "api?" ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/command.py#L57-L73
[ "def", "make_label", "(", "self", ",", "path", ")", ":", "from", "datetime", "import", "datetime", "from", "StringIO", "import", "StringIO", "path", "=", "path", ".", "lstrip", "(", "\"/\"", ")", "bucket", ",", "label", "=", "path", ".", "split", "(", ...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
OFS.get_proxy_config
stub. this really needs to be a call to the remote restful interface to get the appropriate host and headers to use for this upload
ofs/command.py
def get_proxy_config(self, headers, path): """ stub. this really needs to be a call to the remote restful interface to get the appropriate host and headers to use for this upload """ self.ofs.conn.add_aws_auth_header(headers, 'PUT', path) from pprint import pprint...
def get_proxy_config(self, headers, path): """ stub. this really needs to be a call to the remote restful interface to get the appropriate host and headers to use for this upload """ self.ofs.conn.add_aws_auth_header(headers, 'PUT', path) from pprint import pprint...
[ "stub", ".", "this", "really", "needs", "to", "be", "a", "call", "to", "the", "remote", "restful", "interface", "to", "get", "the", "appropriate", "host", "and", "headers", "to", "use", "for", "this", "upload" ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/command.py#L75-L85
[ "def", "get_proxy_config", "(", "self", ",", "headers", ",", "path", ")", ":", "self", ".", "ofs", ".", "conn", ".", "add_aws_auth_header", "(", "headers", ",", "'PUT'", ",", "path", ")", "from", "pprint", "import", "pprint", "pprint", "(", "headers", ")...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
OFS.proxy_upload
This is the main function that uploads. We assume the bucket and key (== path) exists. What we do here is simple. Calculate the headers we will need, (e.g. md5, content-type, etc). Then we ask the self.get_proxy_config method to fill in the authentication information and tell us which re...
ofs/command.py
def proxy_upload(self, path, filename, content_type=None, content_encoding=None, cb=None, num_cb=None): """ This is the main function that uploads. We assume the bucket and key (== path) exists. What we do here is simple. Calculate the headers we will need, (e.g. md5...
def proxy_upload(self, path, filename, content_type=None, content_encoding=None, cb=None, num_cb=None): """ This is the main function that uploads. We assume the bucket and key (== path) exists. What we do here is simple. Calculate the headers we will need, (e.g. md5...
[ "This", "is", "the", "main", "function", "that", "uploads", ".", "We", "assume", "the", "bucket", "and", "key", "(", "==", "path", ")", "exists", ".", "What", "we", "do", "here", "is", "simple", ".", "Calculate", "the", "headers", "we", "will", "need",...
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/command.py#L87-L187
[ "def", "proxy_upload", "(", "self", ",", "path", ",", "filename", ",", "content_type", "=", "None", ",", "content_encoding", "=", "None", ",", "cb", "=", "None", ",", "num_cb", "=", "None", ")", ":", "from", "boto", ".", "connection", "import", "AWSAuthC...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
KKBOXMoodStationFetcher.fetch_all_mood_stations
Fetches all mood stations. :param terr: the current territory. :return: API response. :rtype: dict See `https://docs-en.kkbox.codes/v1.1/reference#moodstations`.
kkbox_developer_sdk/mood_station_fetcher.py
def fetch_all_mood_stations(self, terr=KKBOXTerritory.TAIWAN): ''' Fetches all mood stations. :param terr: the current territory. :return: API response. :rtype: dict See `https://docs-en.kkbox.codes/v1.1/reference#moodstations`. ''' url = 'https://api.kk...
def fetch_all_mood_stations(self, terr=KKBOXTerritory.TAIWAN): ''' Fetches all mood stations. :param terr: the current territory. :return: API response. :rtype: dict See `https://docs-en.kkbox.codes/v1.1/reference#moodstations`. ''' url = 'https://api.kk...
[ "Fetches", "all", "mood", "stations", "." ]
KKBOX/OpenAPI-Python
python
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/mood_station_fetcher.py#L13-L25
[ "def", "fetch_all_mood_stations", "(", "self", ",", "terr", "=", "KKBOXTerritory", ".", "TAIWAN", ")", ":", "url", "=", "'https://api.kkbox.com/v1.1/mood-stations'", "url", "+=", "'?'", "+", "url_parse", ".", "urlencode", "(", "{", "'territory'", ":", "terr", "}...
77aa22fd300ed987d5507a5b66b149edcd28047d
train
KKBOXMoodStationFetcher.fetch_mood_station
Fetches a mood station by given ID. :param station_id: the station ID :param terr: the current territory. :return: API response. :rtype: dict See `https://docs-en.kkbox.codes/v1.1/reference#moodstations-station_id`.
kkbox_developer_sdk/mood_station_fetcher.py
def fetch_mood_station(self, station_id, terr=KKBOXTerritory.TAIWAN): ''' Fetches a mood station by given ID. :param station_id: the station ID :param terr: the current territory. :return: API response. :rtype: dict See `https://docs-en.kkbox.codes/v1.1/referenc...
def fetch_mood_station(self, station_id, terr=KKBOXTerritory.TAIWAN): ''' Fetches a mood station by given ID. :param station_id: the station ID :param terr: the current territory. :return: API response. :rtype: dict See `https://docs-en.kkbox.codes/v1.1/referenc...
[ "Fetches", "a", "mood", "station", "by", "given", "ID", "." ]
KKBOX/OpenAPI-Python
python
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/mood_station_fetcher.py#L28-L41
[ "def", "fetch_mood_station", "(", "self", ",", "station_id", ",", "terr", "=", "KKBOXTerritory", ".", "TAIWAN", ")", ":", "url", "=", "'https://api.kkbox.com/v1.1/mood-stations/%s'", "%", "station_id", "url", "+=", "'?'", "+", "url_parse", ".", "urlencode", "(", ...
77aa22fd300ed987d5507a5b66b149edcd28047d
train
Fetcher.fetch_next_page
Fetches next page based on previously fetched data. Will get the next page url from data['paging']['next']. :param data: previously fetched API response. :type data: dict :return: API response. :rtype: dict
kkbox_developer_sdk/fetcher.py
def fetch_next_page(self, data): ''' Fetches next page based on previously fetched data. Will get the next page url from data['paging']['next']. :param data: previously fetched API response. :type data: dict :return: API response. :rtype: dict '''...
def fetch_next_page(self, data): ''' Fetches next page based on previously fetched data. Will get the next page url from data['paging']['next']. :param data: previously fetched API response. :type data: dict :return: API response. :rtype: dict '''...
[ "Fetches", "next", "page", "based", "on", "previously", "fetched", "data", ".", "Will", "get", "the", "next", "page", "url", "from", "data", "[", "paging", "]", "[", "next", "]", "." ]
KKBOX/OpenAPI-Python
python
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/fetcher.py#L29-L44
[ "def", "fetch_next_page", "(", "self", ",", "data", ")", ":", "next_url", "=", "data", "[", "'paging'", "]", "[", "'next'", "]", "if", "next_url", "!=", "None", ":", "next_data", "=", "self", ".", "http", ".", "_post_data", "(", "next_url", ",", "None"...
77aa22fd300ed987d5507a5b66b149edcd28047d
train
Fetcher.fetch_data
Fetches data from specific url. :return: The response. :rtype: dict
kkbox_developer_sdk/fetcher.py
def fetch_data(self, url): ''' Fetches data from specific url. :return: The response. :rtype: dict ''' return self.http._post_data(url, None, self.http._headers_with_access_token())
def fetch_data(self, url): ''' Fetches data from specific url. :return: The response. :rtype: dict ''' return self.http._post_data(url, None, self.http._headers_with_access_token())
[ "Fetches", "data", "from", "specific", "url", "." ]
KKBOX/OpenAPI-Python
python
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/fetcher.py#L46-L53
[ "def", "fetch_data", "(", "self", ",", "url", ")", ":", "return", "self", ".", "http", ".", "_post_data", "(", "url", ",", "None", ",", "self", ".", "http", ".", "_headers_with_access_token", "(", ")", ")" ]
77aa22fd300ed987d5507a5b66b149edcd28047d
train
KKBOXSharedPlaylistFetcher.fetch_shared_playlist
Fetches a shared playlist by given ID. :param playlist_id: the playlist ID. :type playlist_id: str :param terr: the current territory. :return: API response. :rtype: dictcd See `https://docs-en.kkbox.codes/v1.1/reference#sharedplaylists-playlist_id`.
kkbox_developer_sdk/shared_playlist_fetcher.py
def fetch_shared_playlist(self, playlist_id, terr=KKBOXTerritory.TAIWAN): ''' Fetches a shared playlist by given ID. :param playlist_id: the playlist ID. :type playlist_id: str :param terr: the current territory. :return: API response. :rtype: dictcd See...
def fetch_shared_playlist(self, playlist_id, terr=KKBOXTerritory.TAIWAN): ''' Fetches a shared playlist by given ID. :param playlist_id: the playlist ID. :type playlist_id: str :param terr: the current territory. :return: API response. :rtype: dictcd See...
[ "Fetches", "a", "shared", "playlist", "by", "given", "ID", "." ]
KKBOX/OpenAPI-Python
python
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/shared_playlist_fetcher.py#L13-L27
[ "def", "fetch_shared_playlist", "(", "self", ",", "playlist_id", ",", "terr", "=", "KKBOXTerritory", ".", "TAIWAN", ")", ":", "url", "=", "'https://api.kkbox.com/v1.1/shared-playlists/%s'", "%", "playlist_id", "url", "+=", "'?'", "+", "url_parse", ".", "urlencode", ...
77aa22fd300ed987d5507a5b66b149edcd28047d
train
FirewallManager.get_firewall_rule
Return a FirewallRule object based on server uuid and rule position.
upcloud_api/cloud_manager/firewall_mixin.py
def get_firewall_rule(self, server_uuid, firewall_rule_position, server_instance=None): """ Return a FirewallRule object based on server uuid and rule position. """ url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position) res = self.get_request(url) ...
def get_firewall_rule(self, server_uuid, firewall_rule_position, server_instance=None): """ Return a FirewallRule object based on server uuid and rule position. """ url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position) res = self.get_request(url) ...
[ "Return", "a", "FirewallRule", "object", "based", "on", "server", "uuid", "and", "rule", "position", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/firewall_mixin.py#L20-L26
[ "def", "get_firewall_rule", "(", "self", ",", "server_uuid", ",", "firewall_rule_position", ",", "server_instance", "=", "None", ")", ":", "url", "=", "'/server/{0}/firewall_rule/{1}'", ".", "format", "(", "server_uuid", ",", "firewall_rule_position", ")", "res", "=...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
FirewallManager.get_firewall_rules
Return all FirewallRule objects based on a server instance or uuid.
upcloud_api/cloud_manager/firewall_mixin.py
def get_firewall_rules(self, server): """ Return all FirewallRule objects based on a server instance or uuid. """ server_uuid, server_instance = uuid_and_instance(server) url = '/server/{0}/firewall_rule'.format(server_uuid) res = self.get_request(url) return [ ...
def get_firewall_rules(self, server): """ Return all FirewallRule objects based on a server instance or uuid. """ server_uuid, server_instance = uuid_and_instance(server) url = '/server/{0}/firewall_rule'.format(server_uuid) res = self.get_request(url) return [ ...
[ "Return", "all", "FirewallRule", "objects", "based", "on", "a", "server", "instance", "or", "uuid", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/firewall_mixin.py#L28-L40
[ "def", "get_firewall_rules", "(", "self", ",", "server", ")", ":", "server_uuid", ",", "server_instance", "=", "uuid_and_instance", "(", "server", ")", "url", "=", "'/server/{0}/firewall_rule'", ".", "format", "(", "server_uuid", ")", "res", "=", "self", ".", ...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
FirewallManager.create_firewall_rule
Create a new firewall rule for a given server uuid. The rule can begiven as a dict or with FirewallRule.prepare_post_body(). Returns a FirewallRule object.
upcloud_api/cloud_manager/firewall_mixin.py
def create_firewall_rule(self, server, firewall_rule_body): """ Create a new firewall rule for a given server uuid. The rule can begiven as a dict or with FirewallRule.prepare_post_body(). Returns a FirewallRule object. """ server_uuid, server_instance = uuid_and_instanc...
def create_firewall_rule(self, server, firewall_rule_body): """ Create a new firewall rule for a given server uuid. The rule can begiven as a dict or with FirewallRule.prepare_post_body(). Returns a FirewallRule object. """ server_uuid, server_instance = uuid_and_instanc...
[ "Create", "a", "new", "firewall", "rule", "for", "a", "given", "server", "uuid", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/firewall_mixin.py#L42-L55
[ "def", "create_firewall_rule", "(", "self", ",", "server", ",", "firewall_rule_body", ")", ":", "server_uuid", ",", "server_instance", "=", "uuid_and_instance", "(", "server", ")", "url", "=", "'/server/{0}/firewall_rule'", ".", "format", "(", "server_uuid", ")", ...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
FirewallManager.delete_firewall_rule
Delete a firewall rule based on a server uuid and rule position.
upcloud_api/cloud_manager/firewall_mixin.py
def delete_firewall_rule(self, server_uuid, firewall_rule_position): """ Delete a firewall rule based on a server uuid and rule position. """ url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position) return self.request('DELETE', url)
def delete_firewall_rule(self, server_uuid, firewall_rule_position): """ Delete a firewall rule based on a server uuid and rule position. """ url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position) return self.request('DELETE', url)
[ "Delete", "a", "firewall", "rule", "based", "on", "a", "server", "uuid", "and", "rule", "position", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/firewall_mixin.py#L57-L62
[ "def", "delete_firewall_rule", "(", "self", ",", "server_uuid", ",", "firewall_rule_position", ")", ":", "url", "=", "'/server/{0}/firewall_rule/{1}'", ".", "format", "(", "server_uuid", ",", "firewall_rule_position", ")", "return", "self", ".", "request", "(", "'DE...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
FirewallManager.configure_firewall
Helper for calling create_firewall_rule in series for a list of firewall_rule_bodies.
upcloud_api/cloud_manager/firewall_mixin.py
def configure_firewall(self, server, firewall_rule_bodies): """ Helper for calling create_firewall_rule in series for a list of firewall_rule_bodies. """ server_uuid, server_instance = uuid_and_instance(server) return [ self.create_firewall_rule(server_uuid, rule) ...
def configure_firewall(self, server, firewall_rule_bodies): """ Helper for calling create_firewall_rule in series for a list of firewall_rule_bodies. """ server_uuid, server_instance = uuid_and_instance(server) return [ self.create_firewall_rule(server_uuid, rule) ...
[ "Helper", "for", "calling", "create_firewall_rule", "in", "series", "for", "a", "list", "of", "firewall_rule_bodies", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/firewall_mixin.py#L64-L73
[ "def", "configure_firewall", "(", "self", ",", "server", ",", "firewall_rule_bodies", ")", ":", "server_uuid", ",", "server_instance", "=", "uuid_and_instance", "(", "server", ")", "return", "[", "self", ".", "create_firewall_rule", "(", "server_uuid", ",", "rule"...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
Sinkhole.post
POSTs a raw SMTP message to the Sinkhole API :param data: raw content to be submitted [STRING] :return: { list of predictions }
csirtgsdk/sinkhole.py
def post(self, data): """ POSTs a raw SMTP message to the Sinkhole API :param data: raw content to be submitted [STRING] :return: { list of predictions } """ uri = '{}/sinkhole'.format(self.client.remote) self.logger.debug(uri) if PYVERSION == 2: ...
def post(self, data): """ POSTs a raw SMTP message to the Sinkhole API :param data: raw content to be submitted [STRING] :return: { list of predictions } """ uri = '{}/sinkhole'.format(self.client.remote) self.logger.debug(uri) if PYVERSION == 2: ...
[ "POSTs", "a", "raw", "SMTP", "message", "to", "the", "Sinkhole", "API" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/sinkhole.py#L20-L41
[ "def", "post", "(", "self", ",", "data", ")", ":", "uri", "=", "'{}/sinkhole'", ".", "format", "(", "self", ".", "client", ".", "remote", ")", "self", ".", "logger", ".", "debug", "(", "uri", ")", "if", "PYVERSION", "==", "2", ":", "try", ":", "d...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
pre_process_method_headers
Returns the lowered method. Capitalize headers, prepend HTTP_ and change - to _.
batch_requests/utils.py
def pre_process_method_headers(method, headers): ''' Returns the lowered method. Capitalize headers, prepend HTTP_ and change - to _. ''' method = method.lower() # Standard WSGI supported headers _wsgi_headers = ["content_length", "content_type", "query_string", ...
def pre_process_method_headers(method, headers): ''' Returns the lowered method. Capitalize headers, prepend HTTP_ and change - to _. ''' method = method.lower() # Standard WSGI supported headers _wsgi_headers = ["content_length", "content_type", "query_string", ...
[ "Returns", "the", "lowered", "method", ".", "Capitalize", "headers", "prepend", "HTTP_", "and", "change", "-", "to", "_", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/utils.py#L47-L70
[ "def", "pre_process_method_headers", "(", "method", ",", "headers", ")", ":", "method", "=", "method", ".", "lower", "(", ")", "# Standard WSGI supported headers", "_wsgi_headers", "=", "[", "\"content_length\"", ",", "\"content_type\"", ",", "\"query_string\"", ",", ...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
headers_to_include_from_request
Define headers that needs to be included from the current request.
batch_requests/utils.py
def headers_to_include_from_request(curr_request): ''' Define headers that needs to be included from the current request. ''' return { h: v for h, v in curr_request.META.items() if h in _settings.HEADERS_TO_INCLUDE}
def headers_to_include_from_request(curr_request): ''' Define headers that needs to be included from the current request. ''' return { h: v for h, v in curr_request.META.items() if h in _settings.HEADERS_TO_INCLUDE}
[ "Define", "headers", "that", "needs", "to", "be", "included", "from", "the", "current", "request", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/utils.py#L73-L78
[ "def", "headers_to_include_from_request", "(", "curr_request", ")", ":", "return", "{", "h", ":", "v", "for", "h", ",", "v", "in", "curr_request", ".", "META", ".", "items", "(", ")", "if", "h", "in", "_settings", ".", "HEADERS_TO_INCLUDE", "}" ]
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
get_wsgi_request_object
Based on the given request parameters, constructs and returns the WSGI request object.
batch_requests/utils.py
def get_wsgi_request_object(curr_request, method, url, headers, body): ''' Based on the given request parameters, constructs and returns the WSGI request object. ''' x_headers = headers_to_include_from_request(curr_request) method, t_headers = pre_process_method_headers(method, headers) # A...
def get_wsgi_request_object(curr_request, method, url, headers, body): ''' Based on the given request parameters, constructs and returns the WSGI request object. ''' x_headers = headers_to_include_from_request(curr_request) method, t_headers = pre_process_method_headers(method, headers) # A...
[ "Based", "on", "the", "given", "request", "parameters", "constructs", "and", "returns", "the", "WSGI", "request", "object", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/utils.py#L81-L106
[ "def", "get_wsgi_request_object", "(", "curr_request", ",", "method", ",", "url", ",", "headers", ",", "body", ")", ":", "x_headers", "=", "headers_to_include_from_request", "(", "curr_request", ")", "method", ",", "t_headers", "=", "pre_process_method_headers", "("...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
BatchRequestFactory._base_environ
Override the default values for the wsgi environment variables.
batch_requests/utils.py
def _base_environ(self, **request): ''' Override the default values for the wsgi environment variables. ''' # This is a minimal valid WSGI environ dictionary, plus: # - HTTP_COOKIE: for cookie support, # - REMOTE_ADDR: often useful, see #8551. # See http://www...
def _base_environ(self, **request): ''' Override the default values for the wsgi environment variables. ''' # This is a minimal valid WSGI environ dictionary, plus: # - HTTP_COOKIE: for cookie support, # - REMOTE_ADDR: often useful, see #8551. # See http://www...
[ "Override", "the", "default", "values", "for", "the", "wsgi", "environment", "variables", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/utils.py#L16-L44
[ "def", "_base_environ", "(", "self", ",", "*", "*", "request", ")", ":", "# This is a minimal valid WSGI environ dictionary, plus:", "# - HTTP_COOKIE: for cookie support,", "# - REMOTE_ADDR: often useful, see #8551.", "# See http://www.python.org/dev/peps/pep-3333/#environ-variables", "e...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
BaseAPI.request
Perform a request with a given body to a given endpoint in UpCloud's API. Handles errors with __error_middleware.
upcloud_api/cloud_manager/base.py
def request(self, method, endpoint, body=None, timeout=-1): """ Perform a request with a given body to a given endpoint in UpCloud's API. Handles errors with __error_middleware. """ if method not in set(['GET', 'POST', 'PUT', 'DELETE']): raise Exception('Invalid/Forb...
def request(self, method, endpoint, body=None, timeout=-1): """ Perform a request with a given body to a given endpoint in UpCloud's API. Handles errors with __error_middleware. """ if method not in set(['GET', 'POST', 'PUT', 'DELETE']): raise Exception('Invalid/Forb...
[ "Perform", "a", "request", "with", "a", "given", "body", "to", "a", "given", "endpoint", "in", "UpCloud", "s", "API", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/base.py#L21-L54
[ "def", "request", "(", "self", ",", "method", ",", "endpoint", ",", "body", "=", "None", ",", "timeout", "=", "-", "1", ")", ":", "if", "method", "not", "in", "set", "(", "[", "'GET'", ",", "'POST'", ",", "'PUT'", ",", "'DELETE'", "]", ")", ":", ...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
BaseAPI.post_request
Perform a POST request to a given endpoint in UpCloud's API.
upcloud_api/cloud_manager/base.py
def post_request(self, endpoint, body=None, timeout=-1): """ Perform a POST request to a given endpoint in UpCloud's API. """ return self.request('POST', endpoint, body, timeout)
def post_request(self, endpoint, body=None, timeout=-1): """ Perform a POST request to a given endpoint in UpCloud's API. """ return self.request('POST', endpoint, body, timeout)
[ "Perform", "a", "POST", "request", "to", "a", "given", "endpoint", "in", "UpCloud", "s", "API", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/base.py#L62-L66
[ "def", "post_request", "(", "self", ",", "endpoint", ",", "body", "=", "None", ",", "timeout", "=", "-", "1", ")", ":", "return", "self", ".", "request", "(", "'POST'", ",", "endpoint", ",", "body", ",", "timeout", ")" ]
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
BaseAPI.__error_middleware
Middleware that raises an exception when HTTP statuscode is an error code.
upcloud_api/cloud_manager/base.py
def __error_middleware(self, res, res_json): """ Middleware that raises an exception when HTTP statuscode is an error code. """ if(res.status_code in [400, 401, 402, 403, 404, 405, 406, 409]): err_dict = res_json.get('error', {}) raise UpCloudAPIError(error_code=e...
def __error_middleware(self, res, res_json): """ Middleware that raises an exception when HTTP statuscode is an error code. """ if(res.status_code in [400, 401, 402, 403, 404, 405, 406, 409]): err_dict = res_json.get('error', {}) raise UpCloudAPIError(error_code=e...
[ "Middleware", "that", "raises", "an", "exception", "when", "HTTP", "statuscode", "is", "an", "error", "code", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/base.py#L68-L77
[ "def", "__error_middleware", "(", "self", ",", "res", ",", "res_json", ")", ":", "if", "(", "res", ".", "status_code", "in", "[", "400", ",", "401", ",", "402", ",", "403", ",", "404", ",", "405", ",", "406", ",", "409", "]", ")", ":", "err_dict"...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
SwiftOFS.put_stream
Create a new file to swift object storage.
ofs/remote/swiftstore.py
def put_stream(self, bucket, label, stream_object, params={}): ''' Create a new file to swift object storage. ''' self.claim_bucket(bucket) self.connection.put_object(bucket, label, stream_object, headers=self._convert_to_meta(params))
def put_stream(self, bucket, label, stream_object, params={}): ''' Create a new file to swift object storage. ''' self.claim_bucket(bucket) self.connection.put_object(bucket, label, stream_object, headers=self._convert_to_meta(params))
[ "Create", "a", "new", "file", "to", "swift", "object", "storage", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/remote/swiftstore.py#L116-L120
[ "def", "put_stream", "(", "self", ",", "bucket", ",", "label", ",", "stream_object", ",", "params", "=", "{", "}", ")", ":", "self", ".", "claim_bucket", "(", "bucket", ")", "self", ".", "connection", ".", "put_object", "(", "bucket", ",", "label", ","...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
h
PURPOSE Compute Friedman and Popescu's H statistic, in order to look for an interaction in the passed gradient-boosting model among the variables represented by the elements of the passed array or frame and specified by the passed indices or columns. See Jerome H. Friedman and Bogdan E. Popescu, 2008,...
sklearn_gbmi/sklearn_gbmi.py
def h(gbm, array_or_frame, indices_or_columns = 'all'): """ PURPOSE Compute Friedman and Popescu's H statistic, in order to look for an interaction in the passed gradient-boosting model among the variables represented by the elements of the passed array or frame and specified by the passed indices ...
def h(gbm, array_or_frame, indices_or_columns = 'all'): """ PURPOSE Compute Friedman and Popescu's H statistic, in order to look for an interaction in the passed gradient-boosting model among the variables represented by the elements of the passed array or frame and specified by the passed indices ...
[ "PURPOSE" ]
ralphhaygood/sklearn-gbmi
python
https://github.com/ralphhaygood/sklearn-gbmi/blob/23a1e7fd50e53d6261379f22a337d8fa4ee6aabe/sklearn_gbmi/sklearn_gbmi.py#L16-L95
[ "def", "h", "(", "gbm", ",", "array_or_frame", ",", "indices_or_columns", "=", "'all'", ")", ":", "if", "indices_or_columns", "==", "'all'", ":", "if", "gbm", ".", "max_depth", "<", "array_or_frame", ".", "shape", "[", "1", "]", ":", "raise", "Exception", ...
23a1e7fd50e53d6261379f22a337d8fa4ee6aabe
train
h_all_pairs
PURPOSE Compute Friedman and Popescu's two-variable H statistic, in order to look for an interaction in the passed gradient- boosting model between each pair of variables represented by the elements of the passed array or frame and specified by the passed indices or columns. See Jerome H. Friedman and...
sklearn_gbmi/sklearn_gbmi.py
def h_all_pairs(gbm, array_or_frame, indices_or_columns = 'all'): """ PURPOSE Compute Friedman and Popescu's two-variable H statistic, in order to look for an interaction in the passed gradient- boosting model between each pair of variables represented by the elements of the passed array or frame and s...
def h_all_pairs(gbm, array_or_frame, indices_or_columns = 'all'): """ PURPOSE Compute Friedman and Popescu's two-variable H statistic, in order to look for an interaction in the passed gradient- boosting model between each pair of variables represented by the elements of the passed array or frame and s...
[ "PURPOSE" ]
ralphhaygood/sklearn-gbmi
python
https://github.com/ralphhaygood/sklearn-gbmi/blob/23a1e7fd50e53d6261379f22a337d8fa4ee6aabe/sklearn_gbmi/sklearn_gbmi.py#L98-L169
[ "def", "h_all_pairs", "(", "gbm", ",", "array_or_frame", ",", "indices_or_columns", "=", "'all'", ")", ":", "if", "gbm", ".", "max_depth", "<", "2", ":", "raise", "Exception", "(", "\"gbm.max_depth must be at least 2.\"", ")", "check_args_contd", "(", "array_or_fr...
23a1e7fd50e53d6261379f22a337d8fa4ee6aabe
train
Predict.get
Performs a search against the predict endpoint :param q: query to be searched for [STRING] :return: { score: [0|1] }
csirtgsdk/predict.py
def get(self, q, limit=None): """ Performs a search against the predict endpoint :param q: query to be searched for [STRING] :return: { score: [0|1] } """ uri = '{}/predict?q={}'.format(self.client.remote, q) self.logger.debug(uri) body = self.client.get...
def get(self, q, limit=None): """ Performs a search against the predict endpoint :param q: query to be searched for [STRING] :return: { score: [0|1] } """ uri = '{}/predict?q={}'.format(self.client.remote, q) self.logger.debug(uri) body = self.client.get...
[ "Performs", "a", "search", "against", "the", "predict", "endpoint" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/predict.py#L18-L29
[ "def", "get", "(", "self", ",", "q", ",", "limit", "=", "None", ")", ":", "uri", "=", "'{}/predict?q={}'", ".", "format", "(", "self", ".", "client", ".", "remote", ",", "q", ")", "self", ".", "logger", ".", "debug", "(", "uri", ")", "body", "=",...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
ZOFS.exists
Whether a given bucket:label object already exists.
ofs/local/zipstore.py
def exists(self, bucket, label): '''Whether a given bucket:label object already exists.''' fn = self._zf(bucket, label) try: self.z.getinfo(fn) return True except KeyError: return False
def exists(self, bucket, label): '''Whether a given bucket:label object already exists.''' fn = self._zf(bucket, label) try: self.z.getinfo(fn) return True except KeyError: return False
[ "Whether", "a", "given", "bucket", ":", "label", "object", "already", "exists", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L112-L119
[ "def", "exists", "(", "self", ",", "bucket", ",", "label", ")", ":", "fn", "=", "self", ".", "_zf", "(", "bucket", ",", "label", ")", "try", ":", "self", ".", "z", ".", "getinfo", "(", "fn", ")", "return", "True", "except", "KeyError", ":", "retu...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.list_labels
List labels for the given bucket. Due to zipfiles inherent arbitrary ordering, this is an expensive operation, as it walks the entire archive searching for individual 'buckets' :param bucket: bucket to list labels for. :return: iterator for the labels in the specified bucket.
ofs/local/zipstore.py
def list_labels(self, bucket): '''List labels for the given bucket. Due to zipfiles inherent arbitrary ordering, this is an expensive operation, as it walks the entire archive searching for individual 'buckets' :param bucket: bucket to list labels for. :return: iterator for the ...
def list_labels(self, bucket): '''List labels for the given bucket. Due to zipfiles inherent arbitrary ordering, this is an expensive operation, as it walks the entire archive searching for individual 'buckets' :param bucket: bucket to list labels for. :return: iterator for the ...
[ "List", "labels", "for", "the", "given", "bucket", ".", "Due", "to", "zipfiles", "inherent", "arbitrary", "ordering", "this", "is", "an", "expensive", "operation", "as", "it", "walks", "the", "entire", "archive", "searching", "for", "individual", "buckets" ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L131-L142
[ "def", "list_labels", "(", "self", ",", "bucket", ")", ":", "for", "name", "in", "self", ".", "z", ".", "namelist", "(", ")", ":", "container", ",", "label", "=", "self", ".", "_nf", "(", "name", ".", "encode", "(", "\"utf-8\"", ")", ")", "if", "...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.list_buckets
List all buckets managed by this OFS instance. Like list_labels, this also walks the entire archive, yielding the bucketnames. A local set is retained so that duplicates aren't returned so this will temporarily pull the entire list into memory even though this is a generator and will slow as mor...
ofs/local/zipstore.py
def list_buckets(self): '''List all buckets managed by this OFS instance. Like list_labels, this also walks the entire archive, yielding the bucketnames. A local set is retained so that duplicates aren't returned so this will temporarily pull the entire list into memory even though this ...
def list_buckets(self): '''List all buckets managed by this OFS instance. Like list_labels, this also walks the entire archive, yielding the bucketnames. A local set is retained so that duplicates aren't returned so this will temporarily pull the entire list into memory even though this ...
[ "List", "all", "buckets", "managed", "by", "this", "OFS", "instance", ".", "Like", "list_labels", "this", "also", "walks", "the", "entire", "archive", "yielding", "the", "bucketnames", ".", "A", "local", "set", "is", "retained", "so", "that", "duplicates", "...
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L144-L157
[ "def", "list_buckets", "(", "self", ")", ":", "buckets", "=", "set", "(", ")", "for", "name", "in", "self", ".", "z", ".", "namelist", "(", ")", ":", "bucket", ",", "_", "=", "self", ".", "_nf", "(", "name", ")", "if", "bucket", "not", "in", "b...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.get_stream
Get a bitstream for the given bucket:label combination. :param bucket: the bucket to use. :return: bitstream as a file-like object
ofs/local/zipstore.py
def get_stream(self, bucket, label, as_stream=True): '''Get a bitstream for the given bucket:label combination. :param bucket: the bucket to use. :return: bitstream as a file-like object ''' if self.mode == "w": raise OFSException("Cannot read from archive in 'w' mod...
def get_stream(self, bucket, label, as_stream=True): '''Get a bitstream for the given bucket:label combination. :param bucket: the bucket to use. :return: bitstream as a file-like object ''' if self.mode == "w": raise OFSException("Cannot read from archive in 'w' mod...
[ "Get", "a", "bitstream", "for", "the", "given", "bucket", ":", "label", "combination", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L159-L174
[ "def", "get_stream", "(", "self", ",", "bucket", ",", "label", ",", "as_stream", "=", "True", ")", ":", "if", "self", ".", "mode", "==", "\"w\"", ":", "raise", "OFSException", "(", "\"Cannot read from archive in 'w' mode\"", ")", "elif", "self", ".", "exists...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.get_url
Get a URL that should point at the bucket:labelled resource. Aimed to aid web apps by allowing them to redirect to an open resource, rather than proxy the bitstream. :param bucket: the bucket to use. :param label: the label of the resource to get :return: a string URI - eg 'zip:file:///home/......
ofs/local/zipstore.py
def get_url(self, bucket, label): '''Get a URL that should point at the bucket:labelled resource. Aimed to aid web apps by allowing them to redirect to an open resource, rather than proxy the bitstream. :param bucket: the bucket to use. :param label: the label of the resource to get :re...
def get_url(self, bucket, label): '''Get a URL that should point at the bucket:labelled resource. Aimed to aid web apps by allowing them to redirect to an open resource, rather than proxy the bitstream. :param bucket: the bucket to use. :param label: the label of the resource to get :re...
[ "Get", "a", "URL", "that", "should", "point", "at", "the", "bucket", ":", "labelled", "resource", ".", "Aimed", "to", "aid", "web", "apps", "by", "allowing", "them", "to", "redirect", "to", "an", "open", "resource", "rather", "than", "proxy", "the", "bit...
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L176-L188
[ "def", "get_url", "(", "self", ",", "bucket", ",", "label", ")", ":", "if", "self", ".", "exists", "(", "bucket", ",", "label", ")", ":", "root", "=", "\"zip:file//%s\"", "%", "os", ".", "path", ".", "abspath", "(", "self", ".", "zipfile", ")", "fn...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.put_stream
Put a bitstream (stream_object) for the specified bucket:label identifier. :param bucket: as standard :param label: as standard :param stream_object: file-like object to read from or bytestring. :param params: update metadata with these params (see `update_metadata`)
ofs/local/zipstore.py
def put_stream(self, bucket, label, stream_object, params=None, replace=True, add_md=True): '''Put a bitstream (stream_object) for the specified bucket:label identifier. :param bucket: as standard :param label: as standard :param stream_object: file-like object to read from or bytestrin...
def put_stream(self, bucket, label, stream_object, params=None, replace=True, add_md=True): '''Put a bitstream (stream_object) for the specified bucket:label identifier. :param bucket: as standard :param label: as standard :param stream_object: file-like object to read from or bytestrin...
[ "Put", "a", "bitstream", "(", "stream_object", ")", "for", "the", "specified", "bucket", ":", "label", "identifier", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L190-L224
[ "def", "put_stream", "(", "self", ",", "bucket", ",", "label", ",", "stream_object", ",", "params", "=", "None", ",", "replace", "=", "True", ",", "add_md", "=", "True", ")", ":", "if", "self", ".", "mode", "==", "\"r\"", ":", "raise", "OFSException", ...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.del_stream
Delete a bitstream. This needs more testing - file deletion in a zipfile is problematic. Alternate method is to create second zipfile without the files in question, which is not a nice method for large zip archives.
ofs/local/zipstore.py
def del_stream(self, bucket, label): '''Delete a bitstream. This needs more testing - file deletion in a zipfile is problematic. Alternate method is to create second zipfile without the files in question, which is not a nice method for large zip archives. ''' if self.exists(bucke...
def del_stream(self, bucket, label): '''Delete a bitstream. This needs more testing - file deletion in a zipfile is problematic. Alternate method is to create second zipfile without the files in question, which is not a nice method for large zip archives. ''' if self.exists(bucke...
[ "Delete", "a", "bitstream", ".", "This", "needs", "more", "testing", "-", "file", "deletion", "in", "a", "zipfile", "is", "problematic", ".", "Alternate", "method", "is", "to", "create", "second", "zipfile", "without", "the", "files", "in", "question", "whic...
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L238-L246
[ "def", "del_stream", "(", "self", ",", "bucket", ",", "label", ")", ":", "if", "self", ".", "exists", "(", "bucket", ",", "label", ")", ":", "name", "=", "self", ".", "_zf", "(", "bucket", ",", "label", ")", "#z = ZipFile(self.zipfile, self.mode, self.comp...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.get_metadata
Get the metadata for this bucket:label identifier.
ofs/local/zipstore.py
def get_metadata(self, bucket, label): '''Get the metadata for this bucket:label identifier. ''' if self.mode !="w": try: jsn = self._get_bucket_md(bucket) except OFSFileNotFound: # No MD found... return {} excep...
def get_metadata(self, bucket, label): '''Get the metadata for this bucket:label identifier. ''' if self.mode !="w": try: jsn = self._get_bucket_md(bucket) except OFSFileNotFound: # No MD found... return {} excep...
[ "Get", "the", "metadata", "for", "this", "bucket", ":", "label", "identifier", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L265-L281
[ "def", "get_metadata", "(", "self", ",", "bucket", ",", "label", ")", ":", "if", "self", ".", "mode", "!=", "\"w\"", ":", "try", ":", "jsn", "=", "self", ".", "_get_bucket_md", "(", "bucket", ")", "except", "OFSFileNotFound", ":", "# No MD found...", "re...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.update_metadata
Update the metadata with the provided dictionary of params. :param parmams: dictionary of key values (json serializable).
ofs/local/zipstore.py
def update_metadata(self, bucket, label, params): '''Update the metadata with the provided dictionary of params. :param parmams: dictionary of key values (json serializable). ''' if self.mode !="r": try: payload = self._get_bucket_md(bucket) excep...
def update_metadata(self, bucket, label, params): '''Update the metadata with the provided dictionary of params. :param parmams: dictionary of key values (json serializable). ''' if self.mode !="r": try: payload = self._get_bucket_md(bucket) excep...
[ "Update", "the", "metadata", "with", "the", "provided", "dictionary", "of", "params", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L283-L307
[ "def", "update_metadata", "(", "self", ",", "bucket", ",", "label", ",", "params", ")", ":", "if", "self", ".", "mode", "!=", "\"r\"", ":", "try", ":", "payload", "=", "self", ".", "_get_bucket_md", "(", "bucket", ")", "except", "OFSFileNotFound", ":", ...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
ZOFS.del_metadata_keys
Delete the metadata corresponding to the specified keys.
ofs/local/zipstore.py
def del_metadata_keys(self, bucket, label, keys): '''Delete the metadata corresponding to the specified keys. ''' if self.mode !="r": try: payload = self._get_bucket_md(bucket) except OFSFileNotFound: # No MD found... raise ...
def del_metadata_keys(self, bucket, label, keys): '''Delete the metadata corresponding to the specified keys. ''' if self.mode !="r": try: payload = self._get_bucket_md(bucket) except OFSFileNotFound: # No MD found... raise ...
[ "Delete", "the", "metadata", "corresponding", "to", "the", "specified", "keys", "." ]
okfn/ofs
python
https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipstore.py#L309-L325
[ "def", "del_metadata_keys", "(", "self", ",", "bucket", ",", "label", ",", "keys", ")", ":", "if", "self", ".", "mode", "!=", "\"r\"", ":", "try", ":", "payload", "=", "self", ".", "_get_bucket_md", "(", "bucket", ")", "except", "OFSFileNotFound", ":", ...
c110cbecd7d0ae7e877963914a1a5af030cd6d45
train
get_response
Given a WSGI request, makes a call to a corresponding view function and returns the response.
batch_requests/views.py
def get_response(wsgi_request): ''' Given a WSGI request, makes a call to a corresponding view function and returns the response. ''' service_start_time = datetime.now() # Get the view / handler for this request view, args, kwargs = resolve(wsgi_request.path_info) kwargs.update(...
def get_response(wsgi_request): ''' Given a WSGI request, makes a call to a corresponding view function and returns the response. ''' service_start_time = datetime.now() # Get the view / handler for this request view, args, kwargs = resolve(wsgi_request.path_info) kwargs.update(...
[ "Given", "a", "WSGI", "request", "makes", "a", "call", "to", "a", "corresponding", "view", "function", "and", "returns", "the", "response", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/views.py#L22-L53
[ "def", "get_response", "(", "wsgi_request", ")", ":", "service_start_time", "=", "datetime", ".", "now", "(", ")", "# Get the view / handler for this request", "view", ",", "args", ",", "kwargs", "=", "resolve", "(", "wsgi_request", ".", "path_info", ")", "kwargs"...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
get_wsgi_requests
For the given batch request, extract the individual requests and create WSGIRequest object for each.
batch_requests/views.py
def get_wsgi_requests(request): ''' For the given batch request, extract the individual requests and create WSGIRequest object for each. ''' valid_http_methods = ["get", "post", "put", "patch", "delete", "head", "options", "connect", "trace"] requests = json.loads(request.body) if t...
def get_wsgi_requests(request): ''' For the given batch request, extract the individual requests and create WSGIRequest object for each. ''' valid_http_methods = ["get", "post", "put", "patch", "delete", "head", "options", "connect", "trace"] requests = json.loads(request.body) if t...
[ "For", "the", "given", "batch", "request", "extract", "the", "individual", "requests", "and", "create", "WSGIRequest", "object", "for", "each", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/views.py#L56-L94
[ "def", "get_wsgi_requests", "(", "request", ")", ":", "valid_http_methods", "=", "[", "\"get\"", ",", "\"post\"", ",", "\"put\"", ",", "\"patch\"", ",", "\"delete\"", ",", "\"head\"", ",", "\"options\"", ",", "\"connect\"", ",", "\"trace\"", "]", "requests", "...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
handle_batch_requests
A view function to handle the overall processing of batch requests.
batch_requests/views.py
def handle_batch_requests(request, *args, **kwargs): ''' A view function to handle the overall processing of batch requests. ''' batch_start_time = datetime.now() try: # Get the Individual WSGI requests. wsgi_requests = get_wsgi_requests(request) except BadBatchRequest as brx...
def handle_batch_requests(request, *args, **kwargs): ''' A view function to handle the overall processing of batch requests. ''' batch_start_time = datetime.now() try: # Get the Individual WSGI requests. wsgi_requests = get_wsgi_requests(request) except BadBatchRequest as brx...
[ "A", "view", "function", "to", "handle", "the", "overall", "processing", "of", "batch", "requests", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/views.py#L108-L128
[ "def", "handle_batch_requests", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "batch_start_time", "=", "datetime", ".", "now", "(", ")", "try", ":", "# Get the Individual WSGI requests.", "wsgi_requests", "=", "get_wsgi_requests", "(", "re...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
KKBOXSearchFetcher.search
Searches within KKBOX's database. :param keyword: the keyword. :type keyword: str :param types: the search types. :return: list :param terr: the current territory. :return: API response. :rtype: dict See `https://docs-en.kkbox.codes/v1.1/reference#search...
kkbox_developer_sdk/search_fetcher.py
def search(self, keyword, types=[], terr=KKBOXTerritory.TAIWAN): ''' Searches within KKBOX's database. :param keyword: the keyword. :type keyword: str :param types: the search types. :return: list :param terr: the current territory. :return: API response....
def search(self, keyword, types=[], terr=KKBOXTerritory.TAIWAN): ''' Searches within KKBOX's database. :param keyword: the keyword. :type keyword: str :param types: the search types. :return: list :param terr: the current territory. :return: API response....
[ "Searches", "within", "KKBOX", "s", "database", "." ]
KKBOX/OpenAPI-Python
python
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/search_fetcher.py#L24-L42
[ "def", "search", "(", "self", ",", "keyword", ",", "types", "=", "[", "]", ",", "terr", "=", "KKBOXTerritory", ".", "TAIWAN", ")", ":", "url", "=", "'https://api.kkbox.com/v1.1/search'", "url", "+=", "'?'", "+", "url_parse", ".", "urlencode", "(", "{", "...
77aa22fd300ed987d5507a5b66b149edcd28047d
train
IPAddress.save
IPAddress can only change its PTR record. Saves the current state, PUT /ip_address/uuid.
upcloud_api/ip_address.py
def save(self): """ IPAddress can only change its PTR record. Saves the current state, PUT /ip_address/uuid. """ body = {'ip_address': {'ptr_record': self.ptr_record}} data = self.cloud_manager.request('PUT', '/ip_address/' + self.address, body) self._reset(**data['ip_add...
def save(self): """ IPAddress can only change its PTR record. Saves the current state, PUT /ip_address/uuid. """ body = {'ip_address': {'ptr_record': self.ptr_record}} data = self.cloud_manager.request('PUT', '/ip_address/' + self.address, body) self._reset(**data['ip_add...
[ "IPAddress", "can", "only", "change", "its", "PTR", "record", ".", "Saves", "the", "current", "state", "PUT", "/", "ip_address", "/", "uuid", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/ip_address.py#L32-L38
[ "def", "save", "(", "self", ")", ":", "body", "=", "{", "'ip_address'", ":", "{", "'ptr_record'", ":", "self", ".", "ptr_record", "}", "}", "data", "=", "self", ".", "cloud_manager", ".", "request", "(", "'PUT'", ",", "'/ip_address/'", "+", "self", "."...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
IPAddress._create_ip_address_objs
Create IPAddress objects from API response data. Also associates CloudManager with the objects.
upcloud_api/ip_address.py
def _create_ip_address_objs(ip_addresses, cloud_manager): """ Create IPAddress objects from API response data. Also associates CloudManager with the objects. """ # ip-addresses might be provided as a flat array or as a following dict: # {'ip_addresses': {'ip_address': [.....
def _create_ip_address_objs(ip_addresses, cloud_manager): """ Create IPAddress objects from API response data. Also associates CloudManager with the objects. """ # ip-addresses might be provided as a flat array or as a following dict: # {'ip_addresses': {'ip_address': [.....
[ "Create", "IPAddress", "objects", "from", "API", "response", "data", ".", "Also", "associates", "CloudManager", "with", "the", "objects", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/ip_address.py#L54-L71
[ "def", "_create_ip_address_objs", "(", "ip_addresses", ",", "cloud_manager", ")", ":", "# ip-addresses might be provided as a flat array or as a following dict:", "# {'ip_addresses': {'ip_address': [...]}} || {'ip_address': [...]}", "if", "'ip_addresses'", "in", "ip_addresses", ":", "i...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
Tag._reset
Reset the objects attributes. Accepts servers as either unflattened or flattened UUID strings or Server objects.
upcloud_api/tag.py
def _reset(self, **kwargs): """ Reset the objects attributes. Accepts servers as either unflattened or flattened UUID strings or Server objects. """ super(Tag, self)._reset(**kwargs) # backup name for changing it (look: Tag.save) self._api_name = self.name ...
def _reset(self, **kwargs): """ Reset the objects attributes. Accepts servers as either unflattened or flattened UUID strings or Server objects. """ super(Tag, self)._reset(**kwargs) # backup name for changing it (look: Tag.save) self._api_name = self.name ...
[ "Reset", "the", "objects", "attributes", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/tag.py#L30-L47
[ "def", "_reset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Tag", ",", "self", ")", ".", "_reset", "(", "*", "*", "kwargs", ")", "# backup name for changing it (look: Tag.save)", "self", ".", "_api_name", "=", "self", ".", "name", "# ...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
HTTP._get
HTTP GET function :param uri: REST endpoint :param params: optional HTTP params to pass to the endpoint :return: list of results (usually a list of dicts) Example: ret = cli.get('/search', params={ 'q': 'example.org' })
csirtgsdk/client/http.py
def _get(self, uri, params={}): """ HTTP GET function :param uri: REST endpoint :param params: optional HTTP params to pass to the endpoint :return: list of results (usually a list of dicts) Example: ret = cli.get('/search', params={ 'q': 'example.org' }) ...
def _get(self, uri, params={}): """ HTTP GET function :param uri: REST endpoint :param params: optional HTTP params to pass to the endpoint :return: list of results (usually a list of dicts) Example: ret = cli.get('/search', params={ 'q': 'example.org' }) ...
[ "HTTP", "GET", "function" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/client/http.py#L102-L117
[ "def", "_get", "(", "self", ",", "uri", ",", "params", "=", "{", "}", ")", ":", "if", "not", "uri", ".", "startswith", "(", "self", ".", "remote", ")", ":", "uri", "=", "'{}{}'", ".", "format", "(", "self", ".", "remote", ",", "uri", ")", "retu...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
HTTP._post
HTTP POST function :param uri: REST endpoint to POST to :param data: list of dicts to be passed to the endpoint :return: list of dicts, usually will be a list of objects or id's Example: ret = cli.post('/indicators', { 'indicator': 'example.com' })
csirtgsdk/client/http.py
def _post(self, uri, data): """ HTTP POST function :param uri: REST endpoint to POST to :param data: list of dicts to be passed to the endpoint :return: list of dicts, usually will be a list of objects or id's Example: ret = cli.post('/indicators', { 'indica...
def _post(self, uri, data): """ HTTP POST function :param uri: REST endpoint to POST to :param data: list of dicts to be passed to the endpoint :return: list of dicts, usually will be a list of objects or id's Example: ret = cli.post('/indicators', { 'indica...
[ "HTTP", "POST", "function" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/client/http.py#L119-L135
[ "def", "_post", "(", "self", ",", "uri", ",", "data", ")", ":", "if", "not", "uri", ".", "startswith", "(", "self", ".", "remote", ")", ":", "uri", "=", "'{}/{}'", ".", "format", "(", "self", ".", "remote", ",", "uri", ")", "self", ".", "logger",...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
ServerManager.get_servers
Return a list of (populated or unpopulated) Server instances. - populate = False (default) => 1 API request, returns unpopulated Server instances. - populate = True => Does 1 + n API requests (n = # of servers), returns populated Server instances. New in 0.3.0: the...
upcloud_api/cloud_manager/server_mixin.py
def get_servers(self, populate=False, tags_has_one=None, tags_has_all=None): """ Return a list of (populated or unpopulated) Server instances. - populate = False (default) => 1 API request, returns unpopulated Server instances. - populate = True => Does 1 + n API requests (n = # of serv...
def get_servers(self, populate=False, tags_has_one=None, tags_has_all=None): """ Return a list of (populated or unpopulated) Server instances. - populate = False (default) => 1 API request, returns unpopulated Server instances. - populate = True => Does 1 + n API requests (n = # of serv...
[ "Return", "a", "list", "of", "(", "populated", "or", "unpopulated", ")", "Server", "instances", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/server_mixin.py#L15-L54
[ "def", "get_servers", "(", "self", ",", "populate", "=", "False", ",", "tags_has_one", "=", "None", ",", "tags_has_all", "=", "None", ")", ":", "if", "tags_has_all", "and", "tags_has_one", ":", "raise", "Exception", "(", "'only one of (tags_has_all, tags_has_one) ...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
ServerManager.get_server
Return a (populated) Server instance.
upcloud_api/cloud_manager/server_mixin.py
def get_server(self, UUID): """ Return a (populated) Server instance. """ server, IPAddresses, storages = self.get_server_data(UUID) return Server( server, ip_addresses=IPAddresses, storage_devices=storages, populated=True, ...
def get_server(self, UUID): """ Return a (populated) Server instance. """ server, IPAddresses, storages = self.get_server_data(UUID) return Server( server, ip_addresses=IPAddresses, storage_devices=storages, populated=True, ...
[ "Return", "a", "(", "populated", ")", "Server", "instance", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/server_mixin.py#L56-L68
[ "def", "get_server", "(", "self", ",", "UUID", ")", ":", "server", ",", "IPAddresses", ",", "storages", "=", "self", ".", "get_server_data", "(", "UUID", ")", "return", "Server", "(", "server", ",", "ip_addresses", "=", "IPAddresses", ",", "storage_devices",...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
ServerManager.get_server_by_ip
Return a (populated) Server instance by its IP. Uses GET '/ip_address/x.x.x.x' to retrieve machine UUID using IP-address.
upcloud_api/cloud_manager/server_mixin.py
def get_server_by_ip(self, ip_address): """ Return a (populated) Server instance by its IP. Uses GET '/ip_address/x.x.x.x' to retrieve machine UUID using IP-address. """ data = self.get_request('/ip_address/{0}'.format(ip_address)) UUID = data['ip_address']['server'] ...
def get_server_by_ip(self, ip_address): """ Return a (populated) Server instance by its IP. Uses GET '/ip_address/x.x.x.x' to retrieve machine UUID using IP-address. """ data = self.get_request('/ip_address/{0}'.format(ip_address)) UUID = data['ip_address']['server'] ...
[ "Return", "a", "(", "populated", ")", "Server", "instance", "by", "its", "IP", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/server_mixin.py#L70-L78
[ "def", "get_server_by_ip", "(", "self", ",", "ip_address", ")", ":", "data", "=", "self", ".", "get_request", "(", "'/ip_address/{0}'", ".", "format", "(", "ip_address", ")", ")", "UUID", "=", "data", "[", "'ip_address'", "]", "[", "'server'", "]", "return...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
ServerManager.create_server
Create a server and its storages based on a (locally created) Server object. Populates the given Server instance with the API response. 0.3.0: also supports giving the entire POST body as a dict that is directly serialised into JSON. Refer to the REST API documentation for correct format. ...
upcloud_api/cloud_manager/server_mixin.py
def create_server(self, server): """ Create a server and its storages based on a (locally created) Server object. Populates the given Server instance with the API response. 0.3.0: also supports giving the entire POST body as a dict that is directly serialised into JSON. Refer t...
def create_server(self, server): """ Create a server and its storages based on a (locally created) Server object. Populates the given Server instance with the API response. 0.3.0: also supports giving the entire POST body as a dict that is directly serialised into JSON. Refer t...
[ "Create", "a", "server", "and", "its", "storages", "based", "on", "a", "(", "locally", "created", ")", "Server", "object", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/server_mixin.py#L80-L127
[ "def", "create_server", "(", "self", ",", "server", ")", ":", "if", "isinstance", "(", "server", ",", "Server", ")", ":", "body", "=", "server", ".", "prepare_post_body", "(", ")", "else", ":", "server", "=", "Server", ".", "_create_server_obj", "(", "se...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
ServerManager.modify_server
modify_server allows updating the server's updateable_fields. Note: Server's IP-addresses and Storages are managed by their own add/remove methods.
upcloud_api/cloud_manager/server_mixin.py
def modify_server(self, UUID, **kwargs): """ modify_server allows updating the server's updateable_fields. Note: Server's IP-addresses and Storages are managed by their own add/remove methods. """ body = dict() body['server'] = {} for arg in kwargs: i...
def modify_server(self, UUID, **kwargs): """ modify_server allows updating the server's updateable_fields. Note: Server's IP-addresses and Storages are managed by their own add/remove methods. """ body = dict() body['server'] = {} for arg in kwargs: i...
[ "modify_server", "allows", "updating", "the", "server", "s", "updateable_fields", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/server_mixin.py#L129-L158
[ "def", "modify_server", "(", "self", ",", "UUID", ",", "*", "*", "kwargs", ")", ":", "body", "=", "dict", "(", ")", "body", "[", "'server'", "]", "=", "{", "}", "for", "arg", "in", "kwargs", ":", "if", "arg", "not", "in", "Server", ".", "updateab...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
ServerManager.get_server_data
Return '/server/uuid' data in Python dict. Creates object representations of any IP-address and Storage.
upcloud_api/cloud_manager/server_mixin.py
def get_server_data(self, UUID): """ Return '/server/uuid' data in Python dict. Creates object representations of any IP-address and Storage. """ data = self.get_request('/server/{0}'.format(UUID)) server = data['server'] # Populate subobjects IPAddresse...
def get_server_data(self, UUID): """ Return '/server/uuid' data in Python dict. Creates object representations of any IP-address and Storage. """ data = self.get_request('/server/{0}'.format(UUID)) server = data['server'] # Populate subobjects IPAddresse...
[ "Return", "/", "server", "/", "uuid", "data", "in", "Python", "dict", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/server_mixin.py#L170-L186
[ "def", "get_server_data", "(", "self", ",", "UUID", ")", ":", "data", "=", "self", ".", "get_request", "(", "'/server/{0}'", ".", "format", "(", "UUID", ")", ")", "server", "=", "data", "[", "'server'", "]", "# Populate subobjects", "IPAddresses", "=", "IP...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
feed
Pull a feed :param f: feed name (eg: csirtgadgetes/correlated) :param limit: return value limit (default 25) :return: Feed dict
csirtgsdk/__init__.py
def feed(f, limit=25): """ Pull a feed :param f: feed name (eg: csirtgadgetes/correlated) :param limit: return value limit (default 25) :return: Feed dict """ if '/' not in f: raise ValueError('feed name must be formatted like: ' 'csirtgadgets/scanners') ...
def feed(f, limit=25): """ Pull a feed :param f: feed name (eg: csirtgadgetes/correlated) :param limit: return value limit (default 25) :return: Feed dict """ if '/' not in f: raise ValueError('feed name must be formatted like: ' 'csirtgadgets/scanners') ...
[ "Pull", "a", "feed", ":", "param", "f", ":", "feed", "name", "(", "eg", ":", "csirtgadgetes", "/", "correlated", ")", ":", "param", "limit", ":", "return", "value", "limit", "(", "default", "25", ")", ":", "return", ":", "Feed", "dict" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/__init__.py#L11-L24
[ "def", "feed", "(", "f", ",", "limit", "=", "25", ")", ":", "if", "'/'", "not", "in", "f", ":", "raise", "ValueError", "(", "'feed name must be formatted like: '", "'csirtgadgets/scanners'", ")", "user", ",", "f", "=", "f", ".", "split", "(", "'/'", ")",...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
indicator_create
Create an indicator in a feed :param f: feed name (eg: wes/test) :param i: indicator dict (eg: {'indicator': 'example.com', 'tags': ['ssh'], 'description': 'this is a test'}) :return: dict of indicator
csirtgsdk/__init__.py
def indicator_create(f, i): """ Create an indicator in a feed :param f: feed name (eg: wes/test) :param i: indicator dict (eg: {'indicator': 'example.com', 'tags': ['ssh'], 'description': 'this is a test'}) :return: dict of indicator """ if '/' not in f: raise ValueError('feed na...
def indicator_create(f, i): """ Create an indicator in a feed :param f: feed name (eg: wes/test) :param i: indicator dict (eg: {'indicator': 'example.com', 'tags': ['ssh'], 'description': 'this is a test'}) :return: dict of indicator """ if '/' not in f: raise ValueError('feed na...
[ "Create", "an", "indicator", "in", "a", "feed", ":", "param", "f", ":", "feed", "name", "(", "eg", ":", "wes", "/", "test", ")", ":", "param", "i", ":", "indicator", "dict", "(", "eg", ":", "{", "indicator", ":", "example", ".", "com", "tags", ":...
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/__init__.py#L39-L61
[ "def", "indicator_create", "(", "f", ",", "i", ")", ":", "if", "'/'", "not", "in", "f", ":", "raise", "ValueError", "(", "'feed name must be formatted like: '", "'csirtgadgets/scanners'", ")", "if", "not", "i", ":", "raise", "ValueError", "(", "'missing indicato...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
convert_from_file
Reads the content of file in IDX format, converts it into numpy.ndarray and returns it. file is a file-like object (with read() method) or a file name.
idx2numpy/converters.py
def convert_from_file(file): """ Reads the content of file in IDX format, converts it into numpy.ndarray and returns it. file is a file-like object (with read() method) or a file name. """ if isinstance(file, six_string_types): with open(file, 'rb') as f: return _internal_con...
def convert_from_file(file): """ Reads the content of file in IDX format, converts it into numpy.ndarray and returns it. file is a file-like object (with read() method) or a file name. """ if isinstance(file, six_string_types): with open(file, 'rb') as f: return _internal_con...
[ "Reads", "the", "content", "of", "file", "in", "IDX", "format", "converts", "it", "into", "numpy", ".", "ndarray", "and", "returns", "it", ".", "file", "is", "a", "file", "-", "like", "object", "(", "with", "read", "()", "method", ")", "or", "a", "fi...
ivanyu/idx2numpy
python
https://github.com/ivanyu/idx2numpy/blob/9b88698314973226212181d1747dfad6c6974e51/idx2numpy/converters.py#L49-L59
[ "def", "convert_from_file", "(", "file", ")", ":", "if", "isinstance", "(", "file", ",", "six_string_types", ")", ":", "with", "open", "(", "file", ",", "'rb'", ")", "as", "f", ":", "return", "_internal_convert", "(", "f", ")", "else", ":", "return", "...
9b88698314973226212181d1747dfad6c6974e51
train
_internal_convert
Converts file in IDX format provided by file-like input into numpy.ndarray and returns it.
idx2numpy/converters.py
def _internal_convert(inp): """ Converts file in IDX format provided by file-like input into numpy.ndarray and returns it. """ ''' Converts file in IDX format provided by file-like input into numpy.ndarray and returns it. ''' # Read the "magic number" - 4 bytes. try: mn ...
def _internal_convert(inp): """ Converts file in IDX format provided by file-like input into numpy.ndarray and returns it. """ ''' Converts file in IDX format provided by file-like input into numpy.ndarray and returns it. ''' # Read the "magic number" - 4 bytes. try: mn ...
[ "Converts", "file", "in", "IDX", "format", "provided", "by", "file", "-", "like", "input", "into", "numpy", ".", "ndarray", "and", "returns", "it", "." ]
ivanyu/idx2numpy
python
https://github.com/ivanyu/idx2numpy/blob/9b88698314973226212181d1747dfad6c6974e51/idx2numpy/converters.py#L71-L127
[ "def", "_internal_convert", "(", "inp", ")", ":", "'''\n Converts file in IDX format provided by file-like input into numpy.ndarray\n and returns it.\n '''", "# Read the \"magic number\" - 4 bytes.", "try", ":", "mn", "=", "struct", ".", "unpack", "(", "'>BBBB'", ",", "i...
9b88698314973226212181d1747dfad6c6974e51
train
convert_to_file
Writes the contents of the numpy.ndarray ndarr to file in IDX format. file is a file-like object (with write() method) or a file name.
idx2numpy/converters.py
def convert_to_file(file, ndarr): """ Writes the contents of the numpy.ndarray ndarr to file in IDX format. file is a file-like object (with write() method) or a file name. """ if isinstance(file, six_string_types): with open(file, 'wb') as fp: _internal_write(fp, ndarr) else...
def convert_to_file(file, ndarr): """ Writes the contents of the numpy.ndarray ndarr to file in IDX format. file is a file-like object (with write() method) or a file name. """ if isinstance(file, six_string_types): with open(file, 'wb') as fp: _internal_write(fp, ndarr) else...
[ "Writes", "the", "contents", "of", "the", "numpy", ".", "ndarray", "ndarr", "to", "file", "in", "IDX", "format", ".", "file", "is", "a", "file", "-", "like", "object", "(", "with", "write", "()", "method", ")", "or", "a", "file", "name", "." ]
ivanyu/idx2numpy
python
https://github.com/ivanyu/idx2numpy/blob/9b88698314973226212181d1747dfad6c6974e51/idx2numpy/converters.py#L130-L139
[ "def", "convert_to_file", "(", "file", ",", "ndarr", ")", ":", "if", "isinstance", "(", "file", ",", "six_string_types", ")", ":", "with", "open", "(", "file", ",", "'wb'", ")", "as", "fp", ":", "_internal_write", "(", "fp", ",", "ndarr", ")", "else", ...
9b88698314973226212181d1747dfad6c6974e51
train
convert_to_string
Writes the contents of the numpy.ndarray ndarr to bytes in IDX format and returns it.
idx2numpy/converters.py
def convert_to_string(ndarr): """ Writes the contents of the numpy.ndarray ndarr to bytes in IDX format and returns it. """ with contextlib.closing(BytesIO()) as bytesio: _internal_write(bytesio, ndarr) return bytesio.getvalue()
def convert_to_string(ndarr): """ Writes the contents of the numpy.ndarray ndarr to bytes in IDX format and returns it. """ with contextlib.closing(BytesIO()) as bytesio: _internal_write(bytesio, ndarr) return bytesio.getvalue()
[ "Writes", "the", "contents", "of", "the", "numpy", ".", "ndarray", "ndarr", "to", "bytes", "in", "IDX", "format", "and", "returns", "it", "." ]
ivanyu/idx2numpy
python
https://github.com/ivanyu/idx2numpy/blob/9b88698314973226212181d1747dfad6c6974e51/idx2numpy/converters.py#L142-L149
[ "def", "convert_to_string", "(", "ndarr", ")", ":", "with", "contextlib", ".", "closing", "(", "BytesIO", "(", ")", ")", "as", "bytesio", ":", "_internal_write", "(", "bytesio", ",", "ndarr", ")", "return", "bytesio", ".", "getvalue", "(", ")" ]
9b88698314973226212181d1747dfad6c6974e51
train
_internal_write
Writes numpy.ndarray arr to a file-like object (with write() method) in IDX format.
idx2numpy/converters.py
def _internal_write(out_stream, arr): """ Writes numpy.ndarray arr to a file-like object (with write() method) in IDX format. """ if arr.size == 0: raise FormatError('Cannot encode empty array.') try: type_byte, struct_lib_type = _DATA_TYPES_NUMPY[str(arr.dtype)] except Key...
def _internal_write(out_stream, arr): """ Writes numpy.ndarray arr to a file-like object (with write() method) in IDX format. """ if arr.size == 0: raise FormatError('Cannot encode empty array.') try: type_byte, struct_lib_type = _DATA_TYPES_NUMPY[str(arr.dtype)] except Key...
[ "Writes", "numpy", ".", "ndarray", "arr", "to", "a", "file", "-", "like", "object", "(", "with", "write", "()", "method", ")", "in", "IDX", "format", "." ]
ivanyu/idx2numpy
python
https://github.com/ivanyu/idx2numpy/blob/9b88698314973226212181d1747dfad6c6974e51/idx2numpy/converters.py#L152-L190
[ "def", "_internal_write", "(", "out_stream", ",", "arr", ")", ":", "if", "arr", ".", "size", "==", "0", ":", "raise", "FormatError", "(", "'Cannot encode empty array.'", ")", "try", ":", "type_byte", ",", "struct_lib_type", "=", "_DATA_TYPES_NUMPY", "[", "str"...
9b88698314973226212181d1747dfad6c6974e51
train
KKBOXOAuth.fetch_access_token_by_client_credentials
There are three ways to let you start using KKBOX's Open/Partner API. The first way among them is to generate a client credential to fetch an access token to let KKBOX identify you. It allows you to access public data from KKBOX such as public albums, playlists and so on. Howeve...
kkbox_developer_sdk/auth_flow.py
def fetch_access_token_by_client_credentials(self): ''' There are three ways to let you start using KKBOX's Open/Partner API. The first way among them is to generate a client credential to fetch an access token to let KKBOX identify you. It allows you to access public data from K...
def fetch_access_token_by_client_credentials(self): ''' There are three ways to let you start using KKBOX's Open/Partner API. The first way among them is to generate a client credential to fetch an access token to let KKBOX identify you. It allows you to access public data from K...
[ "There", "are", "three", "ways", "to", "let", "you", "start", "using", "KKBOX", "s", "Open", "/", "Partner", "API", ".", "The", "first", "way", "among", "them", "is", "to", "generate", "a", "client", "credential", "to", "fetch", "an", "access", "token", ...
KKBOX/OpenAPI-Python
python
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/auth_flow.py#L27-L60
[ "def", "fetch_access_token_by_client_credentials", "(", "self", ")", ":", "client_credential_base", "=", "'%s:%s'", "%", "(", "self", ".", "client_id", ",", "self", ".", "client_secret", ")", "try", ":", "client_credentials", "=", "base64", ".", "b64encode", "(", ...
77aa22fd300ed987d5507a5b66b149edcd28047d
train
OperatingSystems.get_OS_UUID
Validate Storage OS and its UUID. If the OS is a custom OS UUID, don't validate against templates.
upcloud_api/constants.py
def get_OS_UUID(cls, os): """ Validate Storage OS and its UUID. If the OS is a custom OS UUID, don't validate against templates. """ if os in cls.templates: return cls.templates[os] uuid_regexp = '^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}...
def get_OS_UUID(cls, os): """ Validate Storage OS and its UUID. If the OS is a custom OS UUID, don't validate against templates. """ if os in cls.templates: return cls.templates[os] uuid_regexp = '^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}...
[ "Validate", "Storage", "OS", "and", "its", "UUID", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/constants.py#L43-L60
[ "def", "get_OS_UUID", "(", "cls", ",", "os", ")", ":", "if", "os", "in", "cls", ".", "templates", ":", "return", "cls", ".", "templates", "[", "os", "]", "uuid_regexp", "=", "'^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$'", "if", "re", ".", "...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
Executor.execute
Calls the resp_generator for all the requests in parallel in an asynchronous way.
batch_requests/concurrent/executor.py
def execute(self, requests, resp_generator, *args, **kwargs): ''' Calls the resp_generator for all the requests in parallel in an asynchronous way. ''' result_futures = [self.executor_pool.submit(resp_generator, req, *args, **kwargs) for req in requests] resp = [res_future.re...
def execute(self, requests, resp_generator, *args, **kwargs): ''' Calls the resp_generator for all the requests in parallel in an asynchronous way. ''' result_futures = [self.executor_pool.submit(resp_generator, req, *args, **kwargs) for req in requests] resp = [res_future.re...
[ "Calls", "the", "resp_generator", "for", "all", "the", "requests", "in", "parallel", "in", "an", "asynchronous", "way", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/concurrent/executor.py#L17-L23
[ "def", "execute", "(", "self", ",", "requests", ",", "resp_generator", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result_futures", "=", "[", "self", ".", "executor_pool", ".", "submit", "(", "resp_generator", ",", "req", ",", "*", "args", ",...
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
SequentialExecutor.execute
Calls the resp_generator for all the requests in sequential order.
batch_requests/concurrent/executor.py
def execute(self, requests, resp_generator, *args, **kwargs): ''' Calls the resp_generator for all the requests in sequential order. ''' return [resp_generator(request) for request in requests]
def execute(self, requests, resp_generator, *args, **kwargs): ''' Calls the resp_generator for all the requests in sequential order. ''' return [resp_generator(request) for request in requests]
[ "Calls", "the", "resp_generator", "for", "all", "the", "requests", "in", "sequential", "order", "." ]
tanwanirahul/django-batch-requests
python
https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/concurrent/executor.py#L31-L35
[ "def", "execute", "(", "self", ",", "requests", ",", "resp_generator", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "[", "resp_generator", "(", "request", ")", "for", "request", "in", "requests", "]" ]
9c5afc42f7542f466247f4ffed9c44e1c49fa20d
train
setup_logging
Sets up basic logging :param args: ArgParse arguments :return: nothing. sets logger up globally
csirtgsdk/client/cli.py
def setup_logging(args): """ Sets up basic logging :param args: ArgParse arguments :return: nothing. sets logger up globally """ loglevel = logging.WARNING if args.verbose: loglevel = logging.INFO if args.debug: loglevel = logging.DEBUG console = logging.StreamHandl...
def setup_logging(args): """ Sets up basic logging :param args: ArgParse arguments :return: nothing. sets logger up globally """ loglevel = logging.WARNING if args.verbose: loglevel = logging.INFO if args.debug: loglevel = logging.DEBUG console = logging.StreamHandl...
[ "Sets", "up", "basic", "logging" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/client/cli.py#L18-L34
[ "def", "setup_logging", "(", "args", ")", ":", "loglevel", "=", "logging", ".", "WARNING", "if", "args", ".", "verbose", ":", "loglevel", "=", "logging", ".", "INFO", "if", "args", ".", "debug", ":", "loglevel", "=", "logging", ".", "DEBUG", "console", ...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
IPManager.get_ip
Get an IPAddress object with the IP address (string) from the API. e.g manager.get_ip('80.69.175.210')
upcloud_api/cloud_manager/ip_address_mixin.py
def get_ip(self, address): """ Get an IPAddress object with the IP address (string) from the API. e.g manager.get_ip('80.69.175.210') """ res = self.get_request('/ip_address/' + address) return IPAddress(cloud_manager=self, **res['ip_address'])
def get_ip(self, address): """ Get an IPAddress object with the IP address (string) from the API. e.g manager.get_ip('80.69.175.210') """ res = self.get_request('/ip_address/' + address) return IPAddress(cloud_manager=self, **res['ip_address'])
[ "Get", "an", "IPAddress", "object", "with", "the", "IP", "address", "(", "string", ")", "from", "the", "API", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/ip_address_mixin.py#L16-L23
[ "def", "get_ip", "(", "self", ",", "address", ")", ":", "res", "=", "self", ".", "get_request", "(", "'/ip_address/'", "+", "address", ")", "return", "IPAddress", "(", "cloud_manager", "=", "self", ",", "*", "*", "res", "[", "'ip_address'", "]", ")" ]
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
IPManager.get_ips
Get all IPAddress objects from the API.
upcloud_api/cloud_manager/ip_address_mixin.py
def get_ips(self): """ Get all IPAddress objects from the API. """ res = self.get_request('/ip_address') IPs = IPAddress._create_ip_address_objs(res['ip_addresses'], cloud_manager=self) return IPs
def get_ips(self): """ Get all IPAddress objects from the API. """ res = self.get_request('/ip_address') IPs = IPAddress._create_ip_address_objs(res['ip_addresses'], cloud_manager=self) return IPs
[ "Get", "all", "IPAddress", "objects", "from", "the", "API", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/ip_address_mixin.py#L25-L31
[ "def", "get_ips", "(", "self", ")", ":", "res", "=", "self", ".", "get_request", "(", "'/ip_address'", ")", "IPs", "=", "IPAddress", ".", "_create_ip_address_objs", "(", "res", "[", "'ip_addresses'", "]", ",", "cloud_manager", "=", "self", ")", "return", "...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
IPManager.attach_ip
Attach a new (random) IPAddress to the given server (object or UUID).
upcloud_api/cloud_manager/ip_address_mixin.py
def attach_ip(self, server, family='IPv4'): """ Attach a new (random) IPAddress to the given server (object or UUID). """ body = { 'ip_address': { 'server': str(server), 'family': family } } res = self.request('POST...
def attach_ip(self, server, family='IPv4'): """ Attach a new (random) IPAddress to the given server (object or UUID). """ body = { 'ip_address': { 'server': str(server), 'family': family } } res = self.request('POST...
[ "Attach", "a", "new", "(", "random", ")", "IPAddress", "to", "the", "given", "server", "(", "object", "or", "UUID", ")", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/ip_address_mixin.py#L33-L45
[ "def", "attach_ip", "(", "self", ",", "server", ",", "family", "=", "'IPv4'", ")", ":", "body", "=", "{", "'ip_address'", ":", "{", "'server'", ":", "str", "(", "server", ")", ",", "'family'", ":", "family", "}", "}", "res", "=", "self", ".", "requ...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
IPManager.modify_ip
Modify an IP address' ptr-record (Reverse DNS). Accepts an IPAddress instance (object) or its address (string).
upcloud_api/cloud_manager/ip_address_mixin.py
def modify_ip(self, ip_addr, ptr_record): """ Modify an IP address' ptr-record (Reverse DNS). Accepts an IPAddress instance (object) or its address (string). """ body = { 'ip_address': { 'ptr_record': ptr_record } } res = ...
def modify_ip(self, ip_addr, ptr_record): """ Modify an IP address' ptr-record (Reverse DNS). Accepts an IPAddress instance (object) or its address (string). """ body = { 'ip_address': { 'ptr_record': ptr_record } } res = ...
[ "Modify", "an", "IP", "address", "ptr", "-", "record", "(", "Reverse", "DNS", ")", "." ]
UpCloudLtd/upcloud-python-api
python
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/ip_address_mixin.py#L47-L60
[ "def", "modify_ip", "(", "self", ",", "ip_addr", ",", "ptr_record", ")", ":", "body", "=", "{", "'ip_address'", ":", "{", "'ptr_record'", ":", "ptr_record", "}", "}", "res", "=", "self", ".", "request", "(", "'PUT'", ",", "'/ip_address/'", "+", "str", ...
954b0ad7c4b932b2be31a95d88975f6b0eeac8ed
train
Feed.new
Creates a new Feed object :param user: feed username :param name: feed name :param description: feed description :return: dict
csirtgsdk/feed.py
def new(self, user, name, description=None): """ Creates a new Feed object :param user: feed username :param name: feed name :param description: feed description :return: dict """ uri = self.client.remote + '/users/{0}/feeds'.format(user) data = ...
def new(self, user, name, description=None): """ Creates a new Feed object :param user: feed username :param name: feed name :param description: feed description :return: dict """ uri = self.client.remote + '/users/{0}/feeds'.format(user) data = ...
[ "Creates", "a", "new", "Feed", "object" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/feed.py#L32-L51
[ "def", "new", "(", "self", ",", "user", ",", "name", ",", "description", "=", "None", ")", ":", "uri", "=", "self", ".", "client", ".", "remote", "+", "'/users/{0}/feeds'", ".", "format", "(", "user", ")", "data", "=", "{", "'feed'", ":", "{", "'na...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
Feed.delete
Removes a feed :param user: feed username :param name: feed name :return: true/false
csirtgsdk/feed.py
def delete(self, user, name): """ Removes a feed :param user: feed username :param name: feed name :return: true/false """ uri = self.client.remote + '/users/{}/feeds/{}'.format(user, name) resp = self.client.session.delete(uri) return resp.stat...
def delete(self, user, name): """ Removes a feed :param user: feed username :param name: feed name :return: true/false """ uri = self.client.remote + '/users/{}/feeds/{}'.format(user, name) resp = self.client.session.delete(uri) return resp.stat...
[ "Removes", "a", "feed" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/feed.py#L53-L65
[ "def", "delete", "(", "self", ",", "user", ",", "name", ")", ":", "uri", "=", "self", ".", "client", ".", "remote", "+", "'/users/{}/feeds/{}'", ".", "format", "(", "user", ",", "name", ")", "resp", "=", "self", ".", "client", ".", "session", ".", ...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
Feed.index
Returns a list of Feeds from the API :param user: feed username :return: list Example: ret = feed.index('csirtgadgets')
csirtgsdk/feed.py
def index(self, user): """ Returns a list of Feeds from the API :param user: feed username :return: list Example: ret = feed.index('csirtgadgets') """ uri = self.client.remote + '/users/{0}/feeds'.format(user) return self.client.get(uri)
def index(self, user): """ Returns a list of Feeds from the API :param user: feed username :return: list Example: ret = feed.index('csirtgadgets') """ uri = self.client.remote + '/users/{0}/feeds'.format(user) return self.client.get(uri)
[ "Returns", "a", "list", "of", "Feeds", "from", "the", "API" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/feed.py#L69-L80
[ "def", "index", "(", "self", ",", "user", ")", ":", "uri", "=", "self", ".", "client", ".", "remote", "+", "'/users/{0}/feeds'", ".", "format", "(", "user", ")", "return", "self", ".", "client", ".", "get", "(", "uri", ")" ]
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
Feed.show
Returns a specific Feed from the API :param user: feed username :param name: feed name :param limit: limit the results :param lasttime: only show >= lasttime :return: dict Example: ret = feed.show('csirtgadgets', 'port-scanners', limit=5)
csirtgsdk/feed.py
def show(self, user, name, limit=None, lasttime=None): """ Returns a specific Feed from the API :param user: feed username :param name: feed name :param limit: limit the results :param lasttime: only show >= lasttime :return: dict Example: re...
def show(self, user, name, limit=None, lasttime=None): """ Returns a specific Feed from the API :param user: feed username :param name: feed name :param limit: limit the results :param lasttime: only show >= lasttime :return: dict Example: re...
[ "Returns", "a", "specific", "Feed", "from", "the", "API" ]
csirtgadgets/csirtgsdk-py
python
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/feed.py#L82-L96
[ "def", "show", "(", "self", ",", "user", ",", "name", ",", "limit", "=", "None", ",", "lasttime", "=", "None", ")", ":", "uri", "=", "self", ".", "client", ".", "remote", "+", "'/users/{0}/feeds/{1}'", ".", "format", "(", "user", ",", "name", ")", ...
5a7ed9c5e6fa27170366ecbdef710dc80d537dc2
train
codenerix
Codenerix CONTEXT
codenerix/context.py
def codenerix(request): ''' Codenerix CONTEXT ''' # Get values DEBUG = getattr(settings, 'DEBUG', False) VERSION = getattr(settings, 'VERSION', _('WARNING: No version set to this code, add VERSION contant to your configuration')) # Set environment return { 'DEBUG': DEBUG, ...
def codenerix(request): ''' Codenerix CONTEXT ''' # Get values DEBUG = getattr(settings, 'DEBUG', False) VERSION = getattr(settings, 'VERSION', _('WARNING: No version set to this code, add VERSION contant to your configuration')) # Set environment return { 'DEBUG': DEBUG, ...
[ "Codenerix", "CONTEXT" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/context.py#L28-L41
[ "def", "codenerix", "(", "request", ")", ":", "# Get values", "DEBUG", "=", "getattr", "(", "settings", ",", "'DEBUG'", ",", "False", ")", "VERSION", "=", "getattr", "(", "settings", ",", "'VERSION'", ",", "_", "(", "'WARNING: No version set to this code, add VE...
1f5527b352141caaee902b37b2648791a06bd57d
train
ProfileView.build_object
Override django-bakery to skip profiles that raise 404
wafer/users/views.py
def build_object(self, obj): """Override django-bakery to skip profiles that raise 404""" try: build_path = self.get_build_path(obj) self.request = self.create_request(build_path) self.request.user = AnonymousUser() self.set_kwargs(obj) self.bu...
def build_object(self, obj): """Override django-bakery to skip profiles that raise 404""" try: build_path = self.get_build_path(obj) self.request = self.create_request(build_path) self.request.user = AnonymousUser() self.set_kwargs(obj) self.bu...
[ "Override", "django", "-", "bakery", "to", "skip", "profiles", "that", "raise", "404" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/users/views.py#L49-L59
[ "def", "build_object", "(", "self", ",", "obj", ")", ":", "try", ":", "build_path", "=", "self", ".", "get_build_path", "(", "obj", ")", "self", ".", "request", "=", "self", ".", "create_request", "(", "build_path", ")", "self", ".", "request", ".", "u...
a20af3c399267f76373dc342f4d542a9bc457c35
train
make_schedule_row
Create a row for the schedule table.
wafer/schedule/views.py
def make_schedule_row(schedule_day, slot, seen_items): """Create a row for the schedule table.""" row = ScheduleRow(schedule_day, slot) skip = {} expanding = {} all_items = list(slot.scheduleitem_set .select_related('talk', 'page', 'venue') .all()) for ...
def make_schedule_row(schedule_day, slot, seen_items): """Create a row for the schedule table.""" row = ScheduleRow(schedule_day, slot) skip = {} expanding = {} all_items = list(slot.scheduleitem_set .select_related('talk', 'page', 'venue') .all()) for ...
[ "Create", "a", "row", "for", "the", "schedule", "table", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L57-L108
[ "def", "make_schedule_row", "(", "schedule_day", ",", "slot", ",", "seen_items", ")", ":", "row", "=", "ScheduleRow", "(", "schedule_day", ",", "slot", ")", "skip", "=", "{", "}", "expanding", "=", "{", "}", "all_items", "=", "list", "(", "slot", ".", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
generate_schedule
Helper function which creates an ordered list of schedule days
wafer/schedule/views.py
def generate_schedule(today=None): """Helper function which creates an ordered list of schedule days""" # We create a list of slots and schedule items schedule_days = {} seen_items = {} for slot in Slot.objects.all().order_by('end_time', 'start_time', 'day'): day = slot.get_day() if ...
def generate_schedule(today=None): """Helper function which creates an ordered list of schedule days""" # We create a list of slots and schedule items schedule_days = {} seen_items = {} for slot in Slot.objects.all().order_by('end_time', 'start_time', 'day'): day = slot.get_day() if ...
[ "Helper", "function", "which", "creates", "an", "ordered", "list", "of", "schedule", "days" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L111-L126
[ "def", "generate_schedule", "(", "today", "=", "None", ")", ":", "# We create a list of slots and schedule items", "schedule_days", "=", "{", "}", "seen_items", "=", "{", "}", "for", "slot", "in", "Slot", ".", "objects", ".", "all", "(", ")", ".", "order_by", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
ScheduleXmlView.get_context_data
Allow adding a 'render_description' parameter
wafer/schedule/views.py
def get_context_data(self, **kwargs): """Allow adding a 'render_description' parameter""" context = super(ScheduleXmlView, self).get_context_data(**kwargs) if self.request.GET.get('render_description', None) == '1': context['render_description'] = True else: conte...
def get_context_data(self, **kwargs): """Allow adding a 'render_description' parameter""" context = super(ScheduleXmlView, self).get_context_data(**kwargs) if self.request.GET.get('render_description', None) == '1': context['render_description'] = True else: conte...
[ "Allow", "adding", "a", "render_description", "parameter" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L164-L171
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "ScheduleXmlView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "if", "self", ".", "request", ".", "GET", ".", "get", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
ICalView.get
Create a iCal file from the schedule
wafer/schedule/views.py
def get(self, request): """Create a iCal file from the schedule""" # Heavily inspired by https://djangosnippets.org/snippets/2223/ and # the icalendar documentation calendar = Calendar() site = get_current_site(request) calendar.add('prodid', '-//%s Schedule//%s//' % (sit...
def get(self, request): """Create a iCal file from the schedule""" # Heavily inspired by https://djangosnippets.org/snippets/2223/ and # the icalendar documentation calendar = Calendar() site = get_current_site(request) calendar.add('prodid', '-//%s Schedule//%s//' % (sit...
[ "Create", "a", "iCal", "file", "from", "the", "schedule" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L344-L367
[ "def", "get", "(", "self", ",", "request", ")", ":", "# Heavily inspired by https://djangosnippets.org/snippets/2223/ and", "# the icalendar documentation", "calendar", "=", "Calendar", "(", ")", "site", "=", "get_current_site", "(", "request", ")", "calendar", ".", "ad...
a20af3c399267f76373dc342f4d542a9bc457c35
train
slug
Look up a page by url (which is a tree of slugs)
wafer/pages/views.py
def slug(request, url): """Look up a page by url (which is a tree of slugs)""" page = None if url: for slug in url.split('/'): if not slug: continue try: page = Page.objects.get(slug=slug, parent=page) except Page.DoesNotExist: ...
def slug(request, url): """Look up a page by url (which is a tree of slugs)""" page = None if url: for slug in url.split('/'): if not slug: continue try: page = Page.objects.get(slug=slug, parent=page) except Page.DoesNotExist: ...
[ "Look", "up", "a", "page", "by", "url", "(", "which", "is", "a", "tree", "of", "slugs", ")" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/views.py#L88-L117
[ "def", "slug", "(", "request", ",", "url", ")", ":", "page", "=", "None", "if", "url", ":", "for", "slug", "in", "url", ".", "split", "(", "'/'", ")", ":", "if", "not", "slug", ":", "continue", "try", ":", "page", "=", "Page", ".", "objects", "...
a20af3c399267f76373dc342f4d542a9bc457c35
train
ShowPage.build_object
Override django-bakery to skip pages marked exclude_from_static
wafer/pages/views.py
def build_object(self, obj): """Override django-bakery to skip pages marked exclude_from_static""" if not obj.exclude_from_static: super(ShowPage, self).build_object(obj)
def build_object(self, obj): """Override django-bakery to skip pages marked exclude_from_static""" if not obj.exclude_from_static: super(ShowPage, self).build_object(obj)
[ "Override", "django", "-", "bakery", "to", "skip", "pages", "marked", "exclude_from_static" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/views.py#L23-L26
[ "def", "build_object", "(", "self", ",", "obj", ")", ":", "if", "not", "obj", ".", "exclude_from_static", ":", "super", "(", "ShowPage", ",", "self", ")", ".", "build_object", "(", "obj", ")" ]
a20af3c399267f76373dc342f4d542a9bc457c35
train
TalkView.build_object
Override django-bakery to skip talks that raise 403
wafer/talks/views.py
def build_object(self, obj): """Override django-bakery to skip talks that raise 403""" try: super(TalkView, self).build_object(obj) except PermissionDenied: # We cleanup the directory created self.unbuild_object(obj)
def build_object(self, obj): """Override django-bakery to skip talks that raise 403""" try: super(TalkView, self).build_object(obj) except PermissionDenied: # We cleanup the directory created self.unbuild_object(obj)
[ "Override", "django", "-", "bakery", "to", "skip", "talks", "that", "raise", "403" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L61-L67
[ "def", "build_object", "(", "self", ",", "obj", ")", ":", "try", ":", "super", "(", "TalkView", ",", "self", ")", ".", "build_object", "(", "obj", ")", "except", "PermissionDenied", ":", "# We cleanup the directory created", "self", ".", "unbuild_object", "(",...
a20af3c399267f76373dc342f4d542a9bc457c35
train
TalkView.get_object
Only talk owners can see talks, unless they've been accepted
wafer/talks/views.py
def get_object(self, *args, **kwargs): '''Only talk owners can see talks, unless they've been accepted''' object_ = super(TalkView, self).get_object(*args, **kwargs) if not object_.can_view(self.request.user): raise PermissionDenied return object_
def get_object(self, *args, **kwargs): '''Only talk owners can see talks, unless they've been accepted''' object_ = super(TalkView, self).get_object(*args, **kwargs) if not object_.can_view(self.request.user): raise PermissionDenied return object_
[ "Only", "talk", "owners", "can", "see", "talks", "unless", "they", "ve", "been", "accepted" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L74-L79
[ "def", "get_object", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "object_", "=", "super", "(", "TalkView", ",", "self", ")", ".", "get_object", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "not", "object_", ".", "ca...
a20af3c399267f76373dc342f4d542a9bc457c35
train
TalkView.render_to_response
Canonicalize the URL if the slug changed
wafer/talks/views.py
def render_to_response(self, *args, **kwargs): '''Canonicalize the URL if the slug changed''' if self.request.path != self.object.get_absolute_url(): return HttpResponseRedirect(self.object.get_absolute_url()) return super(TalkView, self).render_to_response(*args, **kwargs)
def render_to_response(self, *args, **kwargs): '''Canonicalize the URL if the slug changed''' if self.request.path != self.object.get_absolute_url(): return HttpResponseRedirect(self.object.get_absolute_url()) return super(TalkView, self).render_to_response(*args, **kwargs)
[ "Canonicalize", "the", "URL", "if", "the", "slug", "changed" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L81-L85
[ "def", "render_to_response", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "request", ".", "path", "!=", "self", ".", "object", ".", "get_absolute_url", "(", ")", ":", "return", "HttpResponseRedirect", "(", "self", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
TalkWithdraw.delete
Override delete to only withdraw
wafer/talks/views.py
def delete(self, request, *args, **kwargs): """Override delete to only withdraw""" talk = self.get_object() talk.status = WITHDRAWN talk.save() revisions.set_user(self.request.user) revisions.set_comment("Talk Withdrawn") return HttpResponseRedirect(self.success_u...
def delete(self, request, *args, **kwargs): """Override delete to only withdraw""" talk = self.get_object() talk.status = WITHDRAWN talk.save() revisions.set_user(self.request.user) revisions.set_comment("Talk Withdrawn") return HttpResponseRedirect(self.success_u...
[ "Override", "delete", "to", "only", "withdraw" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L173-L180
[ "def", "delete", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "talk", "=", "self", ".", "get_object", "(", ")", "talk", ".", "status", "=", "WITHDRAWN", "talk", ".", "save", "(", ")", "revisions", ".", "set_user...
a20af3c399267f76373dc342f4d542a9bc457c35
train
order_results_by
A decorator that applies an ordering to the QuerySet returned by a function.
wafer/utils.py
def order_results_by(*fields): """A decorator that applies an ordering to the QuerySet returned by a function. """ def decorator(f): @functools.wraps(f) def wrapper(*args, **kw): result = f(*args, **kw) return result.order_by(*fields) return wrapper ...
def order_results_by(*fields): """A decorator that applies an ordering to the QuerySet returned by a function. """ def decorator(f): @functools.wraps(f) def wrapper(*args, **kw): result = f(*args, **kw) return result.order_by(*fields) return wrapper ...
[ "A", "decorator", "that", "applies", "an", "ordering", "to", "the", "QuerySet", "returned", "by", "a", "function", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/utils.py#L21-L31
[ "def", "order_results_by", "(", "*", "fields", ")", ":", "def", "decorator", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "result", "=", "f", "(", "*", "ar...
a20af3c399267f76373dc342f4d542a9bc457c35
train
cache_result
A decorator for caching the result of a function.
wafer/utils.py
def cache_result(cache_key, timeout): """A decorator for caching the result of a function.""" def decorator(f): cache_name = settings.WAFER_CACHE @functools.wraps(f) def wrapper(*args, **kw): cache = caches[cache_name] result = cache.get(cache_key) if...
def cache_result(cache_key, timeout): """A decorator for caching the result of a function.""" def decorator(f): cache_name = settings.WAFER_CACHE @functools.wraps(f) def wrapper(*args, **kw): cache = caches[cache_name] result = cache.get(cache_key) if...
[ "A", "decorator", "for", "caching", "the", "result", "of", "a", "function", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/utils.py#L34-L54
[ "def", "cache_result", "(", "cache_key", ",", "timeout", ")", ":", "def", "decorator", "(", "f", ")", ":", "cache_name", "=", "settings", ".", "WAFER_CACHE", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
PaginatedBuildableListView.build_queryset
Override django-bakery's build logic to fake pagination.
wafer/utils.py
def build_queryset(self): """Override django-bakery's build logic to fake pagination.""" paths = [(os.path.join(self.build_prefix, 'index.html'), {})] self.request = None queryset = self.get_queryset() paginator = self.get_paginator(queryset, self.get_paginate_by(queryset)) ...
def build_queryset(self): """Override django-bakery's build logic to fake pagination.""" paths = [(os.path.join(self.build_prefix, 'index.html'), {})] self.request = None queryset = self.get_queryset() paginator = self.get_paginator(queryset, self.get_paginate_by(queryset)) ...
[ "Override", "django", "-", "bakery", "s", "build", "logic", "to", "fake", "pagination", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/utils.py#L83-L101
[ "def", "build_queryset", "(", "self", ")", ":", "paths", "=", "[", "(", "os", ".", "path", ".", "join", "(", "self", ".", "build_prefix", ",", "'index.html'", ")", ",", "{", "}", ")", "]", "self", ".", "request", "=", "None", "queryset", "=", "self...
a20af3c399267f76373dc342f4d542a9bc457c35
train
BaseForm.get_groups
<--------------------------------------- 12 columns ------------------------------------> <--- 6 columns ---> <--- 6 columns ---> ------------------------------------------ ------------------------------------------ | Info ...
codenerix/forms.py
def get_groups(self, gs=None, processed=[], initial=True): ''' <--------------------------------------- 12 columns ------------------------------------> <--- 6 columns ---> <--- 6 columns ---> ------------------------------------------ -----------...
def get_groups(self, gs=None, processed=[], initial=True): ''' <--------------------------------------- 12 columns ------------------------------------> <--- 6 columns ---> <--- 6 columns ---> ------------------------------------------ -----------...
[ "<", "---------------------------------------", "12", "columns", "------------------------------------", ">", "<", "---", "6", "columns", "---", ">", "<", "---", "6", "columns", "---", ">", "------------------------------------------", "-----------------------------------------...
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/forms.py#L95-L502
[ "def", "get_groups", "(", "self", ",", "gs", "=", "None", ",", "processed", "=", "[", "]", ",", "initial", "=", "True", ")", ":", "# Check if language is set", "if", "not", "self", ".", "__language", ":", "raise", "IOError", "(", "\"ERROR: No language suplie...
1f5527b352141caaee902b37b2648791a06bd57d
train
site_info
Expose the site's info to templates
wafer/context_processors.py
def site_info(request): '''Expose the site's info to templates''' site = get_current_site(request) context = { 'WAFER_CONFERENCE_NAME': site.name, 'WAFER_CONFERENCE_DOMAIN': site.domain, } return context
def site_info(request): '''Expose the site's info to templates''' site = get_current_site(request) context = { 'WAFER_CONFERENCE_NAME': site.name, 'WAFER_CONFERENCE_DOMAIN': site.domain, } return context
[ "Expose", "the", "site", "s", "info", "to", "templates" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/context_processors.py#L6-L13
[ "def", "site_info", "(", "request", ")", ":", "site", "=", "get_current_site", "(", "request", ")", "context", "=", "{", "'WAFER_CONFERENCE_NAME'", ":", "site", ".", "name", ",", "'WAFER_CONFERENCE_DOMAIN'", ":", "site", ".", "domain", ",", "}", "return", "c...
a20af3c399267f76373dc342f4d542a9bc457c35
train
navigation_info
Expose whether to display the navigation header and footer
wafer/context_processors.py
def navigation_info(request): '''Expose whether to display the navigation header and footer''' if request.GET.get('wafer_hide_navigation') == "1": nav_class = "wafer-invisible" else: nav_class = "wafer-visible" context = { 'WAFER_NAVIGATION_VISIBILITY': nav_class, } retur...
def navigation_info(request): '''Expose whether to display the navigation header and footer''' if request.GET.get('wafer_hide_navigation') == "1": nav_class = "wafer-invisible" else: nav_class = "wafer-visible" context = { 'WAFER_NAVIGATION_VISIBILITY': nav_class, } retur...
[ "Expose", "whether", "to", "display", "the", "navigation", "header", "and", "footer" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/context_processors.py#L16-L25
[ "def", "navigation_info", "(", "request", ")", ":", "if", "request", ".", "GET", ".", "get", "(", "'wafer_hide_navigation'", ")", "==", "\"1\"", ":", "nav_class", "=", "\"wafer-invisible\"", "else", ":", "nav_class", "=", "\"wafer-visible\"", "context", "=", "...
a20af3c399267f76373dc342f4d542a9bc457c35
train
registration_settings
Expose selected settings to templates
wafer/context_processors.py
def registration_settings(request): '''Expose selected settings to templates''' context = {} for setting in ( 'WAFER_SSO', 'WAFER_HIDE_LOGIN', 'WAFER_REGISTRATION_OPEN', 'WAFER_REGISTRATION_MODE', 'WAFER_TALKS_OPEN', 'WAFER_VIDEO_LICENS...
def registration_settings(request): '''Expose selected settings to templates''' context = {} for setting in ( 'WAFER_SSO', 'WAFER_HIDE_LOGIN', 'WAFER_REGISTRATION_OPEN', 'WAFER_REGISTRATION_MODE', 'WAFER_TALKS_OPEN', 'WAFER_VIDEO_LICENS...
[ "Expose", "selected", "settings", "to", "templates" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/context_processors.py#L37-L49
[ "def", "registration_settings", "(", "request", ")", ":", "context", "=", "{", "}", "for", "setting", "in", "(", "'WAFER_SSO'", ",", "'WAFER_HIDE_LOGIN'", ",", "'WAFER_REGISTRATION_OPEN'", ",", "'WAFER_REGISTRATION_MODE'", ",", "'WAFER_TALKS_OPEN'", ",", "'WAFER_VIDEO...
a20af3c399267f76373dc342f4d542a9bc457c35
train
GenPerson.profiles
return the rolls this people is related with
codenerix/models_people.py
def profiles(self): ''' return the rolls this people is related with ''' limit = [] if self.is_admin(): limit.append(_("Administrator")) limit.sort() return limit
def profiles(self): ''' return the rolls this people is related with ''' limit = [] if self.is_admin(): limit.append(_("Administrator")) limit.sort() return limit
[ "return", "the", "rolls", "this", "people", "is", "related", "with" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/models_people.py#L114-L124
[ "def", "profiles", "(", "self", ")", ":", "limit", "=", "[", "]", "if", "self", ".", "is_admin", "(", ")", ":", "limit", ".", "append", "(", "_", "(", "\"Administrator\"", ")", ")", "limit", ".", "sort", "(", ")", "return", "limit" ]
1f5527b352141caaee902b37b2648791a06bd57d
train
matern_function
r"""Matern covariance function of arbitrary dimension, for use with :py:class:`ArbitraryKernel`. The Matern kernel has the following hyperparameters, always referenced in the order listed: = ===== ==================================== 0 sigma prefactor 1 nu order of kernel 2 l1 le...
gptools/kernel/matern.py
def matern_function(Xi, Xj, *args): r"""Matern covariance function of arbitrary dimension, for use with :py:class:`ArbitraryKernel`. The Matern kernel has the following hyperparameters, always referenced in the order listed: = ===== ==================================== 0 sigma prefactor ...
def matern_function(Xi, Xj, *args): r"""Matern covariance function of arbitrary dimension, for use with :py:class:`ArbitraryKernel`. The Matern kernel has the following hyperparameters, always referenced in the order listed: = ===== ==================================== 0 sigma prefactor ...
[ "r", "Matern", "covariance", "function", "of", "arbitrary", "dimension", "for", "use", "with", ":", "py", ":", "class", ":", "ArbitraryKernel", ".", "The", "Matern", "kernel", "has", "the", "following", "hyperparameters", "always", "referenced", "in", "the", "...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L44-L100
[ "def", "matern_function", "(", "Xi", ",", "Xj", ",", "*", "args", ")", ":", "num_dim", "=", "len", "(", "args", ")", "-", "2", "nu", "=", "args", "[", "1", "]", "if", "isinstance", "(", "Xi", ",", "scipy", ".", "ndarray", ")", ":", "if", "isins...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
MaternKernel._compute_k
r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) :math:`k(\tau)` (less the :math...
gptools/kernel/matern.py
def _compute_k(self, tau): r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) ...
def _compute_k(self, tau): r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) ...
[ "r", "Evaluate", "the", "kernel", "directly", "at", "the", "given", "values", "of", "tau", ".", "Parameters", "----------", "tau", ":", ":", "py", ":", "class", ":", "Matrix", "(", "M", "D", ")", "M", "inputs", "with", "dimension", "D", ".", "Returns",...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L296-L312
[ "def", "_compute_k", "(", "self", ",", "tau", ")", ":", "y", ",", "r2l2", "=", "self", ".", "_compute_y", "(", "tau", ",", "return_r2l2", "=", "True", ")", "k", "=", "2.0", "**", "(", "1.0", "-", "self", ".", "nu", ")", "/", "scipy", ".", "spec...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
MaternKernel._compute_y
r"""Covert tau to :math:`y=2\nu\sum_i(\tau_i^2/l_i^2)`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. return_r2l2 : bool, optional Set to True to return a tuple of (`y`, `r2l2`). Default is False (on...
gptools/kernel/matern.py
def _compute_y(self, tau, return_r2l2=False): r"""Covert tau to :math:`y=2\nu\sum_i(\tau_i^2/l_i^2)`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. return_r2l2 : bool, optional Set to True to return a tu...
def _compute_y(self, tau, return_r2l2=False): r"""Covert tau to :math:`y=2\nu\sum_i(\tau_i^2/l_i^2)`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. return_r2l2 : bool, optional Set to True to return a tu...
[ "r", "Covert", "tau", "to", ":", "math", ":", "y", "=", "2", "\\", "nu", "\\", "sum_i", "(", "\\", "tau_i^2", "/", "l_i^2", ")", ".", "Parameters", "----------", "tau", ":", ":", "py", ":", "class", ":", "Matrix", "(", "M", "D", ")", "M", "inpu...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L314-L337
[ "def", "_compute_y", "(", "self", ",", "tau", ",", "return_r2l2", "=", "False", ")", ":", "r2l2", "=", "self", ".", "_compute_r2l2", "(", "tau", ")", "y", "=", "2.0", "*", "self", ".", "nu", "*", "r2l2", "if", "return_r2l2", ":", "return", "(", "y"...
225db52bfe6baef1516529ad22177aa2cf7b71e4