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
RemoteAccount.get
Get RemoteAccount object for user. :param user_id: User id :param client_id: Client id. :returns: A :class:`invenio_oauthclient.models.RemoteAccount` instance.
invenio_oauthclient/models.py
def get(cls, user_id, client_id): """Get RemoteAccount object for user. :param user_id: User id :param client_id: Client id. :returns: A :class:`invenio_oauthclient.models.RemoteAccount` instance. """ return cls.query.filter_by( user_id=user_id, c...
def get(cls, user_id, client_id): """Get RemoteAccount object for user. :param user_id: User id :param client_id: Client id. :returns: A :class:`invenio_oauthclient.models.RemoteAccount` instance. """ return cls.query.filter_by( user_id=user_id, c...
[ "Get", "RemoteAccount", "object", "for", "user", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/models.py#L63-L73
[ "def", "get", "(", "cls", ",", "user_id", ",", "client_id", ")", ":", "return", "cls", ".", "query", ".", "filter_by", "(", "user_id", "=", "user_id", ",", "client_id", "=", "client_id", ",", ")", ".", "first", "(", ")" ]
2500dc6935738107617aeade79e050d7608004bb
train
RemoteAccount.create
Create new remote account for user. :param user_id: User id. :param client_id: Client id. :param extra_data: JSON-serializable dictionary of any extra data that needs to be save together with this link. :returns: A :class:`invenio_oauthclient.models.RemoteAccount` instance.
invenio_oauthclient/models.py
def create(cls, user_id, client_id, extra_data): """Create new remote account for user. :param user_id: User id. :param client_id: Client id. :param extra_data: JSON-serializable dictionary of any extra data that needs to be save together with this link. :returns: A ...
def create(cls, user_id, client_id, extra_data): """Create new remote account for user. :param user_id: User id. :param client_id: Client id. :param extra_data: JSON-serializable dictionary of any extra data that needs to be save together with this link. :returns: A ...
[ "Create", "new", "remote", "account", "for", "user", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/models.py#L76-L92
[ "def", "create", "(", "cls", ",", "user_id", ",", "client_id", ",", "extra_data", ")", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "account", "=", "cls", "(", "user_id", "=", "user_id", ",", "client_id", "=", "client_id", ","...
2500dc6935738107617aeade79e050d7608004bb
train
RemoteToken.update_token
Update token with new values. :param token: The token value. :param secret: The secret key.
invenio_oauthclient/models.py
def update_token(self, token, secret): """Update token with new values. :param token: The token value. :param secret: The secret key. """ if self.access_token != token or self.secret != secret: with db.session.begin_nested(): self.access_token = token...
def update_token(self, token, secret): """Update token with new values. :param token: The token value. :param secret: The secret key. """ if self.access_token != token or self.secret != secret: with db.session.begin_nested(): self.access_token = token...
[ "Update", "token", "with", "new", "values", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/models.py#L153-L163
[ "def", "update_token", "(", "self", ",", "token", ",", "secret", ")", ":", "if", "self", ".", "access_token", "!=", "token", "or", "self", ".", "secret", "!=", "secret", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "self", "...
2500dc6935738107617aeade79e050d7608004bb
train
RemoteToken.get
Get RemoteToken for user. :param user_id: The user id. :param client_id: The client id. :param token_type: The token type. (Default: ``''``) :param access_token: If set, will filter also by access token. (Default: ``None``) :returns: A :class:`invenio_oauthclient.mod...
invenio_oauthclient/models.py
def get(cls, user_id, client_id, token_type='', access_token=None): """Get RemoteToken for user. :param user_id: The user id. :param client_id: The client id. :param token_type: The token type. (Default: ``''``) :param access_token: If set, will filter also by access token. ...
def get(cls, user_id, client_id, token_type='', access_token=None): """Get RemoteToken for user. :param user_id: The user id. :param client_id: The client id. :param token_type: The token type. (Default: ``''``) :param access_token: If set, will filter also by access token. ...
[ "Get", "RemoteToken", "for", "user", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/models.py#L166-L188
[ "def", "get", "(", "cls", ",", "user_id", ",", "client_id", ",", "token_type", "=", "''", ",", "access_token", "=", "None", ")", ":", "args", "=", "[", "RemoteAccount", ".", "id", "==", "RemoteToken", ".", "id_remote_account", ",", "RemoteAccount", ".", ...
2500dc6935738107617aeade79e050d7608004bb
train
RemoteToken.get_by_token
Get RemoteAccount object for token. :param client_id: The client id. :param access_token: The access token. :param token_type: The token type. (Default: ``''``) :returns: A :class:`invenio_oauthclient.models.RemoteToken` instance.
invenio_oauthclient/models.py
def get_by_token(cls, client_id, access_token, token_type=''): """Get RemoteAccount object for token. :param client_id: The client id. :param access_token: The access token. :param token_type: The token type. (Default: ``''``) :returns: A :class:`invenio_oauthclient.models.Remot...
def get_by_token(cls, client_id, access_token, token_type=''): """Get RemoteAccount object for token. :param client_id: The client id. :param access_token: The access token. :param token_type: The token type. (Default: ``''``) :returns: A :class:`invenio_oauthclient.models.Remot...
[ "Get", "RemoteAccount", "object", "for", "token", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/models.py#L191-L204
[ "def", "get_by_token", "(", "cls", ",", "client_id", ",", "access_token", ",", "token_type", "=", "''", ")", ":", "return", "cls", ".", "query", ".", "options", "(", "db", ".", "joinedload", "(", "'remote_account'", ")", ")", ".", "filter", "(", "RemoteA...
2500dc6935738107617aeade79e050d7608004bb
train
RemoteToken.create
Create a new access token. .. note:: Creates RemoteAccount as well if it does not exists. :param user_id: The user id. :param client_id: The client id. :param token: The token. :param secret: The secret key. :param token_type: The token type. (Default: ``''``) :...
invenio_oauthclient/models.py
def create(cls, user_id, client_id, token, secret, token_type='', extra_data=None): """Create a new access token. .. note:: Creates RemoteAccount as well if it does not exists. :param user_id: The user id. :param client_id: The client id. :param token: The token....
def create(cls, user_id, client_id, token, secret, token_type='', extra_data=None): """Create a new access token. .. note:: Creates RemoteAccount as well if it does not exists. :param user_id: The user id. :param client_id: The client id. :param token: The token....
[ "Create", "a", "new", "access", "token", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/models.py#L207-L241
[ "def", "create", "(", "cls", ",", "user_id", ",", "client_id", ",", "token", ",", "secret", ",", "token_type", "=", "''", ",", "extra_data", "=", "None", ")", ":", "account", "=", "RemoteAccount", ".", "get", "(", "user_id", ",", "client_id", ")", "wit...
2500dc6935738107617aeade79e050d7608004bb
train
ExportsService.bulk_export
Bulk export a set of configs, devices, packages and results. :param config_ids: (optional) Int list of config IDs. :param device_ids: (optional) Int list of device IDs. :param package_ids: (optional) Int list of package IDs. :param result_ids: (optional) Int list of result IDs. ...
cdrouter/exports.py
def bulk_export(self, config_ids=None, device_ids=None, package_ids=None, result_ids=None, exclude_captures=False): """Bulk export a set of configs, devices, packages and results. :param config_ids: (optional) Int list of config IDs. :param device_ids: (optional) Int list of device IDs. ...
def bulk_export(self, config_ids=None, device_ids=None, package_ids=None, result_ids=None, exclude_captures=False): """Bulk export a set of configs, devices, packages and results. :param config_ids: (optional) Int list of config IDs. :param device_ids: (optional) Int list of device IDs. ...
[ "Bulk", "export", "a", "set", "of", "configs", "devices", "packages", "and", "results", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/exports.py#L22-L52
[ "def", "bulk_export", "(", "self", ",", "config_ids", "=", "None", ",", "device_ids", "=", "None", ",", "package_ids", "=", "None", ",", "result_ids", "=", "None", ",", "exclude_captures", "=", "False", ")", ":", "if", "config_ids", "is", "None", ":", "c...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
Report._init_report
create the report directory and return the directory name
reports/report.py
def _init_report(self): """create the report directory and return the directory name""" self.sections = [] self.section_names = [] # if the directory already exists, print a warning try: if os.path.isdir(self.directory) is False: if self.verbose: ...
def _init_report(self): """create the report directory and return the directory name""" self.sections = [] self.section_names = [] # if the directory already exists, print a warning try: if os.path.isdir(self.directory) is False: if self.verbose: ...
[ "create", "the", "report", "directory", "and", "return", "the", "directory", "name" ]
cokelaer/reports
python
https://github.com/cokelaer/reports/blob/7703b1e27d440c3193ee6cc90bfecd78cc98b737/reports/report.py#L159-L209
[ "def", "_init_report", "(", "self", ")", ":", "self", ".", "sections", "=", "[", "]", "self", ".", "section_names", "=", "[", "]", "# if the directory already exists, print a warning", "try", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "d...
7703b1e27d440c3193ee6cc90bfecd78cc98b737
train
Report.get_time_now
Returns a time stamp
reports/report.py
def get_time_now(self): """Returns a time stamp""" import datetime import getpass username = getpass.getuser() # this is not working on some systems: os.environ["USERNAME"] timenow = str(datetime.datetime.now()) timenow = timenow.split('.')[0] msg = '<div ...
def get_time_now(self): """Returns a time stamp""" import datetime import getpass username = getpass.getuser() # this is not working on some systems: os.environ["USERNAME"] timenow = str(datetime.datetime.now()) timenow = timenow.split('.')[0] msg = '<div ...
[ "Returns", "a", "time", "stamp" ]
cokelaer/reports
python
https://github.com/cokelaer/reports/blob/7703b1e27d440c3193ee6cc90bfecd78cc98b737/reports/report.py#L230-L240
[ "def", "get_time_now", "(", "self", ")", ":", "import", "datetime", "import", "getpass", "username", "=", "getpass", ".", "getuser", "(", ")", "# this is not working on some systems: os.environ[\"USERNAME\"]", "timenow", "=", "str", "(", "datetime", ".", "datetime", ...
7703b1e27d440c3193ee6cc90bfecd78cc98b737
train
Report.get_table_dependencies
Returns dependencies of the pipeline as an HTML/XML table The dependencies are the python dependencies as returned by pkg_resource module.
reports/report.py
def get_table_dependencies(self, package="reports"): """Returns dependencies of the pipeline as an HTML/XML table The dependencies are the python dependencies as returned by pkg_resource module. """ dependencies = easydev.get_dependencies(package) # TODO: Could re-use n...
def get_table_dependencies(self, package="reports"): """Returns dependencies of the pipeline as an HTML/XML table The dependencies are the python dependencies as returned by pkg_resource module. """ dependencies = easydev.get_dependencies(package) # TODO: Could re-use n...
[ "Returns", "dependencies", "of", "the", "pipeline", "as", "an", "HTML", "/", "XML", "table" ]
cokelaer/reports
python
https://github.com/cokelaer/reports/blob/7703b1e27d440c3193ee6cc90bfecd78cc98b737/reports/report.py#L242-L261
[ "def", "get_table_dependencies", "(", "self", ",", "package", "=", "\"reports\"", ")", ":", "dependencies", "=", "easydev", ".", "get_dependencies", "(", "package", ")", "# TODO: Could re-use new method in HTMLTable for adding href", "# but needs some extra work in the add_href...
7703b1e27d440c3193ee6cc90bfecd78cc98b737
train
_track_class_related_field
Track a field on a related model
tracking_fields/decorators.py
def _track_class_related_field(cls, field): """ Track a field on a related model """ # field = field on current model # related_field = field on related model (field, related_field) = field.split('__', 1) field_obj = cls._meta.get_field(field) related_cls = field_obj.remote_field.model relat...
def _track_class_related_field(cls, field): """ Track a field on a related model """ # field = field on current model # related_field = field on related model (field, related_field) = field.split('__', 1) field_obj = cls._meta.get_field(field) related_cls = field_obj.remote_field.model relat...
[ "Track", "a", "field", "on", "a", "related", "model" ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/decorators.py#L35-L71
[ "def", "_track_class_related_field", "(", "cls", ",", "field", ")", ":", "# field = field on current model", "# related_field = field on related model", "(", "field", ",", "related_field", ")", "=", "field", ".", "split", "(", "'__'", ",", "1", ")", "field_obj", "="...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_track_class_field
Track a field on the current model
tracking_fields/decorators.py
def _track_class_field(cls, field): """ Track a field on the current model """ if '__' in field: _track_class_related_field(cls, field) return # Will raise FieldDoesNotExist if there is an error cls._meta.get_field(field) # Detect m2m fields changes if isinstance(cls._meta.get_fi...
def _track_class_field(cls, field): """ Track a field on the current model """ if '__' in field: _track_class_related_field(cls, field) return # Will raise FieldDoesNotExist if there is an error cls._meta.get_field(field) # Detect m2m fields changes if isinstance(cls._meta.get_fi...
[ "Track", "a", "field", "on", "the", "current", "model" ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/decorators.py#L74-L87
[ "def", "_track_class_field", "(", "cls", ",", "field", ")", ":", "if", "'__'", "in", "field", ":", "_track_class_related_field", "(", "cls", ",", "field", ")", "return", "# Will raise FieldDoesNotExist if there is an error", "cls", ".", "_meta", ".", "get_field", ...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_track_class
Track fields on the specified model
tracking_fields/decorators.py
def _track_class(cls, fields): """ Track fields on the specified model """ # Small tests to ensure everything is all right assert not getattr(cls, '_is_tracked', False) for field in fields: _track_class_field(cls, field) _add_signals_to_cls(cls) # Mark the class as tracked cls._is...
def _track_class(cls, fields): """ Track fields on the specified model """ # Small tests to ensure everything is all right assert not getattr(cls, '_is_tracked', False) for field in fields: _track_class_field(cls, field) _add_signals_to_cls(cls) # Mark the class as tracked cls._is...
[ "Track", "fields", "on", "the", "specified", "model" ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/decorators.py#L90-L107
[ "def", "_track_class", "(", "cls", ",", "fields", ")", ":", "# Small tests to ensure everything is all right", "assert", "not", "getattr", "(", "cls", ",", "'_is_tracked'", ",", "False", ")", "for", "field", "in", "fields", ":", "_track_class_field", "(", "cls", ...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_add_get_tracking_url
Add a method to get the tracking url of an object.
tracking_fields/decorators.py
def _add_get_tracking_url(cls): """ Add a method to get the tracking url of an object. """ def get_tracking_url(self): """ return url to tracking view in admin panel """ url = reverse('admin:tracking_fields_trackingevent_changelist') object_id = '{0}%3A{1}'.format( ContentTyp...
def _add_get_tracking_url(cls): """ Add a method to get the tracking url of an object. """ def get_tracking_url(self): """ return url to tracking view in admin panel """ url = reverse('admin:tracking_fields_trackingevent_changelist') object_id = '{0}%3A{1}'.format( ContentTyp...
[ "Add", "a", "method", "to", "get", "the", "tracking", "url", "of", "an", "object", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/decorators.py#L110-L121
[ "def", "_add_get_tracking_url", "(", "cls", ")", ":", "def", "get_tracking_url", "(", "self", ")", ":", "\"\"\" return url to tracking view in admin panel \"\"\"", "url", "=", "reverse", "(", "'admin:tracking_fields_trackingevent_changelist'", ")", "object_id", "=", "'{0}%3...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
track
Decorator used to track changes on Model's fields. :Example: >>> @track('name') ... class Human(models.Model): ... name = models.CharField(max_length=30)
tracking_fields/decorators.py
def track(*fields): """ Decorator used to track changes on Model's fields. :Example: >>> @track('name') ... class Human(models.Model): ... name = models.CharField(max_length=30) """ def inner(cls): _track_class(cls, fields) _add_get_tracking_url(cls) ...
def track(*fields): """ Decorator used to track changes on Model's fields. :Example: >>> @track('name') ... class Human(models.Model): ... name = models.CharField(max_length=30) """ def inner(cls): _track_class(cls, fields) _add_get_tracking_url(cls) ...
[ "Decorator", "used", "to", "track", "changes", "on", "Model", "s", "fields", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/decorators.py#L124-L137
[ "def", "track", "(", "*", "fields", ")", ":", "def", "inner", "(", "cls", ")", ":", "_track_class", "(", "cls", ",", "fields", ")", "_add_get_tracking_url", "(", "cls", ")", "return", "cls", "return", "inner" ]
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
indent
Indent a value by `n` `character`s :param value: string to indent :param n: number of characters to indent by :param character: character to indent with
docs/generate.py
def indent(value, n=2, character=' '): """ Indent a value by `n` `character`s :param value: string to indent :param n: number of characters to indent by :param character: character to indent with """ prefix = n * character return '\n'.join(prefix + line for line in value.splitlines())
def indent(value, n=2, character=' '): """ Indent a value by `n` `character`s :param value: string to indent :param n: number of characters to indent by :param character: character to indent with """ prefix = n * character return '\n'.join(prefix + line for line in value.splitlines())
[ "Indent", "a", "value", "by", "n", "character", "s" ]
dourvaris/nano-python
python
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/docs/generate.py#L13-L23
[ "def", "indent", "(", "value", ",", "n", "=", "2", ",", "character", "=", "' '", ")", ":", "prefix", "=", "n", "*", "character", "return", "'\\n'", ".", "join", "(", "prefix", "+", "line", "for", "line", "in", "value", ".", "splitlines", "(", ")", ...
f26b8bc895b997067780f925049a70e82c0c2479
train
extract_docs
Parses the nano.rpc.Client for methods that have a __doc_meta__ attribute and saves generated docs
docs/generate.py
def extract_docs(): """ Parses the nano.rpc.Client for methods that have a __doc_meta__ attribute and saves generated docs """ methods = [] def _key(entry): return sorted_entries = sorted(Client.__dict__.items(), key=lambda x: x[0]) tree = {} meta_key = '__doc_meta__' ...
def extract_docs(): """ Parses the nano.rpc.Client for methods that have a __doc_meta__ attribute and saves generated docs """ methods = [] def _key(entry): return sorted_entries = sorted(Client.__dict__.items(), key=lambda x: x[0]) tree = {} meta_key = '__doc_meta__' ...
[ "Parses", "the", "nano", ".", "rpc", ".", "Client", "for", "methods", "that", "have", "a", "__doc_meta__", "attribute", "and", "saves", "generated", "docs" ]
dourvaris/nano-python
python
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/docs/generate.py#L26-L109
[ "def", "extract_docs", "(", ")", ":", "methods", "=", "[", "]", "def", "_key", "(", "entry", ")", ":", "return", "sorted_entries", "=", "sorted", "(", "Client", ".", "__dict__", ".", "items", "(", ")", ",", "key", "=", "lambda", "x", ":", "x", "[",...
f26b8bc895b997067780f925049a70e82c0c2479
train
Jaide.check_instance
Wrapper that tests the type of _session. Purpose: This decorator function is used by all functions within | the Jaide class that interact with a device to ensure the | proper session type is in use. If it is not, it will | attempt to migrate _session to that type befor...
jaide/core.py
def check_instance(function): """ Wrapper that tests the type of _session. Purpose: This decorator function is used by all functions within | the Jaide class that interact with a device to ensure the | proper session type is in use. If it is not, it will | atte...
def check_instance(function): """ Wrapper that tests the type of _session. Purpose: This decorator function is used by all functions within | the Jaide class that interact with a device to ensure the | proper session type is in use. If it is not, it will | atte...
[ "Wrapper", "that", "tests", "the", "type", "of", "_session", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L132-L201
[ "def", "check_instance", "(", "function", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "func_trans", "=", "{", "\"commit\"", ":", "manager", ".", "Manager", ",", "\"compare_config\"", ":", "manager", ".", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.cli_to_shell
Move _shell to the shell from the command line interface (CLI).
jaide/core.py
def cli_to_shell(self): """ Move _shell to the shell from the command line interface (CLI). """ if self._in_cli: self._shell.send("start shell\n") time.sleep(2) self._shell.recv(9999) self._in_cli = False return True return False
def cli_to_shell(self): """ Move _shell to the shell from the command line interface (CLI). """ if self._in_cli: self._shell.send("start shell\n") time.sleep(2) self._shell.recv(9999) self._in_cli = False return True return False
[ "Move", "_shell", "to", "the", "shell", "from", "the", "command", "line", "interface", "(", "CLI", ")", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L203-L211
[ "def", "cli_to_shell", "(", "self", ")", ":", "if", "self", ".", "_in_cli", ":", "self", ".", "_shell", ".", "send", "(", "\"start shell\\n\"", ")", "time", ".", "sleep", "(", "2", ")", "self", ".", "_shell", ".", "recv", "(", "9999", ")", "self", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.commit
Perform a commit operation. Purpose: Executes a commit operation. All parameters are optional. | commit confirm and commit at are mutually exclusive. All | the others can be used with each other and commit confirm/at. @param commands: A string or list of multiple commands...
jaide/core.py
def commit(self, commands="", confirmed=None, comment=None, at_time=None, synchronize=False, req_format='text'): """ Perform a commit operation. Purpose: Executes a commit operation. All parameters are optional. | commit confirm and commit at are mutually exclusive. All ...
def commit(self, commands="", confirmed=None, comment=None, at_time=None, synchronize=False, req_format='text'): """ Perform a commit operation. Purpose: Executes a commit operation. All parameters are optional. | commit confirm and commit at are mutually exclusive. All ...
[ "Perform", "a", "commit", "operation", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L214-L298
[ "def", "commit", "(", "self", ",", "commands", "=", "\"\"", ",", "confirmed", "=", "None", ",", "comment", "=", "None", ",", "at_time", "=", "None", ",", "synchronize", "=", "False", ",", "req_format", "=", "'text'", ")", ":", "# ncclient doesn't support a...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.commit_check
Execute a commit check operation. Purpose: This method will take in string of multiple commands, | and perform and 'commit check' on the device to ensure | the commands are syntactically correct. The response can | be formatted as text or as xml. @param com...
jaide/core.py
def commit_check(self, commands="", req_format="text"): """ Execute a commit check operation. Purpose: This method will take in string of multiple commands, | and perform and 'commit check' on the device to ensure | the commands are syntactically correct. The response can ...
def commit_check(self, commands="", req_format="text"): """ Execute a commit check operation. Purpose: This method will take in string of multiple commands, | and perform and 'commit check' on the device to ensure | the commands are syntactically correct. The response can ...
[ "Execute", "a", "commit", "check", "operation", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L301-L352
[ "def", "commit_check", "(", "self", ",", "commands", "=", "\"\"", ",", "req_format", "=", "\"text\"", ")", ":", "if", "not", "commands", ":", "raise", "InvalidCommandError", "(", "'No commands specified'", ")", "clean_cmds", "=", "[", "]", "for", "cmd", "in"...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.compare_config
Execute a 'show | compare' against the specified commands. Purpose: This method will take in string of multiple commands, | and perform and 'show | compare' on the device to show the | differences between the active running configuration and | the changes proposed b...
jaide/core.py
def compare_config(self, commands="", req_format="text"): """ Execute a 'show | compare' against the specified commands. Purpose: This method will take in string of multiple commands, | and perform and 'show | compare' on the device to show the | differences between the ac...
def compare_config(self, commands="", req_format="text"): """ Execute a 'show | compare' against the specified commands. Purpose: This method will take in string of multiple commands, | and perform and 'show | compare' on the device to show the | differences between the ac...
[ "Execute", "a", "show", "|", "compare", "against", "the", "specified", "commands", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L355-L383
[ "def", "compare_config", "(", "self", ",", "commands", "=", "\"\"", ",", "req_format", "=", "\"text\"", ")", ":", "if", "not", "commands", ":", "raise", "InvalidCommandError", "(", "'No commands specified'", ")", "clean_cmds", "=", "[", "cmd", "for", "cmd", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.connect
Establish a connection to the device. Purpose: This method is used to make a connection to the junos | device. The internal property conn_type is what | determines the type of connection we make to the device. | - 'paramiko' is used for operational commands (to allo...
jaide/core.py
def connect(self): """ Establish a connection to the device. Purpose: This method is used to make a connection to the junos | device. The internal property conn_type is what | determines the type of connection we make to the device. | - 'paramiko' is used fo...
def connect(self): """ Establish a connection to the device. Purpose: This method is used to make a connection to the junos | device. The internal property conn_type is what | determines the type of connection we make to the device. | - 'paramiko' is used fo...
[ "Establish", "a", "connection", "to", "the", "device", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L385-L457
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "conn_type", "==", "'paramiko'", ":", "self", ".", "_session", "=", "paramiko", ".", "SSHClient", "(", ")", "# These two lines set the paramiko logging to Critical to", "# remove extra messages from being sent ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide._copy_status
Echo status of an SCP operation. Purpose: Callback function for an SCP operation. Used to show | the progress of an actively running copy. This directly | prints to stdout, one line for each file as it's copied. | The parameters received by this function are those r...
jaide/core.py
def _copy_status(self, filename, size, sent): """ Echo status of an SCP operation. Purpose: Callback function for an SCP operation. Used to show | the progress of an actively running copy. This directly | prints to stdout, one line for each file as it's copied. ...
def _copy_status(self, filename, size, sent): """ Echo status of an SCP operation. Purpose: Callback function for an SCP operation. Used to show | the progress of an actively running copy. This directly | prints to stdout, one line for each file as it's copied. ...
[ "Echo", "status", "of", "an", "SCP", "operation", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L459-L485
[ "def", "_copy_status", "(", "self", ",", "filename", ",", "size", ",", "sent", ")", ":", "output", "=", "\"Transferred %.0f%% of the file %s\"", "%", "(", "(", "float", "(", "sent", ")", "/", "float", "(", "size", ")", "*", "100", ")", ",", "path", "."...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.device_info
Pull basic device information. Purpose: This function grabs the hostname, model, running version, and | serial number of the device. @returns: The output that should be shown to the user. @rtype: str
jaide/core.py
def device_info(self): """ Pull basic device information. Purpose: This function grabs the hostname, model, running version, and | serial number of the device. @returns: The output that should be shown to the user. @rtype: str """ # get hostname, model, a...
def device_info(self): """ Pull basic device information. Purpose: This function grabs the hostname, model, running version, and | serial number of the device. @returns: The output that should be shown to the user. @rtype: str """ # get hostname, model, a...
[ "Pull", "basic", "device", "information", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L488-L588
[ "def", "device_info", "(", "self", ")", ":", "# get hostname, model, and version from 'show version'", "resp", "=", "self", ".", "_session", ".", "get_software_information", "(", "format", "=", "'xml'", ")", "hostname", "=", "resp", ".", "xpath", "(", "'//software-i...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.diff_config
Generate configuration differences with a second device. Purpose: Open a second ncclient.manager.Manager with second_host, and | and pull the configuration from it. We then use difflib to | get the delta between the two, and yield the results. @param second_host: the IP o...
jaide/core.py
def diff_config(self, second_host, mode='stanza'): """ Generate configuration differences with a second device. Purpose: Open a second ncclient.manager.Manager with second_host, and | and pull the configuration from it. We then use difflib to | get the delta between the tw...
def diff_config(self, second_host, mode='stanza'): """ Generate configuration differences with a second device. Purpose: Open a second ncclient.manager.Manager with second_host, and | and pull the configuration from it. We then use difflib to | get the delta between the tw...
[ "Generate", "configuration", "differences", "with", "a", "second", "device", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L592-L633
[ "def", "diff_config", "(", "self", ",", "second_host", ",", "mode", "=", "'stanza'", ")", ":", "second_conn", "=", "manager", ".", "connect", "(", "host", "=", "second_host", ",", "port", "=", "self", ".", "port", ",", "username", "=", "self", ".", "us...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.disconnect
Close the connection(s) to the device. Purpose: Closes the current connection(s) to the device, no matter | what types exist. @returns: None @rtype: None
jaide/core.py
def disconnect(self): """ Close the connection(s) to the device. Purpose: Closes the current connection(s) to the device, no matter | what types exist. @returns: None @rtype: None """ if self._shell: self._shell.close() self._shell...
def disconnect(self): """ Close the connection(s) to the device. Purpose: Closes the current connection(s) to the device, no matter | what types exist. @returns: None @rtype: None """ if self._shell: self._shell.close() self._shell...
[ "Close", "the", "connection", "(", "s", ")", "to", "the", "device", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L635-L655
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "_shell", ":", "self", ".", "_shell", ".", "close", "(", ")", "self", ".", "_shell", "=", "\"\"", "if", "isinstance", "(", "self", ".", "_session", ",", "manager", ".", "Manager", ")", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide._error_parse
Parse the extensive xml output of an interface and yield errors. Purpose: Takes the xml output of 'show interfaces extensive' for a | given interface and yields the error types that have a | significant number of errors. @param interface: The xml output of the 'sh int ext...
jaide/core.py
def _error_parse(self, interface, face): """ Parse the extensive xml output of an interface and yield errors. Purpose: Takes the xml output of 'show interfaces extensive' for a | given interface and yields the error types that have a | significant number of errors. ...
def _error_parse(self, interface, face): """ Parse the extensive xml output of an interface and yield errors. Purpose: Takes the xml output of 'show interfaces extensive' for a | given interface and yields the error types that have a | significant number of errors. ...
[ "Parse", "the", "extensive", "xml", "output", "of", "an", "interface", "and", "yield", "errors", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L657-L685
[ "def", "_error_parse", "(", "self", ",", "interface", ",", "face", ")", ":", "try", ":", "error_list", "=", "interface", ".", "xpath", "(", "face", "+", "'-error-list'", ")", "[", "0", "]", ".", "getchildren", "(", ")", "except", "IndexError", ":", "# ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.health_check
Pull health and alarm information from the device. Purpose: Grab the cpu/mem usage, system/chassis alarms, top 5 | processes, and states if the primary/backup partitions are on | different versions. @returns: The output that should be shown to the user. @rtype: st...
jaide/core.py
def health_check(self): """ Pull health and alarm information from the device. Purpose: Grab the cpu/mem usage, system/chassis alarms, top 5 | processes, and states if the primary/backup partitions are on | different versions. @returns: The output that should be s...
def health_check(self): """ Pull health and alarm information from the device. Purpose: Grab the cpu/mem usage, system/chassis alarms, top 5 | processes, and states if the primary/backup partitions are on | different versions. @returns: The output that should be s...
[ "Pull", "health", "and", "alarm", "information", "from", "the", "device", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L688-L734
[ "def", "health_check", "(", "self", ")", ":", "output", "=", "'Chassis Alarms:\\n\\t'", "# Grab chassis alarms, system alarms, show chassis routing-engine,", "# 'show system processes extensive', and also xpath to the", "# relevant nodes on each.", "chassis_alarms", "=", "self", ".", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.interface_errors
Parse 'show interfaces extensive' and return interfaces with errors. Purpose: This function is called for the -e flag. It will let the user | know if there are any interfaces with errors, and what those | interfaces are. @returns: The output that should be shown to the us...
jaide/core.py
def interface_errors(self): """ Parse 'show interfaces extensive' and return interfaces with errors. Purpose: This function is called for the -e flag. It will let the user | know if there are any interfaces with errors, and what those | interfaces are. @returns: T...
def interface_errors(self): """ Parse 'show interfaces extensive' and return interfaces with errors. Purpose: This function is called for the -e flag. It will let the user | know if there are any interfaces with errors, and what those | interfaces are. @returns: T...
[ "Parse", "show", "interfaces", "extensive", "and", "return", "interfaces", "with", "errors", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L737-L772
[ "def", "interface_errors", "(", "self", ")", ":", "output", "=", "[", "]", "# used to store the list of interfaces with errors.", "# get a string of each physical and logical interface element", "dev_response", "=", "self", ".", "_session", ".", "command", "(", "'sh interface...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.lock
Lock the candidate config. Requires ncclient.manager.Manager.
jaide/core.py
def lock(self): """ Lock the candidate config. Requires ncclient.manager.Manager. """ if isinstance(self._session, manager.Manager): self._session.lock()
def lock(self): """ Lock the candidate config. Requires ncclient.manager.Manager. """ if isinstance(self._session, manager.Manager): self._session.lock()
[ "Lock", "the", "candidate", "config", ".", "Requires", "ncclient", ".", "manager", ".", "Manager", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L774-L777
[ "def", "lock", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_session", ",", "manager", ".", "Manager", ")", ":", "self", ".", "_session", ".", "lock", "(", ")" ]
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.op_cmd
Execute an operational mode command. Purpose: Used to send an operational mode command to the connected | device. This requires and uses a paramiko.SSHClient() as | the handler so that we can easily pass and allow all pipe | commands to be used. | ...
jaide/core.py
def op_cmd(self, command, req_format='text', xpath_expr=""): """ Execute an operational mode command. Purpose: Used to send an operational mode command to the connected | device. This requires and uses a paramiko.SSHClient() as | the handler so that we can easily pass and ...
def op_cmd(self, command, req_format='text', xpath_expr=""): """ Execute an operational mode command. Purpose: Used to send an operational mode command to the connected | device. This requires and uses a paramiko.SSHClient() as | the handler so that we can easily pass and ...
[ "Execute", "an", "operational", "mode", "command", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L780-L832
[ "def", "op_cmd", "(", "self", ",", "command", ",", "req_format", "=", "'text'", ",", "xpath_expr", "=", "\"\"", ")", ":", "if", "not", "command", ":", "raise", "InvalidCommandError", "(", "\"Parameter 'command' cannot be empty\"", ")", "if", "req_format", ".", ...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.scp_pull
Makes an SCP pull request for the specified file(s)/dir. Purpose: By leveraging the _scp private variable, we make an scp pull | request to retrieve file(s) from a Junos device. @param src: string containing the source file or directory @type src: str @param dest: destin...
jaide/core.py
def scp_pull(self, src, dest, progress=False, preserve_times=True): """ Makes an SCP pull request for the specified file(s)/dir. Purpose: By leveraging the _scp private variable, we make an scp pull | request to retrieve file(s) from a Junos device. @param src: string containing...
def scp_pull(self, src, dest, progress=False, preserve_times=True): """ Makes an SCP pull request for the specified file(s)/dir. Purpose: By leveraging the _scp private variable, we make an scp pull | request to retrieve file(s) from a Junos device. @param src: string containing...
[ "Makes", "an", "SCP", "pull", "request", "for", "the", "specified", "file", "(", "s", ")", "/", "dir", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L835-L868
[ "def", "scp_pull", "(", "self", ",", "src", ",", "dest", ",", "progress", "=", "False", ",", "preserve_times", "=", "True", ")", ":", "# set up the progress callback if they want to see the process", "if", "progress", "is", "True", ":", "self", ".", "_scp", ".",...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.scp_push
Purpose: Makes an SCP push request for the specified file(s)/dir. @param src: string containing the source file or directory @type src: str @param dest: destination string of where to put the file(s)/dir @type dest: str @param progress: set to `True` to have the progress callbac...
jaide/core.py
def scp_push(self, src, dest, progress=False, preserve_times=True): """ Purpose: Makes an SCP push request for the specified file(s)/dir. @param src: string containing the source file or directory @type src: str @param dest: destination string of where to put the file(s)/dir @ty...
def scp_push(self, src, dest, progress=False, preserve_times=True): """ Purpose: Makes an SCP push request for the specified file(s)/dir. @param src: string containing the source file or directory @type src: str @param dest: destination string of where to put the file(s)/dir @ty...
[ "Purpose", ":", "Makes", "an", "SCP", "push", "request", "for", "the", "specified", "file", "(", "s", ")", "/", "dir", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L871-L901
[ "def", "scp_push", "(", "self", ",", "src", ",", "dest", ",", "progress", "=", "False", ",", "preserve_times", "=", "True", ")", ":", "# set up the progress callback if they want to see the process", "if", "progress", "is", "True", ":", "self", ".", "_scp", ".",...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.shell_cmd
Execute a shell command. Purpose: Used to send a shell command to the connected device. | This uses the self._shell instance, which should be a | paramiko.Channel object, instead of a SSHClient. | This is because we cannot send shell commands to the |...
jaide/core.py
def shell_cmd(self, command=""): """ Execute a shell command. Purpose: Used to send a shell command to the connected device. | This uses the self._shell instance, which should be a | paramiko.Channel object, instead of a SSHClient. | This is because we canno...
def shell_cmd(self, command=""): """ Execute a shell command. Purpose: Used to send a shell command to the connected device. | This uses the self._shell instance, which should be a | paramiko.Channel object, instead of a SSHClient. | This is because we canno...
[ "Execute", "a", "shell", "command", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L904-L930
[ "def", "shell_cmd", "(", "self", ",", "command", "=", "\"\"", ")", ":", "if", "not", "command", ":", "raise", "InvalidCommandError", "(", "\"Parameter 'command' must not be empty.\"", ")", "command", "=", "command", ".", "strip", "(", ")", "+", "'\\n'", "self"...
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
Jaide.unlock
Unlock the candidate config. Purpose: Unlocks the candidate configuration, so that other people can | edit the device. Requires the _session private variable to be | a type of a ncclient.manager.Manager.
jaide/core.py
def unlock(self): """ Unlock the candidate config. Purpose: Unlocks the candidate configuration, so that other people can | edit the device. Requires the _session private variable to be | a type of a ncclient.manager.Manager. """ if isinstance(self._session...
def unlock(self): """ Unlock the candidate config. Purpose: Unlocks the candidate configuration, so that other people can | edit the device. Requires the _session private variable to be | a type of a ncclient.manager.Manager. """ if isinstance(self._session...
[ "Unlock", "the", "candidate", "config", "." ]
NetworkAutomation/jaide
python
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/core.py#L942-L950
[ "def", "unlock", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_session", ",", "manager", ".", "Manager", ")", ":", "self", ".", "_session", ".", "unlock", "(", ")" ]
8571b987a8c24c246dc09f1bcc11cb0f045ec33f
train
basic_cleanup
Test: >>> from common_cache import Cache >>> import time >>> cache = Cache(expire=1, cleanup_func=basic_cleanup, regularly_cleanup=False) >>> cache.put('a', value=0) >>> cache.put('b', value=1) >>> cache.put('c', value=2) >>> cache.put('d', value=3, expire=3) >>> cache.size() 4 ...
common_cache/cleanup.py
def basic_cleanup(self): """ Test: >>> from common_cache import Cache >>> import time >>> cache = Cache(expire=1, cleanup_func=basic_cleanup, regularly_cleanup=False) >>> cache.put('a', value=0) >>> cache.put('b', value=1) >>> cache.put('c', value=2) >>> cache.put('d', value=3, expi...
def basic_cleanup(self): """ Test: >>> from common_cache import Cache >>> import time >>> cache = Cache(expire=1, cleanup_func=basic_cleanup, regularly_cleanup=False) >>> cache.put('a', value=0) >>> cache.put('b', value=1) >>> cache.put('c', value=2) >>> cache.put('d', value=3, expi...
[ "Test", ":" ]
SylvanasSun/python-common-cache
python
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/cleanup.py#L9-L50
[ "def", "basic_cleanup", "(", "self", ")", ":", "next_expire", "=", "None", "keys_to_delete", "=", "[", "]", "if", "self", ".", "expire", "is", "not", "None", "and", "self", ".", "expire", ">", "0", ":", "# cleanup invalid cache item until the meet valid cache it...
f113eb3cd751eed5ab5373e8610a31a444220cf8
train
intercept
Wraps an existing method on an object with the provided generator, which will be "sent" the value when it yields control. :: >>> def ensure_primary_key_is_set(): ... assert model.pk is None ... saved = yield ... aasert model is saved ... assert model.pk ...
exam/helpers.py
def intercept(obj, methodname, wrapper): """ Wraps an existing method on an object with the provided generator, which will be "sent" the value when it yields control. :: >>> def ensure_primary_key_is_set(): ... assert model.pk is None ... saved = yield ... a...
def intercept(obj, methodname, wrapper): """ Wraps an existing method on an object with the provided generator, which will be "sent" the value when it yields control. :: >>> def ensure_primary_key_is_set(): ... assert model.pk is None ... saved = yield ... a...
[ "Wraps", "an", "existing", "method", "on", "an", "object", "with", "the", "provided", "generator", "which", "will", "be", "sent", "the", "value", "when", "it", "yields", "control", "." ]
Fluxx/exam
python
https://github.com/Fluxx/exam/blob/27dc53a703349ec09433a6b989d6fc32ad523c0b/exam/helpers.py#L28-L72
[ "def", "intercept", "(", "obj", ",", "methodname", ",", "wrapper", ")", ":", "original", "=", "getattr", "(", "obj", ",", "methodname", ")", "def", "replacement", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "wrapfn", "=", "wrapper", "(", "*"...
27dc53a703349ec09433a6b989d6fc32ad523c0b
train
imports
Should be used as a decorator to *attach* import statments to function definitions. These imports are added to the global (i.e. module-level of the decorated function) namespace. Two forms of import statements are supported (in the following examples ``foo``, ``bar``, ``oof, and ``rab`` are mo...
src/numap/NuMap.py
def imports(modules, forgive=False): """ Should be used as a decorator to *attach* import statments to function definitions. These imports are added to the global (i.e. module-level of the decorated function) namespace. Two forms of import statements are supported (in the following example...
def imports(modules, forgive=False): """ Should be used as a decorator to *attach* import statments to function definitions. These imports are added to the global (i.e. module-level of the decorated function) namespace. Two forms of import statements are supported (in the following example...
[ "Should", "be", "used", "as", "a", "decorator", "to", "*", "attach", "*", "import", "statments", "to", "function", "definitions", ".", "These", "imports", "are", "added", "to", "the", "global", "(", "i", ".", "e", ".", "module", "-", "level", "of", "th...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L766-L842
[ "def", "imports", "(", "modules", ",", "forgive", "=", "False", ")", ":", "def", "wrap", "(", "f", ")", ":", "if", "modules", ":", "# attach import to function", "setattr", "(", "f", ",", "'imports'", ",", "modules", ")", "for", "alternatives", "in", "mo...
708e50827b5db46bbea081982cb74b9b0e464064
train
_pool_worker
(internal) Function which is executed by worker pool processes or threads. It waits for tasks (function, data, arguments) at the input queue "inqueue" evaluates the result and passes it to the output queue "outqueue". It optionally evaluates the function on a remote host.
src/numap/NuMap.py
def _pool_worker(inqueue, outqueue, host=None): """ (internal) Function which is executed by worker pool processes or threads. It waits for tasks (function, data, arguments) at the input queue "inqueue" evaluates the result and passes it to the output queue "outqueue". It optionally evaluates the f...
def _pool_worker(inqueue, outqueue, host=None): """ (internal) Function which is executed by worker pool processes or threads. It waits for tasks (function, data, arguments) at the input queue "inqueue" evaluates the result and passes it to the output queue "outqueue". It optionally evaluates the f...
[ "(", "internal", ")", "Function", "which", "is", "executed", "by", "worker", "pool", "processes", "or", "threads", ".", "It", "waits", "for", "tasks", "(", "function", "data", "arguments", ")", "at", "the", "input", "queue", "inqueue", "evaluates", "the", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L944-L990
[ "def", "_pool_worker", "(", "inqueue", ",", "outqueue", ",", "host", "=", "None", ")", ":", "put", "=", "outqueue", ".", "put", "get", "=", "inqueue", ".", "get", "if", "hasattr", "(", "inqueue", ",", "'_writer'", ")", ":", "inqueue", ".", "_writer", ...
708e50827b5db46bbea081982cb74b9b0e464064
train
_inject_func
(internal) injects a function object into a RPyC connection object.
src/numap/NuMap.py
def _inject_func(func, conn): """ (internal) injects a function object into a RPyC connection object. """ name = func.__name__ if not name in conn.namespace: if isbuiltin(func): inject_code = '%s = %s' % (name, name) elif isfunction(func): inject_code = getsou...
def _inject_func(func, conn): """ (internal) injects a function object into a RPyC connection object. """ name = func.__name__ if not name in conn.namespace: if isbuiltin(func): inject_code = '%s = %s' % (name, name) elif isfunction(func): inject_code = getsou...
[ "(", "internal", ")", "injects", "a", "function", "object", "into", "a", "RPyC", "connection", "object", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L992-L1003
[ "def", "_inject_func", "(", "func", ",", "conn", ")", ":", "name", "=", "func", ".", "__name__", "if", "not", "name", "in", "conn", ".", "namespace", ":", "if", "isbuiltin", "(", "func", ")", ":", "inject_code", "=", "'%s = %s'", "%", "(", "name", ",...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap._pool_put
(internal) Intended to be run in a seperate thread. Feeds tasks into to the pool whenever semaphore permits. Finishes if self._stopping is set.
src/numap/NuMap.py
def _pool_put(pool_semaphore, tasks, put_to_pool_in, pool_size, id_self, \ is_stopping): """ (internal) Intended to be run in a seperate thread. Feeds tasks into to the pool whenever semaphore permits. Finishes if self._stopping is set. """ log.debug(...
def _pool_put(pool_semaphore, tasks, put_to_pool_in, pool_size, id_self, \ is_stopping): """ (internal) Intended to be run in a seperate thread. Feeds tasks into to the pool whenever semaphore permits. Finishes if self._stopping is set. """ log.debug(...
[ "(", "internal", ")", "Intended", "to", "be", "run", "in", "a", "seperate", "thread", ".", "Feeds", "tasks", "into", "to", "the", "pool", "whenever", "semaphore", "permits", ".", "Finishes", "if", "self", ".", "_stopping", "is", "set", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L184-L248
[ "def", "_pool_put", "(", "pool_semaphore", ",", "tasks", ",", "put_to_pool_in", ",", "pool_size", ",", "id_self", ",", "is_stopping", ")", ":", "log", ".", "debug", "(", "'NuMap(%s) started pool_putter.'", "%", "id_self", ")", "last_tasks", "=", "{", "}", "for...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap._pool_get
(internal) Intended to be run in a separate thread and take results from the pool and put them into queues depending on the task of the result. It finishes if it receives termination-sentinels from all pool workers.
src/numap/NuMap.py
def _pool_get(get, results, next_available, task_next_lock, to_skip, \ task_num, pool_size, id_self): """ (internal) Intended to be run in a separate thread and take results from the pool and put them into queues depending on the task of the result. It finishes if it ...
def _pool_get(get, results, next_available, task_next_lock, to_skip, \ task_num, pool_size, id_self): """ (internal) Intended to be run in a separate thread and take results from the pool and put them into queues depending on the task of the result. It finishes if it ...
[ "(", "internal", ")", "Intended", "to", "be", "run", "in", "a", "separate", "thread", "and", "take", "results", "from", "the", "pool", "and", "put", "them", "into", "queues", "depending", "on", "the", "task", "of", "the", "result", ".", "It", "finishes",...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L251-L342
[ "def", "_pool_get", "(", "get", ",", "results", ",", "next_available", ",", "task_next_lock", ",", "to_skip", ",", "task_num", ",", "pool_size", ",", "id_self", ")", ":", "log", ".", "debug", "(", "'NuMap(%s) started pool_getter'", "%", "id_self", ")", "# shou...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap._start_managers
(internal) starts input and output pool queue manager threads.
src/numap/NuMap.py
def _start_managers(self): """ (internal) starts input and output pool queue manager threads. """ self._task_queue = _Weave(self._tasks, self.stride) # here we determine the size of the maximum memory consumption self._semaphore_value = (self.buffer or (len(self._tasks) *...
def _start_managers(self): """ (internal) starts input and output pool queue manager threads. """ self._task_queue = _Weave(self._tasks, self.stride) # here we determine the size of the maximum memory consumption self._semaphore_value = (self.buffer or (len(self._tasks) *...
[ "(", "internal", ")", "starts", "input", "and", "output", "pool", "queue", "manager", "threads", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L424-L447
[ "def", "_start_managers", "(", "self", ")", ":", "self", ".", "_task_queue", "=", "_Weave", "(", "self", ".", "_tasks", ",", "self", ".", "stride", ")", "# here we determine the size of the maximum memory consumption", "self", ".", "_semaphore_value", "=", "(", "s...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap._start_workers
(internal) starts **worker pool** threads or processes.
src/numap/NuMap.py
def _start_workers(self): """ (internal) starts **worker pool** threads or processes. """ # creating the pool of worker process or threads log.debug('%s starts a %s-pool of %s workers.' % \ (self, self.worker_type, self.worker_num)) self.pool = [] ...
def _start_workers(self): """ (internal) starts **worker pool** threads or processes. """ # creating the pool of worker process or threads log.debug('%s starts a %s-pool of %s workers.' % \ (self, self.worker_type, self.worker_num)) self.pool = [] ...
[ "(", "internal", ")", "starts", "**", "worker", "pool", "**", "threads", "or", "processes", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L449-L469
[ "def", "_start_workers", "(", "self", ")", ":", "# creating the pool of worker process or threads", "log", ".", "debug", "(", "'%s starts a %s-pool of %s workers.'", "%", "(", "self", ",", "self", ".", "worker_type", ",", "self", ".", "worker_num", ")", ")", "self",...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap._stop
(internal) stops input and output pool queue manager threads.
src/numap/NuMap.py
def _stop(self): """ (internal) stops input and output pool queue manager threads. """ if self._started.isSet(): # join threads self._pool_getter.join() self._pool_putter.join() for worker in self.pool: worker.join() ...
def _stop(self): """ (internal) stops input and output pool queue manager threads. """ if self._started.isSet(): # join threads self._pool_getter.join() self._pool_putter.join() for worker in self.pool: worker.join() ...
[ "(", "internal", ")", "stops", "input", "and", "output", "pool", "queue", "manager", "threads", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L471-L490
[ "def", "_stop", "(", "self", ")", ":", "if", "self", ".", "_started", ".", "isSet", "(", ")", ":", "# join threads", "self", ".", "_pool_getter", ".", "join", "(", ")", "self", ".", "_pool_putter", ".", "join", "(", ")", "for", "worker", "in", "self"...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap.add_task
Adds a **task** to evaluate. A **task** is jointly a function or callable an iterable with optional arguments and keyworded arguments. The iterable can be the result iterator of a previously added **task** (to the same or to a different ``NuMap`` instance). Arguments: ...
src/numap/NuMap.py
def add_task(self, func, iterable, args=None, kwargs=None, timeout=None, \ block=True, track=False): """ Adds a **task** to evaluate. A **task** is jointly a function or callable an iterable with optional arguments and keyworded arguments. The iterable can be the result...
def add_task(self, func, iterable, args=None, kwargs=None, timeout=None, \ block=True, track=False): """ Adds a **task** to evaluate. A **task** is jointly a function or callable an iterable with optional arguments and keyworded arguments. The iterable can be the result...
[ "Adds", "a", "**", "task", "**", "to", "evaluate", ".", "A", "**", "task", "**", "is", "jointly", "a", "function", "or", "callable", "an", "iterable", "with", "optional", "arguments", "and", "keyworded", "arguments", ".", "The", "iterable", "can", "be", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L492-L541
[ "def", "add_task", "(", "self", ",", "func", ",", "iterable", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "timeout", "=", "None", ",", "block", "=", "True", ",", "track", "=", "False", ")", ":", "if", "not", "self", ".", "_started", ...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap.pop_task
Removes a previously added **task** from the ``NuMap`` instance. Arguments: - number (``int`` or ``True``) A positive integer specifying the number of **tasks** to pop. If number is set ``True`` all **tasks** will be popped.
src/numap/NuMap.py
def pop_task(self, number): """ Removes a previously added **task** from the ``NuMap`` instance. Arguments: - number (``int`` or ``True``) A positive integer specifying the number of **tasks** to pop. If number is set ``True`` all **tasks** w...
def pop_task(self, number): """ Removes a previously added **task** from the ``NuMap`` instance. Arguments: - number (``int`` or ``True``) A positive integer specifying the number of **tasks** to pop. If number is set ``True`` all **tasks** w...
[ "Removes", "a", "previously", "added", "**", "task", "**", "from", "the", "NuMap", "instance", ".", "Arguments", ":", "-", "number", "(", "int", "or", "True", ")", "A", "positive", "integer", "specifying", "the", "number", "of", "**", "tasks", "**", "to"...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L543-L565
[ "def", "pop_task", "(", "self", ",", "number", ")", ":", "if", "not", "self", ".", "_started", ".", "isSet", "(", ")", ":", "if", "number", "is", "True", ":", "self", ".", "_tasks", "=", "[", "]", "self", ".", "_tasks_tracked", "=", "{", "}", "el...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap.get_task
Returns an iterator which results are limited to one **task**. The default iterator the one which e.g. will be used in a for loop is the iterator for the first task (task =0). The returned iterator is a ``_NuMapTask`` instance. Compare:: for result_from_task_0 in ...
src/numap/NuMap.py
def get_task(self, task=0, timeout=None, block=True): """ Returns an iterator which results are limited to one **task**. The default iterator the one which e.g. will be used in a for loop is the iterator for the first task (task =0). The returned iterator is a ``_NuMapTask`` in...
def get_task(self, task=0, timeout=None, block=True): """ Returns an iterator which results are limited to one **task**. The default iterator the one which e.g. will be used in a for loop is the iterator for the first task (task =0). The returned iterator is a ``_NuMapTask`` in...
[ "Returns", "an", "iterator", "which", "results", "are", "limited", "to", "one", "**", "task", "**", ".", "The", "default", "iterator", "the", "one", "which", "e", ".", "g", ".", "will", "be", "used", "in", "a", "for", "loop", "is", "the", "iterator", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L567-L593
[ "def", "get_task", "(", "self", ",", "task", "=", "0", ",", "timeout", "=", "None", ",", "block", "=", "True", ")", ":", "return", "_NuMapTask", "(", "self", ",", "task", "=", "task", ",", "timeout", "=", "timeout", ",", "block", "=", "block", ")" ...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap.start
Starts the processes or threads in the internal pool and the threads, which manage the **worker pool** input and output queues. The **starting mode** is split into **two stages**, which can be initiated seperately. After the first stage the **worker pool** processes or threads are s...
src/numap/NuMap.py
def start(self, stages=(1, 2)): """ Starts the processes or threads in the internal pool and the threads, which manage the **worker pool** input and output queues. The **starting mode** is split into **two stages**, which can be initiated seperately. After the first stage the ...
def start(self, stages=(1, 2)): """ Starts the processes or threads in the internal pool and the threads, which manage the **worker pool** input and output queues. The **starting mode** is split into **two stages**, which can be initiated seperately. After the first stage the ...
[ "Starts", "the", "processes", "or", "threads", "in", "the", "internal", "pool", "and", "the", "threads", "which", "manage", "the", "**", "worker", "pool", "**", "input", "and", "output", "queues", ".", "The", "**", "starting", "mode", "**", "is", "split", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L595-L619
[ "def", "start", "(", "self", ",", "stages", "=", "(", "1", ",", "2", ")", ")", ":", "if", "1", "in", "stages", ":", "if", "not", "self", ".", "_started", ".", "isSet", "(", ")", ":", "self", ".", "_start_workers", "(", ")", "self", ".", "_start...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap.stop
Stops an ``NuMap`` instance. If the list of end tasks is specified *via* the "ends" argument a call to ``NuMap.stop`` will block the calling thread and retrieve (discards) a maximum of 2 * stride of results. This will stop the worker pool and the threads which manage its input and ou...
src/numap/NuMap.py
def stop(self, ends=None, forced=False): """ Stops an ``NuMap`` instance. If the list of end tasks is specified *via* the "ends" argument a call to ``NuMap.stop`` will block the calling thread and retrieve (discards) a maximum of 2 * stride of results. This will stop the worke...
def stop(self, ends=None, forced=False): """ Stops an ``NuMap`` instance. If the list of end tasks is specified *via* the "ends" argument a call to ``NuMap.stop`` will block the calling thread and retrieve (discards) a maximum of 2 * stride of results. This will stop the worke...
[ "Stops", "an", "NuMap", "instance", ".", "If", "the", "list", "of", "end", "tasks", "is", "specified", "*", "via", "*", "the", "ends", "argument", "a", "call", "to", "NuMap", ".", "stop", "will", "block", "the", "calling", "thread", "and", "retrieve", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L621-L680
[ "def", "stop", "(", "self", ",", "ends", "=", "None", ",", "forced", "=", "False", ")", ":", "if", "self", ".", "_started", ".", "isSet", "(", ")", ":", "if", "ends", ":", "self", ".", "_stopping", ".", "set", "(", ")", "# if _stopping is set the poo...
708e50827b5db46bbea081982cb74b9b0e464064
train
NuMap.next
Returns the next result for the given **task**. Defaults to ``0``, which is the first **task**. If multiple chained tasks are evaluated then the next method of only the last should be called directly. Arguments: - timeout (``float``) Number of seconds to wait...
src/numap/NuMap.py
def next(self, timeout=None, task=0, block=True): """ Returns the next result for the given **task**. Defaults to ``0``, which is the first **task**. If multiple chained tasks are evaluated then the next method of only the last should be called directly. Argumen...
def next(self, timeout=None, task=0, block=True): """ Returns the next result for the given **task**. Defaults to ``0``, which is the first **task**. If multiple chained tasks are evaluated then the next method of only the last should be called directly. Argumen...
[ "Returns", "the", "next", "result", "for", "the", "given", "**", "task", "**", ".", "Defaults", "to", "0", "which", "is", "the", "first", "**", "task", "**", ".", "If", "multiple", "chained", "tasks", "are", "evaluated", "then", "the", "next", "method", ...
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L682-L763
[ "def", "next", "(", "self", ",", "timeout", "=", "None", ",", "task", "=", "0", ",", "block", "=", "True", ")", ":", "# check if any result is expected (started and not finished)", "if", "not", "self", ".", "_started", ".", "isSet", "(", ")", ":", "log", "...
708e50827b5db46bbea081982cb74b9b0e464064
train
_Weave.next
Returns the next element or raises ``StopIteration`` if stopped.
src/numap/NuMap.py
def next(self): """ Returns the next element or raises ``StopIteration`` if stopped. """ # need new iterable? if self.r == self.repeats: self.i = (self.i + 1) % self.lenght self.r = 0 self.r += 1 if self.stopping and self.i == 0 and self.r...
def next(self): """ Returns the next element or raises ``StopIteration`` if stopped. """ # need new iterable? if self.r == self.repeats: self.i = (self.i + 1) % self.lenght self.r = 0 self.r += 1 if self.stopping and self.i == 0 and self.r...
[ "Returns", "the", "next", "element", "or", "raises", "StopIteration", "if", "stopped", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L880-L896
[ "def", "next", "(", "self", ")", ":", "# need new iterable?", "if", "self", ".", "r", "==", "self", ".", "repeats", ":", "self", ".", "i", "=", "(", "self", ".", "i", "+", "1", ")", "%", "self", ".", "lenght", "self", ".", "r", "=", "0", "self"...
708e50827b5db46bbea081982cb74b9b0e464064
train
_NuMapTask.next
Returns a result if availble within "timeout" else raises a ``TimeoutError`` exception. See documentation for ``NuMap.next``.
src/numap/NuMap.py
def next(self): """ Returns a result if availble within "timeout" else raises a ``TimeoutError`` exception. See documentation for ``NuMap.next``. """ return self.iterator.next(task=self.task, timeout=self.timeout, block=self.bl...
def next(self): """ Returns a result if availble within "timeout" else raises a ``TimeoutError`` exception. See documentation for ``NuMap.next``. """ return self.iterator.next(task=self.task, timeout=self.timeout, block=self.bl...
[ "Returns", "a", "result", "if", "availble", "within", "timeout", "else", "raises", "a", "TimeoutError", "exception", ".", "See", "documentation", "for", "NuMap", ".", "next", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L919-L925
[ "def", "next", "(", "self", ")", ":", "return", "self", ".", "iterator", ".", "next", "(", "task", "=", "self", ".", "task", ",", "timeout", "=", "self", ".", "timeout", ",", "block", "=", "self", ".", "block", ")" ]
708e50827b5db46bbea081982cb74b9b0e464064
train
write_template
Write language-specific script template to file. Arguments: - fn(``string``) path to save the template to - lang('python', 'bash') which programming language
src/papy/util/script.py
def write_template(fn, lang="python"): """ Write language-specific script template to file. Arguments: - fn(``string``) path to save the template to - lang('python', 'bash') which programming language """ with open(fn, "wb") as fh: if lang == "python": fh.wri...
def write_template(fn, lang="python"): """ Write language-specific script template to file. Arguments: - fn(``string``) path to save the template to - lang('python', 'bash') which programming language """ with open(fn, "wb") as fh: if lang == "python": fh.wri...
[ "Write", "language", "-", "specific", "script", "template", "to", "file", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/util/script.py#L94-L108
[ "def", "write_template", "(", "fn", ",", "lang", "=", "\"python\"", ")", ":", "with", "open", "(", "fn", ",", "\"wb\"", ")", "as", "fh", ":", "if", "lang", "==", "\"python\"", ":", "fh", ".", "write", "(", "PY_TEMPLATE", ")", "elif", "lang", "==", ...
708e50827b5db46bbea081982cb74b9b0e464064
train
script
Execute arbitrary scripts. Arguments: - cfg(``dict``) script configuartion dictionary
src/papy/util/script.py
def script(inbox, cfg): """ Execute arbitrary scripts. Arguments: - cfg(``dict``) script configuartion dictionary """ script_name = cfg["id"] script_id = str(abs(hash((cfg["id"],) + tuple(inbox[0].values()))))[0:8] # LOG.log(mp.DEFAULT, "@papy;script %s:%s started" % (script_na...
def script(inbox, cfg): """ Execute arbitrary scripts. Arguments: - cfg(``dict``) script configuartion dictionary """ script_name = cfg["id"] script_id = str(abs(hash((cfg["id"],) + tuple(inbox[0].values()))))[0:8] # LOG.log(mp.DEFAULT, "@papy;script %s:%s started" % (script_na...
[ "Execute", "arbitrary", "scripts", "." ]
mcieslik-mctp/papy
python
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/util/script.py#L152-L203
[ "def", "script", "(", "inbox", ",", "cfg", ")", ":", "script_name", "=", "cfg", "[", "\"id\"", "]", "script_id", "=", "str", "(", "abs", "(", "hash", "(", "(", "cfg", "[", "\"id\"", "]", ",", ")", "+", "tuple", "(", "inbox", "[", "0", "]", ".",...
708e50827b5db46bbea081982cb74b9b0e464064
train
JobsService.edit
Edit a job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job
cdrouter/jobs.py
def edit(self, resource): """Edit a job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job """ schema = JobSchema(exclude=('id', 'status', 'options', 'package_name', 'config_name', 'device_name', 'result_id...
def edit(self, resource): """Edit a job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job """ schema = JobSchema(exclude=('id', 'status', 'options', 'package_name', 'config_name', 'device_name', 'result_id...
[ "Edit", "a", "job", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/jobs.py#L153-L165
[ "def", "edit", "(", "self", ",", "resource", ")", ":", "schema", "=", "JobSchema", "(", "exclude", "=", "(", "'id'", ",", "'status'", ",", "'options'", ",", "'package_name'", ",", "'config_name'", ",", "'device_name'", ",", "'result_id'", ",", "'user_id'", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
JobsService.launch
Launch a new job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job
cdrouter/jobs.py
def launch(self, resource): """Launch a new job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job """ schema = JobSchema(exclude=('id', 'status', 'package_name', 'config_name', 'device_name', 'result_id', ...
def launch(self, resource): """Launch a new job. :param resource: :class:`jobs.Job <jobs.Job>` object :return: :class:`jobs.Job <jobs.Job>` object :rtype: jobs.Job """ schema = JobSchema(exclude=('id', 'status', 'package_name', 'config_name', 'device_name', 'result_id', ...
[ "Launch", "a", "new", "job", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/jobs.py#L167-L179
[ "def", "launch", "(", "self", ",", "resource", ")", ":", "schema", "=", "JobSchema", "(", "exclude", "=", "(", "'id'", ",", "'status'", ",", "'package_name'", ",", "'config_name'", ",", "'device_name'", ",", "'result_id'", ",", "'user_id'", ",", "'created'",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
JobsService.bulk_launch
Bulk launch a set of jobs. :param jobs: :class:`jobs.Job <jobs.Job>` list :param filter: (optional) Filters to apply as a string list. :param all: (optional) Apply to all if bool `True`.
cdrouter/jobs.py
def bulk_launch(self, jobs=None, filter=None, all=False): # pylint: disable=redefined-builtin """Bulk launch a set of jobs. :param jobs: :class:`jobs.Job <jobs.Job>` list :param filter: (optional) Filters to apply as a string list. :param all: (optional) Apply to all if bool `True`. ...
def bulk_launch(self, jobs=None, filter=None, all=False): # pylint: disable=redefined-builtin """Bulk launch a set of jobs. :param jobs: :class:`jobs.Job <jobs.Job>` list :param filter: (optional) Filters to apply as a string list. :param all: (optional) Apply to all if bool `True`. ...
[ "Bulk", "launch", "a", "set", "of", "jobs", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/jobs.py#L188-L204
[ "def", "bulk_launch", "(", "self", ",", "jobs", "=", "None", ",", "filter", "=", "None", ",", "all", "=", "False", ")", ":", "# pylint: disable=redefined-builtin", "json", "=", "None", "if", "jobs", "is", "not", "None", ":", "schema", "=", "JobSchema", "...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
g_square_bin
G square test for a binary data. Args: dm: the data matrix to be used (as a numpy.ndarray). x: the first node (as an integer). y: the second node (as an integer). s: the set of neibouring nodes of x and y (as a set()). Returns: p_val: the p-value of conditional independ...
gsq/binary.py
def g_square_bin(dm, x, y, s): """G square test for a binary data. Args: dm: the data matrix to be used (as a numpy.ndarray). x: the first node (as an integer). y: the second node (as an integer). s: the set of neibouring nodes of x and y (as a set()). Returns: p_va...
def g_square_bin(dm, x, y, s): """G square test for a binary data. Args: dm: the data matrix to be used (as a numpy.ndarray). x: the first node (as an integer). y: the second node (as an integer). s: the set of neibouring nodes of x and y (as a set()). Returns: p_va...
[ "G", "square", "test", "for", "a", "binary", "data", "." ]
keiichishima/gsq
python
https://github.com/keiichishima/gsq/blob/6d9a0298e3aae1ae27384c2567e254c32554260d/gsq/binary.py#L24-L157
[ "def", "g_square_bin", "(", "dm", ",", "x", ",", "y", ",", "s", ")", ":", "def", "_calculate_tlog", "(", "x", ",", "y", ",", "s", ",", "dof", ",", "dm", ")", ":", "nijk", "=", "np", ".", "zeros", "(", "(", "2", ",", "2", ",", "dof", ")", ...
6d9a0298e3aae1ae27384c2567e254c32554260d
train
HighlightsService.get
Get a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int. :return: :class:`highlights.Highlight <highlights.Highlight>` object
cdrouter/highlights.py
def get(self, id, seq, line): # pylint: disable=invalid-name,redefined-builtin """Get a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int. :return: :class:`highlights.Highlight <hig...
def get(self, id, seq, line): # pylint: disable=invalid-name,redefined-builtin """Get a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int. :return: :class:`highlights.Highlight <hig...
[ "Get", "a", "highlight", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/highlights.py#L57-L67
[ "def", "get", "(", "self", ",", "id", ",", "seq", ",", "line", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "HighlightSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get_id", "(", "self", ".", "_base", "(", "id...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
HighlightsService.create_or_edit
Create or edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class:`highlights.Highlight <highlights.Highlight>` object :rtype: highlights.Highligh...
cdrouter/highlights.py
def create_or_edit(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Create or edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object ...
def create_or_edit(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Create or edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object ...
[ "Create", "or", "edit", "a", "highlight", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/highlights.py#L69-L83
[ "def", "create_or_edit", "(", "self", ",", "id", ",", "seq", ",", "resource", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "HighlightSchema", "(", "exclude", "=", "(", "'id'", ",", "'seq'", ")", ")", "json", "=", "self", ".", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
HighlightsService.create
Create a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class:`highlights.Highlight <highlights.Highlight>` object :rtype: highlights.Highlight
cdrouter/highlights.py
def create(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Create a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class...
def create(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Create a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class...
[ "Create", "a", "highlight", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/highlights.py#L85-L94
[ "def", "create", "(", "self", ",", "id", ",", "seq", ",", "resource", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "return", "self", ".", "create_or_edit", "(", "id", ",", "seq", ",", "resource", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
HighlightsService.edit
Edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class:`highlights.Highlight <highlights.Highlight>` object :rtype: highlights.Highlight
cdrouter/highlights.py
def edit(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class:`hi...
def edit(self, id, seq, resource): # pylint: disable=invalid-name,redefined-builtin """Edit a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param resource: :class:`highlights.Highlight <highlights.Highlight>` object :return: :class:`hi...
[ "Edit", "a", "highlight", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/highlights.py#L96-L105
[ "def", "edit", "(", "self", ",", "id", ",", "seq", ",", "resource", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "return", "self", ".", "create_or_edit", "(", "id", ",", "seq", ",", "resource", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
HighlightsService.delete
Delete a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int.
cdrouter/highlights.py
def delete(self, id, seq, line): # pylint: disable=invalid-name,redefined-builtin """Delete a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int. """ return self.service.dele...
def delete(self, id, seq, line): # pylint: disable=invalid-name,redefined-builtin """Delete a highlight. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param line: Line number in TestResult's logfile as an int. """ return self.service.dele...
[ "Delete", "a", "highlight", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/highlights.py#L107-L114
[ "def", "delete", "(", "self", ",", "id", ",", "seq", ",", "line", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "return", "self", ".", "service", ".", "delete_id", "(", "self", ".", "_base", "(", "id", ",", "seq", ")", ",", "line", ")" ]
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
post_ext_init
Setup blueprint.
invenio_oauthclient/views/client.py
def post_ext_init(state): """Setup blueprint.""" app = state.app app.config.setdefault( 'OAUTHCLIENT_SITENAME', app.config.get('THEME_SITENAME', 'Invenio')) app.config.setdefault( 'OAUTHCLIENT_BASE_TEMPLATE', app.config.get('BASE_TEMPLATE', 'inveni...
def post_ext_init(state): """Setup blueprint.""" app = state.app app.config.setdefault( 'OAUTHCLIENT_SITENAME', app.config.get('THEME_SITENAME', 'Invenio')) app.config.setdefault( 'OAUTHCLIENT_BASE_TEMPLATE', app.config.get('BASE_TEMPLATE', 'inveni...
[ "Setup", "blueprint", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/client.py#L43-L61
[ "def", "post_ext_init", "(", "state", ")", ":", "app", "=", "state", ".", "app", "app", ".", "config", ".", "setdefault", "(", "'OAUTHCLIENT_SITENAME'", ",", "app", ".", "config", ".", "get", "(", "'THEME_SITENAME'", ",", "'Invenio'", ")", ")", "app", "....
2500dc6935738107617aeade79e050d7608004bb
train
login
Send user to remote application for authentication.
invenio_oauthclient/views/client.py
def login(remote_app): """Send user to remote application for authentication.""" oauth = current_app.extensions['oauthlib.client'] if remote_app not in oauth.remote_apps: return abort(404) # Get redirect target in safe manner. next_param = get_safe_redirect_target(arg='next') # Redire...
def login(remote_app): """Send user to remote application for authentication.""" oauth = current_app.extensions['oauthlib.client'] if remote_app not in oauth.remote_apps: return abort(404) # Get redirect target in safe manner. next_param = get_safe_redirect_target(arg='next') # Redire...
[ "Send", "user", "to", "remote", "application", "for", "authentication", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/client.py#L65-L93
[ "def", "login", "(", "remote_app", ")", ":", "oauth", "=", "current_app", ".", "extensions", "[", "'oauthlib.client'", "]", "if", "remote_app", "not", "in", "oauth", ".", "remote_apps", ":", "return", "abort", "(", "404", ")", "# Get redirect target in safe mann...
2500dc6935738107617aeade79e050d7608004bb
train
authorized
Authorized handler callback.
invenio_oauthclient/views/client.py
def authorized(remote_app=None): """Authorized handler callback.""" if remote_app not in current_oauthclient.handlers: return abort(404) state_token = request.args.get('state') # Verify state parameter try: assert state_token # Checks authenticity and integrity of state and...
def authorized(remote_app=None): """Authorized handler callback.""" if remote_app not in current_oauthclient.handlers: return abort(404) state_token = request.args.get('state') # Verify state parameter try: assert state_token # Checks authenticity and integrity of state and...
[ "Authorized", "handler", "callback", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/client.py#L97-L128
[ "def", "authorized", "(", "remote_app", "=", "None", ")", ":", "if", "remote_app", "not", "in", "current_oauthclient", ".", "handlers", ":", "return", "abort", "(", "404", ")", "state_token", "=", "request", ".", "args", ".", "get", "(", "'state'", ")", ...
2500dc6935738107617aeade79e050d7608004bb
train
signup
Extra signup step.
invenio_oauthclient/views/client.py
def signup(remote_app): """Extra signup step.""" if remote_app not in current_oauthclient.signup_handlers: return abort(404) res = current_oauthclient.signup_handlers[remote_app]['view']() return abort(404) if res is None else res
def signup(remote_app): """Extra signup step.""" if remote_app not in current_oauthclient.signup_handlers: return abort(404) res = current_oauthclient.signup_handlers[remote_app]['view']() return abort(404) if res is None else res
[ "Extra", "signup", "step", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/client.py#L132-L137
[ "def", "signup", "(", "remote_app", ")", ":", "if", "remote_app", "not", "in", "current_oauthclient", ".", "signup_handlers", ":", "return", "abort", "(", "404", ")", "res", "=", "current_oauthclient", ".", "signup_handlers", "[", "remote_app", "]", "[", "'vie...
2500dc6935738107617aeade79e050d7608004bb
train
disconnect
Disconnect user from remote application. Removes application as well as associated information.
invenio_oauthclient/views/client.py
def disconnect(remote_app): """Disconnect user from remote application. Removes application as well as associated information. """ if remote_app not in current_oauthclient.disconnect_handlers: return abort(404) ret = current_oauthclient.disconnect_handlers[remote_app]() db.session.comm...
def disconnect(remote_app): """Disconnect user from remote application. Removes application as well as associated information. """ if remote_app not in current_oauthclient.disconnect_handlers: return abort(404) ret = current_oauthclient.disconnect_handlers[remote_app]() db.session.comm...
[ "Disconnect", "user", "from", "remote", "application", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/client.py#L141-L151
[ "def", "disconnect", "(", "remote_app", ")", ":", "if", "remote_app", "not", "in", "current_oauthclient", ".", "disconnect_handlers", ":", "return", "abort", "(", "404", ")", "ret", "=", "current_oauthclient", ".", "disconnect_handlers", "[", "remote_app", "]", ...
2500dc6935738107617aeade79e050d7608004bb
train
address_checksum
Returns the checksum in bytes for an address in bytes
src/nano/crypto.py
def address_checksum(address): """ Returns the checksum in bytes for an address in bytes """ address_bytes = address h = blake2b(digest_size=5) h.update(address_bytes) checksum = bytearray(h.digest()) checksum.reverse() return checksum
def address_checksum(address): """ Returns the checksum in bytes for an address in bytes """ address_bytes = address h = blake2b(digest_size=5) h.update(address_bytes) checksum = bytearray(h.digest()) checksum.reverse() return checksum
[ "Returns", "the", "checksum", "in", "bytes", "for", "an", "address", "in", "bytes" ]
dourvaris/nano-python
python
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/crypto.py#L16-L25
[ "def", "address_checksum", "(", "address", ")", ":", "address_bytes", "=", "address", "h", "=", "blake2b", "(", "digest_size", "=", "5", ")", "h", ".", "update", "(", "address_bytes", ")", "checksum", "=", "bytearray", "(", "h", ".", "digest", "(", ")", ...
f26b8bc895b997067780f925049a70e82c0c2479
train
keypair_from_seed
Generates a deterministic keypair from `seed` based on `index` :param seed: bytes value of seed :type seed: bytes :param index: offset from seed :type index: int :return: dict of the form: { 'private': private_key 'public': public_key }
src/nano/crypto.py
def keypair_from_seed(seed, index=0): """ Generates a deterministic keypair from `seed` based on `index` :param seed: bytes value of seed :type seed: bytes :param index: offset from seed :type index: int :return: dict of the form: { 'private': private_key 'public': public_...
def keypair_from_seed(seed, index=0): """ Generates a deterministic keypair from `seed` based on `index` :param seed: bytes value of seed :type seed: bytes :param index: offset from seed :type index: int :return: dict of the form: { 'private': private_key 'public': public_...
[ "Generates", "a", "deterministic", "keypair", "from", "seed", "based", "on", "index" ]
dourvaris/nano-python
python
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/crypto.py#L38-L58
[ "def", "keypair_from_seed", "(", "seed", ",", "index", "=", "0", ")", ":", "h", "=", "blake2b", "(", "digest_size", "=", "32", ")", "h", ".", "update", "(", "seed", "+", "struct", ".", "pack", "(", "\">L\"", ",", "index", ")", ")", "priv_key", "=",...
f26b8bc895b997067780f925049a70e82c0c2479
train
verify_signature
Verifies `signature` is correct for a `message` signed with `public_key` :param message: message to check :type message: bytes :param signature: signature to check :type signature: bytes :param public_key: public_key to check :type public_key: bytes :return: True if valid, False otherwis...
src/nano/crypto.py
def verify_signature(message, signature, public_key): """ Verifies `signature` is correct for a `message` signed with `public_key` :param message: message to check :type message: bytes :param signature: signature to check :type signature: bytes :param public_key: public_key to check :...
def verify_signature(message, signature, public_key): """ Verifies `signature` is correct for a `message` signed with `public_key` :param message: message to check :type message: bytes :param signature: signature to check :type signature: bytes :param public_key: public_key to check :...
[ "Verifies", "signature", "is", "correct", "for", "a", "message", "signed", "with", "public_key" ]
dourvaris/nano-python
python
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/crypto.py#L95-L116
[ "def", "verify_signature", "(", "message", ",", "signature", ",", "public_key", ")", ":", "try", ":", "ed25519_blake2", ".", "checkvalid", "(", "signature", ",", "message", ",", "public_key", ")", "except", "ed25519_blake2", ".", "SignatureMismatch", ":", "retur...
f26b8bc895b997067780f925049a70e82c0c2479
train
sign_message
Signs a `message` using `private_key` and `public_key` .. warning:: Not safe to use with secret keys or secret data. See module docstring. This function should be used for testing only. :param message: the message to sign :type message: bytes :param private_key: private key used to ...
src/nano/crypto.py
def sign_message(message, private_key, public_key=None): """ Signs a `message` using `private_key` and `public_key` .. warning:: Not safe to use with secret keys or secret data. See module docstring. This function should be used for testing only. :param message: the message to sign ...
def sign_message(message, private_key, public_key=None): """ Signs a `message` using `private_key` and `public_key` .. warning:: Not safe to use with secret keys or secret data. See module docstring. This function should be used for testing only. :param message: the message to sign ...
[ "Signs", "a", "message", "using", "private_key", "and", "public_key" ]
dourvaris/nano-python
python
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/crypto.py#L119-L142
[ "def", "sign_message", "(", "message", ",", "private_key", ",", "public_key", "=", "None", ")", ":", "if", "public_key", "is", "None", ":", "public_key", "=", "private_to_public_key", "(", "private_key", ")", "return", "ed25519_blake2", ".", "signature_unsafe", ...
f26b8bc895b997067780f925049a70e82c0c2479
train
SystemService.check_for_lounge_upgrade
Check the CDRouter Support Lounge for eligible upgrades using your Support Lounge email & password. :param email: CDRouter Support Lounge email as a string. :param password: CDRouter Support Lounge password as a string. :return: :class:`system.Release <system.Release>` object :r...
cdrouter/system.py
def check_for_lounge_upgrade(self, email, password): """Check the CDRouter Support Lounge for eligible upgrades using your Support Lounge email & password. :param email: CDRouter Support Lounge email as a string. :param password: CDRouter Support Lounge password as a string. :re...
def check_for_lounge_upgrade(self, email, password): """Check the CDRouter Support Lounge for eligible upgrades using your Support Lounge email & password. :param email: CDRouter Support Lounge email as a string. :param password: CDRouter Support Lounge password as a string. :re...
[ "Check", "the", "CDRouter", "Support", "Lounge", "for", "eligible", "upgrades", "using", "your", "Support", "Lounge", "email", "&", "password", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L323-L335
[ "def", "check_for_lounge_upgrade", "(", "self", ",", "email", ",", "password", ")", ":", "schema", "=", "ReleaseSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "'lounge/check/'", ",", "json", "=", "{", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
SystemService.lounge_upgrade
Download & install an upgrade from the CDRouter Support Lounge using your Support Lounge email & password. Please note that any running tests will be stopped. :param email: CDRouter Support Lounge email as a string. :param password: CDRouter Support Lounge password as a string. ...
cdrouter/system.py
def lounge_upgrade(self, email, password, release_id): """Download & install an upgrade from the CDRouter Support Lounge using your Support Lounge email & password. Please note that any running tests will be stopped. :param email: CDRouter Support Lounge email as a string. :para...
def lounge_upgrade(self, email, password, release_id): """Download & install an upgrade from the CDRouter Support Lounge using your Support Lounge email & password. Please note that any running tests will be stopped. :param email: CDRouter Support Lounge email as a string. :para...
[ "Download", "&", "install", "an", "upgrade", "from", "the", "CDRouter", "Support", "Lounge", "using", "your", "Support", "Lounge", "email", "&", "password", ".", "Please", "note", "that", "any", "running", "tests", "will", "be", "stopped", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L337-L351
[ "def", "lounge_upgrade", "(", "self", ",", "email", ",", "password", ",", "release_id", ")", ":", "schema", "=", "UpgradeSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "'lounge/upgrade/'", ",", "json",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
SystemService.lounge_update_license
Download & install a license for your CDRouter system from the CDRouter Support Lounge. :return: :class:`system.Upgrade <system.Upgrade>` object :rtype: system.Upgrade
cdrouter/system.py
def lounge_update_license(self): """Download & install a license for your CDRouter system from the CDRouter Support Lounge. :return: :class:`system.Upgrade <system.Upgrade>` object :rtype: system.Upgrade """ schema = UpgradeSchema() resp = self.service.post(self....
def lounge_update_license(self): """Download & install a license for your CDRouter system from the CDRouter Support Lounge. :return: :class:`system.Upgrade <system.Upgrade>` object :rtype: system.Upgrade """ schema = UpgradeSchema() resp = self.service.post(self....
[ "Download", "&", "install", "a", "license", "for", "your", "CDRouter", "system", "from", "the", "CDRouter", "Support", "Lounge", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L368-L377
[ "def", "lounge_update_license", "(", "self", ")", ":", "schema", "=", "UpgradeSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "'license/'", ")", "return", "self", ".", "service", ".", "decode", "(", "...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
SystemService.manual_update_license
Update the license on your CDRouter system manually by uploading a .lic license from the CDRouter Support Lounge. :param fd: File-like object to upload. :param filename: (optional) Filename to use for license as string. :return: :class:`system.Upgrade <system.Upgrade>` object :r...
cdrouter/system.py
def manual_update_license(self, fd, filename='cdrouter.lic'): """Update the license on your CDRouter system manually by uploading a .lic license from the CDRouter Support Lounge. :param fd: File-like object to upload. :param filename: (optional) Filename to use for license as string. ...
def manual_update_license(self, fd, filename='cdrouter.lic'): """Update the license on your CDRouter system manually by uploading a .lic license from the CDRouter Support Lounge. :param fd: File-like object to upload. :param filename: (optional) Filename to use for license as string. ...
[ "Update", "the", "license", "on", "your", "CDRouter", "system", "manually", "by", "uploading", "a", ".", "lic", "license", "from", "the", "CDRouter", "Support", "Lounge", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L379-L391
[ "def", "manual_update_license", "(", "self", ",", "fd", ",", "filename", "=", "'cdrouter.lic'", ")", ":", "schema", "=", "UpgradeSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "post", "(", "self", ".", "base", "+", "'license/'", ",", "files...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
SystemService.space
Get system disk space usage. :return: :class:`system.Space <system.Space>` object :rtype: system.Space
cdrouter/system.py
def space(self): """Get system disk space usage. :return: :class:`system.Space <system.Space>` object :rtype: system.Space """ schema = SpaceSchema() resp = self.service.get(self.base+'space/') return self.service.decode(schema, resp)
def space(self): """Get system disk space usage. :return: :class:`system.Space <system.Space>` object :rtype: system.Space """ schema = SpaceSchema() resp = self.service.get(self.base+'space/') return self.service.decode(schema, resp)
[ "Get", "system", "disk", "space", "usage", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L425-L433
[ "def", "space", "(", "self", ")", ":", "schema", "=", "SpaceSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "'space/'", ")", "return", "self", ".", "service", ".", "decode", "(", "schema", ",", "re...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
SystemService.interfaces
Get system interfaces. :param addresses: (optional) If bool `True`, include interface addresses. :return: :class:`system.Interface <system.Interface>` list
cdrouter/system.py
def interfaces(self, addresses=False): """Get system interfaces. :param addresses: (optional) If bool `True`, include interface addresses. :return: :class:`system.Interface <system.Interface>` list """ schema = InterfaceSchema() resp = self.service.get(self.base+'interfa...
def interfaces(self, addresses=False): """Get system interfaces. :param addresses: (optional) If bool `True`, include interface addresses. :return: :class:`system.Interface <system.Interface>` list """ schema = InterfaceSchema() resp = self.service.get(self.base+'interfa...
[ "Get", "system", "interfaces", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L442-L450
[ "def", "interfaces", "(", "self", ",", "addresses", "=", "False", ")", ":", "schema", "=", "InterfaceSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "'interfaces/'", ",", "params", "=", "{", "'addresse...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
SystemService.get_preferences
Get preferences from /usr/cdrouter-data/etc/config.yml. :return: :class:`system.Preferences <system.Preferences>` object :rtype: system.Preferences
cdrouter/system.py
def get_preferences(self): """Get preferences from /usr/cdrouter-data/etc/config.yml. :return: :class:`system.Preferences <system.Preferences>` object :rtype: system.Preferences """ schema = PreferencesSchema() resp = self.service.get(self.base+'preferences/') re...
def get_preferences(self): """Get preferences from /usr/cdrouter-data/etc/config.yml. :return: :class:`system.Preferences <system.Preferences>` object :rtype: system.Preferences """ schema = PreferencesSchema() resp = self.service.get(self.base+'preferences/') re...
[ "Get", "preferences", "from", "/", "usr", "/", "cdrouter", "-", "data", "/", "etc", "/", "config", ".", "yml", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L452-L460
[ "def", "get_preferences", "(", "self", ")", ":", "schema", "=", "PreferencesSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get", "(", "self", ".", "base", "+", "'preferences/'", ")", "return", "self", ".", "service", ".", "decode", "(", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
SystemService.edit_preferences
Edit preferences in /usr/cdrouter-data/etc/config.yml. :param resource: :class:`system.Preferences <system.Preferences>` object :return: :class:`system.Preferences <system.Preferences>` object :rtype: system.Preferences
cdrouter/system.py
def edit_preferences(self, resource): """Edit preferences in /usr/cdrouter-data/etc/config.yml. :param resource: :class:`system.Preferences <system.Preferences>` object :return: :class:`system.Preferences <system.Preferences>` object :rtype: system.Preferences """ schema...
def edit_preferences(self, resource): """Edit preferences in /usr/cdrouter-data/etc/config.yml. :param resource: :class:`system.Preferences <system.Preferences>` object :return: :class:`system.Preferences <system.Preferences>` object :rtype: system.Preferences """ schema...
[ "Edit", "preferences", "in", "/", "usr", "/", "cdrouter", "-", "data", "/", "etc", "/", "config", ".", "yml", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/system.py#L462-L474
[ "def", "edit_preferences", "(", "self", ",", "resource", ")", ":", "schema", "=", "PreferencesSchema", "(", ")", "json", "=", "self", ".", "service", ".", "encode", "(", "schema", ",", "resource", ")", "schema", "=", "PreferencesSchema", "(", ")", "resp", ...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
_set_original_fields
Save fields value, only for non-m2m fields.
tracking_fields/tracking.py
def _set_original_fields(instance): """ Save fields value, only for non-m2m fields. """ original_fields = {} def _set_original_field(instance, field): if instance.pk is None: original_fields[field] = None else: if isinstance(instance._meta.get_field(field), F...
def _set_original_fields(instance): """ Save fields value, only for non-m2m fields. """ original_fields = {} def _set_original_field(instance, field): if instance.pk is None: original_fields[field] = None else: if isinstance(instance._meta.get_field(field), F...
[ "Save", "fields", "value", "only", "for", "non", "-", "m2m", "fields", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L29-L54
[ "def", "_set_original_fields", "(", "instance", ")", ":", "original_fields", "=", "{", "}", "def", "_set_original_field", "(", "instance", ",", "field", ")", ":", "if", "instance", ".", "pk", "is", "None", ":", "original_fields", "[", "field", "]", "=", "N...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_has_changed
Check if some tracked fields have changed
tracking_fields/tracking.py
def _has_changed(instance): """ Check if some tracked fields have changed """ for field, value in instance._original_fields.items(): if field != 'pk' and \ not isinstance(instance._meta.get_field(field), ManyToManyField): try: if field in getattr(instance, ...
def _has_changed(instance): """ Check if some tracked fields have changed """ for field, value in instance._original_fields.items(): if field != 'pk' and \ not isinstance(instance._meta.get_field(field), ManyToManyField): try: if field in getattr(instance, ...
[ "Check", "if", "some", "tracked", "fields", "have", "changed" ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L57-L75
[ "def", "_has_changed", "(", "instance", ")", ":", "for", "field", ",", "value", "in", "instance", ".", "_original_fields", ".", "items", "(", ")", ":", "if", "field", "!=", "'pk'", "and", "not", "isinstance", "(", "instance", ".", "_meta", ".", "get_fiel...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_has_changed_related
Check if some related tracked fields have changed
tracking_fields/tracking.py
def _has_changed_related(instance): """ Check if some related tracked fields have changed """ tracked_related_fields = getattr( instance, '_tracked_related_fields', {} ).keys() for field, value in instance._original_fields.items(): if field != 'pk' and \ ...
def _has_changed_related(instance): """ Check if some related tracked fields have changed """ tracked_related_fields = getattr( instance, '_tracked_related_fields', {} ).keys() for field, value in instance._original_fields.items(): if field != 'pk' and \ ...
[ "Check", "if", "some", "related", "tracked", "fields", "have", "changed" ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L78-L97
[ "def", "_has_changed_related", "(", "instance", ")", ":", "tracked_related_fields", "=", "getattr", "(", "instance", ",", "'_tracked_related_fields'", ",", "{", "}", ")", ".", "keys", "(", ")", "for", "field", ",", "value", "in", "instance", ".", "_original_fi...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_create_event
Create a new event, getting the use if django-cuser is available.
tracking_fields/tracking.py
def _create_event(instance, action): """ Create a new event, getting the use if django-cuser is available. """ user = None user_repr = repr(user) if CUSER: user = CuserMiddleware.get_user() user_repr = repr(user) if user is not None and user.is_anonymous: user...
def _create_event(instance, action): """ Create a new event, getting the use if django-cuser is available. """ user = None user_repr = repr(user) if CUSER: user = CuserMiddleware.get_user() user_repr = repr(user) if user is not None and user.is_anonymous: user...
[ "Create", "a", "new", "event", "getting", "the", "use", "if", "django", "-", "cuser", "is", "available", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L100-L117
[ "def", "_create_event", "(", "instance", ",", "action", ")", ":", "user", "=", "None", "user_repr", "=", "repr", "(", "user", ")", "if", "CUSER", ":", "user", "=", "CuserMiddleware", ".", "get_user", "(", ")", "user_repr", "=", "repr", "(", "user", ")"...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_create_tracked_field
Create a TrackedFieldModification for the instance. :param event: The TrackingEvent on which to add TrackingField :param instance: The instance on which the field is :param field: The field name to track :param fieldname: The displayed name for the field. Default to field.
tracking_fields/tracking.py
def _create_tracked_field(event, instance, field, fieldname=None): """ Create a TrackedFieldModification for the instance. :param event: The TrackingEvent on which to add TrackingField :param instance: The instance on which the field is :param field: The field name to track :param fieldname: Th...
def _create_tracked_field(event, instance, field, fieldname=None): """ Create a TrackedFieldModification for the instance. :param event: The TrackingEvent on which to add TrackingField :param instance: The instance on which the field is :param field: The field name to track :param fieldname: Th...
[ "Create", "a", "TrackedFieldModification", "for", "the", "instance", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L145-L170
[ "def", "_create_tracked_field", "(", "event", ",", "instance", ",", "field", ",", "fieldname", "=", "None", ")", ":", "fieldname", "=", "fieldname", "or", "field", "if", "isinstance", "(", "instance", ".", "_meta", ".", "get_field", "(", "field", ")", ",",...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_create_create_tracking_event
Create a TrackingEvent and TrackedFieldModification for a CREATE event.
tracking_fields/tracking.py
def _create_create_tracking_event(instance): """ Create a TrackingEvent and TrackedFieldModification for a CREATE event. """ event = _create_event(instance, CREATE) for field in instance._tracked_fields: if not isinstance(instance._meta.get_field(field), ManyToManyField): _create...
def _create_create_tracking_event(instance): """ Create a TrackingEvent and TrackedFieldModification for a CREATE event. """ event = _create_event(instance, CREATE) for field in instance._tracked_fields: if not isinstance(instance._meta.get_field(field), ManyToManyField): _create...
[ "Create", "a", "TrackingEvent", "and", "TrackedFieldModification", "for", "a", "CREATE", "event", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L173-L180
[ "def", "_create_create_tracking_event", "(", "instance", ")", ":", "event", "=", "_create_event", "(", "instance", ",", "CREATE", ")", "for", "field", "in", "instance", ".", "_tracked_fields", ":", "if", "not", "isinstance", "(", "instance", ".", "_meta", ".",...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_create_update_tracking_event
Create a TrackingEvent and TrackedFieldModification for an UPDATE event.
tracking_fields/tracking.py
def _create_update_tracking_event(instance): """ Create a TrackingEvent and TrackedFieldModification for an UPDATE event. """ event = _create_event(instance, UPDATE) for field in instance._tracked_fields: if not isinstance(instance._meta.get_field(field), ManyToManyField): try: ...
def _create_update_tracking_event(instance): """ Create a TrackingEvent and TrackedFieldModification for an UPDATE event. """ event = _create_event(instance, UPDATE) for field in instance._tracked_fields: if not isinstance(instance._meta.get_field(field), ManyToManyField): try: ...
[ "Create", "a", "TrackingEvent", "and", "TrackedFieldModification", "for", "an", "UPDATE", "event", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L183-L200
[ "def", "_create_update_tracking_event", "(", "instance", ")", ":", "event", "=", "_create_event", "(", "instance", ",", "UPDATE", ")", "for", "field", "in", "instance", ".", "_tracked_fields", ":", "if", "not", "isinstance", "(", "instance", ".", "_meta", ".",...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_create_update_tracking_related_event
Create a TrackingEvent and TrackedFieldModification for an UPDATE event for each related model.
tracking_fields/tracking.py
def _create_update_tracking_related_event(instance): """ Create a TrackingEvent and TrackedFieldModification for an UPDATE event for each related model. """ events = {} # Create a dict mapping related model field to modified fields for field, related_fields in instance._tracked_related_field...
def _create_update_tracking_related_event(instance): """ Create a TrackingEvent and TrackedFieldModification for an UPDATE event for each related model. """ events = {} # Create a dict mapping related model field to modified fields for field, related_fields in instance._tracked_related_field...
[ "Create", "a", "TrackingEvent", "and", "TrackedFieldModification", "for", "an", "UPDATE", "event", "for", "each", "related", "model", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L203-L239
[ "def", "_create_update_tracking_related_event", "(", "instance", ")", ":", "events", "=", "{", "}", "# Create a dict mapping related model field to modified fields", "for", "field", ",", "related_fields", "in", "instance", ".", "_tracked_related_fields", ".", "items", "(", ...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_get_m2m_field
Get the field name from a model and a sender from m2m_changed signal.
tracking_fields/tracking.py
def _get_m2m_field(model, sender): """ Get the field name from a model and a sender from m2m_changed signal. """ for field in getattr(model, '_tracked_fields', []): if isinstance(model._meta.get_field(field), ManyToManyField): if getattr(model, field).through == sender: ...
def _get_m2m_field(model, sender): """ Get the field name from a model and a sender from m2m_changed signal. """ for field in getattr(model, '_tracked_fields', []): if isinstance(model._meta.get_field(field), ManyToManyField): if getattr(model, field).through == sender: ...
[ "Get", "the", "field", "name", "from", "a", "model", "and", "a", "sender", "from", "m2m_changed", "signal", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L249-L260
[ "def", "_get_m2m_field", "(", "model", ",", "sender", ")", ":", "for", "field", "in", "getattr", "(", "model", ",", "'_tracked_fields'", ",", "[", "]", ")", ":", "if", "isinstance", "(", "model", ".", "_meta", ".", "get_field", "(", "field", ")", ",", ...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
_create_tracked_event_m2m
Create the ``TrackedEvent`` and it's related ``TrackedFieldModification`` for a m2m modification. The first thing needed is to get the m2m field on the object being tracked. The current related objects are then taken (``old_value``). The new value is calculated in function of ``action`` (``new_value``)....
tracking_fields/tracking.py
def _create_tracked_event_m2m(model, instance, sender, objects, action): """ Create the ``TrackedEvent`` and it's related ``TrackedFieldModification`` for a m2m modification. The first thing needed is to get the m2m field on the object being tracked. The current related objects are then taken (``old...
def _create_tracked_event_m2m(model, instance, sender, objects, action): """ Create the ``TrackedEvent`` and it's related ``TrackedFieldModification`` for a m2m modification. The first thing needed is to get the m2m field on the object being tracked. The current related objects are then taken (``old...
[ "Create", "the", "TrackedEvent", "and", "it", "s", "related", "TrackedFieldModification", "for", "a", "m2m", "modification", ".", "The", "first", "thing", "needed", "is", "to", "get", "the", "m2m", "field", "on", "the", "object", "being", "tracked", ".", "Th...
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L283-L320
[ "def", "_create_tracked_event_m2m", "(", "model", ",", "instance", ",", "sender", ",", "objects", ",", "action", ")", ":", "field", "=", "_get_m2m_field", "(", "model", ",", "sender", ")", "if", "field", "in", "getattr", "(", "model", ",", "'_tracked_related...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
tracking_save
Post save, detect creation or changes and log them. We need post_save to have the object for a create.
tracking_fields/tracking.py
def tracking_save(sender, instance, raw, using, update_fields, **kwargs): """ Post save, detect creation or changes and log them. We need post_save to have the object for a create. """ if _has_changed(instance): if instance._original_fields['pk'] is None: # Create _cr...
def tracking_save(sender, instance, raw, using, update_fields, **kwargs): """ Post save, detect creation or changes and log them. We need post_save to have the object for a create. """ if _has_changed(instance): if instance._original_fields['pk'] is None: # Create _cr...
[ "Post", "save", "detect", "creation", "or", "changes", "and", "log", "them", ".", "We", "need", "post_save", "to", "have", "the", "object", "for", "a", "create", "." ]
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L332-L349
[ "def", "tracking_save", "(", "sender", ",", "instance", ",", "raw", ",", "using", ",", "update_fields", ",", "*", "*", "kwargs", ")", ":", "if", "_has_changed", "(", "instance", ")", ":", "if", "instance", ".", "_original_fields", "[", "'pk'", "]", "is",...
463313d0f9c0f8107a0413f4d418d1a8c2311981
train
tracking_m2m
m2m_changed callback. The idea is to get the model and the instance of the object being tracked, and the different objects being added/removed. It is then send to the ``_create_tracked_field_m2m`` method to extract the proper attribute for the TrackedFieldModification.
tracking_fields/tracking.py
def tracking_m2m( sender, instance, action, reverse, model, pk_set, using, **kwargs ): """ m2m_changed callback. The idea is to get the model and the instance of the object being tracked, and the different objects being added/removed. It is then send to the ``_create_tracked_field_m2m`` meth...
def tracking_m2m( sender, instance, action, reverse, model, pk_set, using, **kwargs ): """ m2m_changed callback. The idea is to get the model and the instance of the object being tracked, and the different objects being added/removed. It is then send to the ``_create_tracked_field_m2m`` meth...
[ "m2m_changed", "callback", ".", "The", "idea", "is", "to", "get", "the", "model", "and", "the", "instance", "of", "the", "object", "being", "tracked", "and", "the", "different", "objects", "being", "added", "/", "removed", ".", "It", "is", "then", "send", ...
makinacorpus/django-tracking-fields
python
https://github.com/makinacorpus/django-tracking-fields/blob/463313d0f9c0f8107a0413f4d418d1a8c2311981/tracking_fields/tracking.py#L359-L400
[ "def", "tracking_m2m", "(", "sender", ",", "instance", ",", "action", ",", "reverse", ",", "model", ",", "pk_set", ",", "using", ",", "*", "*", "kwargs", ")", ":", "action_event", "=", "{", "'pre_clear'", ":", "'CLEAR'", ",", "'pre_add'", ":", "'ADD'", ...
463313d0f9c0f8107a0413f4d418d1a8c2311981
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/orcid.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. """ with db.session.begin_nested(): # Retrieve ORCID from response. orcid = resp.g...
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. """ with db.session.begin_nested(): # Retrieve ORCID from response. orcid = resp.g...
[ "Perform", "additional", "setup", "after", "user", "have", "been", "logged", "in", "." ]
inveniosoftware/invenio-oauthclient
python
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/orcid.py#L196-L217
[ "def", "account_setup", "(", "remote", ",", "token", ",", "resp", ")", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "# Retrieve ORCID from response.", "orcid", "=", "resp", ".", "get", "(", "'orcid'", ")", "full_name", "=", "resp"...
2500dc6935738107617aeade79e050d7608004bb
train
log_entry_generator
:yield: The next LogEntry from the REST API :raise: StopIteration when there are no more log entries to show, please note that if you call this again at a later time the REST API could have different results and more data could be returned
w3af_api_client/log.py
def log_entry_generator(log_instance): """ :yield: The next LogEntry from the REST API :raise: StopIteration when there are no more log entries to show, please note that if you call this again at a later time the REST API could have different results and more data could be returned ...
def log_entry_generator(log_instance): """ :yield: The next LogEntry from the REST API :raise: StopIteration when there are no more log entries to show, please note that if you call this again at a later time the REST API could have different results and more data could be returned ...
[ ":", "yield", ":", "The", "next", "LogEntry", "from", "the", "REST", "API", ":", "raise", ":", "StopIteration", "when", "there", "are", "no", "more", "log", "entries", "to", "show", "please", "note", "that", "if", "you", "call", "this", "again", "at", ...
andresriancho/w3af-api-client
python
https://github.com/andresriancho/w3af-api-client/blob/adeb79bad75264d754de69f0bb981b366da96f32/w3af_api_client/log.py#L110-L129
[ "def", "log_entry_generator", "(", "log_instance", ")", ":", "current_page_num", "=", "0", "while", "True", ":", "has_results", "=", "False", "for", "log_entry", "in", "log_instance", ".", "get_page", "(", "current_page_num", ")", ":", "has_results", "=", "True"...
adeb79bad75264d754de69f0bb981b366da96f32
train
LogEntry.from_entry_dict
This is a "constructor" for the LogEntry class. :param entry_dict: A dict we get from the REST API :return: An instance of LogEntry.
w3af_api_client/log.py
def from_entry_dict(cls, entry_dict): """ This is a "constructor" for the LogEntry class. :param entry_dict: A dict we get from the REST API :return: An instance of LogEntry. """ # Debug helper # https://circleci.com/gh/andresriancho/w3af-api-docker/30 tr...
def from_entry_dict(cls, entry_dict): """ This is a "constructor" for the LogEntry class. :param entry_dict: A dict we get from the REST API :return: An instance of LogEntry. """ # Debug helper # https://circleci.com/gh/andresriancho/w3af-api-docker/30 tr...
[ "This", "is", "a", "constructor", "for", "the", "LogEntry", "class", "." ]
andresriancho/w3af-api-client
python
https://github.com/andresriancho/w3af-api-client/blob/adeb79bad75264d754de69f0bb981b366da96f32/w3af_api_client/log.py#L22-L42
[ "def", "from_entry_dict", "(", "cls", ",", "entry_dict", ")", ":", "# Debug helper", "# https://circleci.com/gh/andresriancho/w3af-api-docker/30", "try", ":", "_type", "=", "entry_dict", "[", "'type'", "]", "_id", "=", "entry_dict", "[", "'id'", "]", "_time", "=", ...
adeb79bad75264d754de69f0bb981b366da96f32
train
Log.get_by_start_id
:yield: Log entries starting from :start_id: and ending 200 entries after. In most cases easier to call than the paginate one because there is no need to keep track of the already read entries in a specific page.
w3af_api_client/log.py
def get_by_start_id(self, start_id): """ :yield: Log entries starting from :start_id: and ending 200 entries after. In most cases easier to call than the paginate one because there is no need to keep track of the already read entries in a specific page. ...
def get_by_start_id(self, start_id): """ :yield: Log entries starting from :start_id: and ending 200 entries after. In most cases easier to call than the paginate one because there is no need to keep track of the already read entries in a specific page. ...
[ ":", "yield", ":", "Log", "entries", "starting", "from", ":", "start_id", ":", "and", "ending", "200", "entries", "after", ".", "In", "most", "cases", "easier", "to", "call", "than", "the", "paginate", "one", "because", "there", "is", "no", "need", "to",...
andresriancho/w3af-api-client
python
https://github.com/andresriancho/w3af-api-client/blob/adeb79bad75264d754de69f0bb981b366da96f32/w3af_api_client/log.py#L61-L83
[ "def", "get_by_start_id", "(", "self", ",", "start_id", ")", ":", "url", "=", "'/scans/%s/log?id=%s'", "%", "(", "self", ".", "scan_id", ",", "start_id", ")", "code", ",", "page", "=", "self", ".", "conn", ".", "send_request", "(", "url", ",", "method", ...
adeb79bad75264d754de69f0bb981b366da96f32
train
CapturesService.list
Get a list of captures. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :return: :class:`captures.Capture <captures.Capture>` list
cdrouter/captures.py
def list(self, id, seq): # pylint: disable=invalid-name,redefined-builtin """Get a list of captures. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :return: :class:`captures.Capture <captures.Capture>` list """ schema = CaptureSchema(exclud...
def list(self, id, seq): # pylint: disable=invalid-name,redefined-builtin """Get a list of captures. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :return: :class:`captures.Capture <captures.Capture>` list """ schema = CaptureSchema(exclud...
[ "Get", "a", "list", "of", "captures", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/captures.py#L308-L317
[ "def", "list", "(", "self", ",", "id", ",", "seq", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "CaptureSchema", "(", "exclude", "=", "(", "'id'", ",", "'seq'", ")", ")", "resp", "=", "self", ".", "service", ".", "list", "("...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5
train
CapturesService.get
Get a capture. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :return: :class:`captures.Capture <captures.Capture>` object :rtype: captures.Capture
cdrouter/captures.py
def get(self, id, seq, intf): # pylint: disable=invalid-name,redefined-builtin """Get a capture. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :return: :class:`captures.Capture <captures.Capture>` object ...
def get(self, id, seq, intf): # pylint: disable=invalid-name,redefined-builtin """Get a capture. :param id: Result ID as an int. :param seq: TestResult sequence ID as an int. :param intf: Interface name as string. :return: :class:`captures.Capture <captures.Capture>` object ...
[ "Get", "a", "capture", "." ]
qacafe/cdrouter.py
python
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/captures.py#L319-L330
[ "def", "get", "(", "self", ",", "id", ",", "seq", ",", "intf", ")", ":", "# pylint: disable=invalid-name,redefined-builtin", "schema", "=", "CaptureSchema", "(", ")", "resp", "=", "self", ".", "service", ".", "get_id", "(", "self", ".", "_base", "(", "id",...
aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5