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
CapturesService.download
Download a capture as a PCAP file. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param inline: (optional) Use inline version of capture file. :rtype: tuple `(io.BytesIO, 'filename')`
cdrouter/captures.py
def download(self, id, seq, intf, inline=False): # pylint: disable=invalid-name,redefined-builtin """Download a capture as a PCAP file. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param inline: (optional) ...
def download(self, id, seq, intf, inline=False): # pylint: disable=invalid-name,redefined-builtin """Download a capture as a PCAP file. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param inline: (optional) ...
[ "Download", "a", "capture", "as", "a", "PCAP", "file", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/captures.py#L332-L346
[ "def", "download", "(", "self", ",", "id", ",", "seq", ",", "intf", ",", "inline", "=", "False", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "resp", "=", "self", ".", "service", ".", "get_id", "(", "self", ".", "_base", "(", "id", ",", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
CapturesService.summary
Get a capture's summary. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter: (optional) PCAP filter to apply as string. :param inline: (optional) Use inline version of capture file. :return: ...
cdrouter/captures.py
def summary(self, id, seq, intf, filter=None, inline=False): # pylint: disable=invalid-name,redefined-builtin """Get a capture's summary. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter: (optional...
def summary(self, id, seq, intf, filter=None, inline=False): # pylint: disable=invalid-name,redefined-builtin """Get a capture's summary. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter: (optional...
[ "Get", "a", "capture", "s", "summary", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/captures.py#L348-L362
[ "def", "summary", "(", "self", ",", "id", ",", "seq", ",", "intf", ",", "filter", "=", "None", ",", "inline", "=", "False", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "SummarySchema", "(", ")", "resp", "=", "self", ".", "s...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
CapturesService.decode
Get a capture's decode. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter: (optional) PCAP filter to apply as string. :param frame: (optional) Frame number to decode. :param inline: (optiona...
cdrouter/captures.py
def decode(self, id, seq, intf, filter=None, frame=None, inline=False): # pylint: disable=invalid-name,redefined-builtin """Get a capture's decode. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter:...
def decode(self, id, seq, intf, filter=None, frame=None, inline=False): # pylint: disable=invalid-name,redefined-builtin """Get a capture's decode. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :param filter:...
[ "Get", "a", "capture", "s", "decode", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/captures.py#L364-L379
[ "def", "decode", "(", "self", ",", "id", ",", "seq", ",", "intf", ",", "filter", "=", "None", ",", "frame", "=", "None", ",", "inline", "=", "False", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "DecodeSchema", "(", ")", "re...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
CapturesService.send_to_cloudshark
Send a capture to a CloudShark Appliance. Both cloudshark_appliance_url and cloudshark_appliance_token must be properly configured via system preferences. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. ...
cdrouter/captures.py
def send_to_cloudshark(self, id, seq, intf, inline=False): # pylint: disable=invalid-name,redefined-builtin """Send a capture to a CloudShark Appliance. Both cloudshark_appliance_url and cloudshark_appliance_token must be properly configured via system preferences. :param id: Result ID ...
def send_to_cloudshark(self, id, seq, intf, inline=False): # pylint: disable=invalid-name,redefined-builtin """Send a capture to a CloudShark Appliance. Both cloudshark_appliance_url and cloudshark_appliance_token must be properly configured via system preferences. :param id: Result ID ...
[ "Send", "a", "capture", "to", "a", "CloudShark", "Appliance", ".", "Both", "cloudshark_appliance_url", "and", "cloudshark_appliance_token", "must", "be", "properly", "configured", "via", "system", "preferences", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/captures.py#L398-L412
[ "def", "send_to_cloudshark", "(", "self", ",", "id", ",", "seq", ",", "intf", ",", "inline", "=", "False", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "CloudSharkSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "pos...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
get_dict_from_response
Check for errors in the response and return the resulting JSON.
invenio_oauthclient/contrib/globus.py
def get_dict_from_response(response): """Check for errors in the response and return the resulting JSON.""" if getattr(response, '_resp') and response._resp.code > 400: raise OAuthResponseError( 'Application mis-configuration in Globus', None, response ) return response....
def get_dict_from_response(response): """Check for errors in the response and return the resulting JSON.""" if getattr(response, '_resp') and response._resp.code > 400: raise OAuthResponseError( 'Application mis-configuration in Globus', None, response ) return response....
[ "Check", "for", "errors", "in", "the", "response", "and", "return", "the", "resulting", "JSON", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/globus.py#L88-L95
[ "def", "get_dict_from_response", "(", "response", ")", ":", "if", "getattr", "(", "response", ",", "'_resp'", ")", "and", "response", ".", "_resp", ".", "code", ">", "400", ":", "raise", "OAuthResponseError", "(", "'Application mis-configuration in Globus'", ",", ...
2500dc6935738107617aeade79e050d7608004bb
train
get_user_info
Get user information from Globus. See the docs here for v2/oauth/userinfo: https://docs.globus.org/api/auth/reference/
invenio_oauthclient/contrib/globus.py
def get_user_info(remote): """Get user information from Globus. See the docs here for v2/oauth/userinfo: https://docs.globus.org/api/auth/reference/ """ response = remote.get(GLOBUS_USER_INFO_URL) user_info = get_dict_from_response(response) response.data['username'] = response.data['prefer...
def get_user_info(remote): """Get user information from Globus. See the docs here for v2/oauth/userinfo: https://docs.globus.org/api/auth/reference/ """ response = remote.get(GLOBUS_USER_INFO_URL) user_info = get_dict_from_response(response) response.data['username'] = response.data['prefer...
[ "Get", "user", "information", "from", "Globus", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/globus.py#L98-L109
[ "def", "get_user_info", "(", "remote", ")", ":", "response", "=", "remote", ".", "get", "(", "GLOBUS_USER_INFO_URL", ")", "user_info", "=", "get_dict_from_response", "(", "response", ")", "response", ".", "data", "[", "'username'", "]", "=", "response", ".", ...
2500dc6935738107617aeade79e050d7608004bb
train
get_user_id
Get the Globus identity for a users given email. A Globus ID is a UUID that can uniquely identify a Globus user. See the docs here for v2/api/identities https://docs.globus.org/api/auth/reference/
invenio_oauthclient/contrib/globus.py
def get_user_id(remote, email): """Get the Globus identity for a users given email. A Globus ID is a UUID that can uniquely identify a Globus user. See the docs here for v2/api/identities https://docs.globus.org/api/auth/reference/ """ try: url = '{}?usernames={}'.format(GLOBUS_USER_ID_...
def get_user_id(remote, email): """Get the Globus identity for a users given email. A Globus ID is a UUID that can uniquely identify a Globus user. See the docs here for v2/api/identities https://docs.globus.org/api/auth/reference/ """ try: url = '{}?usernames={}'.format(GLOBUS_USER_ID_...
[ "Get", "the", "Globus", "identity", "for", "a", "users", "given", "email", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/globus.py#L112-L127
[ "def", "get_user_id", "(", "remote", ",", "email", ")", ":", "try", ":", "url", "=", "'{}?usernames={}'", ".", "format", "(", "GLOBUS_USER_ID_URL", ",", "email", ")", "user_id", "=", "get_dict_from_response", "(", "remote", ".", "get", "(", "url", ")", ")"...
2500dc6935738107617aeade79e050d7608004bb
train
account_info
Retrieve remote account information used to find local user. It returns a dictionary with the following structure: .. code-block:: python { 'user': { 'email': '...', 'profile': { 'username': '...', 'full_name': '...',...
invenio_oauthclient/contrib/globus.py
def account_info(remote, resp): """Retrieve remote account information used to find local user. It returns a dictionary with the following structure: .. code-block:: python { 'user': { 'email': '...', 'profile': { 'username': '...', ...
def account_info(remote, resp): """Retrieve remote account information used to find local user. It returns a dictionary with the following structure: .. code-block:: python { 'user': { 'email': '...', 'profile': { 'username': '...', ...
[ "Retrieve", "remote", "account", "information", "used", "to", "find", "local", "user", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/globus.py#L130-L169
[ "def", "account_info", "(", "remote", ",", "resp", ")", ":", "info", "=", "get_user_info", "(", "remote", ")", "return", "{", "'user'", ":", "{", "'email'", ":", "info", "[", "'email'", "]", ",", "'profile'", ":", "{", "'username'", ":", "info", "[", ...
2500dc6935738107617aeade79e050d7608004bb
train
account_setup
Perform additional setup after user have been logged in. :param remote: The remote application. :param token: The token value. :param resp: The response.
invenio_oauthclient/contrib/globus.py
def account_setup(remote, token, resp): """Perform additional setup after user have been logged in. :param remote: The remote application. :param token: The token value. :param resp: The response. """ info = get_user_info(remote) user_id = get_user_id(remote, info['preferred_username']) ...
def account_setup(remote, token, resp): """Perform additional setup after user have been logged in. :param remote: The remote application. :param token: The token value. :param resp: The response. """ info = get_user_info(remote) user_id = get_user_id(remote, info['preferred_username']) ...
[ "Perform", "additional", "setup", "after", "user", "have", "been", "logged", "in", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/globus.py#L172-L192
[ "def", "account_setup", "(", "remote", ",", "token", ",", "resp", ")", ":", "info", "=", "get_user_info", "(", "remote", ")", "user_id", "=", "get_user_id", "(", "remote", ",", "info", "[", "'preferred_username'", "]", ")", "with", "db", ".", "session", ...
2500dc6935738107617aeade79e050d7608004bb
train
disconnect_handler
Handle unlinking of remote account. :param remote: The remote application. :returns: The HTML response.
invenio_oauthclient/contrib/globus.py
def disconnect_handler(remote, *args, **kwargs): """Handle unlinking of remote account. :param remote: The remote application. :returns: The HTML response. """ if not current_user.is_authenticated: return current_app.login_manager.unauthorized() remote_account = RemoteAccount.get(user_...
def disconnect_handler(remote, *args, **kwargs): """Handle unlinking of remote account. :param remote: The remote application. :returns: The HTML response. """ if not current_user.is_authenticated: return current_app.login_manager.unauthorized() remote_account = RemoteAccount.get(user_...
[ "Handle", "unlinking", "of", "remote", "account", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/globus.py#L195-L217
[ "def", "disconnect_handler", "(", "remote", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "current_user", ".", "is_authenticated", ":", "return", "current_app", ".", "login_manager", ".", "unauthorized", "(", ")", "remote_account", "=", "...
2500dc6935738107617aeade79e050d7608004bb
train
get_function_signature
Return the signature string of the specified function. >>> def foo(name): pass >>> get_function_signature(foo) 'foo(name)' >>> something = 'Hello' >>> get_function_signature(something) Traceback (most recent call last): ... TypeError: The argument must be a function object: None typ...
common_cache/utils.py
def get_function_signature(func): """ Return the signature string of the specified function. >>> def foo(name): pass >>> get_function_signature(foo) 'foo(name)' >>> something = 'Hello' >>> get_function_signature(something) Traceback (most recent call last): ... TypeError: Th...
def get_function_signature(func): """ Return the signature string of the specified function. >>> def foo(name): pass >>> get_function_signature(foo) 'foo(name)' >>> something = 'Hello' >>> get_function_signature(something) Traceback (most recent call last): ... TypeError: Th...
[ "Return", "the", "signature", "string", "of", "the", "specified", "function", "." ]
SylvanasSun/python-common-cache
python
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/utils.py#L10-L34
[ "def", "get_function_signature", "(", "func", ")", ":", "if", "func", "is", "None", ":", "return", "'Function is None'", "try", ":", "func_name", "=", "func", ".", "__name__", "except", "AttributeError", ":", "func_name", "=", "'None'", "if", "not", "inspect",...
f113eb3cd751eed5ab5373e8610a31a444220cf8
train
RWLock.acquire_reader
Acquire a read lock, several threads can hold this type of lock.
common_cache/utils.py
def acquire_reader(self): """ Acquire a read lock, several threads can hold this type of lock. """ with self.mutex: while self.rwlock < 0 or self.rwlock == self.max_reader_concurrency or self.writers_waiting: self.readers_ok.wait() self.rwlock += 1
def acquire_reader(self): """ Acquire a read lock, several threads can hold this type of lock. """ with self.mutex: while self.rwlock < 0 or self.rwlock == self.max_reader_concurrency or self.writers_waiting: self.readers_ok.wait() self.rwlock += 1
[ "Acquire", "a", "read", "lock", "several", "threads", "can", "hold", "this", "type", "of", "lock", "." ]
SylvanasSun/python-common-cache
python
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/utils.py#L73-L80
[ "def", "acquire_reader", "(", "self", ")", ":", "with", "self", ".", "mutex", ":", "while", "self", ".", "rwlock", "<", "0", "or", "self", ".", "rwlock", "==", "self", ".", "max_reader_concurrency", "or", "self", ".", "writers_waiting", ":", "self", ".",...
f113eb3cd751eed5ab5373e8610a31a444220cf8
train
RWLock.acquire_writer
Acquire a write lock, only one thread can hold this lock and only when no read locks are also held.
common_cache/utils.py
def acquire_writer(self): """ Acquire a write lock, only one thread can hold this lock and only when no read locks are also held. """ with self.mutex: while self.rwlock != 0: self._writer_wait() self.rwlock = -1
def acquire_writer(self): """ Acquire a write lock, only one thread can hold this lock and only when no read locks are also held. """ with self.mutex: while self.rwlock != 0: self._writer_wait() self.rwlock = -1
[ "Acquire", "a", "write", "lock", "only", "one", "thread", "can", "hold", "this", "lock", "and", "only", "when", "no", "read", "locks", "are", "also", "held", "." ]
SylvanasSun/python-common-cache
python
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/utils.py#L82-L90
[ "def", "acquire_writer", "(", "self", ")", ":", "with", "self", ".", "mutex", ":", "while", "self", ".", "rwlock", "!=", "0", ":", "self", ".", "_writer_wait", "(", ")", "self", ".", "rwlock", "=", "-", "1" ]
f113eb3cd751eed5ab5373e8610a31a444220cf8
train
RWLock.promote
Promote an already acquired read lock to a write lock notice: this function can easily cause a deadlock!!!!!!!!!
common_cache/utils.py
def promote(self): """ Promote an already acquired read lock to a write lock notice: this function can easily cause a deadlock!!!!!!!!! """ with self.mutex: self.rwlock -= 1 while self.rwlock != 0: self._writer_wait() self.rwloc...
def promote(self): """ Promote an already acquired read lock to a write lock notice: this function can easily cause a deadlock!!!!!!!!! """ with self.mutex: self.rwlock -= 1 while self.rwlock != 0: self._writer_wait() self.rwloc...
[ "Promote", "an", "already", "acquired", "read", "lock", "to", "a", "write", "lock", "notice", ":", "this", "function", "can", "easily", "cause", "a", "deadlock!!!!!!!!!" ]
SylvanasSun/python-common-cache
python
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/utils.py#L92-L101
[ "def", "promote", "(", "self", ")", ":", "with", "self", ".", "mutex", ":", "self", ".", "rwlock", "-=", "1", "while", "self", ".", "rwlock", "!=", "0", ":", "self", ".", "_writer_wait", "(", ")", "self", ".", "rwlock", "=", "-", "1" ]
f113eb3cd751eed5ab5373e8610a31a444220cf8
train
PackagesService.list
Get a list of packages. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Pa...
cdrouter/packages.py
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of packages. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields...
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of packages. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields...
[ "Get", "a", "list", "of", "packages", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/packages.py#L190-L203
[ "def", "list", "(", "self", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "sort", "=", "None", ",", "limit", "=", "None", ",", "page", "=", "None", ")", ":", "# pylint: disable=redefined-builtin", "schema", "=", "PackageSchema", "(", "exclud...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
PackagesService.get
Get a package. :param id: Package ID as an int. :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package
cdrouter/packages.py
def get(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a package. :param id: Package ID as an int. :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package """ schema = PackageSchema() resp = self.service.get_id(se...
def get(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a package. :param id: Package ID as an int. :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package """ schema = PackageSchema() resp = self.service.get_id(se...
[ "Get", "a", "package", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/packages.py#L218-L227
[ "def", "get", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "PackageSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get_id", "(", "self", ".", "base", ",", "id", ")", "return", "self", "....
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
PackagesService.create
Create a new package. :param resource: :class:`packages.Package <packages.Package>` object :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package
cdrouter/packages.py
def create(self, resource): """Create a new package. :param resource: :class:`packages.Package <packages.Package>` object :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package """ schema = PackageSchema(exclude=('id', 'created', 'updated',...
def create(self, resource): """Create a new package. :param resource: :class:`packages.Package <packages.Package>` object :return: :class:`packages.Package <packages.Package>` object :rtype: packages.Package """ schema = PackageSchema(exclude=('id', 'created', 'updated',...
[ "Create", "a", "new", "package", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/packages.py#L241-L253
[ "def", "create", "(", "self", ",", "resource", ")", ":", "schema", "=", "PackageSchema", "(", "exclude", "=", "(", "'id'", ",", "'created'", ",", "'updated'", ",", "'test_count'", ",", "'agent_id'", ",", "'result_id'", ")", ")", "json", "=", "self", ".",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
PackagesService.analyze
Get a list of tests that will be skipped for a package. :param id: Package ID as an int. :return: :class:`packages.Analysis <packages.Analysis>` object :rtype: packages.Analysis
cdrouter/packages.py
def analyze(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a list of tests that will be skipped for a package. :param id: Package ID as an int. :return: :class:`packages.Analysis <packages.Analysis>` object :rtype: packages.Analysis """ schema = Analy...
def analyze(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a list of tests that will be skipped for a package. :param id: Package ID as an int. :return: :class:`packages.Analysis <packages.Analysis>` object :rtype: packages.Analysis """ schema = Analy...
[ "Get", "a", "list", "of", "tests", "that", "will", "be", "skipped", "for", "a", "package", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/packages.py#L301-L310
[ "def", "analyze", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "AnalysisSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
PackagesService.bulk_copy
Bulk copy a set of packages. :param ids: Int list of package IDs. :return: :class:`packages.Package <packages.Package>` list
cdrouter/packages.py
def bulk_copy(self, ids): """Bulk copy a set of packages. :param ids: Int list of package IDs. :return: :class:`packages.Package <packages.Package>` list """ schema = PackageSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
def bulk_copy(self, ids): """Bulk copy a set of packages. :param ids: Int list of package IDs. :return: :class:`packages.Package <packages.Package>` list """ schema = PackageSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
[ "Bulk", "copy", "a", "set", "of", "packages", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/packages.py#L320-L327
[ "def", "bulk_copy", "(", "self", ",", "ids", ")", ":", "schema", "=", "PackageSchema", "(", ")", "return", "self", ".", "service", ".", "bulk_copy", "(", "self", ".", "base", ",", "self", ".", "RESOURCE", ",", "ids", ",", "schema", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
PackagesService.bulk_edit
Bulk edit a set of packages. :param _fields: :class:`packages.Package <packages.Package>` object :param ids: (optional) Int list of package IDs. :param filter: (optional) String list of filters. :param type: (optional) `union` or `inter` as string. :param all: (optional) Apply t...
cdrouter/packages.py
def bulk_edit(self, _fields, ids=None, filter=None, type=None, all=False): # pylint: disable=redefined-builtin """Bulk edit a set of packages. :param _fields: :class:`packages.Package <packages.Package>` object :param ids: (optional) Int list of package IDs. :param filter: (optional) St...
def bulk_edit(self, _fields, ids=None, filter=None, type=None, all=False): # pylint: disable=redefined-builtin """Bulk edit a set of packages. :param _fields: :class:`packages.Package <packages.Package>` object :param ids: (optional) Int list of package IDs. :param filter: (optional) St...
[ "Bulk", "edit", "a", "set", "of", "packages", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/packages.py#L329-L341
[ "def", "bulk_edit", "(", "self", ",", "_fields", ",", "ids", "=", "None", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "all", "=", "False", ")", ":", "# pylint: disable=redefined-builtin", "schema", "=", "PackageSchema", "(", "exclude", "=", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
clean_lines
Generate strings that are not comments or lines with only whitespace. Purpose: This function is a generator that will read in either a | plain text file of strings(IP list, command list, etc), a | comma separated string of strings, or a list of strings. It | will crop out any comme...
jaide/utils.py
def clean_lines(commands): """ Generate strings that are not comments or lines with only whitespace. Purpose: This function is a generator that will read in either a | plain text file of strings(IP list, command list, etc), a | comma separated string of strings, or a list of strings. It ...
def clean_lines(commands): """ Generate strings that are not comments or lines with only whitespace. Purpose: This function is a generator that will read in either a | plain text file of strings(IP list, command list, etc), a | comma separated string of strings, or a list of strings. It ...
[ "Generate", "strings", "that", "are", "not", "comments", "or", "lines", "with", "only", "whitespace", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/utils.py#L8-L54
[ "def", "clean_lines", "(", "commands", ")", ":", "if", "isinstance", "(", "commands", ",", "basestring", ")", ":", "# if the command argument is a filename, we need to open it.", "if", "path", ".", "isfile", "(", "commands", ")", ":", "commands", "=", "open", "(",...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
xpath
Filter xml based on an xpath expression. Purpose: This function applies an Xpath expression to the XML | supplied by source_xml. Returns a string subtree or | subtrees that match the Xpath expression. It can also return | an xml object if desired. @param source_xml: Plain text...
jaide/utils.py
def xpath(source_xml, xpath_expr, req_format='string'): """ Filter xml based on an xpath expression. Purpose: This function applies an Xpath expression to the XML | supplied by source_xml. Returns a string subtree or | subtrees that match the Xpath expression. It can also return ...
def xpath(source_xml, xpath_expr, req_format='string'): """ Filter xml based on an xpath expression. Purpose: This function applies an Xpath expression to the XML | supplied by source_xml. Returns a string subtree or | subtrees that match the Xpath expression. It can also return ...
[ "Filter", "xml", "based", "on", "an", "xpath", "expression", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/utils.py#L57-L97
[ "def", "xpath", "(", "source_xml", ",", "xpath_expr", ",", "req_format", "=", "'string'", ")", ":", "tree", "=", "source_xml", "if", "not", "isinstance", "(", "source_xml", ",", "ET", ".", "Element", ")", ":", "tree", "=", "objectify", ".", "fromstring", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
lowcase_str_boolean
Делает из obj строку `true` или `false`
yandex_weather_api/__init__.py
def lowcase_str_boolean(obj): "Делает из obj строку `true` или `false`" if isinstance(obj, str): if obj not in ["true", "false"]: raise RuntimeError( 'Expecting "true" or "false", got {}'.format(obj)) return obj return str(bool(obj)).lower()
def lowcase_str_boolean(obj): "Делает из obj строку `true` или `false`" if isinstance(obj, str): if obj not in ["true", "false"]: raise RuntimeError( 'Expecting "true" or "false", got {}'.format(obj)) return obj return str(bool(obj)).lower()
[ "Делает", "из", "obj", "строку", "true", "или", "false" ]
ASMfreaK/yandex_weather_api
python
https://github.com/ASMfreaK/yandex_weather_api/blob/d58ad80f7389dc3b58c721bb42c2441e9ff3e351/yandex_weather_api/__init__.py#L48-L55
[ "def", "lowcase_str_boolean", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "if", "obj", "not", "in", "[", "\"true\"", ",", "\"false\"", "]", ":", "raise", "RuntimeError", "(", "'Expecting \"true\" or \"false\", got {}'", ".", "...
d58ad80f7389dc3b58c721bb42c2441e9ff3e351
train
validate_args
Проверяет и формирует аргументы для запроса
yandex_weather_api/__init__.py
def validate_args(api_key, *, rate="informers", **kwargs): "Проверяет и формирует аргументы для запроса" rate = Rate.validate(rate) headers = {"X-Yandex-API-Key": api_key} url = "https://api.weather.yandex.ru/v1/{}".format(rate) if rate == "informers": params = ARGS_SCHEMA(kwargs) else: ...
def validate_args(api_key, *, rate="informers", **kwargs): "Проверяет и формирует аргументы для запроса" rate = Rate.validate(rate) headers = {"X-Yandex-API-Key": api_key} url = "https://api.weather.yandex.ru/v1/{}".format(rate) if rate == "informers": params = ARGS_SCHEMA(kwargs) else: ...
[ "Проверяет", "и", "формирует", "аргументы", "для", "запроса" ]
ASMfreaK/yandex_weather_api
python
https://github.com/ASMfreaK/yandex_weather_api/blob/d58ad80f7389dc3b58c721bb42c2441e9ff3e351/yandex_weather_api/__init__.py#L72-L81
[ "def", "validate_args", "(", "api_key", ",", "*", ",", "rate", "=", "\"informers\"", ",", "*", "*", "kwargs", ")", ":", "rate", "=", "Rate", ".", "validate", "(", "rate", ")", "headers", "=", "{", "\"X-Yandex-API-Key\"", ":", "api_key", "}", "url", "="...
d58ad80f7389dc3b58c721bb42c2441e9ff3e351
train
get
Выполняет доступ к API. session - модуль requests или сессия из него api_key - строка ключа доступа к API rate - тариф, может быть `informers` или `forecast` lat, lon - широта и долгота ``` import yandex_weather_api import requests as req yandex_weather_api.get(req, "ЗАМЕНИ_МЕНЯ_КЛЮЧО...
yandex_weather_api/__init__.py
def get(session, api_key, **kwargs): """ Выполняет доступ к API. session - модуль requests или сессия из него api_key - строка ключа доступа к API rate - тариф, может быть `informers` или `forecast` lat, lon - широта и долгота ``` import yandex_weather_api import requests as req ...
def get(session, api_key, **kwargs): """ Выполняет доступ к API. session - модуль requests или сессия из него api_key - строка ключа доступа к API rate - тариф, может быть `informers` или `forecast` lat, lon - широта и долгота ``` import yandex_weather_api import requests as req ...
[ "Выполняет", "доступ", "к", "API", "." ]
ASMfreaK/yandex_weather_api
python
https://github.com/ASMfreaK/yandex_weather_api/blob/d58ad80f7389dc3b58c721bb42c2441e9ff3e351/yandex_weather_api/__init__.py#L84-L102
[ "def", "get", "(", "session", ",", "api_key", ",", "*", "*", "kwargs", ")", ":", "args", ",", "kwargs", "=", "validate_args", "(", "api_key", ",", "*", "*", "kwargs", ")", "resp", "=", "session", ".", "get", "(", "*", "args", ",", "*", "*", "kwar...
d58ad80f7389dc3b58c721bb42c2441e9ff3e351
train
Client.status
Get etcd status. :param timeout: Request timeout in seconds. :type timeout: int :returns: The current etcd cluster status. :rtype: instance of :class:`txaioetcd.Status`
txaioetcd/_client_tx.py
def status(self, timeout=None): """ Get etcd status. :param timeout: Request timeout in seconds. :type timeout: int :returns: The current etcd cluster status. :rtype: instance of :class:`txaioetcd.Status` """ assembler = commons.StatusRequestAssembler(se...
def status(self, timeout=None): """ Get etcd status. :param timeout: Request timeout in seconds. :type timeout: int :returns: The current etcd cluster status. :rtype: instance of :class:`txaioetcd.Status` """ assembler = commons.StatusRequestAssembler(se...
[ "Get", "etcd", "status", "." ]
crossbario/txaio-etcd
python
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L237-L253
[ "def", "status", "(", "self", ",", "timeout", "=", "None", ")", ":", "assembler", "=", "commons", ".", "StatusRequestAssembler", "(", "self", ".", "_url", ")", "obj", "=", "yield", "self", ".", "_post", "(", "assembler", ".", "url", ",", "assembler", "...
c9aebff7f288a0b219bffc9d2579d22cf543baa5
train
Client.set
Set the value for the key in the key-value store. Setting a value on a key increments the revision of the key-value store and generates one event in the event history. :param key: key is the key, in bytes, to put into the key-value store. :type key: bytes :...
txaioetcd/_client_tx.py
def set(self, key, value, lease=None, return_previous=None, timeout=None): """ Set the value for the key in the key-value store. Setting a value on a key increments the revision of the key-value store and generates one event in the event history. :param key: key is the ...
def set(self, key, value, lease=None, return_previous=None, timeout=None): """ Set the value for the key in the key-value store. Setting a value on a key increments the revision of the key-value store and generates one event in the event history. :param key: key is the ...
[ "Set", "the", "value", "for", "the", "key", "in", "the", "key", "-", "value", "store", "." ]
crossbario/txaio-etcd
python
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L256-L291
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "lease", "=", "None", ",", "return_previous", "=", "None", ",", "timeout", "=", "None", ")", ":", "assembler", "=", "commons", ".", "PutRequestAssembler", "(", "self", ".", "_url", ",", "key", ...
c9aebff7f288a0b219bffc9d2579d22cf543baa5
train
Client.get
Range gets the keys in the range from the key-value store. :param key: key is the first key for the range. If range_end is not given, the request only looks up key. :type key: bytes :param range_end: range_end is the upper bound on the requested range [key, range_end). ...
txaioetcd/_client_tx.py
def get(self, key, range_end=None, count_only=None, keys_only=None, limit=None, max_create_revision=None, min_create_revision=None, min_mod_revision=None, revision=None, serializable=None, ...
def get(self, key, range_end=None, count_only=None, keys_only=None, limit=None, max_create_revision=None, min_create_revision=None, min_mod_revision=None, revision=None, serializable=None, ...
[ "Range", "gets", "the", "keys", "in", "the", "range", "from", "the", "key", "-", "value", "store", "." ]
crossbario/txaio-etcd
python
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L294-L381
[ "def", "get", "(", "self", ",", "key", ",", "range_end", "=", "None", ",", "count_only", "=", "None", ",", "keys_only", "=", "None", ",", "limit", "=", "None", ",", "max_create_revision", "=", "None", ",", "min_create_revision", "=", "None", ",", "min_mo...
c9aebff7f288a0b219bffc9d2579d22cf543baa5
train
Client.delete
Delete value(s) from etcd. :param key: key is the first key to delete in the range. :type key: bytes or instance of :class:`txaioetcd.KeySet` :param return_previous: If enabled, return the deleted key-value pairs :type return_previous: bool or None :param timeout: Request time...
txaioetcd/_client_tx.py
def delete(self, key, return_previous=None, timeout=None): """ Delete value(s) from etcd. :param key: key is the first key to delete in the range. :type key: bytes or instance of :class:`txaioetcd.KeySet` :param return_previous: If enabled, return the deleted key-value pairs ...
def delete(self, key, return_previous=None, timeout=None): """ Delete value(s) from etcd. :param key: key is the first key to delete in the range. :type key: bytes or instance of :class:`txaioetcd.KeySet` :param return_previous: If enabled, return the deleted key-value pairs ...
[ "Delete", "value", "(", "s", ")", "from", "etcd", "." ]
crossbario/txaio-etcd
python
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L384-L406
[ "def", "delete", "(", "self", ",", "key", ",", "return_previous", "=", "None", ",", "timeout", "=", "None", ")", ":", "assembler", "=", "commons", ".", "DeleteRequestAssembler", "(", "self", ".", "_url", ",", "key", ",", "return_previous", ")", "obj", "=...
c9aebff7f288a0b219bffc9d2579d22cf543baa5
train
Client.watch
Watch one or more keys or key sets and invoke a callback. Watch watches for events happening or that have happened. The entire event history can be watched starting from the last compaction revision. :param keys: Watch these keys / key sets. :type keys: list of bytes or list of instanc...
txaioetcd/_client_tx.py
def watch(self, keys, on_watch, filters=None, start_revision=None, return_previous=None): """ Watch one or more keys or key sets and invoke a callback. Watch watches for events happening or that have happened. The entire event history can be watched starting from the last compaction rev...
def watch(self, keys, on_watch, filters=None, start_revision=None, return_previous=None): """ Watch one or more keys or key sets and invoke a callback. Watch watches for events happening or that have happened. The entire event history can be watched starting from the last compaction rev...
[ "Watch", "one", "or", "more", "keys", "or", "key", "sets", "and", "invoke", "a", "callback", "." ]
crossbario/txaio-etcd
python
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L408-L446
[ "def", "watch", "(", "self", ",", "keys", ",", "on_watch", ",", "filters", "=", "None", ",", "start_revision", "=", "None", ",", "return_previous", "=", "None", ")", ":", "d", "=", "self", ".", "_start_watching", "(", "keys", ",", "on_watch", ",", "fil...
c9aebff7f288a0b219bffc9d2579d22cf543baa5
train
Client.submit
Submit a transaction. Processes multiple requests in a single transaction. A transaction increments the revision of the key-value store and generates events with the same revision for every completed request. It is not allowed to modify the same key several times within...
txaioetcd/_client_tx.py
def submit(self, txn, timeout=None): """ Submit a transaction. Processes multiple requests in a single transaction. A transaction increments the revision of the key-value store and generates events with the same revision for every completed request. It is not al...
def submit(self, txn, timeout=None): """ Submit a transaction. Processes multiple requests in a single transaction. A transaction increments the revision of the key-value store and generates events with the same revision for every completed request. It is not al...
[ "Submit", "a", "transaction", "." ]
crossbario/txaio-etcd
python
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L528-L587
[ "def", "submit", "(", "self", ",", "txn", ",", "timeout", "=", "None", ")", ":", "url", "=", "ENDPOINT_SUBMIT", ".", "format", "(", "self", ".", "_url", ")", ".", "encode", "(", ")", "data", "=", "txn", ".", "_marshal", "(", ")", "obj", "=", "yie...
c9aebff7f288a0b219bffc9d2579d22cf543baa5
train
Client.lease
Creates a lease which expires if the server does not receive a keep alive within a given time to live period. All keys attached to the lease will be expired and deleted if the lease expires. Each expired key generates a delete event in the event history. :param time_to_live: T...
txaioetcd/_client_tx.py
def lease(self, time_to_live, lease_id=None, timeout=None): """ Creates a lease which expires if the server does not receive a keep alive within a given time to live period. All keys attached to the lease will be expired and deleted if the lease expires. Each expired ke...
def lease(self, time_to_live, lease_id=None, timeout=None): """ Creates a lease which expires if the server does not receive a keep alive within a given time to live period. All keys attached to the lease will be expired and deleted if the lease expires. Each expired ke...
[ "Creates", "a", "lease", "which", "expires", "if", "the", "server", "does", "not", "receive", "a", "keep", "alive", "within", "a", "given", "time", "to", "live", "period", "." ]
crossbario/txaio-etcd
python
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L590-L620
[ "def", "lease", "(", "self", ",", "time_to_live", ",", "lease_id", "=", "None", ",", "timeout", "=", "None", ")", ":", "assembler", "=", "commons", ".", "LeaseRequestAssembler", "(", "self", ".", "_url", ",", "time_to_live", ",", "lease_id", ")", "obj", ...
c9aebff7f288a0b219bffc9d2579d22cf543baa5
train
ImportsService.list
Get a list of staged (in-progress) imports. :return: :class:`imports.Import <imports.Import>` list
cdrouter/imports.py
def list(self): """Get a list of staged (in-progress) imports. :return: :class:`imports.Import <imports.Import>` list """ schema = ImportSchema() resp = self.service.list(self.base) return self.service.decode(schema, resp, many=True)
def list(self): """Get a list of staged (in-progress) imports. :return: :class:`imports.Import <imports.Import>` list """ schema = ImportSchema() resp = self.service.list(self.base) return self.service.decode(schema, resp, many=True)
[ "Get", "a", "list", "of", "staged", "(", "in", "-", "progress", ")", "imports", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/imports.py#L144-L151
[ "def", "list", "(", "self", ")", ":", "schema", "=", "ImportSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "list", "(", "self", ".", "base", ")", "return", "self", ".", "service", ".", "decode", "(", "schema", ",", "resp", ",", "many"...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
ImportsService.stage_import_from_file
Stage an import from a file upload. :param fd: File-like object to upload. :param filename: (optional) Filename to use for import as string. :return: :class:`imports.Import <imports.Import>` object
cdrouter/imports.py
def stage_import_from_file(self, fd, filename='upload.gz'): """Stage an import from a file upload. :param fd: File-like object to upload. :param filename: (optional) Filename to use for import as string. :return: :class:`imports.Import <imports.Import>` object """ schema...
def stage_import_from_file(self, fd, filename='upload.gz'): """Stage an import from a file upload. :param fd: File-like object to upload. :param filename: (optional) Filename to use for import as string. :return: :class:`imports.Import <imports.Import>` object """ schema...
[ "Stage", "an", "import", "from", "a", "file", "upload", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/imports.py#L153-L163
[ "def", "stage_import_from_file", "(", "self", ",", "fd", ",", "filename", "=", "'upload.gz'", ")", ":", "schema", "=", "ImportSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "files", "=", "{", "'file'...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
ImportsService.stage_import_from_filesystem
Stage an import from a filesystem path. :param filepath: Local filesystem path as string. :return: :class:`imports.Import <imports.Import>` object
cdrouter/imports.py
def stage_import_from_filesystem(self, filepath): """Stage an import from a filesystem path. :param filepath: Local filesystem path as string. :return: :class:`imports.Import <imports.Import>` object """ schema = ImportSchema() resp = self.service.post(self.base, ...
def stage_import_from_filesystem(self, filepath): """Stage an import from a filesystem path. :param filepath: Local filesystem path as string. :return: :class:`imports.Import <imports.Import>` object """ schema = ImportSchema() resp = self.service.post(self.base, ...
[ "Stage", "an", "import", "from", "a", "filesystem", "path", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/imports.py#L165-L174
[ "def", "stage_import_from_filesystem", "(", "self", ",", "filepath", ")", ":", "schema", "=", "ImportSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", ",", "params", "=", "{", "'path'", ":", "filepath", "}", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
ImportsService.stage_import_from_url
Stage an import from a URL to another CDRouter system. :param url: URL to import as string. :param token: (optional) API token to use as string (may be required if importing from a CDRouter 10+ system). :param username: (optional) API username to use as string (may be required if importing from...
cdrouter/imports.py
def stage_import_from_url(self, url, token=None, username=None, password=None, insecure=False): """Stage an import from a URL to another CDRouter system. :param url: URL to import as string. :param token: (optional) API token to use as string (may be required if importing from a CDRouter 10+ sy...
def stage_import_from_url(self, url, token=None, username=None, password=None, insecure=False): """Stage an import from a URL to another CDRouter system. :param url: URL to import as string. :param token: (optional) API token to use as string (may be required if importing from a CDRouter 10+ sy...
[ "Stage", "an", "import", "from", "a", "URL", "to", "another", "CDRouter", "system", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/imports.py#L176-L189
[ "def", "stage_import_from_url", "(", "self", ",", "url", ",", "token", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ",", "insecure", "=", "False", ")", ":", "schema", "=", "ImportSchema", "(", ")", "resp", "=", "self", ".", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
ImportsService.get_commit_request
Get a commit request for a staged import. :param id: Staged import ID as an int. :return: :class:`imports.Request <imports.Request>` object :rtype: imports.Request
cdrouter/imports.py
def get_commit_request(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a commit request for a staged import. :param id: Staged import ID as an int. :return: :class:`imports.Request <imports.Request>` object :rtype: imports.Request """ schema = RequestS...
def get_commit_request(self, id): # pylint: disable=invalid-name,redefined-builtin """Get a commit request for a staged import. :param id: Staged import ID as an int. :return: :class:`imports.Request <imports.Request>` object :rtype: imports.Request """ schema = RequestS...
[ "Get", "a", "commit", "request", "for", "a", "staged", "import", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/imports.py#L202-L211
[ "def", "get_commit_request", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "RequestSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "str", "(", "id", ")"...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
ImportsService.commit
Commit a staged import. :param id: Staged import ID as an int. :param impreq: :class:`imports.Request <imports.Request>` object :return: :class:`imports.Request <imports.Request>` object :rtype: imports.Request
cdrouter/imports.py
def commit(self, id, impreq): # pylint: disable=invalid-name,redefined-builtin """Commit a staged import. :param id: Staged import ID as an int. :param impreq: :class:`imports.Request <imports.Request>` object :return: :class:`imports.Request <imports.Request>` object :rtype: im...
def commit(self, id, impreq): # pylint: disable=invalid-name,redefined-builtin """Commit a staged import. :param id: Staged import ID as an int. :param impreq: :class:`imports.Request <imports.Request>` object :return: :class:`imports.Request <imports.Request>` object :rtype: im...
[ "Commit", "a", "staged", "import", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/imports.py#L213-L226
[ "def", "commit", "(", "self", ",", "id", ",", "impreq", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "RequestSchema", "(", ")", "json", "=", "self", ".", "service", ".", "encode", "(", "schema", ",", "impreq", ")", "schema", "...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
model_to_dict
Takes a model instance and converts it into a dict.
preserialize/serialize.py
def model_to_dict(instance, **options): "Takes a model instance and converts it into a dict." options = _defaults(options) attrs = {} if options['prehook']: if isinstance(options['prehook'], collections.Callable): instance = options['prehook'](instance) if instance is N...
def model_to_dict(instance, **options): "Takes a model instance and converts it into a dict." options = _defaults(options) attrs = {} if options['prehook']: if isinstance(options['prehook'], collections.Callable): instance = options['prehook'](instance) if instance is N...
[ "Takes", "a", "model", "instance", "and", "converts", "it", "into", "a", "dict", "." ]
bruth/django-preserialize
python
https://github.com/bruth/django-preserialize/blob/d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6/preserialize/serialize.py#L59-L124
[ "def", "model_to_dict", "(", "instance", ",", "*", "*", "options", ")", ":", "options", "=", "_defaults", "(", "options", ")", "attrs", "=", "{", "}", "if", "options", "[", "'prehook'", "]", ":", "if", "isinstance", "(", "options", "[", "'prehook'", "]...
d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6
train
Serializer.serialize
Recursively attempts to find ``Model`` and ``QuerySet`` instances to convert them into their representative datastructure per their ``Resource`` (if one exists).
preserialize/serialize.py
def serialize(self, obj, fields=None, exclude=None, **options): """Recursively attempts to find ``Model`` and ``QuerySet`` instances to convert them into their representative datastructure per their ``Resource`` (if one exists). """ options = _merge({}, self.options, options) ...
def serialize(self, obj, fields=None, exclude=None, **options): """Recursively attempts to find ``Model`` and ``QuerySet`` instances to convert them into their representative datastructure per their ``Resource`` (if one exists). """ options = _merge({}, self.options, options) ...
[ "Recursively", "attempts", "to", "find", "Model", "and", "QuerySet", "instances", "to", "convert", "them", "into", "their", "representative", "datastructure", "per", "their", "Resource", "(", "if", "one", "exists", ")", "." ]
bruth/django-preserialize
python
https://github.com/bruth/django-preserialize/blob/d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6/preserialize/serialize.py#L160-L189
[ "def", "serialize", "(", "self", ",", "obj", ",", "fields", "=", "None", ",", "exclude", "=", "None", ",", "*", "*", "options", ")", ":", "options", "=", "_merge", "(", "{", "}", ",", "self", ".", "options", ",", "options", ")", "# Handle model insta...
d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6
train
set_save_directory
Sets the root save directory for saving screenshots. Screenshots will be saved in subdirectories under this directory by browser window size.
lettuce_webdriver/screenshot.py
def set_save_directory(base, source): """Sets the root save directory for saving screenshots. Screenshots will be saved in subdirectories under this directory by browser window size. """ root = os.path.join(base, source) if not os.path.isdir(root): os.makedirs(root) world.screensho...
def set_save_directory(base, source): """Sets the root save directory for saving screenshots. Screenshots will be saved in subdirectories under this directory by browser window size. """ root = os.path.join(base, source) if not os.path.isdir(root): os.makedirs(root) world.screensho...
[ "Sets", "the", "root", "save", "directory", "for", "saving", "screenshots", ".", "Screenshots", "will", "be", "saved", "in", "subdirectories", "under", "this", "directory", "by", "browser", "window", "size", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/screenshot.py#L13-L22
[ "def", "set_save_directory", "(", "base", ",", "source", ")", ":", "root", "=", "os", ".", "path", ".", "join", "(", "base", ",", "source", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "root", ")", ":", "os", ".", "makedirs", "(", "roo...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
UsersService.change_password
Change a user's password. :param id: User ID as an int. :param new: New password as string. :param old: (optional) Old password as string (required if performing action as non-admin). :param change_token: (optional) If bool `True`, also generate a new API token for user. :return...
cdrouter/users.py
def change_password(self, id, new, old=None, change_token=True): # pylint: disable=invalid-name,redefined-builtin """Change a user's password. :param id: User ID as an int. :param new: New password as string. :param old: (optional) Old password as string (required if performing action a...
def change_password(self, id, new, old=None, change_token=True): # pylint: disable=invalid-name,redefined-builtin """Change a user's password. :param id: User ID as an int. :param new: New password as string. :param old: (optional) Old password as string (required if performing action a...
[ "Change", "a", "user", "s", "password", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/users.py#L154-L168
[ "def", "change_password", "(", "self", ",", "id", ",", "new", ",", "old", "=", "None", ",", "change_token", "=", "True", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "UserSchema", "(", "exclude", "=", "(", "'password'", ",", "'p...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
UsersService.change_token
Change a user's token. :param id: User ID as an int. :return: :class:`users.User <users.User>` object :rtype: users.User
cdrouter/users.py
def change_token(self, id): # pylint: disable=invalid-name,redefined-builtin """Change a user's token. :param id: User ID as an int. :return: :class:`users.User <users.User>` object :rtype: users.User """ schema = UserSchema(exclude=('password', 'password_confirm')) ...
def change_token(self, id): # pylint: disable=invalid-name,redefined-builtin """Change a user's token. :param id: User ID as an int. :return: :class:`users.User <users.User>` object :rtype: users.User """ schema = UserSchema(exclude=('password', 'password_confirm')) ...
[ "Change", "a", "user", "s", "token", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/users.py#L170-L179
[ "def", "change_token", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "UserSchema", "(", "exclude", "=", "(", "'password'", ",", "'password_confirm'", ")", ")", "resp", "=", "self", ".", "service", ".", "post...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
UsersService.bulk_copy
Bulk copy a set of users. :param ids: Int list of user IDs. :return: :class:`users.User <users.User>` list
cdrouter/users.py
def bulk_copy(self, ids): """Bulk copy a set of users. :param ids: Int list of user IDs. :return: :class:`users.User <users.User>` list """ schema = UserSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
def bulk_copy(self, ids): """Bulk copy a set of users. :param ids: Int list of user IDs. :return: :class:`users.User <users.User>` list """ schema = UserSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
[ "Bulk", "copy", "a", "set", "of", "users", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/users.py#L188-L195
[ "def", "bulk_copy", "(", "self", ",", "ids", ")", ":", "schema", "=", "UserSchema", "(", ")", "return", "self", ".", "service", ".", "bulk_copy", "(", "self", ".", "base", ",", "self", ".", "RESOURCE", ",", "ids", ",", "schema", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
fifo_for_evict
Use FIFO(First In First Out) strategy for evicting, it will find an item by earliest birthday date then remove it. Test: >>> from common_cache import CacheItem >>> dict = {} >>> dict['a'] = CacheItem(key='a', value=0, expire=5) >>> dict['b'] = CacheItem(key='b', value=1, expire=5) >>> dict['c']...
common_cache/eviction.py
def fifo_for_evict(cache_dict, evict_number=1): """ Use FIFO(First In First Out) strategy for evicting, it will find an item by earliest birthday date then remove it. Test: >>> from common_cache import CacheItem >>> dict = {} >>> dict['a'] = CacheItem(key='a', value=0, expire=5) >>> dict['b...
def fifo_for_evict(cache_dict, evict_number=1): """ Use FIFO(First In First Out) strategy for evicting, it will find an item by earliest birthday date then remove it. Test: >>> from common_cache import CacheItem >>> dict = {} >>> dict['a'] = CacheItem(key='a', value=0, expire=5) >>> dict['b...
[ "Use", "FIFO", "(", "First", "In", "First", "Out", ")", "strategy", "for", "evicting", "it", "will", "find", "an", "item", "by", "earliest", "birthday", "date", "then", "remove", "it", "." ]
SylvanasSun/python-common-cache
python
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/eviction.py#L6-L40
[ "def", "fifo_for_evict", "(", "cache_dict", ",", "evict_number", "=", "1", ")", ":", "ordered_dict", "=", "sorted", "(", "cache_dict", ".", "items", "(", ")", ",", "key", "=", "lambda", "t", ":", "t", "[", "1", "]", "[", "'birthday'", "]", ")", "evic...
f113eb3cd751eed5ab5373e8610a31a444220cf8
train
lru_for_evict
Use LRU(Least Recently Used) strategy for evicting, the item that last used of time is the earliest will be removed. The parameter cache_dict must is an OrderedDict because its implementation based on the OrderedDict and reinsert key and value when every time to get the cache, this operation will make the cache...
common_cache/eviction.py
def lru_for_evict(cache_dict, evict_number=1): """ Use LRU(Least Recently Used) strategy for evicting, the item that last used of time is the earliest will be removed. The parameter cache_dict must is an OrderedDict because its implementation based on the OrderedDict and reinsert key and value when ever...
def lru_for_evict(cache_dict, evict_number=1): """ Use LRU(Least Recently Used) strategy for evicting, the item that last used of time is the earliest will be removed. The parameter cache_dict must is an OrderedDict because its implementation based on the OrderedDict and reinsert key and value when ever...
[ "Use", "LRU", "(", "Least", "Recently", "Used", ")", "strategy", "for", "evicting", "the", "item", "that", "last", "used", "of", "time", "is", "the", "earliest", "will", "be", "removed", ".", "The", "parameter", "cache_dict", "must", "is", "an", "OrderedDi...
SylvanasSun/python-common-cache
python
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/eviction.py#L43-L84
[ "def", "lru_for_evict", "(", "cache_dict", ",", "evict_number", "=", "1", ")", ":", "if", "not", "isinstance", "(", "cache_dict", ",", "collections", ".", "OrderedDict", ")", ":", "raise", "ValueError", "(", "'Not supported type %s'", "%", "type", "(", "cache_...
f113eb3cd751eed5ab5373e8610a31a444220cf8
train
AttachmentsService.list
Get a list of a device's attachments. :param id: Device ID as an int. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit re...
cdrouter/attachments.py
def list(self, id, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of a device's attachments. :param id: Device ID as an int. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `u...
def list(self, id, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of a device's attachments. :param id: Device ID as an int. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `u...
[ "Get", "a", "list", "of", "a", "device", "s", "attachments", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/attachments.py#L68-L82
[ "def", "list", "(", "self", ",", "id", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "sort", "=", "None", ",", "limit", "=", "None", ",", "page", "=", "None", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "Atta...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
AttachmentsService.iter_list
Get a list of attachments. Whereas ``list`` fetches a single page of attachments according to its ``limit`` and ``page`` arguments, ``iter_list`` returns all attachments by internally making successive calls to ``list``. :param id: Device ID as an int. :param args: Arguments th...
cdrouter/attachments.py
def iter_list(self, id, *args, **kwargs): """Get a list of attachments. Whereas ``list`` fetches a single page of attachments according to its ``limit`` and ``page`` arguments, ``iter_list`` returns all attachments by internally making successive calls to ``list``. :param id: D...
def iter_list(self, id, *args, **kwargs): """Get a list of attachments. Whereas ``list`` fetches a single page of attachments according to its ``limit`` and ``page`` arguments, ``iter_list`` returns all attachments by internally making successive calls to ``list``. :param id: D...
[ "Get", "a", "list", "of", "attachments", ".", "Whereas", "list", "fetches", "a", "single", "page", "of", "attachments", "according", "to", "its", "limit", "and", "page", "arguments", "iter_list", "returns", "all", "attachments", "by", "internally", "making", "...
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/attachments.py#L84-L97
[ "def", "iter_list", "(", "self", ",", "id", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "l", "=", "partial", "(", "self", ".", "list", ",", "id", ")", "return", "self", ".", "service", ".", "iter_list", "(", "l", ",", "*", "args", ",",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
AttachmentsService.get
Get a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachment
cdrouter/attachments.py
def get(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Get a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachment...
def get(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Get a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachment...
[ "Get", "a", "device", "s", "attachment", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/attachments.py#L99-L109
[ "def", "get", "(", "self", ",", "id", ",", "attid", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "AttachmentSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get_id", "(", "self", ".", "_base", "(", "id", ")", ",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
AttachmentsService.create
Add an attachment to a device. :param id: Device ID as an int. :param fd: File-like object to upload. :param filename: (optional) Name to use for new attachment as a string. :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachment
cdrouter/attachments.py
def create(self, id, fd, filename='attachment-name'): # pylint: disable=invalid-name,redefined-builtin """Add an attachment to a device. :param id: Device ID as an int. :param fd: File-like object to upload. :param filename: (optional) Name to use for new attachment as a string. ...
def create(self, id, fd, filename='attachment-name'): # pylint: disable=invalid-name,redefined-builtin """Add an attachment to a device. :param id: Device ID as an int. :param fd: File-like object to upload. :param filename: (optional) Name to use for new attachment as a string. ...
[ "Add", "an", "attachment", "to", "a", "device", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/attachments.py#L111-L123
[ "def", "create", "(", "self", ",", "id", ",", "fd", ",", "filename", "=", "'attachment-name'", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "AttachmentSchema", "(", "exclude", "=", "(", "'id'", ",", "'created'", ",", "'updated'", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
AttachmentsService.download
Download a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :rtype: tuple `(io.BytesIO, 'filename')`
cdrouter/attachments.py
def download(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Download a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :rtype: tuple `(io.BytesIO, 'filename')` """ resp = self.service.get_id(self._base(id...
def download(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Download a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. :rtype: tuple `(io.BytesIO, 'filename')` """ resp = self.service.get_id(self._base(id...
[ "Download", "a", "device", "s", "attachment", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/attachments.py#L125-L137
[ "def", "download", "(", "self", ",", "id", ",", "attid", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "resp", "=", "self", ".", "service", ".", "get_id", "(", "self", ".", "_base", "(", "id", ")", ",", "attid", ",", "params", "=", "{", "...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
AttachmentsService.edit
Edit a device's attachment. :param resource: :class:`attachments.Attachment <attachments.Attachment>` object :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachment
cdrouter/attachments.py
def edit(self, resource): # pylint: disable=invalid-name,redefined-builtin """Edit a device's attachment. :param resource: :class:`attachments.Attachment <attachments.Attachment>` object :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachm...
def edit(self, resource): # pylint: disable=invalid-name,redefined-builtin """Edit a device's attachment. :param resource: :class:`attachments.Attachment <attachments.Attachment>` object :return: :class:`attachments.Attachment <attachments.Attachment>` object :rtype: attachments.Attachm...
[ "Edit", "a", "device", "s", "attachment", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/attachments.py#L156-L168
[ "def", "edit", "(", "self", ",", "resource", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "AttachmentSchema", "(", "exclude", "=", "(", "'id'", ",", "'created'", ",", "'updated'", ",", "'size'", ",", "'path'", ",", "'device_id'", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
AttachmentsService.delete
Delete a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int.
cdrouter/attachments.py
def delete(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Delete a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. """ return self.service.edit(self._base(id), attid)
def delete(self, id, attid): # pylint: disable=invalid-name,redefined-builtin """Delete a device's attachment. :param id: Device ID as an int. :param attid: Attachment ID as an int. """ return self.service.edit(self._base(id), attid)
[ "Delete", "a", "device", "s", "attachment", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/attachments.py#L170-L176
[ "def", "delete", "(", "self", ",", "id", ",", "attid", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "return", "self", ".", "service", ".", "edit", "(", "self", ".", "_base", "(", "id", ")", ",", "attid", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
DevicesService.get_by_name
Get a device by name. :param name: Device name as string. :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device
cdrouter/devices.py
def get_by_name(self, name): # pylint: disable=invalid-name,redefined-builtin """Get a device by name. :param name: Device name as string. :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device """ rs, _ = self.list(filter=field('name').eq(name),...
def get_by_name(self, name): # pylint: disable=invalid-name,redefined-builtin """Get a device by name. :param name: Device name as string. :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device """ rs, _ = self.list(filter=field('name').eq(name),...
[ "Get", "a", "device", "by", "name", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L229-L239
[ "def", "get_by_name", "(", "self", ",", "name", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "rs", ",", "_", "=", "self", ".", "list", "(", "filter", "=", "field", "(", "'name'", ")", ".", "eq", "(", "name", ")", ",", "limit", "=", "1", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
DevicesService.edit
Edit a device. :param resource: :class:`devices.Device <devices.Device>` object :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device
cdrouter/devices.py
def edit(self, resource): """Edit a device. :param resource: :class:`devices.Device <devices.Device>` object :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device """ schema = DeviceSchema(exclude=('id', 'created', 'updated', 'result_id', 'attac...
def edit(self, resource): """Edit a device. :param resource: :class:`devices.Device <devices.Device>` object :return: :class:`devices.Device <devices.Device>` object :rtype: devices.Device """ schema = DeviceSchema(exclude=('id', 'created', 'updated', 'result_id', 'attac...
[ "Edit", "a", "device", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L255-L267
[ "def", "edit", "(", "self", ",", "resource", ")", ":", "schema", "=", "DeviceSchema", "(", "exclude", "=", "(", "'id'", ",", "'created'", ",", "'updated'", ",", "'result_id'", ",", "'attachments_dir'", ")", ")", "json", "=", "self", ".", "service", ".", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
DevicesService.get_connection
Get information on proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection
cdrouter/devices.py
def get_connection(self, id): # pylint: disable=invalid-name,redefined-builtin """Get information on proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection "...
def get_connection(self, id): # pylint: disable=invalid-name,redefined-builtin """Get information on proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection "...
[ "Get", "information", "on", "proxy", "connection", "to", "a", "device", "s", "management", "interface", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L301-L310
[ "def", "get_connection", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "ConnectionSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "str", "(", "id", ")",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
DevicesService.connect
Open proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection
cdrouter/devices.py
def connect(self, id): # pylint: disable=invalid-name,redefined-builtin """Open proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection """ schema = C...
def connect(self, id): # pylint: disable=invalid-name,redefined-builtin """Open proxy connection to a device's management interface. :param id: Device ID as an int. :return: :class:`devices.Connection <devices.Connection>` object :rtype: devices.Connection """ schema = C...
[ "Open", "proxy", "connection", "to", "a", "device", "s", "management", "interface", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L312-L321
[ "def", "connect", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "ConnectionSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+"...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
DevicesService.disconnect
Close proxy connection to a device's management interface. :param id: Device ID as an int.
cdrouter/devices.py
def disconnect(self, id): # pylint: disable=invalid-name,redefined-builtin """Close proxy connection to a device's management interface. :param id: Device ID as an int. """ return self.service.post(self.base+str(id)+'/disconnect/')
def disconnect(self, id): # pylint: disable=invalid-name,redefined-builtin """Close proxy connection to a device's management interface. :param id: Device ID as an int. """ return self.service.post(self.base+str(id)+'/disconnect/')
[ "Close", "proxy", "connection", "to", "a", "device", "s", "management", "interface", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L323-L328
[ "def", "disconnect", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "return", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+", "'/disconnect/'", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
DevicesService.power_on
Power on a device using it's power on command. :param id: Device ID as an int. :return: :class:`devices.PowerCmd <devices.PowerCmd>` object :rtype: devices.PowerCmd
cdrouter/devices.py
def power_on(self, id): # pylint: disable=invalid-name,redefined-builtin """Power on a device using it's power on command. :param id: Device ID as an int. :return: :class:`devices.PowerCmd <devices.PowerCmd>` object :rtype: devices.PowerCmd """ schema = PowerCmdSchema() ...
def power_on(self, id): # pylint: disable=invalid-name,redefined-builtin """Power on a device using it's power on command. :param id: Device ID as an int. :return: :class:`devices.PowerCmd <devices.PowerCmd>` object :rtype: devices.PowerCmd """ schema = PowerCmdSchema() ...
[ "Power", "on", "a", "device", "using", "it", "s", "power", "on", "command", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L330-L339
[ "def", "power_on", "(", "self", ",", "id", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "PowerCmdSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "str", "(", "id", ")", "+",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
DevicesService.bulk_copy
Bulk copy a set of devices. :param ids: Int list of device IDs. :return: :class:`devices.Device <devices.Device>` list
cdrouter/devices.py
def bulk_copy(self, ids): """Bulk copy a set of devices. :param ids: Int list of device IDs. :return: :class:`devices.Device <devices.Device>` list """ schema = DeviceSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
def bulk_copy(self, ids): """Bulk copy a set of devices. :param ids: Int list of device IDs. :return: :class:`devices.Device <devices.Device>` list """ schema = DeviceSchema() return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
[ "Bulk", "copy", "a", "set", "of", "devices", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L360-L367
[ "def", "bulk_copy", "(", "self", ",", "ids", ")", ":", "schema", "=", "DeviceSchema", "(", ")", "return", "self", ".", "service", ".", "bulk_copy", "(", "self", ".", "base", ",", "self", ".", "RESOURCE", ",", "ids", ",", "schema", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
ensure_list
Wrap value in list if it is not one.
yandex_weather_api/types.py
def ensure_list(value: Union[T, Sequence[T]]) -> Sequence[T]: """Wrap value in list if it is not one.""" if value is None: return [] return value if isinstance(value, list) else [value]
def ensure_list(value: Union[T, Sequence[T]]) -> Sequence[T]: """Wrap value in list if it is not one.""" if value is None: return [] return value if isinstance(value, list) else [value]
[ "Wrap", "value", "in", "list", "if", "it", "is", "not", "one", "." ]
ASMfreaK/yandex_weather_api
python
https://github.com/ASMfreaK/yandex_weather_api/blob/d58ad80f7389dc3b58c721bb42c2441e9ff3e351/yandex_weather_api/types.py#L28-L32
[ "def", "ensure_list", "(", "value", ":", "Union", "[", "T", ",", "Sequence", "[", "T", "]", "]", ")", "->", "Sequence", "[", "T", "]", ":", "if", "value", "is", "None", ":", "return", "[", "]", "return", "value", "if", "isinstance", "(", "value", ...
d58ad80f7389dc3b58c721bb42c2441e9ff3e351
train
Enum.validate
Проверяет, что переданный объект - один из возможных `VALUES`
yandex_weather_api/types.py
def validate(cls, cnd): "Проверяет, что переданный объект - один из возможных `VALUES`" if cnd not in cls.VALUES: raise ValueError("Value {} cannot be used in {}".format( cnd, cls )) return cls(cnd)
def validate(cls, cnd): "Проверяет, что переданный объект - один из возможных `VALUES`" if cnd not in cls.VALUES: raise ValueError("Value {} cannot be used in {}".format( cnd, cls )) return cls(cnd)
[ "Проверяет", "что", "переданный", "объект", "-", "один", "из", "возможных", "VALUES" ]
ASMfreaK/yandex_weather_api
python
https://github.com/ASMfreaK/yandex_weather_api/blob/d58ad80f7389dc3b58c721bb42c2441e9ff3e351/yandex_weather_api/types.py#L60-L66
[ "def", "validate", "(", "cls", ",", "cnd", ")", ":", "if", "cnd", "not", "in", "cls", ".", "VALUES", ":", "raise", "ValueError", "(", "\"Value {} cannot be used in {}\"", ".", "format", "(", "cnd", ",", "cls", ")", ")", "return", "cls", "(", "cnd", ")"...
d58ad80f7389dc3b58c721bb42c2441e9ff3e351
train
color
Highlight string for terminal color coding. Purpose: We use this utility function to insert a ANSI/win32 color code | and Bright style marker before a string, and reset the color and | style after the string. We then return the string with these | codes inserted. @param out_st...
jaide/color_utils.py
def color(out_string, color='grn'): """ Highlight string for terminal color coding. Purpose: We use this utility function to insert a ANSI/win32 color code | and Bright style marker before a string, and reset the color and | style after the string. We then return the string with these ...
def color(out_string, color='grn'): """ Highlight string for terminal color coding. Purpose: We use this utility function to insert a ANSI/win32 color code | and Bright style marker before a string, and reset the color and | style after the string. We then return the string with these ...
[ "Highlight", "string", "for", "terminal", "color", "coding", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/color_utils.py#L6-L38
[ "def", "color", "(", "out_string", ",", "color", "=", "'grn'", ")", ":", "c", "=", "{", "'blk'", ":", "Fore", ".", "BLACK", ",", "'blu'", ":", "Fore", ".", "BLUE", ",", "'cyn'", ":", "Fore", ".", "CYAN", ",", "'grn'", ":", "Fore", ".", "GREEN", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
color_diffs
Add color ANSI codes for diff lines. Purpose: Adds the ANSI/win32 color coding for terminal output to output | produced from difflib. @param string: The string to be replacing @type string: str @returns: The new string with ANSI codes injected. @rtype: str
jaide/color_utils.py
def color_diffs(string): """ Add color ANSI codes for diff lines. Purpose: Adds the ANSI/win32 color coding for terminal output to output | produced from difflib. @param string: The string to be replacing @type string: str @returns: The new string with ANSI codes injected. @rtype: ...
def color_diffs(string): """ Add color ANSI codes for diff lines. Purpose: Adds the ANSI/win32 color coding for terminal output to output | produced from difflib. @param string: The string to be replacing @type string: str @returns: The new string with ANSI codes injected. @rtype: ...
[ "Add", "color", "ANSI", "codes", "for", "diff", "lines", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/color_utils.py#L57-L74
[ "def", "color_diffs", "(", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "'--- '", ",", "color", "(", "'--- '", ",", "'red'", ")", ")", "string", "=", "string", ".", "replace", "(", "'\\n+++ '", ",", "color", "(", "'\\n+++ '", ")", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
index
List linked accounts.
invenio_oauthclient/views/settings.py
def index(): """List linked accounts.""" oauth = current_app.extensions['oauthlib.client'] services = [] service_map = {} i = 0 for appid, conf in six.iteritems( current_app.config['OAUTHCLIENT_REMOTE_APPS']): if not conf.get('hide', False): services.append(dict...
def index(): """List linked accounts.""" oauth = current_app.extensions['oauthlib.client'] services = [] service_map = {} i = 0 for appid, conf in six.iteritems( current_app.config['OAUTHCLIENT_REMOTE_APPS']): if not conf.get('hide', False): services.append(dict...
[ "List", "linked", "accounts", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/settings.py#L47-L83
[ "def", "index", "(", ")", ":", "oauth", "=", "current_app", ".", "extensions", "[", "'oauthlib.client'", "]", "services", "=", "[", "]", "service_map", "=", "{", "}", "i", "=", "0", "for", "appid", ",", "conf", "in", "six", ".", "iteritems", "(", "cu...
2500dc6935738107617aeade79e050d7608004bb
train
load_script
Ensure that JavaScript at a given URL is available to the browser.
lettuce_webdriver/css_selector_steps.py
def load_script(browser, url): """Ensure that JavaScript at a given URL is available to the browser.""" if browser.current_url.startswith('file:'): url = 'https:' + url browser.execute_script(""" var script_tag = document.createElement("script"); script_tag.setAttribute("type", "text/javascr...
def load_script(browser, url): """Ensure that JavaScript at a given URL is available to the browser.""" if browser.current_url.startswith('file:'): url = 'https:' + url browser.execute_script(""" var script_tag = document.createElement("script"); script_tag.setAttribute("type", "text/javascr...
[ "Ensure", "that", "JavaScript", "at", "a", "given", "URL", "is", "available", "to", "the", "browser", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/css_selector_steps.py#L20-L31
[ "def", "load_script", "(", "browser", ",", "url", ")", ":", "if", "browser", ".", "current_url", ".", "startswith", "(", "'file:'", ")", ":", "url", "=", "'https:'", "+", "url", "browser", ".", "execute_script", "(", "\"\"\"\n var script_tag = document.create...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
find_elements_by_jquery
Find HTML elements using jQuery-style selectors. Ensures that jQuery is available to the browser; if it gets a WebDriverException that looks like jQuery is not available, it attempts to include it and reexecute the script.
lettuce_webdriver/css_selector_steps.py
def find_elements_by_jquery(browser, selector): """Find HTML elements using jQuery-style selectors. Ensures that jQuery is available to the browser; if it gets a WebDriverException that looks like jQuery is not available, it attempts to include it and reexecute the script.""" try: return br...
def find_elements_by_jquery(browser, selector): """Find HTML elements using jQuery-style selectors. Ensures that jQuery is available to the browser; if it gets a WebDriverException that looks like jQuery is not available, it attempts to include it and reexecute the script.""" try: return br...
[ "Find", "HTML", "elements", "using", "jQuery", "-", "style", "selectors", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/css_selector_steps.py#L34-L47
[ "def", "find_elements_by_jquery", "(", "browser", ",", "selector", ")", ":", "try", ":", "return", "browser", ".", "execute_script", "(", "\"\"\"return ($ || jQuery)(arguments[0]).get();\"\"\"", ",", "selector", ")", "except", "WebDriverException", "as", "e", ":", "if...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
find_element_by_jquery
Find a single HTML element using jQuery-style selectors.
lettuce_webdriver/css_selector_steps.py
def find_element_by_jquery(step, browser, selector): """Find a single HTML element using jQuery-style selectors.""" elements = find_elements_by_jquery(browser, selector) assert_true(step, len(elements) > 0) return elements[0]
def find_element_by_jquery(step, browser, selector): """Find a single HTML element using jQuery-style selectors.""" elements = find_elements_by_jquery(browser, selector) assert_true(step, len(elements) > 0) return elements[0]
[ "Find", "a", "single", "HTML", "element", "using", "jQuery", "-", "style", "selectors", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/css_selector_steps.py#L50-L54
[ "def", "find_element_by_jquery", "(", "step", ",", "browser", ",", "selector", ")", ":", "elements", "=", "find_elements_by_jquery", "(", "browser", ",", "selector", ")", "assert_true", "(", "step", ",", "len", "(", "elements", ")", ">", "0", ")", "return", ...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
Connection.can_access_api
:return: True when we can access the REST API
w3af_api_client/connection.py
def can_access_api(self): """ :return: True when we can access the REST API """ try: version_dict = self.get_version() except Exception, e: msg = 'An exception was raised when connecting to REST API: "%s"' raise APIException(msg % e) el...
def can_access_api(self): """ :return: True when we can access the REST API """ try: version_dict = self.get_version() except Exception, e: msg = 'An exception was raised when connecting to REST API: "%s"' raise APIException(msg % e) el...
[ ":", "return", ":", "True", "when", "we", "can", "access", "the", "REST", "API" ]
andresriancho/w3af-api-client
python
https://github.com/andresriancho/w3af-api-client/blob/adeb79bad75264d754de69f0bb981b366da96f32/w3af_api_client/connection.py#L44-L68
[ "def", "can_access_api", "(", "self", ")", ":", "try", ":", "version_dict", "=", "self", ".", "get_version", "(", ")", "except", "Exception", ",", "e", ":", "msg", "=", "'An exception was raised when connecting to REST API: \"%s\"'", "raise", "APIException", "(", ...
adeb79bad75264d754de69f0bb981b366da96f32
train
Connection.get_scans
:return: A list with all the Scan instances available in the remote API
w3af_api_client/connection.py
def get_scans(self): """ :return: A list with all the Scan instances available in the remote API """ code, data = self.send_request('/scans/', method='GET') if code != 200: msg = 'Failed to retrieve scans. Unexpected code %s' raise APIException(msg % code...
def get_scans(self): """ :return: A list with all the Scan instances available in the remote API """ code, data = self.send_request('/scans/', method='GET') if code != 200: msg = 'Failed to retrieve scans. Unexpected code %s' raise APIException(msg % code...
[ ":", "return", ":", "A", "list", "with", "all", "the", "Scan", "instances", "available", "in", "the", "remote", "API" ]
andresriancho/w3af-api-client
python
https://github.com/andresriancho/w3af-api-client/blob/adeb79bad75264d754de69f0bb981b366da96f32/w3af_api_client/connection.py#L156-L178
[ "def", "get_scans", "(", "self", ")", ":", "code", ",", "data", "=", "self", ".", "send_request", "(", "'/scans/'", ",", "method", "=", "'GET'", ")", "if", "code", "!=", "200", ":", "msg", "=", "'Failed to retrieve scans. Unexpected code %s'", "raise", "APIE...
adeb79bad75264d754de69f0bb981b366da96f32
train
element_id_by_label
Return the id of a label's for attribute
lettuce_webdriver/util.py
def element_id_by_label(browser, label): """Return the id of a label's for attribute""" label = XPathSelector(browser, unicode('//label[contains(., "%s")]' % label)) if not label: return False return label.get_attribute('for')
def element_id_by_label(browser, label): """Return the id of a label's for attribute""" label = XPathSelector(browser, unicode('//label[contains(., "%s")]' % label)) if not label: return False return label.get_attribute('for')
[ "Return", "the", "id", "of", "a", "label", "s", "for", "attribute" ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L141-L147
[ "def", "element_id_by_label", "(", "browser", ",", "label", ")", ":", "label", "=", "XPathSelector", "(", "browser", ",", "unicode", "(", "'//label[contains(., \"%s\")]'", "%", "label", ")", ")", "if", "not", "label", ":", "return", "False", "return", "label",...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
find_field
Locate an input field of a given value This first looks for the value as the id of the element, then the name of the element, then a label for the element.
lettuce_webdriver/util.py
def find_field(browser, field, value): """Locate an input field of a given value This first looks for the value as the id of the element, then the name of the element, then a label for the element. """ return find_field_by_id(browser, field, value) + \ find_field_by_name(browser, field, va...
def find_field(browser, field, value): """Locate an input field of a given value This first looks for the value as the id of the element, then the name of the element, then a label for the element. """ return find_field_by_id(browser, field, value) + \ find_field_by_name(browser, field, va...
[ "Locate", "an", "input", "field", "of", "a", "given", "value" ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L197-L206
[ "def", "find_field", "(", "browser", ",", "field", ",", "value", ")", ":", "return", "find_field_by_id", "(", "browser", ",", "field", ",", "value", ")", "+", "find_field_by_name", "(", "browser", ",", "field", ",", "value", ")", "+", "find_field_by_label", ...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
find_any_field
Find a field of any of the specified types.
lettuce_webdriver/util.py
def find_any_field(browser, field_types, field_name): """ Find a field of any of the specified types. """ return reduce( operator.add, (find_field(browser, field_type, field_name) for field_type in field_types) )
def find_any_field(browser, field_types, field_name): """ Find a field of any of the specified types. """ return reduce( operator.add, (find_field(browser, field_type, field_name) for field_type in field_types) )
[ "Find", "a", "field", "of", "any", "of", "the", "specified", "types", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L209-L218
[ "def", "find_any_field", "(", "browser", ",", "field_types", ",", "field_name", ")", ":", "return", "reduce", "(", "operator", ".", "add", ",", "(", "find_field", "(", "browser", ",", "field_type", ",", "field_name", ")", "for", "field_type", "in", "field_ty...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
find_field_by_label
Locate the control input that has a label pointing to it This will first locate the label element that has a label of the given name. It then pulls the id out of the 'for' attribute, and uses it to locate the element by its id.
lettuce_webdriver/util.py
def find_field_by_label(browser, field, label): """Locate the control input that has a label pointing to it This will first locate the label element that has a label of the given name. It then pulls the id out of the 'for' attribute, and uses it to locate the element by its id. """ return XPa...
def find_field_by_label(browser, field, label): """Locate the control input that has a label pointing to it This will first locate the label element that has a label of the given name. It then pulls the id out of the 'for' attribute, and uses it to locate the element by its id. """ return XPa...
[ "Locate", "the", "control", "input", "that", "has", "a", "label", "pointing", "to", "it" ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L246-L257
[ "def", "find_field_by_label", "(", "browser", ",", "field", ",", "label", ")", ":", "return", "XPathSelector", "(", "browser", ",", "field_xpath", "(", "field", ",", "'id'", ",", "escape", "=", "False", ")", "%", "u'//label[contains(., \"{0}\")]/@for'", ".", "...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
option_in_select
Returns the Element specified by @option or None Looks at the real <select> not the select2 widget, since that doesn't create the DOM until we click on it.
lettuce_webdriver/util.py
def option_in_select(browser, select_name, option): """ Returns the Element specified by @option or None Looks at the real <select> not the select2 widget, since that doesn't create the DOM until we click on it. """ select = find_field(browser, 'select', select_name) assert select try...
def option_in_select(browser, select_name, option): """ Returns the Element specified by @option or None Looks at the real <select> not the select2 widget, since that doesn't create the DOM until we click on it. """ select = find_field(browser, 'select', select_name) assert select try...
[ "Returns", "the", "Element", "specified", "by", "@option", "or", "None" ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L260-L275
[ "def", "option_in_select", "(", "browser", ",", "select_name", ",", "option", ")", ":", "select", "=", "find_field", "(", "browser", ",", "'select'", ",", "select_name", ")", "assert", "select", "try", ":", "return", "select", ".", "find_element_by_xpath", "("...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
wait_for
A decorator to invoke a function periodically until it returns a truthy value.
lettuce_webdriver/util.py
def wait_for(func): """ A decorator to invoke a function periodically until it returns a truthy value. """ def wrapped(*args, **kwargs): timeout = kwargs.pop('timeout', 15) start = time() result = None while time() - start < timeout: result = func(*args...
def wait_for(func): """ A decorator to invoke a function periodically until it returns a truthy value. """ def wrapped(*args, **kwargs): timeout = kwargs.pop('timeout', 15) start = time() result = None while time() - start < timeout: result = func(*args...
[ "A", "decorator", "to", "invoke", "a", "function", "periodically", "until", "it", "returns", "a", "truthy", "value", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L278-L298
[ "def", "wait_for", "(", "func", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "timeout", "=", "kwargs", ".", "pop", "(", "'timeout'", ",", "15", ")", "start", "=", "time", "(", ")", "result", "=", "None", "while...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
XPathSelector._elements
The cached list of elements.
lettuce_webdriver/util.py
def _elements(self): """ The cached list of elements. """ if not hasattr(self, '_elements_cached'): setattr(self, '_elements_cached', list(self._select())) return self._elements_cached
def _elements(self): """ The cached list of elements. """ if not hasattr(self, '_elements_cached'): setattr(self, '_elements_cached', list(self._select())) return self._elements_cached
[ "The", "cached", "list", "of", "elements", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L79-L85
[ "def", "_elements", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_elements_cached'", ")", ":", "setattr", "(", "self", ",", "'_elements_cached'", ",", "list", "(", "self", ".", "_select", "(", ")", ")", ")", "return", "self", ".",...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
get_defaults
Returns a dictionary of variables and their possibly os-dependent defaults.
src/papy/util/config.py
def get_defaults(): """ Returns a dictionary of variables and their possibly os-dependent defaults. """ DEFAULTS = {} # Determine the run-time pipe read/write buffer. if 'PC_PIPE_BUF' in os.pathconf_names: # unix x, y = os.pipe() DEFAULTS['PIPE_BUF'] = os.fpathconf(x...
def get_defaults(): """ Returns a dictionary of variables and their possibly os-dependent defaults. """ DEFAULTS = {} # Determine the run-time pipe read/write buffer. if 'PC_PIPE_BUF' in os.pathconf_names: # unix x, y = os.pipe() DEFAULTS['PIPE_BUF'] = os.fpathconf(x...
[ "Returns", "a", "dictionary", "of", "variables", "and", "their", "possibly", "os", "-", "dependent", "defaults", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/util/config.py#L16-L50
[ "def", "get_defaults", "(", ")", ":", "DEFAULTS", "=", "{", "}", "# Determine the run-time pipe read/write buffer.", "if", "'PC_PIPE_BUF'", "in", "os", ".", "pathconf_names", ":", "# unix", "x", ",", "y", "=", "os", ".", "pipe", "(", ")", "DEFAULTS", "[", "'...
708e50827b5db46bbea081982cb74b9b0e464064
train
start_logger
Configures and starts a logger to monitor the execution of a **PaPy** pipeline. Arguments: - log_to_file(``bool``) [default: ``True``] Should we write logging messages into a file? - log_to_stream(``bool`` or ``object``) [default: ``False``] Should we print logging messages to a...
src/papy/util/config.py
def start_logger(log_to_file=False, \ log_to_stream=False, \ log_to_file_level=logging.INFO, \ log_to_stream_level=logging.INFO, \ log_filename=None, \ log_stream=None, \ log_rotate=True, \ log_size=52...
def start_logger(log_to_file=False, \ log_to_stream=False, \ log_to_file_level=logging.INFO, \ log_to_stream_level=logging.INFO, \ log_filename=None, \ log_stream=None, \ log_rotate=True, \ log_size=52...
[ "Configures", "and", "starts", "a", "logger", "to", "monitor", "the", "execution", "of", "a", "**", "PaPy", "**", "pipeline", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/util/config.py#L52-L110
[ "def", "start_logger", "(", "log_to_file", "=", "False", ",", "log_to_stream", "=", "False", ",", "log_to_file_level", "=", "logging", ".", "INFO", ",", "log_to_stream_level", "=", "logging", ".", "INFO", ",", "log_filename", "=", "None", ",", "log_stream", "=...
708e50827b5db46bbea081982cb74b9b0e464064
train
site_url
Determine the server URL.
lettuce_webdriver/django.py
def site_url(url): """ Determine the server URL. """ base_url = 'http://%s' % socket.gethostname() if server.port is not 80: base_url += ':%d' % server.port return urlparse.urljoin(base_url, url)
def site_url(url): """ Determine the server URL. """ base_url = 'http://%s' % socket.gethostname() if server.port is not 80: base_url += ':%d' % server.port return urlparse.urljoin(base_url, url)
[ "Determine", "the", "server", "URL", "." ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/django.py#L15-L24
[ "def", "site_url", "(", "url", ")", ":", "base_url", "=", "'http://%s'", "%", "socket", ".", "gethostname", "(", ")", "if", "server", ".", "port", "is", "not", "80", ":", "base_url", "+=", "':%d'", "%", "server", ".", "port", "return", "urlparse", ".",...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
_get_external_id
Get external id from account info.
invenio_oauthclient/utils.py
def _get_external_id(account_info): """Get external id from account info.""" if all(k in account_info for k in ('external_id', 'external_method')): return dict(id=account_info['external_id'], method=account_info['external_method']) return None
def _get_external_id(account_info): """Get external id from account info.""" if all(k in account_info for k in ('external_id', 'external_method')): return dict(id=account_info['external_id'], method=account_info['external_method']) return None
[ "Get", "external", "id", "from", "account", "info", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L40-L45
[ "def", "_get_external_id", "(", "account_info", ")", ":", "if", "all", "(", "k", "in", "account_info", "for", "k", "in", "(", "'external_id'", ",", "'external_method'", ")", ")", ":", "return", "dict", "(", "id", "=", "account_info", "[", "'external_id'", ...
2500dc6935738107617aeade79e050d7608004bb
train
oauth_get_user
Retrieve user object for the given request. Uses either the access token or extracted account information to retrieve the user object. :param client_id: The client id. :param account_info: The dictionary with the account info. (Default: ``None``) :param access_token: The access token. (Def...
invenio_oauthclient/utils.py
def oauth_get_user(client_id, account_info=None, access_token=None): """Retrieve user object for the given request. Uses either the access token or extracted account information to retrieve the user object. :param client_id: The client id. :param account_info: The dictionary with the account info....
def oauth_get_user(client_id, account_info=None, access_token=None): """Retrieve user object for the given request. Uses either the access token or extracted account information to retrieve the user object. :param client_id: The client id. :param account_info: The dictionary with the account info....
[ "Retrieve", "user", "object", "for", "the", "given", "request", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L48-L75
[ "def", "oauth_get_user", "(", "client_id", ",", "account_info", "=", "None", ",", "access_token", "=", "None", ")", ":", "if", "access_token", ":", "token", "=", "RemoteToken", ".", "get_by_token", "(", "client_id", ",", "access_token", ")", "if", "token", "...
2500dc6935738107617aeade79e050d7608004bb
train
oauth_authenticate
Authenticate an oauth authorized callback. :param client_id: The client id. :param user: A user instance. :param require_existing_link: If ``True``, check if remote account exists. (Default: ``False``) :returns: ``True`` if the user is successfully authenticated.
invenio_oauthclient/utils.py
def oauth_authenticate(client_id, user, require_existing_link=False): """Authenticate an oauth authorized callback. :param client_id: The client id. :param user: A user instance. :param require_existing_link: If ``True``, check if remote account exists. (Default: ``False``) :returns: ``True...
def oauth_authenticate(client_id, user, require_existing_link=False): """Authenticate an oauth authorized callback. :param client_id: The client id. :param user: A user instance. :param require_existing_link: If ``True``, check if remote account exists. (Default: ``False``) :returns: ``True...
[ "Authenticate", "an", "oauth", "authorized", "callback", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L78-L97
[ "def", "oauth_authenticate", "(", "client_id", ",", "user", ",", "require_existing_link", "=", "False", ")", ":", "# Authenticate via the access token (access token used to get user_id)", "if", "not", "requires_confirmation", "(", "user", ")", ":", "after_this_request", "("...
2500dc6935738107617aeade79e050d7608004bb
train
oauth_register
Register user if possible. :param form: A form instance. :returns: A :class:`invenio_accounts.models.User` instance.
invenio_oauthclient/utils.py
def oauth_register(form): """Register user if possible. :param form: A form instance. :returns: A :class:`invenio_accounts.models.User` instance. """ if form.validate(): data = form.to_dict() if not data.get('password'): data['password'] = '' user = register_user...
def oauth_register(form): """Register user if possible. :param form: A form instance. :returns: A :class:`invenio_accounts.models.User` instance. """ if form.validate(): data = form.to_dict() if not data.get('password'): data['password'] = '' user = register_user...
[ "Register", "user", "if", "possible", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L100-L114
[ "def", "oauth_register", "(", "form", ")", ":", "if", "form", ".", "validate", "(", ")", ":", "data", "=", "form", ".", "to_dict", "(", ")", "if", "not", "data", ".", "get", "(", "'password'", ")", ":", "data", "[", "'password'", "]", "=", "''", ...
2500dc6935738107617aeade79e050d7608004bb
train
oauth_link_external_id
Link a user to an external id. :param user: A :class:`invenio_accounts.models.User` instance. :param external_id: The external id associated with the user. (Default: ``None``) :raises invenio_oauthclient.errors.AlreadyLinkedError: Raised if already exists a link.
invenio_oauthclient/utils.py
def oauth_link_external_id(user, external_id=None): """Link a user to an external id. :param user: A :class:`invenio_accounts.models.User` instance. :param external_id: The external id associated with the user. (Default: ``None``) :raises invenio_oauthclient.errors.AlreadyLinkedError: Raised if...
def oauth_link_external_id(user, external_id=None): """Link a user to an external id. :param user: A :class:`invenio_accounts.models.User` instance. :param external_id: The external id associated with the user. (Default: ``None``) :raises invenio_oauthclient.errors.AlreadyLinkedError: Raised if...
[ "Link", "a", "user", "to", "an", "external", "id", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L117-L134
[ "def", "oauth_link_external_id", "(", "user", ",", "external_id", "=", "None", ")", ":", "try", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "db", ".", "session", ".", "add", "(", "UserIdentity", "(", "id", "=", "external_id", ...
2500dc6935738107617aeade79e050d7608004bb
train
oauth_unlink_external_id
Unlink a user from an external id. :param external_id: The external id associated with the user.
invenio_oauthclient/utils.py
def oauth_unlink_external_id(external_id): """Unlink a user from an external id. :param external_id: The external id associated with the user. """ with db.session.begin_nested(): UserIdentity.query.filter_by(id=external_id['id'], method=external_id['method']...
def oauth_unlink_external_id(external_id): """Unlink a user from an external id. :param external_id: The external id associated with the user. """ with db.session.begin_nested(): UserIdentity.query.filter_by(id=external_id['id'], method=external_id['method']...
[ "Unlink", "a", "user", "from", "an", "external", "id", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L137-L144
[ "def", "oauth_unlink_external_id", "(", "external_id", ")", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "UserIdentity", ".", "query", ".", "filter_by", "(", "id", "=", "external_id", "[", "'id'", "]", ",", "method", "=", "externa...
2500dc6935738107617aeade79e050d7608004bb
train
get_safe_redirect_target
Get URL to redirect to and ensure that it is local. :param arg: URL argument. :returns: The redirect target or ``None``.
invenio_oauthclient/utils.py
def get_safe_redirect_target(arg='next'): """Get URL to redirect to and ensure that it is local. :param arg: URL argument. :returns: The redirect target or ``None``. """ for target in request.args.get(arg), request.referrer: if target: redirect_uri = urisplit(target) ...
def get_safe_redirect_target(arg='next'): """Get URL to redirect to and ensure that it is local. :param arg: URL argument. :returns: The redirect target or ``None``. """ for target in request.args.get(arg), request.referrer: if target: redirect_uri = urisplit(target) ...
[ "Get", "URL", "to", "redirect", "to", "and", "ensure", "that", "it", "is", "local", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L147-L165
[ "def", "get_safe_redirect_target", "(", "arg", "=", "'next'", ")", ":", "for", "target", "in", "request", ".", "args", ".", "get", "(", "arg", ")", ",", "request", ".", "referrer", ":", "if", "target", ":", "redirect_uri", "=", "urisplit", "(", "target",...
2500dc6935738107617aeade79e050d7608004bb
train
create_registrationform
Make a registration form.
invenio_oauthclient/utils.py
def create_registrationform(*args, **kwargs): """Make a registration form.""" class RegistrationForm(_security.confirm_register_form): password = None recaptcha = None return RegistrationForm(*args, **kwargs)
def create_registrationform(*args, **kwargs): """Make a registration form.""" class RegistrationForm(_security.confirm_register_form): password = None recaptcha = None return RegistrationForm(*args, **kwargs)
[ "Make", "a", "registration", "form", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L184-L189
[ "def", "create_registrationform", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "class", "RegistrationForm", "(", "_security", ".", "confirm_register_form", ")", ":", "password", "=", "None", "recaptcha", "=", "None", "return", "RegistrationForm", "(", ...
2500dc6935738107617aeade79e050d7608004bb
train
fill_form
Prefill form with data. :param form: The form to fill. :param data: The data to insert in the form. :returns: A pre-filled form.
invenio_oauthclient/utils.py
def fill_form(form, data): """Prefill form with data. :param form: The form to fill. :param data: The data to insert in the form. :returns: A pre-filled form. """ for (key, value) in data.items(): if hasattr(form, key): if isinstance(value, dict): fill_form(g...
def fill_form(form, data): """Prefill form with data. :param form: The form to fill. :param data: The data to insert in the form. :returns: A pre-filled form. """ for (key, value) in data.items(): if hasattr(form, key): if isinstance(value, dict): fill_form(g...
[ "Prefill", "form", "with", "data", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L197-L210
[ "def", "fill_form", "(", "form", ",", "data", ")", ":", "for", "(", "key", ",", "value", ")", "in", "data", ".", "items", "(", ")", ":", "if", "hasattr", "(", "form", ",", "key", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":"...
2500dc6935738107617aeade79e050d7608004bb
train
_get_csrf_disabled_param
Return the right param to disable CSRF depending on WTF-Form version. From Flask-WTF 0.14.0, `csrf_enabled` param has been deprecated in favor of `meta={csrf: True/False}`.
invenio_oauthclient/utils.py
def _get_csrf_disabled_param(): """Return the right param to disable CSRF depending on WTF-Form version. From Flask-WTF 0.14.0, `csrf_enabled` param has been deprecated in favor of `meta={csrf: True/False}`. """ import flask_wtf from pkg_resources import parse_version supports_meta = parse_...
def _get_csrf_disabled_param(): """Return the right param to disable CSRF depending on WTF-Form version. From Flask-WTF 0.14.0, `csrf_enabled` param has been deprecated in favor of `meta={csrf: True/False}`. """ import flask_wtf from pkg_resources import parse_version supports_meta = parse_...
[ "Return", "the", "right", "param", "to", "disable", "CSRF", "depending", "on", "WTF", "-", "Form", "version", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/utils.py#L224-L235
[ "def", "_get_csrf_disabled_param", "(", ")", ":", "import", "flask_wtf", "from", "pkg_resources", "import", "parse_version", "supports_meta", "=", "parse_version", "(", "flask_wtf", ".", "__version__", ")", ">=", "parse_version", "(", "\"0.14.0\"", ")", "return", "d...
2500dc6935738107617aeade79e050d7608004bb
train
ParallelRunner.run
Find and load step definitions, and them find and load features under `base_path` specified on constructor
lettuce_webdriver/parallel_runner.py
def run(self): """ Find and load step definitions, and them find and load features under `base_path` specified on constructor """ try: self.loader.find_and_load_step_definitions() except StepLoadingError, e: print "Error loading step definitions:\n", e ...
def run(self): """ Find and load step definitions, and them find and load features under `base_path` specified on constructor """ try: self.loader.find_and_load_step_definitions() except StepLoadingError, e: print "Error loading step definitions:\n", e ...
[ "Find", "and", "load", "step", "definitions", "and", "them", "find", "and", "load", "features", "under", "base_path", "specified", "on", "constructor" ]
bbangert/lettuce_webdriver
python
https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/parallel_runner.py#L107-L140
[ "def", "run", "(", "self", ")", ":", "try", ":", "self", ".", "loader", ".", "find_and_load_step_definitions", "(", ")", "except", "StepLoadingError", ",", "e", ":", "print", "\"Error loading step definitions:\\n\"", ",", "e", "return", "results", "=", "[", "]...
d11f8531c43bb7150c316e0dc4ccd083617becf7
train
DictNode.deep_nodes
A recursive method to return a ``list`` of *all* **node objects** connected from this **toplogical node**.
src/papy/graph.py
def deep_nodes(self, allnodes=None): """ A recursive method to return a ``list`` of *all* **node objects** connected from this **toplogical node**. """ allnodes = (allnodes or []) for (node, node_) in ((node, node_) for (node, node_) in\ self.iterite...
def deep_nodes(self, allnodes=None): """ A recursive method to return a ``list`` of *all* **node objects** connected from this **toplogical node**. """ allnodes = (allnodes or []) for (node, node_) in ((node, node_) for (node, node_) in\ self.iterite...
[ "A", "recursive", "method", "to", "return", "a", "list", "of", "*", "all", "*", "**", "node", "objects", "**", "connected", "from", "this", "**", "toplogical", "node", "**", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L68-L79
[ "def", "deep_nodes", "(", "self", ",", "allnodes", "=", "None", ")", ":", "allnodes", "=", "(", "allnodes", "or", "[", "]", ")", "for", "(", "node", ",", "node_", ")", "in", "(", "(", "node", ",", "node_", ")", "for", "(", "node", ",", "node_", ...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.cmp_branch
comparison of **node objects** based on the ``"branch"`` attribute of their **topological nodes**.
src/papy/graph.py
def cmp_branch(self, node1, node2): """ comparison of **node objects** based on the ``"branch"`` attribute of their **topological nodes**. """ # note reverse return cmp(getattr(self[node2], "branch", None), \ getattr(self[node1], "branch", Non...
def cmp_branch(self, node1, node2): """ comparison of **node objects** based on the ``"branch"`` attribute of their **topological nodes**. """ # note reverse return cmp(getattr(self[node2], "branch", None), \ getattr(self[node1], "branch", Non...
[ "comparison", "of", "**", "node", "objects", "**", "based", "on", "the", "branch", "attribute", "of", "their", "**", "topological", "nodes", "**", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L114-L122
[ "def", "cmp_branch", "(", "self", ",", "node1", ",", "node2", ")", ":", "# note reverse", "return", "cmp", "(", "getattr", "(", "self", "[", "node2", "]", ",", "\"branch\"", ",", "None", ")", ",", "getattr", "(", "self", "[", "node1", "]", ",", "\"br...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.dfs
Recursive depth first search. By default ("order" = ``"append"``) this returns the **node objects** in the reverse postorder. To change this into the preorder use a ``collections.deque`` as "bucket" and ``"appendleft"`` as "order". Arguments: - bucket(``list`` ...
src/papy/graph.py
def dfs(self, node, bucket=None, order="append"): """ Recursive depth first search. By default ("order" = ``"append"``) this returns the **node objects** in the reverse postorder. To change this into the preorder use a ``collections.deque`` as "bucket" and ``"appendleft"`` as ...
def dfs(self, node, bucket=None, order="append"): """ Recursive depth first search. By default ("order" = ``"append"``) this returns the **node objects** in the reverse postorder. To change this into the preorder use a ``collections.deque`` as "bucket" and ``"appendleft"`` as ...
[ "Recursive", "depth", "first", "search", ".", "By", "default", "(", "order", "=", "append", ")", "this", "returns", "the", "**", "node", "objects", "**", "in", "the", "reverse", "postorder", ".", "To", "change", "this", "into", "the", "preorder", "use", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L124-L150
[ "def", "dfs", "(", "self", ",", "node", ",", "bucket", "=", "None", ",", "order", "=", "\"append\"", ")", ":", "if", "self", "[", "node", "]", ".", "discovered", ":", "return", "bucket", "self", "[", "node", "]", ".", "discovered", "=", "True", "no...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.postorder
Returns a valid postorder of the **node objects** of the ``DictGraph`` *if* the topology is a directed acyclic graph. This postorder is semi-random, because the order of elements in a dictionary is semi-random and so are the starting nodes of the depth-first search traversal, which d...
src/papy/graph.py
def postorder(self): """ Returns a valid postorder of the **node objects** of the ``DictGraph`` *if* the topology is a directed acyclic graph. This postorder is semi-random, because the order of elements in a dictionary is semi-random and so are the starting nodes of the depth...
def postorder(self): """ Returns a valid postorder of the **node objects** of the ``DictGraph`` *if* the topology is a directed acyclic graph. This postorder is semi-random, because the order of elements in a dictionary is semi-random and so are the starting nodes of the depth...
[ "Returns", "a", "valid", "postorder", "of", "the", "**", "node", "objects", "**", "of", "the", "DictGraph", "*", "if", "*", "the", "topology", "is", "a", "directed", "acyclic", "graph", ".", "This", "postorder", "is", "semi", "-", "random", "because", "t...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L152-L194
[ "def", "postorder", "(", "self", ")", ":", "nodes_random", "=", "self", ".", "nodes", "(", ")", "# for debugging we could make it more random;)", "# from random import shuffle", "# shuffle(nodes_random)", "# 1. sort branches", "nodes_by_branch", "=", "sorted", "(", "nodes_r...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.node_rank
Returns the maximum rank for each **topological node** in the ``DictGraph``. The rank of a node is defined as the number of edges between the node and a node which has rank 0. A **topological node** has rank 0 if it has no incoming edges.
src/papy/graph.py
def node_rank(self): """ Returns the maximum rank for each **topological node** in the ``DictGraph``. The rank of a node is defined as the number of edges between the node and a node which has rank 0. A **topological node** has rank 0 if it has no incoming edges. ...
def node_rank(self): """ Returns the maximum rank for each **topological node** in the ``DictGraph``. The rank of a node is defined as the number of edges between the node and a node which has rank 0. A **topological node** has rank 0 if it has no incoming edges. ...
[ "Returns", "the", "maximum", "rank", "for", "each", "**", "topological", "node", "**", "in", "the", "DictGraph", ".", "The", "rank", "of", "a", "node", "is", "defined", "as", "the", "number", "of", "edges", "between", "the", "node", "and", "a", "node", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L196-L212
[ "def", "node_rank", "(", "self", ")", ":", "nodes", "=", "self", ".", "postorder", "(", ")", "node_rank", "=", "{", "}", "for", "node", "in", "nodes", ":", "max_rank", "=", "0", "for", "child", "in", "self", "[", "node", "]", ".", "nodes", "(", "...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.node_width
Returns the width of each node in the graph. #TODO
src/papy/graph.py
def node_width(self): """ Returns the width of each node in the graph. #TODO """ nodes = self.postorder() node_width = {} for node in nodes: sum_width = 0 for child in self[node].nodes(): sum_width += node_width[child] ...
def node_width(self): """ Returns the width of each node in the graph. #TODO """ nodes = self.postorder() node_width = {} for node in nodes: sum_width = 0 for child in self[node].nodes(): sum_width += node_width[child] ...
[ "Returns", "the", "width", "of", "each", "node", "in", "the", "graph", ".", "#TODO" ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L214-L226
[ "def", "node_width", "(", "self", ")", ":", "nodes", "=", "self", ".", "postorder", "(", ")", "node_width", "=", "{", "}", "for", "node", "in", "nodes", ":", "sum_width", "=", "0", "for", "child", "in", "self", "[", "node", "]", ".", "nodes", "(", ...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.rank_width
Returns the width of each rank in the graph. #TODO
src/papy/graph.py
def rank_width(self): """ Returns the width of each rank in the graph. #TODO """ rank_width = defaultdict(int) node_rank = self.node_rank() for rank in node_rank.values(): rank_width[rank] += 1 return dict(rank_width)
def rank_width(self): """ Returns the width of each rank in the graph. #TODO """ rank_width = defaultdict(int) node_rank = self.node_rank() for rank in node_rank.values(): rank_width[rank] += 1 return dict(rank_width)
[ "Returns", "the", "width", "of", "each", "rank", "in", "the", "graph", ".", "#TODO" ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L228-L237
[ "def", "rank_width", "(", "self", ")", ":", "rank_width", "=", "defaultdict", "(", "int", ")", "node_rank", "=", "self", ".", "node_rank", "(", ")", "for", "rank", "in", "node_rank", ".", "values", "(", ")", ":", "rank_width", "[", "rank", "]", "+=", ...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.add_node
Adds a **node object** to the ``DictGraph``. Returns ``True`` if a new **node object** has been added. If the **node object** is already in the ``DictGraph`` returns ``False``. Arguments: - node(``object``) Node to be added. Any hashable Python ``object``. ...
src/papy/graph.py
def add_node(self, node, xtra=None, branch=None): """ Adds a **node object** to the ``DictGraph``. Returns ``True`` if a new **node object** has been added. If the **node object** is already in the ``DictGraph`` returns ``False``. Arguments: - node(``...
def add_node(self, node, xtra=None, branch=None): """ Adds a **node object** to the ``DictGraph``. Returns ``True`` if a new **node object** has been added. If the **node object** is already in the ``DictGraph`` returns ``False``. Arguments: - node(``...
[ "Adds", "a", "**", "node", "object", "**", "to", "the", "DictGraph", ".", "Returns", "True", "if", "a", "new", "**", "node", "object", "**", "has", "been", "added", ".", "If", "the", "**", "node", "object", "**", "is", "already", "in", "the", "DictGr...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L240-L261
[ "def", "add_node", "(", "self", ",", "node", ",", "xtra", "=", "None", ",", "branch", "=", "None", ")", ":", "if", "not", "node", "in", "self", ":", "node_", "=", "DictNode", "(", "node", ",", "xtra", ")", "self", ".", "update", "(", "node_", ")"...
708e50827b5db46bbea081982cb74b9b0e464064
train
DictGraph.del_node
Removes a **node object** from the ``DictGraph``. Returns ``True`` if a **node object** has been removed. If the **node object** is not in the ``DictGraph`` raises a ``KeyError``. Arguments: - node(``object``) **node object** to be removed. Any hashable Python ...
src/papy/graph.py
def del_node(self, node): """ Removes a **node object** from the ``DictGraph``. Returns ``True`` if a **node object** has been removed. If the **node object** is not in the ``DictGraph`` raises a ``KeyError``. Arguments: - node(``object``) **node ...
def del_node(self, node): """ Removes a **node object** from the ``DictGraph``. Returns ``True`` if a **node object** has been removed. If the **node object** is not in the ``DictGraph`` raises a ``KeyError``. Arguments: - node(``object``) **node ...
[ "Removes", "a", "**", "node", "object", "**", "from", "the", "DictGraph", ".", "Returns", "True", "if", "a", "**", "node", "object", "**", "has", "been", "removed", ".", "If", "the", "**", "node", "object", "**", "is", "not", "in", "the", "DictGraph", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L263-L278
[ "def", "del_node", "(", "self", ",", "node", ")", ":", "for", "node_", "in", "self", ".", "values", "(", ")", ":", "if", "node", "in", "node_", ":", "node_", ".", "pop", "(", "node", ")", "return", "bool", "(", "self", ".", "pop", "(", "node", ...
708e50827b5db46bbea081982cb74b9b0e464064