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
_assert_input_is_valid
Called by the `validating_wrapper` in the first step (a) `apply_on_each_func_args` for each function input before executing the function. It simply delegates to the validator. The signature of this function is hardcoded to correspond to `apply_on_each_func_args`'s behaviour and should therefore not be changed. ...
valid8/entry_points_annotations.py
def _assert_input_is_valid(input_value, # type: Any validators, # type: List[InputValidator] validated_func, # type: Callable input_name # type: str ): """ Called by the `validating_wrappe...
def _assert_input_is_valid(input_value, # type: Any validators, # type: List[InputValidator] validated_func, # type: Callable input_name # type: str ): """ Called by the `validating_wrappe...
[ "Called", "by", "the", "validating_wrapper", "in", "the", "first", "step", "(", "a", ")", "apply_on_each_func_args", "for", "each", "function", "input", "before", "executing", "the", "function", ".", "It", "simply", "delegates", "to", "the", "validator", ".", ...
smarie/python-valid8
python
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L945-L963
[ "def", "_assert_input_is_valid", "(", "input_value", ",", "# type: Any", "validators", ",", "# type: List[InputValidator]", "validated_func", ",", "# type: Callable", "input_name", "# type: str", ")", ":", "for", "validator", "in", "validators", ":", "validator", ".", "...
5e15d1de11602933c5114eb9f73277ad91d97800
train
InputValidationError.get_what_txt
Overrides the base behaviour defined in ValidationError in order to add details about the function. :return:
valid8/entry_points_annotations.py
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the function. :return: """ return 'input [{var}] for function [{func}]'.format(var=self.get_variable_str(), ...
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the function. :return: """ return 'input [{var}] for function [{func}]'.format(var=self.get_variable_str(), ...
[ "Overrides", "the", "base", "behaviour", "defined", "in", "ValidationError", "in", "order", "to", "add", "details", "about", "the", "function", ".", ":", "return", ":" ]
smarie/python-valid8
python
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L42-L48
[ "def", "get_what_txt", "(", "self", ")", ":", "return", "'input [{var}] for function [{func}]'", ".", "format", "(", "var", "=", "self", ".", "get_variable_str", "(", ")", ",", "func", "=", "self", ".", "validator", ".", "get_validated_func_display_name", "(", "...
5e15d1de11602933c5114eb9f73277ad91d97800
train
ClassFieldValidationError.get_what_txt
Overrides the base behaviour defined in ValidationError in order to add details about the class field. :return:
valid8/entry_points_annotations.py
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the class field. :return: """ return 'field [{field}] for class [{clazz}]'.format(field=self.get_variable_str(), ...
def get_what_txt(self): """ Overrides the base behaviour defined in ValidationError in order to add details about the class field. :return: """ return 'field [{field}] for class [{clazz}]'.format(field=self.get_variable_str(), ...
[ "Overrides", "the", "base", "behaviour", "defined", "in", "ValidationError", "in", "order", "to", "add", "details", "about", "the", "class", "field", ".", ":", "return", ":" ]
smarie/python-valid8
python
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L80-L86
[ "def", "get_what_txt", "(", "self", ")", ":", "return", "'field [{field}] for class [{clazz}]'", ".", "format", "(", "field", "=", "self", ".", "get_variable_str", "(", ")", ",", "clazz", "=", "self", ".", "validator", ".", "get_validated_class_display_name", "(",...
5e15d1de11602933c5114eb9f73277ad91d97800
train
generate_nonce_timestamp
Generate unique nonce with counter, uuid and rng.
cryptoshop/_nonce_engine.py
def generate_nonce_timestamp(): """ Generate unique nonce with counter, uuid and rng.""" global count rng = botan.rng().get(30) uuid4 = uuid.uuid4().bytes # 16 byte tmpnonce = (bytes(str(count).encode('utf-8'))) + uuid4 + rng nonce = tmpnonce[:41] # 41 byte (328 bit) count += 1 return ...
def generate_nonce_timestamp(): """ Generate unique nonce with counter, uuid and rng.""" global count rng = botan.rng().get(30) uuid4 = uuid.uuid4().bytes # 16 byte tmpnonce = (bytes(str(count).encode('utf-8'))) + uuid4 + rng nonce = tmpnonce[:41] # 41 byte (328 bit) count += 1 return ...
[ "Generate", "unique", "nonce", "with", "counter", "uuid", "and", "rng", "." ]
Antidote1911/cryptoshop
python
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_nonce_engine.py#L45-L53
[ "def", "generate_nonce_timestamp", "(", ")", ":", "global", "count", "rng", "=", "botan", ".", "rng", "(", ")", ".", "get", "(", "30", ")", "uuid4", "=", "uuid", ".", "uuid4", "(", ")", ".", "bytes", "# 16 byte", "tmpnonce", "=", "(", "bytes", "(", ...
0b7ff4a6848f2733f4737606957e8042a4d6ca0b
train
dict_merge
recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary.
dci/common/schemas.py
def dict_merge(*dict_list): """recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. """ result = collections.defaultdict(dict) dicts_items = itert...
def dict_merge(*dict_list): """recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. """ result = collections.defaultdict(dict) dicts_items = itert...
[ "recursively", "merges", "dict", "s", ".", "not", "just", "simple", "a", "[", "key", "]", "=", "b", "[", "key", "]", "if", "both", "a", "and", "bhave", "a", "key", "who", "s", "value", "is", "a", "dict", "then", "dict_merge", "is", "called", "on", ...
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/schemas.py#L108-L127
[ "def", "dict_merge", "(", "*", "dict_list", ")", ":", "result", "=", "collections", ".", "defaultdict", "(", "dict", ")", "dicts_items", "=", "itertools", ".", "chain", "(", "*", "[", "six", ".", "iteritems", "(", "d", "or", "{", "}", ")", "for", "d"...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
schedule_jobs
Dispatch jobs to remotecis. The remoteci can use this method to request a new job. Before a job is dispatched, the server will flag as 'killed' all the running jobs that were associated with the remoteci. This is because they will never be finished.
dci/api/v1/jobs.py
def schedule_jobs(user): """Dispatch jobs to remotecis. The remoteci can use this method to request a new job. Before a job is dispatched, the server will flag as 'killed' all the running jobs that were associated with the remoteci. This is because they will never be finished. """ values ...
def schedule_jobs(user): """Dispatch jobs to remotecis. The remoteci can use this method to request a new job. Before a job is dispatched, the server will flag as 'killed' all the running jobs that were associated with the remoteci. This is because they will never be finished. """ values ...
[ "Dispatch", "jobs", "to", "remotecis", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L195-L267
[ "def", "schedule_jobs", "(", "user", ")", ":", "values", "=", "schemas", ".", "job_schedule", ".", "post", "(", "flask", ".", "request", ".", "json", ")", "values", ".", "update", "(", "{", "'id'", ":", "utils", ".", "gen_uuid", "(", ")", ",", "'crea...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
create_new_update_job_from_an_existing_job
Create a new job in the same topic as the job_id provided and associate the latest components of this topic.
dci/api/v1/jobs.py
def create_new_update_job_from_an_existing_job(user, job_id): """Create a new job in the same topic as the job_id provided and associate the latest components of this topic.""" values = { 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), 'updated_at': dat...
def create_new_update_job_from_an_existing_job(user, job_id): """Create a new job in the same topic as the job_id provided and associate the latest components of this topic.""" values = { 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), 'updated_at': dat...
[ "Create", "a", "new", "job", "in", "the", "same", "topic", "as", "the", "job_id", "provided", "and", "associate", "the", "latest", "components", "of", "this", "topic", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L272-L313
[ "def", "create_new_update_job_from_an_existing_job", "(", "user", ",", "job_id", ")", ":", "values", "=", "{", "'id'", ":", "utils", ".", "gen_uuid", "(", ")", ",", "'created_at'", ":", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "isoformat", ...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
create_new_upgrade_job_from_an_existing_job
Create a new job in the 'next topic' of the topic of the provided job_id.
dci/api/v1/jobs.py
def create_new_upgrade_job_from_an_existing_job(user): """Create a new job in the 'next topic' of the topic of the provided job_id.""" values = schemas.job_upgrade.post(flask.request.json) values.update({ 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), ...
def create_new_upgrade_job_from_an_existing_job(user): """Create a new job in the 'next topic' of the topic of the provided job_id.""" values = schemas.job_upgrade.post(flask.request.json) values.update({ 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat(), ...
[ "Create", "a", "new", "job", "in", "the", "next", "topic", "of", "the", "topic", "of", "the", "provided", "job_id", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L318-L367
[ "def", "create_new_upgrade_job_from_an_existing_job", "(", "user", ")", ":", "values", "=", "schemas", ".", "job_upgrade", ".", "post", "(", "flask", ".", "request", ".", "json", ")", "values", ".", "update", "(", "{", "'id'", ":", "utils", ".", "gen_uuid", ...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
get_all_jobs
Get all jobs. If topic_id is not None, then return all the jobs with a topic pointed by topic_id.
dci/api/v1/jobs.py
def get_all_jobs(user, topic_id=None): """Get all jobs. If topic_id is not None, then return all the jobs with a topic pointed by topic_id. """ # get the diverse parameters args = schemas.args(flask.request.args.to_dict()) # build the query thanks to the QueryBuilder class query = v1_u...
def get_all_jobs(user, topic_id=None): """Get all jobs. If topic_id is not None, then return all the jobs with a topic pointed by topic_id. """ # get the diverse parameters args = schemas.args(flask.request.args.to_dict()) # build the query thanks to the QueryBuilder class query = v1_u...
[ "Get", "all", "jobs", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L372-L405
[ "def", "get_all_jobs", "(", "user", ",", "topic_id", "=", "None", ")", ":", "# get the diverse parameters", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "# build the query thanks to the QueryBuild...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
update_job_by_id
Update a job
dci/api/v1/jobs.py
def update_job_by_id(user, job_id): """Update a job """ # get If-Match header if_match_etag = utils.check_and_get_etag(flask.request.headers) # get the diverse parameters values = schemas.job.put(flask.request.json) job = v1_utils.verify_existence_and_get(job_id, _TABLE) job = dict(job...
def update_job_by_id(user, job_id): """Update a job """ # get If-Match header if_match_etag = utils.check_and_get_etag(flask.request.headers) # get the diverse parameters values = schemas.job.put(flask.request.json) job = v1_utils.verify_existence_and_get(job_id, _TABLE) job = dict(job...
[ "Update", "a", "job" ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L437-L477
[ "def", "update_job_by_id", "(", "user", ",", "job_id", ")", ":", "# get If-Match header", "if_match_etag", "=", "utils", ".", "check_and_get_etag", "(", "flask", ".", "request", ".", "headers", ")", "# get the diverse parameters", "values", "=", "schemas", ".", "j...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
get_all_results_from_jobs
Get all results from job.
dci/api/v1/jobs.py
def get_all_results_from_jobs(user, j_id): """Get all results from job. """ job = v1_utils.verify_existence_and_get(j_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() # get testscases from tests_results query = sql.selec...
def get_all_results_from_jobs(user, j_id): """Get all results from job. """ job = v1_utils.verify_existence_and_get(j_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() # get testscases from tests_results query = sql.selec...
[ "Get", "all", "results", "from", "job", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L521-L551
[ "def", "get_all_results_from_jobs", "(", "user", ",", "j_id", ")", ":", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "j_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team", "(", "job", "[", "'team_id'", "]", ")", "and", "not", ...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
get_tags_from_job
Retrieve all tags attached to a job.
dci/api/v1/jobs.py
def get_tags_from_job(user, job_id): """Retrieve all tags attached to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() JTT = models.JOIN_JOBS_TAGS query = (sql.select([mod...
def get_tags_from_job(user, job_id): """Retrieve all tags attached to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']) and not user.is_read_only_user(): raise dci_exc.Unauthorized() JTT = models.JOIN_JOBS_TAGS query = (sql.select([mod...
[ "Retrieve", "all", "tags", "attached", "to", "a", "job", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L587-L600
[ "def", "get_tags_from_job", "(", "user", ",", "job_id", ")", ":", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team", "(", "job", "[", "'team_id'", "]", ")", "and", "not", "u...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
add_tag_to_job
Add a tag to a job.
dci/api/v1/jobs.py
def add_tag_to_job(user, job_id): """Add a tag to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() values = { 'job_id': job_id } job_tagged = tags.add_tag_to_resource(values, models.JOIN_JOBS...
def add_tag_to_job(user, job_id): """Add a tag to a job.""" job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() values = { 'job_id': job_id } job_tagged = tags.add_tag_to_resource(values, models.JOIN_JOBS...
[ "Add", "a", "tag", "to", "a", "job", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L605-L619
[ "def", "add_tag_to_job", "(", "user", ",", "job_id", ")", ":", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team", "(", "job", "[", "'team_id'", "]", ")", ":", "raise", "dci_...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
delete_tag_from_job
Delete a tag from a job.
dci/api/v1/jobs.py
def delete_tag_from_job(user, job_id, tag_id): """Delete a tag from a job.""" _JJT = models.JOIN_JOBS_TAGS job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() v1_utils.verify_existence_and_get(tag_id, models.TAGS) ...
def delete_tag_from_job(user, job_id, tag_id): """Delete a tag from a job.""" _JJT = models.JOIN_JOBS_TAGS job = v1_utils.verify_existence_and_get(job_id, _TABLE) if not user.is_in_team(job['team_id']): raise dci_exc.Unauthorized() v1_utils.verify_existence_and_get(tag_id, models.TAGS) ...
[ "Delete", "a", "tag", "from", "a", "job", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs.py#L624-L641
[ "def", "delete_tag_from_job", "(", "user", ",", "job_id", ",", "tag_id", ")", ":", "_JJT", "=", "models", ".", "JOIN_JOBS_TAGS", "job", "=", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "_TABLE", ")", "if", "not", "user", ".", "is_in_team...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
ElementTreeAdapter._lookup_node_parent
Return the parent of the given node, based on an internal dictionary mapping of child nodes to the child's parent required since ElementTree doesn't make info about node ancestry/parentage available.
xml4h/impls/xml_etree_elementtree.py
def _lookup_node_parent(self, node): """ Return the parent of the given node, based on an internal dictionary mapping of child nodes to the child's parent required since ElementTree doesn't make info about node ancestry/parentage available. """ # Basic caching of our inte...
def _lookup_node_parent(self, node): """ Return the parent of the given node, based on an internal dictionary mapping of child nodes to the child's parent required since ElementTree doesn't make info about node ancestry/parentage available. """ # Basic caching of our inte...
[ "Return", "the", "parent", "of", "the", "given", "node", "based", "on", "an", "internal", "dictionary", "mapping", "of", "child", "nodes", "to", "the", "child", "s", "parent", "required", "since", "ElementTree", "doesn", "t", "make", "info", "about", "node",...
jmurty/xml4h
python
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L108-L120
[ "def", "_lookup_node_parent", "(", "self", ",", "node", ")", ":", "# Basic caching of our internal ancestry dict to help performance", "if", "not", "node", "in", "self", ".", "CACHED_ANCESTRY_DICT", ":", "# Given node isn't in cached ancestry dictionary, rebuild this now", "ances...
adbb45e27a01a869a505aee7bc16bad2f517b511
train
ElementTreeAdapter._is_node_an_element
Return True if the given node is an ElementTree Element, a fact that can be tricky to determine if the cElementTree implementation is used.
xml4h/impls/xml_etree_elementtree.py
def _is_node_an_element(self, node): """ Return True if the given node is an ElementTree Element, a fact that can be tricky to determine if the cElementTree implementation is used. """ # Try the simplest approach first, works for plain old ElementTree if isinstanc...
def _is_node_an_element(self, node): """ Return True if the given node is an ElementTree Element, a fact that can be tricky to determine if the cElementTree implementation is used. """ # Try the simplest approach first, works for plain old ElementTree if isinstanc...
[ "Return", "True", "if", "the", "given", "node", "is", "an", "ElementTree", "Element", "a", "fact", "that", "can", "be", "tricky", "to", "determine", "if", "the", "cElementTree", "implementation", "is", "used", "." ]
jmurty/xml4h
python
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L122-L133
[ "def", "_is_node_an_element", "(", "self", ",", "node", ")", ":", "# Try the simplest approach first, works for plain old ElementTree", "if", "isinstance", "(", "node", ",", "BaseET", ".", "Element", ")", ":", "return", "True", "# For cElementTree we need to be more cunning...
adbb45e27a01a869a505aee7bc16bad2f517b511
train
ElementTreeAdapter.xpath_on_node
Return result of performing the given XPath query on the given node. All known namespace prefix-to-URI mappings in the document are automatically included in the XPath invocation. If an empty/default namespace (i.e. None) is defined, this is converted to the prefix name '_' so it can b...
xml4h/impls/xml_etree_elementtree.py
def xpath_on_node(self, node, xpath, **kwargs): """ Return result of performing the given XPath query on the given node. All known namespace prefix-to-URI mappings in the document are automatically included in the XPath invocation. If an empty/default namespace (i.e. None) is d...
def xpath_on_node(self, node, xpath, **kwargs): """ Return result of performing the given XPath query on the given node. All known namespace prefix-to-URI mappings in the document are automatically included in the XPath invocation. If an empty/default namespace (i.e. None) is d...
[ "Return", "result", "of", "performing", "the", "given", "XPath", "query", "on", "the", "given", "node", "." ]
jmurty/xml4h
python
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_etree_elementtree.py#L200-L228
[ "def", "xpath_on_node", "(", "self", ",", "node", ",", "xpath", ",", "*", "*", "kwargs", ")", ":", "namespaces_dict", "=", "{", "}", "if", "'namespaces'", "in", "kwargs", ":", "namespaces_dict", ".", "update", "(", "kwargs", "[", "'namespaces'", "]", ")"...
adbb45e27a01a869a505aee7bc16bad2f517b511
train
get_to_purge_archived_resources
List the entries to be purged from the database.
dci/api/v1/base.py
def get_to_purge_archived_resources(user, table): """List the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() archived_resources = get_archived_resources(table) return flask.jsonify({table.name: archived_resources, ...
def get_to_purge_archived_resources(user, table): """List the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() archived_resources = get_archived_resources(table) return flask.jsonify({table.name: archived_resources, ...
[ "List", "the", "entries", "to", "be", "purged", "from", "the", "database", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L67-L76
[ "def", "get_to_purge_archived_resources", "(", "user", ",", "table", ")", ":", "if", "user", ".", "is_not_super_admin", "(", ")", ":", "raise", "dci_exc", ".", "Unauthorized", "(", ")", "archived_resources", "=", "get_archived_resources", "(", "table", ")", "ret...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
purge_archived_resources
Remove the entries to be purged from the database.
dci/api/v1/base.py
def purge_archived_resources(user, table): """Remove the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() where_clause = sql.and_( table.c.state == 'archived' ) query = table.delete().where(where_clause) flask.g.db_conn.exec...
def purge_archived_resources(user, table): """Remove the entries to be purged from the database. """ if user.is_not_super_admin(): raise dci_exc.Unauthorized() where_clause = sql.and_( table.c.state == 'archived' ) query = table.delete().where(where_clause) flask.g.db_conn.exec...
[ "Remove", "the", "entries", "to", "be", "purged", "from", "the", "database", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L79-L91
[ "def", "purge_archived_resources", "(", "user", ",", "table", ")", ":", "if", "user", ".", "is_not_super_admin", "(", ")", ":", "raise", "dci_exc", ".", "Unauthorized", "(", ")", "where_clause", "=", "sql", ".", "and_", "(", "table", ".", "c", ".", "stat...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
refresh_api_secret
Refresh the resource API Secret.
dci/api/v1/base.py
def refresh_api_secret(user, resource, table): """Refresh the resource API Secret. """ resource_name = table.name[0:-1] where_clause = sql.and_( table.c.etag == resource['etag'], table.c.id == resource['id'], ) values = { 'api_secret': signature.gen_secret(), 'etag...
def refresh_api_secret(user, resource, table): """Refresh the resource API Secret. """ resource_name = table.name[0:-1] where_clause = sql.and_( table.c.etag == resource['etag'], table.c.id == resource['id'], ) values = { 'api_secret': signature.gen_secret(), 'etag...
[ "Refresh", "the", "resource", "API", "Secret", "." ]
redhat-cip/dci-control-server
python
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/base.py#L94-L118
[ "def", "refresh_api_secret", "(", "user", ",", "resource", ",", "table", ")", ":", "resource_name", "=", "table", ".", "name", "[", "0", ":", "-", "1", "]", "where_clause", "=", "sql", ".", "and_", "(", "table", ".", "c", ".", "etag", "==", "resource...
b416cf935ec93e4fdd5741f61a21cabecf8454d2
train
npm
Generate a package.json file.
invenio_assets/cli.py
def npm(package_json, output_file, pinned_file): """Generate a package.json file.""" amd_build_deprecation_warning() try: version = get_distribution(current_app.name).version except DistributionNotFound: version = '' output = { 'name': current_app.name, 'version': ma...
def npm(package_json, output_file, pinned_file): """Generate a package.json file.""" amd_build_deprecation_warning() try: version = get_distribution(current_app.name).version except DistributionNotFound: version = '' output = { 'name': current_app.name, 'version': ma...
[ "Generate", "a", "package", ".", "json", "file", "." ]
inveniosoftware/invenio-assets
python
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/cli.py#L73-L111
[ "def", "npm", "(", "package_json", ",", "output_file", ",", "pinned_file", ")", ":", "amd_build_deprecation_warning", "(", ")", "try", ":", "version", "=", "get_distribution", "(", "current_app", ".", "name", ")", ".", "version", "except", "DistributionNotFound", ...
836cc75ebe0c179f0d72456bd8b784cdc18394a6
train
PingdomCheck.getAnalyses
Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer Default: 100 * offset -- O...
pingdomlib/check.py
def getAnalyses(self, **kwargs): """Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer ...
def getAnalyses(self, **kwargs): """Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer ...
[ "Returns", "a", "list", "of", "the", "latest", "root", "cause", "analysis", "results", "for", "a", "specified", "check", "." ]
KennethWilke/PingdomLib
python
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L87-L143
[ "def", "getAnalyses", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# 'from' is a reserved word, use time_from instead", "if", "kwargs", ".", "get", "(", "'time_from'", ")", ":", "kwargs", "[", "'from'", "]", "=", "kwargs", ".", "get", "(", "'time_from'", ...
3ed1e481f9c9d16b032558d62fb05c2166e162ed
train
PingdomCheck.getDetails
Update check details, returns dictionary of details
pingdomlib/check.py
def getDetails(self): """Update check details, returns dictionary of details""" response = self.pingdom.request('GET', 'checks/%s' % self.id) self.__addDetails__(response.json()['check']) return response.json()['check']
def getDetails(self): """Update check details, returns dictionary of details""" response = self.pingdom.request('GET', 'checks/%s' % self.id) self.__addDetails__(response.json()['check']) return response.json()['check']
[ "Update", "check", "details", "returns", "dictionary", "of", "details" ]
KennethWilke/PingdomLib
python
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L175-L180
[ "def", "getDetails", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'GET'", ",", "'checks/%s'", "%", "self", ".", "id", ")", "self", ".", "__addDetails__", "(", "response", ".", "json", "(", ")", "[", "'check'", ...
3ed1e481f9c9d16b032558d62fb05c2166e162ed
train
PingdomCheck.modify
Modify settings for a check. The provided settings will overwrite previous values. Settings not provided will stay the same as before the update. To clear an existing value, provide an empty value. Please note that you cannot change the type of a check once it has been cr...
pingdomlib/check.py
def modify(self, **kwargs): """Modify settings for a check. The provided settings will overwrite previous values. Settings not provided will stay the same as before the update. To clear an existing value, provide an empty value. Please note that you cannot change the type of ...
def modify(self, **kwargs): """Modify settings for a check. The provided settings will overwrite previous values. Settings not provided will stay the same as before the update. To clear an existing value, provide an empty value. Please note that you cannot change the type of ...
[ "Modify", "settings", "for", "a", "check", ".", "The", "provided", "settings", "will", "overwrite", "previous", "values", ".", "Settings", "not", "provided", "will", "stay", "the", "same", "as", "before", "the", "update", ".", "To", "clear", "an", "existing"...
KennethWilke/PingdomLib
python
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L182-L382
[ "def", "modify", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'paused'", ",", "'resolution'", ",", "'contactids'", ",", "'sendtoemail'", ",", "'se...
3ed1e481f9c9d16b032558d62fb05c2166e162ed
train
PingdomCheck.averages
Get the average time / uptime value for a specified check and time period. Optional parameters: * time_from -- Start time of period. Format is UNIX timestamp Type: Integer Default: 0 * time_to -- End time of period. Format is UNIX ti...
pingdomlib/check.py
def averages(self, **kwargs): """Get the average time / uptime value for a specified check and time period. Optional parameters: * time_from -- Start time of period. Format is UNIX timestamp Type: Integer Default: 0 * time_to...
def averages(self, **kwargs): """Get the average time / uptime value for a specified check and time period. Optional parameters: * time_from -- Start time of period. Format is UNIX timestamp Type: Integer Default: 0 * time_to...
[ "Get", "the", "average", "time", "/", "uptime", "value", "for", "a", "specified", "check", "and", "time", "period", "." ]
KennethWilke/PingdomLib
python
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L392-L454
[ "def", "averages", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# 'from' is a reserved word, use time_from instead", "if", "kwargs", ".", "get", "(", "'time_from'", ")", ":", "kwargs", "[", "'from'", "]", "=", "kwargs", ".", "get", "(", "'time_from'", ")...
3ed1e481f9c9d16b032558d62fb05c2166e162ed
train
PingdomCheck.probes
Get a list of probes that performed tests for a specified check during a specified period.
pingdomlib/check.py
def probes(self, fromtime, totime=None): """Get a list of probes that performed tests for a specified check during a specified period.""" args = {'from': fromtime} if totime: args['to'] = totime response = self.pingdom.request('GET', 'summary.probes/%s' % self.i...
def probes(self, fromtime, totime=None): """Get a list of probes that performed tests for a specified check during a specified period.""" args = {'from': fromtime} if totime: args['to'] = totime response = self.pingdom.request('GET', 'summary.probes/%s' % self.i...
[ "Get", "a", "list", "of", "probes", "that", "performed", "tests", "for", "a", "specified", "check", "during", "a", "specified", "period", "." ]
KennethWilke/PingdomLib
python
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L639-L650
[ "def", "probes", "(", "self", ",", "fromtime", ",", "totime", "=", "None", ")", ":", "args", "=", "{", "'from'", ":", "fromtime", "}", "if", "totime", ":", "args", "[", "'to'", "]", "=", "totime", "response", "=", "self", ".", "pingdom", ".", "requ...
3ed1e481f9c9d16b032558d62fb05c2166e162ed
train
PingdomCheck.publishPublicReport
Activate public report for this check. Returns status message
pingdomlib/check.py
def publishPublicReport(self): """Activate public report for this check. Returns status message""" response = self.pingdom.request('PUT', 'reports.public/%s' % self.id) return response.json()['message']
def publishPublicReport(self): """Activate public report for this check. Returns status message""" response = self.pingdom.request('PUT', 'reports.public/%s' % self.id) return response.json()['message']
[ "Activate", "public", "report", "for", "this", "check", "." ]
KennethWilke/PingdomLib
python
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L740-L746
[ "def", "publishPublicReport", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'PUT'", ",", "'reports.public/%s'", "%", "self", ".", "id", ")", "return", "response", ".", "json", "(", ")", "[", "'message'", "]" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
train
PingdomCheck.removePublicReport
Deactivate public report for this check. Returns status message
pingdomlib/check.py
def removePublicReport(self): """Deactivate public report for this check. Returns status message""" response = self.pingdom.request('DELETE', 'reports.public/%s' % self.id) return response.json()['message']
def removePublicReport(self): """Deactivate public report for this check. Returns status message""" response = self.pingdom.request('DELETE', 'reports.public/%s' % self.id) return response.json()['message']
[ "Deactivate", "public", "report", "for", "this", "check", "." ]
KennethWilke/PingdomLib
python
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L748-L755
[ "def", "removePublicReport", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'DELETE'", ",", "'reports.public/%s'", "%", "self", ".", "id", ")", "return", "response", ".", "json", "(", ")", "[", "'message'", "]" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
train
extract_deps
Extract the dependencies from the bundle and its sub-bundles.
invenio_assets/npm.py
def extract_deps(bundles, log=None): """Extract the dependencies from the bundle and its sub-bundles.""" def _flatten(bundle): deps = [] if hasattr(bundle, 'npm'): deps.append(bundle.npm) for content in bundle.contents: if isinstance(content, BundleBase): ...
def extract_deps(bundles, log=None): """Extract the dependencies from the bundle and its sub-bundles.""" def _flatten(bundle): deps = [] if hasattr(bundle, 'npm'): deps.append(bundle.npm) for content in bundle.contents: if isinstance(content, BundleBase): ...
[ "Extract", "the", "dependencies", "from", "the", "bundle", "and", "its", "sub", "-", "bundles", "." ]
inveniosoftware/invenio-assets
python
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/npm.py#L54-L83
[ "def", "extract_deps", "(", "bundles", ",", "log", "=", "None", ")", ":", "def", "_flatten", "(", "bundle", ")", ":", "deps", "=", "[", "]", "if", "hasattr", "(", "bundle", ",", "'npm'", ")", ":", "deps", ".", "append", "(", "bundle", ".", "npm", ...
836cc75ebe0c179f0d72456bd8b784cdc18394a6
train
make_semver
Make a semantic version from Python PEP440 version. Semantic versions does not handle post-releases.
invenio_assets/npm.py
def make_semver(version_str): """Make a semantic version from Python PEP440 version. Semantic versions does not handle post-releases. """ v = parse_version(version_str) major = v._version.release[0] try: minor = v._version.release[1] except IndexError: minor = 0 try: ...
def make_semver(version_str): """Make a semantic version from Python PEP440 version. Semantic versions does not handle post-releases. """ v = parse_version(version_str) major = v._version.release[0] try: minor = v._version.release[1] except IndexError: minor = 0 try: ...
[ "Make", "a", "semantic", "version", "from", "Python", "PEP440", "version", "." ]
inveniosoftware/invenio-assets
python
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/npm.py#L86-L118
[ "def", "make_semver", "(", "version_str", ")", ":", "v", "=", "parse_version", "(", "version_str", ")", "major", "=", "v", ".", "_version", ".", "release", "[", "0", "]", "try", ":", "minor", "=", "v", ".", "_version", ".", "release", "[", "1", "]", ...
836cc75ebe0c179f0d72456bd8b784cdc18394a6
train
get_max_size
Calculate the max number of item that an option can stored in the pool at give time. This is to limit the pool size to POOL_SIZE Args: option_index (int): the index of the option to calculate the size for pool (dict): answer pool num_option (int): total number of options available for ...
ubcpi/answer_pool.py
def get_max_size(pool, num_option, item_length): """ Calculate the max number of item that an option can stored in the pool at give time. This is to limit the pool size to POOL_SIZE Args: option_index (int): the index of the option to calculate the size for pool (dict): answer pool ...
def get_max_size(pool, num_option, item_length): """ Calculate the max number of item that an option can stored in the pool at give time. This is to limit the pool size to POOL_SIZE Args: option_index (int): the index of the option to calculate the size for pool (dict): answer pool ...
[ "Calculate", "the", "max", "number", "of", "item", "that", "an", "option", "can", "stored", "in", "the", "pool", "at", "give", "time", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L21-L40
[ "def", "get_max_size", "(", "pool", ",", "num_option", ",", "item_length", ")", ":", "max_items", "=", "POOL_SIZE", "/", "item_length", "# existing items plus the reserved for min size. If there is an option has 1 item, POOL_OPTION_MIN_SIZE - 1 space", "# is reserved.", "existing",...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
offer_answer
submit a student answer to the answer pool The answer maybe selected to stay in the pool depending on the selection algorithm Args: pool (dict): answer pool Answer pool format: { option1_index: { 'student_id': { can store algorithm specific i...
ubcpi/answer_pool.py
def offer_answer(pool, answer, rationale, student_id, algo, options): """ submit a student answer to the answer pool The answer maybe selected to stay in the pool depending on the selection algorithm Args: pool (dict): answer pool Answer pool format: { o...
def offer_answer(pool, answer, rationale, student_id, algo, options): """ submit a student answer to the answer pool The answer maybe selected to stay in the pool depending on the selection algorithm Args: pool (dict): answer pool Answer pool format: { o...
[ "submit", "a", "student", "answer", "to", "the", "answer", "pool" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L43-L73
[ "def", "offer_answer", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "algo", ",", "options", ")", ":", "if", "algo", "[", "'name'", "]", "==", "'simple'", ":", "offer_simple", "(", "pool", ",", "answer", ",", "rationale", ",", "...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
offer_simple
The simple selection algorithm. This algorithm randomly select an answer from the pool to discard and add the new one when the pool reaches the limit
ubcpi/answer_pool.py
def offer_simple(pool, answer, rationale, student_id, options): """ The simple selection algorithm. This algorithm randomly select an answer from the pool to discard and add the new one when the pool reaches the limit """ existing = pool.setdefault(answer, {}) if len(existing) >= get_max_si...
def offer_simple(pool, answer, rationale, student_id, options): """ The simple selection algorithm. This algorithm randomly select an answer from the pool to discard and add the new one when the pool reaches the limit """ existing = pool.setdefault(answer, {}) if len(existing) >= get_max_si...
[ "The", "simple", "selection", "algorithm", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L76-L88
[ "def", "offer_simple", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "options", ")", ":", "existing", "=", "pool", ".", "setdefault", "(", "answer", ",", "{", "}", ")", "if", "len", "(", "existing", ")", ">=", "get_max_size", "(...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
offer_random
The random selection algorithm. The same as simple algorithm
ubcpi/answer_pool.py
def offer_random(pool, answer, rationale, student_id, options): """ The random selection algorithm. The same as simple algorithm """ offer_simple(pool, answer, rationale, student_id, options)
def offer_random(pool, answer, rationale, student_id, options): """ The random selection algorithm. The same as simple algorithm """ offer_simple(pool, answer, rationale, student_id, options)
[ "The", "random", "selection", "algorithm", ".", "The", "same", "as", "simple", "algorithm" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L91-L95
[ "def", "offer_random", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "options", ")", ":", "offer_simple", "(", "pool", ",", "answer", ",", "rationale", ",", "student_id", ",", "options", ")" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
validate_seeded_answers_simple
This validator checks if the answers includes all possible options Args: answers (str): the answers to be checked options (dict): all options that should exist in the answers algo (str): selection algorithm Returns: None if everything is good. Otherwise, the missing option erro...
ubcpi/answer_pool.py
def validate_seeded_answers_simple(answers, options, algo): """ This validator checks if the answers includes all possible options Args: answers (str): the answers to be checked options (dict): all options that should exist in the answers algo (str): selection algorithm Returns...
def validate_seeded_answers_simple(answers, options, algo): """ This validator checks if the answers includes all possible options Args: answers (str): the answers to be checked options (dict): all options that should exist in the answers algo (str): selection algorithm Returns...
[ "This", "validator", "checks", "if", "the", "answers", "includes", "all", "possible", "options" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L98-L131
[ "def", "validate_seeded_answers_simple", "(", "answers", ",", "options", ",", "algo", ")", ":", "seen_options", "=", "{", "}", "for", "answer", "in", "answers", ":", "if", "answer", ":", "key", "=", "options", "[", "answer", "[", "'answer'", "]", "]", "....
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
validate_seeded_answers
Validate answers based on selection algorithm This is called when instructor setup the tool and providing seeded answers to the question. This function is trying to validate if instructor provided enough seeds for a give algorithm. e.g. we require 1 seed for each option in simple algorithm and at least 1 s...
ubcpi/answer_pool.py
def validate_seeded_answers(answers, options, algo): """ Validate answers based on selection algorithm This is called when instructor setup the tool and providing seeded answers to the question. This function is trying to validate if instructor provided enough seeds for a give algorithm. e.g. we re...
def validate_seeded_answers(answers, options, algo): """ Validate answers based on selection algorithm This is called when instructor setup the tool and providing seeded answers to the question. This function is trying to validate if instructor provided enough seeds for a give algorithm. e.g. we re...
[ "Validate", "answers", "based", "on", "selection", "algorithm" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L150-L173
[ "def", "validate_seeded_answers", "(", "answers", ",", "options", ",", "algo", ")", ":", "if", "algo", "[", "'name'", "]", "==", "'simple'", ":", "return", "validate_seeded_answers_simple", "(", "answers", ",", "options", ",", "algo", ")", "elif", "algo", "[...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
get_other_answers
Select other student's answers from answer pool or seeded answers based on the selection algorithm Args: pool (dict): answer pool, format: { option1_index: { student_id: { can store algorithm specific info here } }, option2_ind...
ubcpi/answer_pool.py
def get_other_answers(pool, seeded_answers, get_student_item_dict, algo, options): """ Select other student's answers from answer pool or seeded answers based on the selection algorithm Args: pool (dict): answer pool, format: { option1_index: { studen...
def get_other_answers(pool, seeded_answers, get_student_item_dict, algo, options): """ Select other student's answers from answer pool or seeded answers based on the selection algorithm Args: pool (dict): answer pool, format: { option1_index: { studen...
[ "Select", "other", "student", "s", "answers", "from", "answer", "pool", "or", "seeded", "answers", "based", "on", "the", "selection", "algorithm" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L176-L212
[ "def", "get_other_answers", "(", "pool", ",", "seeded_answers", ",", "get_student_item_dict", ",", "algo", ",", "options", ")", ":", "# \"#\" means the number of responses returned should be the same as the number of options.", "num_responses", "=", "len", "(", "options", ")"...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
get_other_answers_simple
Get answers from others with simple algorithm, which picks one answer for each option. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value may not be respected if there is not enough answers to return Returns: dict: answers ...
ubcpi/answer_pool.py
def get_other_answers_simple(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with simple algorithm, which picks one answer for each option. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value may not ...
def get_other_answers_simple(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with simple algorithm, which picks one answer for each option. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value may not ...
[ "Get", "answers", "from", "others", "with", "simple", "algorithm", "which", "picks", "one", "answer", "for", "each", "option", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L215-L274
[ "def", "get_other_answers_simple", "(", "pool", ",", "seeded_answers", ",", "get_student_item_dict", ",", "num_responses", ")", ":", "ret", "=", "[", "]", "# clean up answers so that all keys are int", "pool", "=", "{", "int", "(", "k", ")", ":", "v", "for", "k"...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
get_other_answers_random
Get answers from others with random algorithm, which randomly select answer from the pool. Student may get three answers for option 1 or one answer for option 1 and two answers for option 2. Args: see `get_other_answers` num_responses (int): the number of responses to be returned. This value m...
ubcpi/answer_pool.py
def get_other_answers_random(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with random algorithm, which randomly select answer from the pool. Student may get three answers for option 1 or one answer for option 1 and two answers for option 2. Args: see...
def get_other_answers_random(pool, seeded_answers, get_student_item_dict, num_responses): """ Get answers from others with random algorithm, which randomly select answer from the pool. Student may get three answers for option 1 or one answer for option 1 and two answers for option 2. Args: see...
[ "Get", "answers", "from", "others", "with", "random", "algorithm", "which", "randomly", "select", "answer", "from", "the", "pool", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L277-L323
[ "def", "get_other_answers_random", "(", "pool", ",", "seeded_answers", ",", "get_student_item_dict", ",", "num_responses", ")", ":", "ret", "=", "[", "]", "# clean up answers so that all keys are int", "pool", "=", "{", "int", "(", "k", ")", ":", "v", "for", "k"...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
convert_seeded_answers
Convert seeded answers into the format that can be merged into student answers. Args: answers (list): seeded answers Returns: dict: seeded answers with student answers format: { 0: { 'seeded0': 'rationaleA' } 1: { ...
ubcpi/answer_pool.py
def convert_seeded_answers(answers): """ Convert seeded answers into the format that can be merged into student answers. Args: answers (list): seeded answers Returns: dict: seeded answers with student answers format: { 0: { 'seeded0': 'ra...
def convert_seeded_answers(answers): """ Convert seeded answers into the format that can be merged into student answers. Args: answers (list): seeded answers Returns: dict: seeded answers with student answers format: { 0: { 'seeded0': 'ra...
[ "Convert", "seeded", "answers", "into", "the", "format", "that", "can", "be", "merged", "into", "student", "answers", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/answer_pool.py#L326-L349
[ "def", "convert_seeded_answers", "(", "answers", ")", ":", "converted", "=", "{", "}", "for", "index", ",", "answer", "in", "enumerate", "(", "answers", ")", ":", "converted", ".", "setdefault", "(", "answer", "[", "'answer'", "]", ",", "{", "}", ")", ...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
upgradeProcessor1to2
Batch processors stopped polling at version 2, so they no longer needed the idleInterval attribute. They also gained a scheduled attribute which tracks their interaction with the scheduler. Since they stopped polling, we also set them up as a timed event here to make sure that they don't silently disa...
axiom/batch.py
def upgradeProcessor1to2(oldProcessor): """ Batch processors stopped polling at version 2, so they no longer needed the idleInterval attribute. They also gained a scheduled attribute which tracks their interaction with the scheduler. Since they stopped polling, we also set them up as a timed event...
def upgradeProcessor1to2(oldProcessor): """ Batch processors stopped polling at version 2, so they no longer needed the idleInterval attribute. They also gained a scheduled attribute which tracks their interaction with the scheduler. Since they stopped polling, we also set them up as a timed event...
[ "Batch", "processors", "stopped", "polling", "at", "version", "2", "so", "they", "no", "longer", "needed", "the", "idleInterval", "attribute", ".", "They", "also", "gained", "a", "scheduled", "attribute", "which", "tracks", "their", "interaction", "with", "the",...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L428-L460
[ "def", "upgradeProcessor1to2", "(", "oldProcessor", ")", ":", "newProcessor", "=", "oldProcessor", ".", "upgradeVersion", "(", "oldProcessor", ".", "typeName", ",", "1", ",", "2", ",", "busyInterval", "=", "oldProcessor", ".", "busyInterval", ")", "newProcessor", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
processor
Create an Axiom Item type which is suitable to use as a batch processor for the given Axiom Item type. Processors created this way depend on a L{iaxiom.IScheduler} powerup on the on which store they are installed. @type forType: L{item.MetaItem} @param forType: The Axiom Item type for which to cre...
axiom/batch.py
def processor(forType): """ Create an Axiom Item type which is suitable to use as a batch processor for the given Axiom Item type. Processors created this way depend on a L{iaxiom.IScheduler} powerup on the on which store they are installed. @type forType: L{item.MetaItem} @param forType: ...
def processor(forType): """ Create an Axiom Item type which is suitable to use as a batch processor for the given Axiom Item type. Processors created this way depend on a L{iaxiom.IScheduler} powerup on the on which store they are installed. @type forType: L{item.MetaItem} @param forType: ...
[ "Create", "an", "Axiom", "Item", "type", "which", "is", "suitable", "to", "use", "as", "a", "batch", "processor", "for", "the", "given", "Axiom", "Item", "type", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L462-L518
[ "def", "processor", "(", "forType", ")", ":", "MILLI", "=", "1000", "try", ":", "processor", "=", "_processors", "[", "forType", "]", "except", "KeyError", ":", "def", "__init__", "(", "self", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "item", "...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
storeBatchServiceSpecialCase
Adapt a L{Store} to L{IBatchService}. If C{st} is a substore, return a simple wrapper that delegates to the site store's L{IBatchService} powerup. Return C{None} if C{st} has no L{BatchProcessingControllerService}.
axiom/batch.py
def storeBatchServiceSpecialCase(st, pups): """ Adapt a L{Store} to L{IBatchService}. If C{st} is a substore, return a simple wrapper that delegates to the site store's L{IBatchService} powerup. Return C{None} if C{st} has no L{BatchProcessingControllerService}. """ if st.parent is not Non...
def storeBatchServiceSpecialCase(st, pups): """ Adapt a L{Store} to L{IBatchService}. If C{st} is a substore, return a simple wrapper that delegates to the site store's L{IBatchService} powerup. Return C{None} if C{st} has no L{BatchProcessingControllerService}. """ if st.parent is not Non...
[ "Adapt", "a", "L", "{", "Store", "}", "to", "L", "{", "IBatchService", "}", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L1017-L1034
[ "def", "storeBatchServiceSpecialCase", "(", "st", ",", "pups", ")", ":", "if", "st", ".", "parent", "is", "not", "None", ":", "try", ":", "return", "_SubStoreBatchChannel", "(", "st", ")", "except", "TypeError", ":", "return", "None", "storeService", "=", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_ProcessingFailure.mark
Mark the unit of work as failed in the database and update the listener so as to skip it next time.
axiom/batch.py
def mark(self): """ Mark the unit of work as failed in the database and update the listener so as to skip it next time. """ self.reliableListener.lastRun = extime.Time() BatchProcessingError( store=self.reliableListener.store, processor=self.reliab...
def mark(self): """ Mark the unit of work as failed in the database and update the listener so as to skip it next time. """ self.reliableListener.lastRun = extime.Time() BatchProcessingError( store=self.reliableListener.store, processor=self.reliab...
[ "Mark", "the", "unit", "of", "work", "as", "failed", "in", "the", "database", "and", "update", "the", "listener", "so", "as", "to", "skip", "it", "next", "time", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L53-L64
[ "def", "mark", "(", "self", ")", ":", "self", ".", "reliableListener", ".", "lastRun", "=", "extime", ".", "Time", "(", ")", "BatchProcessingError", "(", "store", "=", "self", ".", "reliableListener", ".", "store", ",", "processor", "=", "self", ".", "re...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_BatchProcessorMixin.run
Try to run one unit of work through one listener. If there are more listeners or more work, reschedule this item to be run again in C{self.busyInterval} milliseconds, otherwise unschedule it. @rtype: L{extime.Time} or C{None} @return: The next time at which to run this item, used by th...
axiom/batch.py
def run(self): """ Try to run one unit of work through one listener. If there are more listeners or more work, reschedule this item to be run again in C{self.busyInterval} milliseconds, otherwise unschedule it. @rtype: L{extime.Time} or C{None} @return: The next time at...
def run(self): """ Try to run one unit of work through one listener. If there are more listeners or more work, reschedule this item to be run again in C{self.busyInterval} milliseconds, otherwise unschedule it. @rtype: L{extime.Time} or C{None} @return: The next time at...
[ "Try", "to", "run", "one", "unit", "of", "work", "through", "one", "listener", ".", "If", "there", "are", "more", "listeners", "or", "more", "work", "reschedule", "this", "item", "to", "be", "run", "again", "in", "C", "{", "self", ".", "busyInterval", ...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L297-L312
[ "def", "run", "(", "self", ")", ":", "now", "=", "extime", ".", "Time", "(", ")", "if", "self", ".", "step", "(", ")", ":", "self", ".", "scheduled", "=", "now", "+", "datetime", ".", "timedelta", "(", "milliseconds", "=", "self", ".", "busyInterva...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_BatchProcessorMixin.addReliableListener
Add the given Item to the set which will be notified of Items available for processing. Note: Each Item is processed synchronously. Adding too many listeners to a single batch processor will cause the L{step} method to block while it sends notification to each listener. @param...
axiom/batch.py
def addReliableListener(self, listener, style=iaxiom.LOCAL): """ Add the given Item to the set which will be notified of Items available for processing. Note: Each Item is processed synchronously. Adding too many listeners to a single batch processor will cause the L{step} ...
def addReliableListener(self, listener, style=iaxiom.LOCAL): """ Add the given Item to the set which will be notified of Items available for processing. Note: Each Item is processed synchronously. Adding too many listeners to a single batch processor will cause the L{step} ...
[ "Add", "the", "given", "Item", "to", "the", "set", "which", "will", "be", "notified", "of", "Items", "available", "for", "processing", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L323-L363
[ "def", "addReliableListener", "(", "self", ",", "listener", ",", "style", "=", "iaxiom", ".", "LOCAL", ")", ":", "existing", "=", "self", ".", "store", ".", "findUnique", "(", "_ReliableListener", ",", "attributes", ".", "AND", "(", "_ReliableListener", ".",...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_BatchProcessorMixin.removeReliableListener
Remove a previously added listener.
axiom/batch.py
def removeReliableListener(self, listener): """ Remove a previously added listener. """ self.store.query(_ReliableListener, attributes.AND(_ReliableListener.processor == self, _ReliableListener.listener == listener)).delete...
def removeReliableListener(self, listener): """ Remove a previously added listener. """ self.store.query(_ReliableListener, attributes.AND(_ReliableListener.processor == self, _ReliableListener.listener == listener)).delete...
[ "Remove", "a", "previously", "added", "listener", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L366-L375
[ "def", "removeReliableListener", "(", "self", ",", "listener", ")", ":", "self", ".", "store", ".", "query", "(", "_ReliableListener", ",", "attributes", ".", "AND", "(", "_ReliableListener", ".", "processor", "==", "self", ",", "_ReliableListener", ".", "list...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_BatchProcessorMixin.getReliableListeners
Return an iterable of the listeners which have been added to this batch processor.
axiom/batch.py
def getReliableListeners(self): """ Return an iterable of the listeners which have been added to this batch processor. """ for rellist in self.store.query(_ReliableListener, _ReliableListener.processor == self): yield rellist.listener
def getReliableListeners(self): """ Return an iterable of the listeners which have been added to this batch processor. """ for rellist in self.store.query(_ReliableListener, _ReliableListener.processor == self): yield rellist.listener
[ "Return", "an", "iterable", "of", "the", "listeners", "which", "have", "been", "added", "to", "this", "batch", "processor", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L378-L384
[ "def", "getReliableListeners", "(", "self", ")", ":", "for", "rellist", "in", "self", ".", "store", ".", "query", "(", "_ReliableListener", ",", "_ReliableListener", ".", "processor", "==", "self", ")", ":", "yield", "rellist", ".", "listener" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_BatchProcessorMixin.getFailedItems
Return an iterable of two-tuples of listeners which raised an exception from C{processItem} and the item which was passed as the argument to that method.
axiom/batch.py
def getFailedItems(self): """ Return an iterable of two-tuples of listeners which raised an exception from C{processItem} and the item which was passed as the argument to that method. """ for failed in self.store.query(BatchProcessingError, BatchProcessingError.processor ...
def getFailedItems(self): """ Return an iterable of two-tuples of listeners which raised an exception from C{processItem} and the item which was passed as the argument to that method. """ for failed in self.store.query(BatchProcessingError, BatchProcessingError.processor ...
[ "Return", "an", "iterable", "of", "two", "-", "tuples", "of", "listeners", "which", "raised", "an", "exception", "from", "C", "{", "processItem", "}", "and", "the", "item", "which", "was", "passed", "as", "the", "argument", "to", "that", "method", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L387-L394
[ "def", "getFailedItems", "(", "self", ")", ":", "for", "failed", "in", "self", ".", "store", ".", "query", "(", "BatchProcessingError", ",", "BatchProcessingError", ".", "processor", "==", "self", ")", ":", "yield", "(", "failed", ".", "listener", ",", "fa...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_BatchProcessorMixin.itemAdded
Called to indicate that a new item of the type monitored by this batch processor is being added to the database. If this processor is not already scheduled to run, this will schedule it. It will also start the batch process if it is not yet running and there are any registered remote l...
axiom/batch.py
def itemAdded(self): """ Called to indicate that a new item of the type monitored by this batch processor is being added to the database. If this processor is not already scheduled to run, this will schedule it. It will also start the batch process if it is not yet running and ...
def itemAdded(self): """ Called to indicate that a new item of the type monitored by this batch processor is being added to the database. If this processor is not already scheduled to run, this will schedule it. It will also start the batch process if it is not yet running and ...
[ "Called", "to", "indicate", "that", "a", "new", "item", "of", "the", "type", "monitored", "by", "this", "batch", "processor", "is", "being", "added", "to", "the", "database", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L397-L424
[ "def", "itemAdded", "(", "self", ")", ":", "localCount", "=", "self", ".", "store", ".", "query", "(", "_ReliableListener", ",", "attributes", ".", "AND", "(", "_ReliableListener", ".", "processor", "==", "self", ",", "_ReliableListener", ".", "style", "==",...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
BatchProcessingControllerService.call
Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked.
axiom/batch.py
def call(self, itemMethod): """ Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked. """ item = itemMethod.im_self method = itemMethod.im_func.func_name return self.batchController.getProcess().a...
def call(self, itemMethod): """ Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked. """ item = itemMethod.im_self method = itemMethod.im_func.func_name return self.batchController.getProcess().a...
[ "Invoke", "the", "given", "bound", "item", "method", "in", "the", "batch", "process", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L956-L967
[ "def", "call", "(", "self", ",", "itemMethod", ")", ":", "item", "=", "itemMethod", ".", "im_self", "method", "=", "itemMethod", ".", "im_func", ".", "func_name", "return", "self", ".", "batchController", ".", "getProcess", "(", ")", ".", "addCallback", "(...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
BatchProcessingService.processWhileRunning
Run tasks until stopService is called.
axiom/batch.py
def processWhileRunning(self): """ Run tasks until stopService is called. """ work = self.step() for result, more in work: yield result if not self.running: break if more: delay = 0.1 else: ...
def processWhileRunning(self): """ Run tasks until stopService is called. """ work = self.step() for result, more in work: yield result if not self.running: break if more: delay = 0.1 else: ...
[ "Run", "tasks", "until", "stopService", "is", "called", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L1158-L1171
[ "def", "processWhileRunning", "(", "self", ")", ":", "work", "=", "self", ".", "step", "(", ")", "for", "result", ",", "more", "in", "work", ":", "yield", "result", "if", "not", "self", ".", "running", ":", "break", "if", "more", ":", "delay", "=", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
getcols
find every column in every sheet and put it in a new sheet or book.
PyOriginTools/scratch.py
def getcols(sheetMatch=None,colMatch="Decay"): """find every column in every sheet and put it in a new sheet or book.""" book=BOOK() if sheetMatch is None: matchingSheets=book.sheetNames print('all %d sheets selected '%(len(matchingSheets))) else: matchingSheets=[x for x in book....
def getcols(sheetMatch=None,colMatch="Decay"): """find every column in every sheet and put it in a new sheet or book.""" book=BOOK() if sheetMatch is None: matchingSheets=book.sheetNames print('all %d sheets selected '%(len(matchingSheets))) else: matchingSheets=[x for x in book....
[ "find", "every", "column", "in", "every", "sheet", "and", "put", "it", "in", "a", "new", "sheet", "or", "book", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/scratch.py#L55-L75
[ "def", "getcols", "(", "sheetMatch", "=", "None", ",", "colMatch", "=", "\"Decay\"", ")", ":", "book", "=", "BOOK", "(", ")", "if", "sheetMatch", "is", "None", ":", "matchingSheets", "=", "book", ".", "sheetNames", "print", "(", "'all %d sheets selected '", ...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
Upgrade.upgradeStore
Recursively upgrade C{store}.
axiom/plugins/axiom_plugins.py
def upgradeStore(self, store): """ Recursively upgrade C{store}. """ self.upgradeEverything(store) upgradeExplicitOid(store) for substore in store.query(SubStore): print 'Upgrading: {!r}'.format(substore) self.upgradeStore(substore.open())
def upgradeStore(self, store): """ Recursively upgrade C{store}. """ self.upgradeEverything(store) upgradeExplicitOid(store) for substore in store.query(SubStore): print 'Upgrading: {!r}'.format(substore) self.upgradeStore(substore.open())
[ "Recursively", "upgrade", "C", "{", "store", "}", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L56-L65
[ "def", "upgradeStore", "(", "self", ",", "store", ")", ":", "self", ".", "upgradeEverything", "(", "store", ")", "upgradeExplicitOid", "(", "store", ")", "for", "substore", "in", "store", ".", "query", "(", "SubStore", ")", ":", "print", "'Upgrading: {!r}'",...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Upgrade.perform
Upgrade C{store} performing C{count} upgrades per transaction. Also, catch any exceptions and print out something useful.
axiom/plugins/axiom_plugins.py
def perform(self, store, count): """ Upgrade C{store} performing C{count} upgrades per transaction. Also, catch any exceptions and print out something useful. """ self.count = count try: self.upgradeStore(store) print 'Upgrade complete' e...
def perform(self, store, count): """ Upgrade C{store} performing C{count} upgrades per transaction. Also, catch any exceptions and print out something useful. """ self.count = count try: self.upgradeStore(store) print 'Upgrade complete' e...
[ "Upgrade", "C", "{", "store", "}", "performing", "C", "{", "count", "}", "upgrades", "per", "transaction", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L67-L83
[ "def", "perform", "(", "self", ",", "store", ",", "count", ")", ":", "self", ".", "count", "=", "count", "try", ":", "self", ".", "upgradeStore", "(", "store", ")", "print", "'Upgrade complete'", "except", "errors", ".", "ItemUpgradeError", "as", "e", ":...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
AxiomConsole.runcode
Override L{code.InteractiveConsole.runcode} to run the code in a transaction unless the local C{autocommit} is currently set to a true value.
axiom/plugins/axiom_plugins.py
def runcode(self, code): """ Override L{code.InteractiveConsole.runcode} to run the code in a transaction unless the local C{autocommit} is currently set to a true value. """ if not self.locals.get('autocommit', None): return self.locals['db'].transact(code.In...
def runcode(self, code): """ Override L{code.InteractiveConsole.runcode} to run the code in a transaction unless the local C{autocommit} is currently set to a true value. """ if not self.locals.get('autocommit', None): return self.locals['db'].transact(code.In...
[ "Override", "L", "{", "code", ".", "InteractiveConsole", ".", "runcode", "}", "to", "run", "the", "code", "in", "a", "transaction", "unless", "the", "local", "C", "{", "autocommit", "}", "is", "currently", "set", "to", "a", "true", "value", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L98-L106
[ "def", "runcode", "(", "self", ",", "code", ")", ":", "if", "not", "self", ".", "locals", ".", "get", "(", "'autocommit'", ",", "None", ")", ":", "return", "self", ".", "locals", "[", "'db'", "]", ".", "transact", "(", "code", ".", "InteractiveConsol...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Browse.namespace
Return a dictionary representing the namespace which should be available to the user.
axiom/plugins/axiom_plugins.py
def namespace(self): """ Return a dictionary representing the namespace which should be available to the user. """ self._ns = { 'db': self.store, 'store': store, 'autocommit': False, } return self._ns
def namespace(self): """ Return a dictionary representing the namespace which should be available to the user. """ self._ns = { 'db': self.store, 'store': store, 'autocommit': False, } return self._ns
[ "Return", "a", "dictionary", "representing", "the", "namespace", "which", "should", "be", "available", "to", "the", "user", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L137-L147
[ "def", "namespace", "(", "self", ")", ":", "self", ".", "_ns", "=", "{", "'db'", ":", "self", ".", "store", ",", "'store'", ":", "store", ",", "'autocommit'", ":", "False", ",", "}", "return", "self", ".", "_ns" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Create.addAccount
Create a new account in the given store. @param siteStore: A site Store to which login credentials will be added. @param username: Local part of the username for the credentials to add. @param domain: Domain part of the username for the credentials to add. @param password: Passw...
axiom/plugins/axiom_plugins.py
def addAccount(self, siteStore, username, domain, password): """ Create a new account in the given store. @param siteStore: A site Store to which login credentials will be added. @param username: Local part of the username for the credentials to add. @param domain: Domai...
def addAccount(self, siteStore, username, domain, password): """ Create a new account in the given store. @param siteStore: A site Store to which login credentials will be added. @param username: Local part of the username for the credentials to add. @param domain: Domai...
[ "Create", "a", "new", "account", "in", "the", "given", "store", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/plugins/axiom_plugins.py#L191-L211
[ "def", "addAccount", "(", "self", ",", "siteStore", ",", "username", ",", "domain", ",", "password", ")", ":", "for", "ls", "in", "siteStore", ".", "query", "(", "userbase", ".", "LoginSystem", ")", ":", "break", "else", ":", "ls", "=", "self", ".", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
itemTypeWithSomeAttributes
Create a new L{Item} subclass with L{numAttributes} integers in its schema.
benchmark/benchlib.py
def itemTypeWithSomeAttributes(attributeTypes): """ Create a new L{Item} subclass with L{numAttributes} integers in its schema. """ class SomeItem(Item): typeName = 'someitem_' + str(typeNameCounter()) for i, attributeType in enumerate(attributeTypes): locals()['attr_' + ...
def itemTypeWithSomeAttributes(attributeTypes): """ Create a new L{Item} subclass with L{numAttributes} integers in its schema. """ class SomeItem(Item): typeName = 'someitem_' + str(typeNameCounter()) for i, attributeType in enumerate(attributeTypes): locals()['attr_' + ...
[ "Create", "a", "new", "L", "{", "Item", "}", "subclass", "with", "L", "{", "numAttributes", "}", "integers", "in", "its", "schema", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/benchmark/benchlib.py#L13-L22
[ "def", "itemTypeWithSomeAttributes", "(", "attributeTypes", ")", ":", "class", "SomeItem", "(", "Item", ")", ":", "typeName", "=", "'someitem_'", "+", "str", "(", "typeNameCounter", "(", ")", ")", "for", "i", ",", "attributeType", "in", "enumerate", "(", "at...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
createSomeItems
Create some instances of a particular type in a store.
benchmark/benchlib.py
def createSomeItems(store, itemType, values, counter): """ Create some instances of a particular type in a store. """ for i in counter: itemType(store=store, **values)
def createSomeItems(store, itemType, values, counter): """ Create some instances of a particular type in a store. """ for i in counter: itemType(store=store, **values)
[ "Create", "some", "instances", "of", "a", "particular", "type", "in", "a", "store", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/benchmark/benchlib.py#L25-L30
[ "def", "createSomeItems", "(", "store", ",", "itemType", ",", "values", ",", "counter", ")", ":", "for", "i", "in", "counter", ":", "itemType", "(", "store", "=", "store", ",", "*", "*", "values", ")" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
MongoForm.save
save the instance or create a new one..
mongoforms/forms.py
def save(self, commit=True): """save the instance or create a new one..""" # walk through the document fields for field_name, field in iter_valid_fields(self._meta): setattr(self.instance, field_name, self.cleaned_data.get(field_name)) if commit: self.instance.s...
def save(self, commit=True): """save the instance or create a new one..""" # walk through the document fields for field_name, field in iter_valid_fields(self._meta): setattr(self.instance, field_name, self.cleaned_data.get(field_name)) if commit: self.instance.s...
[ "save", "the", "instance", "or", "create", "a", "new", "one", ".." ]
stephrdev/django-mongoforms
python
https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/forms.py#L95-L105
[ "def", "save", "(", "self", ",", "commit", "=", "True", ")", ":", "# walk through the document fields", "for", "field_name", ",", "field", "in", "iter_valid_fields", "(", "self", ".", "_meta", ")", ":", "setattr", "(", "self", ".", "instance", ",", "field_na...
6fa46824c438555c703f293d682ca92710938985
train
transacted
Return a callable which will invoke C{func} in a transaction using the C{store} attribute of the first parameter passed to it. Typically this is used to create Item methods which are automatically run in a transaction. The attributes of the returned callable will resemble those of C{func} as closely a...
axiom/item.py
def transacted(func): """ Return a callable which will invoke C{func} in a transaction using the C{store} attribute of the first parameter passed to it. Typically this is used to create Item methods which are automatically run in a transaction. The attributes of the returned callable will resemble...
def transacted(func): """ Return a callable which will invoke C{func} in a transaction using the C{store} attribute of the first parameter passed to it. Typically this is used to create Item methods which are automatically run in a transaction. The attributes of the returned callable will resemble...
[ "Return", "a", "callable", "which", "will", "invoke", "C", "{", "func", "}", "in", "a", "transaction", "using", "the", "C", "{", "store", "}", "attribute", "of", "the", "first", "parameter", "passed", "to", "it", ".", "Typically", "this", "is", "used", ...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L403-L414
[ "def", "transacted", "(", "func", ")", ":", "def", "transactionified", "(", "item", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "return", "item", ".", "store", ".", "transact", "(", "func", ",", "item", ",", "*", "a", ",", "*", "*", "kw", ")"...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
dependentItems
Collect all the items that should be deleted when an item or items of a particular item type are deleted. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxiom.IComparison} describing the items to collect. @return: An ...
axiom/item.py
def dependentItems(store, tableClass, comparisonFactory): """ Collect all the items that should be deleted when an item or items of a particular item type are deleted. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxi...
def dependentItems(store, tableClass, comparisonFactory): """ Collect all the items that should be deleted when an item or items of a particular item type are deleted. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxi...
[ "Collect", "all", "the", "items", "that", "should", "be", "deleted", "when", "an", "item", "or", "items", "of", "a", "particular", "item", "type", "are", "deleted", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L419-L436
[ "def", "dependentItems", "(", "store", ",", "tableClass", ",", "comparisonFactory", ")", ":", "for", "cascadingAttr", "in", "(", "_cascadingDeletes", ".", "get", "(", "tableClass", ",", "[", "]", ")", "+", "_cascadingDeletes", ".", "get", "(", "None", ",", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
allowDeletion
Returns a C{bool} indicating whether deletion of an item or items of a particular item type should be allowed to proceed. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and returning an L{iaxiom.IComparison} describing the items to collect. ...
axiom/item.py
def allowDeletion(store, tableClass, comparisonFactory): """ Returns a C{bool} indicating whether deletion of an item or items of a particular item type should be allowed to proceed. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and retu...
def allowDeletion(store, tableClass, comparisonFactory): """ Returns a C{bool} indicating whether deletion of an item or items of a particular item type should be allowed to proceed. @param tableClass: An L{Item} subclass. @param comparison: A one-argument callable taking an attribute and retu...
[ "Returns", "a", "C", "{", "bool", "}", "indicating", "whether", "deletion", "of", "an", "item", "or", "items", "of", "a", "particular", "item", "type", "should", "be", "allowed", "to", "proceed", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L440-L460
[ "def", "allowDeletion", "(", "store", ",", "tableClass", ",", "comparisonFactory", ")", ":", "for", "cascadingAttr", "in", "(", "_disallows", ".", "get", "(", "tableClass", ",", "[", "]", ")", "+", "_disallows", ".", "get", "(", "None", ",", "[", "]", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
declareLegacyItem
Generate a dummy subclass of Item that will have the given attributes, and the base Item methods, but no methods of its own. This is for use with upgrading. @param typeName: a string, the Axiom TypeName to have attributes for. @param schemaVersion: an int, the (old) version of the schema this is a pro...
axiom/item.py
def declareLegacyItem(typeName, schemaVersion, attributes, dummyBases=()): """ Generate a dummy subclass of Item that will have the given attributes, and the base Item methods, but no methods of its own. This is for use with upgrading. @param typeName: a string, the Axiom TypeName to have attribut...
def declareLegacyItem(typeName, schemaVersion, attributes, dummyBases=()): """ Generate a dummy subclass of Item that will have the given attributes, and the base Item methods, but no methods of its own. This is for use with upgrading. @param typeName: a string, the Axiom TypeName to have attribut...
[ "Generate", "a", "dummy", "subclass", "of", "Item", "that", "will", "have", "the", "given", "attributes", "and", "the", "base", "Item", "methods", "but", "no", "methods", "of", "its", "own", ".", "This", "is", "for", "use", "with", "upgrading", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L1094-L1126
[ "def", "declareLegacyItem", "(", "typeName", ",", "schemaVersion", ",", "attributes", ",", "dummyBases", "=", "(", ")", ")", ":", "if", "(", "typeName", ",", "schemaVersion", ")", "in", "_legacyTypes", ":", "return", "_legacyTypes", "[", "typeName", ",", "sc...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
empowerment
Class decorator for indicating a powerup's powerup interfaces. The class will also be declared as implementing the interface. @type iface: L{zope.interface.Interface} @param iface: The powerup interface. @type priority: int @param priority: The priority the powerup will be installed at.
axiom/item.py
def empowerment(iface, priority=0): """ Class decorator for indicating a powerup's powerup interfaces. The class will also be declared as implementing the interface. @type iface: L{zope.interface.Interface} @param iface: The powerup interface. @type priority: int @param priority: The prio...
def empowerment(iface, priority=0): """ Class decorator for indicating a powerup's powerup interfaces. The class will also be declared as implementing the interface. @type iface: L{zope.interface.Interface} @param iface: The powerup interface. @type priority: int @param priority: The prio...
[ "Class", "decorator", "for", "indicating", "a", "powerup", "s", "powerup", "interfaces", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L1147-L1165
[ "def", "empowerment", "(", "iface", ",", "priority", "=", "0", ")", ":", "def", "_deco", "(", "cls", ")", ":", "cls", ".", "powerupInterfaces", "=", "(", "tuple", "(", "getattr", "(", "cls", ",", "'powerupInterfaces'", ",", "(", ")", ")", ")", "+", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Empowered.powerUp
Installs a powerup (e.g. plugin) on an item or store. Powerups will be returned in an iterator when queried for using the 'powerupsFor' method. Normally they will be returned in order of installation [this may change in future versions, so please don't depend on it]. Higher priorities...
axiom/item.py
def powerUp(self, powerup, interface=None, priority=0): """ Installs a powerup (e.g. plugin) on an item or store. Powerups will be returned in an iterator when queried for using the 'powerupsFor' method. Normally they will be returned in order of installation [this may change i...
def powerUp(self, powerup, interface=None, priority=0): """ Installs a powerup (e.g. plugin) on an item or store. Powerups will be returned in an iterator when queried for using the 'powerupsFor' method. Normally they will be returned in order of installation [this may change i...
[ "Installs", "a", "powerup", "(", "e", ".", "g", ".", "plugin", ")", "on", "an", "item", "or", "store", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L213-L270
[ "def", "powerUp", "(", "self", ",", "powerup", ",", "interface", "=", "None", ",", "priority", "=", "0", ")", ":", "if", "interface", "is", "None", ":", "for", "iface", ",", "priority", "in", "powerup", ".", "_getPowerupInterfaces", "(", ")", ":", "sel...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Empowered.powerDown
Remove a powerup. If no interface is specified, and the type of the object being installed has a "powerupInterfaces" attribute (containing either a sequence of interfaces, or a sequence of (interface, priority) tuples), the target will be powered down with this object on those i...
axiom/item.py
def powerDown(self, powerup, interface=None): """ Remove a powerup. If no interface is specified, and the type of the object being installed has a "powerupInterfaces" attribute (containing either a sequence of interfaces, or a sequence of (interface, priority) tuples), t...
def powerDown(self, powerup, interface=None): """ Remove a powerup. If no interface is specified, and the type of the object being installed has a "powerupInterfaces" attribute (containing either a sequence of interfaces, or a sequence of (interface, priority) tuples), t...
[ "Remove", "a", "powerup", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L273-L303
[ "def", "powerDown", "(", "self", ",", "powerup", ",", "interface", "=", "None", ")", ":", "if", "interface", "is", "None", ":", "for", "interface", ",", "priority", "in", "powerup", ".", "_getPowerupInterfaces", "(", ")", ":", "self", ".", "powerDown", "...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Empowered.powerupsFor
Returns powerups installed using C{powerUp}, in order of descending priority. Powerups found to have been deleted, either during the course of this powerupsFor iteration, during an upgrader, or previously, will not be returned.
axiom/item.py
def powerupsFor(self, interface): """ Returns powerups installed using C{powerUp}, in order of descending priority. Powerups found to have been deleted, either during the course of this powerupsFor iteration, during an upgrader, or previously, will not be returned. ...
def powerupsFor(self, interface): """ Returns powerups installed using C{powerUp}, in order of descending priority. Powerups found to have been deleted, either during the course of this powerupsFor iteration, during an upgrader, or previously, will not be returned. ...
[ "Returns", "powerups", "installed", "using", "C", "{", "powerUp", "}", "in", "order", "of", "descending", "priority", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L330-L359
[ "def", "powerupsFor", "(", "self", ",", "interface", ")", ":", "inMemoryPowerup", "=", "self", ".", "_inMemoryPowerups", ".", "get", "(", "interface", ",", "None", ")", "if", "inMemoryPowerup", "is", "not", "None", ":", "yield", "inMemoryPowerup", "if", "sel...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Empowered.interfacesFor
Return an iterator of the interfaces for which the given powerup is installed on this object. This is not implemented for in-memory powerups. It will probably fail in an unpredictable, implementation-dependent way if used on one.
axiom/item.py
def interfacesFor(self, powerup): """ Return an iterator of the interfaces for which the given powerup is installed on this object. This is not implemented for in-memory powerups. It will probably fail in an unpredictable, implementation-dependent way if used on one. ""...
def interfacesFor(self, powerup): """ Return an iterator of the interfaces for which the given powerup is installed on this object. This is not implemented for in-memory powerups. It will probably fail in an unpredictable, implementation-dependent way if used on one. ""...
[ "Return", "an", "iterator", "of", "the", "interfaces", "for", "which", "the", "given", "powerup", "is", "installed", "on", "this", "object", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L361-L373
[ "def", "interfacesFor", "(", "self", ",", "powerup", ")", ":", "pc", "=", "_PowerupConnector", "for", "iface", "in", "self", ".", "store", ".", "query", "(", "pc", ",", "AND", "(", "pc", ".", "item", "==", "self", ",", "pc", ".", "powerup", "==", "...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Empowered._getPowerupInterfaces
Collect powerup interfaces this object declares that it can be installed on.
axiom/item.py
def _getPowerupInterfaces(self): """ Collect powerup interfaces this object declares that it can be installed on. """ powerupInterfaces = getattr(self.__class__, "powerupInterfaces", ()) pifs = [] for x in powerupInterfaces: if isinstance(x, type(Inter...
def _getPowerupInterfaces(self): """ Collect powerup interfaces this object declares that it can be installed on. """ powerupInterfaces = getattr(self.__class__, "powerupInterfaces", ()) pifs = [] for x in powerupInterfaces: if isinstance(x, type(Inter...
[ "Collect", "powerup", "interfaces", "this", "object", "declares", "that", "it", "can", "be", "installed", "on", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L376-L399
[ "def", "_getPowerupInterfaces", "(", "self", ")", ":", "powerupInterfaces", "=", "getattr", "(", "self", ".", "__class__", ",", "\"powerupInterfaces\"", ",", "(", ")", ")", "pifs", "=", "[", "]", "for", "x", "in", "powerupInterfaces", ":", "if", "isinstance"...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Item._currentlyValidAsReferentFor
Is this object currently valid as a reference? Objects which will be deleted in this transaction, or objects which are not in the same store are not valid. See attributes.reference.__get__.
axiom/item.py
def _currentlyValidAsReferentFor(self, store): """ Is this object currently valid as a reference? Objects which will be deleted in this transaction, or objects which are not in the same store are not valid. See attributes.reference.__get__. """ if store is None: ...
def _currentlyValidAsReferentFor(self, store): """ Is this object currently valid as a reference? Objects which will be deleted in this transaction, or objects which are not in the same store are not valid. See attributes.reference.__get__. """ if store is None: ...
[ "Is", "this", "object", "currently", "valid", "as", "a", "reference?", "Objects", "which", "will", "be", "deleted", "in", "this", "transaction", "or", "objects", "which", "are", "not", "in", "the", "same", "store", "are", "not", "valid", ".", "See", "attri...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L500-L514
[ "def", "_currentlyValidAsReferentFor", "(", "self", ",", "store", ")", ":", "if", "store", "is", "None", ":", "# If your store is None, you can refer to whoever you want. I'm in", "# a store but it doesn't matter that you're not.", "return", "True", "if", "self", ".", "store...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Item._schemaPrepareInsert
Prepare each attribute in my schema for insertion into a given store, either by upgrade or by creation. This makes sure all references point to this store and all relative paths point to this store's files directory.
axiom/item.py
def _schemaPrepareInsert(self, store): """ Prepare each attribute in my schema for insertion into a given store, either by upgrade or by creation. This makes sure all references point to this store and all relative paths point to this store's files directory. """ ...
def _schemaPrepareInsert(self, store): """ Prepare each attribute in my schema for insertion into a given store, either by upgrade or by creation. This makes sure all references point to this store and all relative paths point to this store's files directory. """ ...
[ "Prepare", "each", "attribute", "in", "my", "schema", "for", "insertion", "into", "a", "given", "store", "either", "by", "upgrade", "or", "by", "creation", ".", "This", "makes", "sure", "all", "references", "point", "to", "this", "store", "and", "all", "re...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L517-L525
[ "def", "_schemaPrepareInsert", "(", "self", ",", "store", ")", ":", "for", "name", ",", "atr", "in", "self", ".", "getSchema", "(", ")", ":", "atr", ".", "prepareInsert", "(", "self", ",", "store", ")" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Item.existingInStore
Create and return a new instance from a row from the store.
axiom/item.py
def existingInStore(cls, store, storeID, attrs): """Create and return a new instance from a row from the store.""" self = cls.__new__(cls) self.__justCreated = False self.__subinit__(__store=store, storeID=storeID, __everInserted=True) ...
def existingInStore(cls, store, storeID, attrs): """Create and return a new instance from a row from the store.""" self = cls.__new__(cls) self.__justCreated = False self.__subinit__(__store=store, storeID=storeID, __everInserted=True) ...
[ "Create", "and", "return", "a", "new", "instance", "from", "a", "row", "from", "the", "store", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L647-L661
[ "def", "existingInStore", "(", "cls", ",", "store", ",", "storeID", ",", "attrs", ")", ":", "self", "=", "cls", ".", "__new__", "(", "cls", ")", "self", ".", "__justCreated", "=", "False", "self", ".", "__subinit__", "(", "__store", "=", "store", ",", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Item.getSchema
return all persistent class attributes
axiom/item.py
def getSchema(cls): """ return all persistent class attributes """ schema = [] for name, atr in cls.__attributes__: atr = atr.__get__(None, cls) if isinstance(atr, SQLAttribute): schema.append((name, atr)) cls.getSchema = staticmeth...
def getSchema(cls): """ return all persistent class attributes """ schema = [] for name, atr in cls.__attributes__: atr = atr.__get__(None, cls) if isinstance(atr, SQLAttribute): schema.append((name, atr)) cls.getSchema = staticmeth...
[ "return", "all", "persistent", "class", "attributes" ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L668-L678
[ "def", "getSchema", "(", "cls", ")", ":", "schema", "=", "[", "]", "for", "name", ",", "atr", "in", "cls", ".", "__attributes__", ":", "atr", "=", "atr", ".", "__get__", "(", "None", ",", "cls", ")", "if", "isinstance", "(", "atr", ",", "SQLAttribu...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Item.persistentValues
Return a dictionary of all attributes which will be/have been/are being stored in the database.
axiom/item.py
def persistentValues(self): """ Return a dictionary of all attributes which will be/have been/are being stored in the database. """ return dict((k, getattr(self, k)) for (k, attr) in self.getSchema())
def persistentValues(self): """ Return a dictionary of all attributes which will be/have been/are being stored in the database. """ return dict((k, getattr(self, k)) for (k, attr) in self.getSchema())
[ "Return", "a", "dictionary", "of", "all", "attributes", "which", "will", "be", "/", "have", "been", "/", "are", "being", "stored", "in", "the", "database", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L682-L687
[ "def", "persistentValues", "(", "self", ")", ":", "return", "dict", "(", "(", "k", ",", "getattr", "(", "self", ",", "k", ")", ")", "for", "(", "k", ",", "attr", ")", "in", "self", ".", "getSchema", "(", ")", ")" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Item.committed
Called after the database is brought into a consistent state with this object.
axiom/item.py
def committed(self): """ Called after the database is brought into a consistent state with this object. """ if self.__deleting: self.deleted() if not self.__legacy__: self.store.objectCache.uncache(self.storeID, self) self._...
def committed(self): """ Called after the database is brought into a consistent state with this object. """ if self.__deleting: self.deleted() if not self.__legacy__: self.store.objectCache.uncache(self.storeID, self) self._...
[ "Called", "after", "the", "database", "is", "brought", "into", "a", "consistent", "state", "with", "this", "object", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L731-L741
[ "def", "committed", "(", "self", ")", ":", "if", "self", ".", "__deleting", ":", "self", ".", "deleted", "(", ")", "if", "not", "self", ".", "__legacy__", ":", "self", ".", "store", ".", "objectCache", ".", "uncache", "(", "self", ".", "storeID", ","...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Item.checkpoint
Update the database to reflect in-memory changes made to this item; for example, to make it show up in store.query() calls where it is now valid, but was not the last time it was persisted to the database. This is called automatically when in 'autocommit mode' (i.e. not in a transaction...
axiom/item.py
def checkpoint(self): """ Update the database to reflect in-memory changes made to this item; for example, to make it show up in store.query() calls where it is now valid, but was not the last time it was persisted to the database. This is called automatically when in 'autocommi...
def checkpoint(self): """ Update the database to reflect in-memory changes made to this item; for example, to make it show up in store.query() calls where it is now valid, but was not the last time it was persisted to the database. This is called automatically when in 'autocommi...
[ "Update", "the", "database", "to", "reflect", "in", "-", "memory", "changes", "made", "to", "this", "item", ";", "for", "example", "to", "make", "it", "show", "up", "in", "store", ".", "query", "()", "calls", "where", "it", "is", "now", "valid", "but",...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L744-L817
[ "def", "checkpoint", "(", "self", ")", ":", "if", "self", ".", "store", "is", "None", ":", "raise", "NotInStore", "(", "\"You can't checkpoint %r: not in a store\"", "%", "(", "self", ",", ")", ")", "if", "self", ".", "__deleting", ":", "if", "not", "self"...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
registerUpgrader
Register a callable which can perform a schema upgrade between two particular versions. @param upgrader: A one-argument callable which will upgrade an object. It is invoked with an instance of the old version of the object. @param typeName: The database typename for which this is an upgrader. @par...
axiom/upgrade.py
def registerUpgrader(upgrader, typeName, oldVersion, newVersion): """ Register a callable which can perform a schema upgrade between two particular versions. @param upgrader: A one-argument callable which will upgrade an object. It is invoked with an instance of the old version of the object. ...
def registerUpgrader(upgrader, typeName, oldVersion, newVersion): """ Register a callable which can perform a schema upgrade between two particular versions. @param upgrader: A one-argument callable which will upgrade an object. It is invoked with an instance of the old version of the object. ...
[ "Register", "a", "callable", "which", "can", "perform", "a", "schema", "upgrade", "between", "two", "particular", "versions", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L187-L204
[ "def", "registerUpgrader", "(", "upgrader", ",", "typeName", ",", "oldVersion", ",", "newVersion", ")", ":", "# assert (typeName, oldVersion, newVersion) not in _upgradeRegistry, \"duplicate upgrader\"", "# ^ this makes the tests blow up so it's just disabled for now; perhaps we", "# sho...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
registerAttributeCopyingUpgrader
Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion}, which will copy all attributes from the legacy item to the new item. If postCopy is provided, it will be called with the new item after upgrading. @param itemType: L{axiom.item.Item} subclass @param postCopy: a callable of one ...
axiom/upgrade.py
def registerAttributeCopyingUpgrader(itemType, fromVersion, toVersion, postCopy=None): """ Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion}, which will copy all attributes from the legacy item to the new item. If postCopy is provided, it will be called with the new item after u...
def registerAttributeCopyingUpgrader(itemType, fromVersion, toVersion, postCopy=None): """ Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion}, which will copy all attributes from the legacy item to the new item. If postCopy is provided, it will be called with the new item after u...
[ "Register", "an", "upgrader", "for", "C", "{", "itemType", "}", "from", "C", "{", "fromVersion", "}", "to", "C", "{", "toVersion", "}", "which", "will", "copy", "all", "attributes", "from", "the", "legacy", "item", "to", "the", "new", "item", ".", "If"...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L206-L223
[ "def", "registerAttributeCopyingUpgrader", "(", "itemType", ",", "fromVersion", ",", "toVersion", ",", "postCopy", "=", "None", ")", ":", "def", "upgrader", "(", "old", ")", ":", "newitem", "=", "old", ".", "upgradeVersion", "(", "itemType", ".", "typeName", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
registerDeletionUpgrader
Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion}, which will delete the item from the database. @param itemType: L{axiom.item.Item} subclass @return: None
axiom/upgrade.py
def registerDeletionUpgrader(itemType, fromVersion, toVersion): """ Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion}, which will delete the item from the database. @param itemType: L{axiom.item.Item} subclass @return: None """ # XXX This should actually do something...
def registerDeletionUpgrader(itemType, fromVersion, toVersion): """ Register an upgrader for C{itemType}, from C{fromVersion} to C{toVersion}, which will delete the item from the database. @param itemType: L{axiom.item.Item} subclass @return: None """ # XXX This should actually do something...
[ "Register", "an", "upgrader", "for", "C", "{", "itemType", "}", "from", "C", "{", "fromVersion", "}", "to", "C", "{", "toVersion", "}", "which", "will", "delete", "the", "item", "from", "the", "database", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L226-L239
[ "def", "registerDeletionUpgrader", "(", "itemType", ",", "fromVersion", ",", "toVersion", ")", ":", "# XXX This should actually do something more special so that a new table is", "# not created and such.", "def", "upgrader", "(", "old", ")", ":", "old", ".", "deleteFromStore"...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_hasExplicitOid
Does the given table have an explicit oid column?
axiom/upgrade.py
def _hasExplicitOid(store, table): """ Does the given table have an explicit oid column? """ return any(info[1] == 'oid' for info in store.querySchemaSQL( 'PRAGMA *DATABASE*.table_info({})'.format(table)))
def _hasExplicitOid(store, table): """ Does the given table have an explicit oid column? """ return any(info[1] == 'oid' for info in store.querySchemaSQL( 'PRAGMA *DATABASE*.table_info({})'.format(table)))
[ "Does", "the", "given", "table", "have", "an", "explicit", "oid", "column?" ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L258-L264
[ "def", "_hasExplicitOid", "(", "store", ",", "table", ")", ":", "return", "any", "(", "info", "[", "1", "]", "==", "'oid'", "for", "info", "in", "store", ".", "querySchemaSQL", "(", "'PRAGMA *DATABASE*.table_info({})'", ".", "format", "(", "table", ")", ")...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_upgradeTableOid
Upgrade a table to have an explicit oid. Must be called in a transaction to avoid corrupting the database.
axiom/upgrade.py
def _upgradeTableOid(store, table, createTable, postCreate=lambda: None): """ Upgrade a table to have an explicit oid. Must be called in a transaction to avoid corrupting the database. """ if _hasExplicitOid(store, table): return store.executeSchemaSQL( 'ALTER TABLE *DATABASE*.{...
def _upgradeTableOid(store, table, createTable, postCreate=lambda: None): """ Upgrade a table to have an explicit oid. Must be called in a transaction to avoid corrupting the database. """ if _hasExplicitOid(store, table): return store.executeSchemaSQL( 'ALTER TABLE *DATABASE*.{...
[ "Upgrade", "a", "table", "to", "have", "an", "explicit", "oid", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L268-L283
[ "def", "_upgradeTableOid", "(", "store", ",", "table", ",", "createTable", ",", "postCreate", "=", "lambda", ":", "None", ")", ":", "if", "_hasExplicitOid", "(", "store", ",", "table", ")", ":", "return", "store", ".", "executeSchemaSQL", "(", "'ALTER TABLE ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
upgradeSystemOid
Upgrade the system tables to use explicit oid columns.
axiom/upgrade.py
def upgradeSystemOid(store): """ Upgrade the system tables to use explicit oid columns. """ store.transact( _upgradeTableOid, store, 'axiom_types', lambda: store.executeSchemaSQL(CREATE_TYPES)) store.transact( _upgradeTableOid, store, 'axiom_objects', lambda: store.ex...
def upgradeSystemOid(store): """ Upgrade the system tables to use explicit oid columns. """ store.transact( _upgradeTableOid, store, 'axiom_types', lambda: store.executeSchemaSQL(CREATE_TYPES)) store.transact( _upgradeTableOid, store, 'axiom_objects', lambda: store.ex...
[ "Upgrade", "the", "system", "tables", "to", "use", "explicit", "oid", "columns", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L287-L297
[ "def", "upgradeSystemOid", "(", "store", ")", ":", "store", ".", "transact", "(", "_upgradeTableOid", ",", "store", ",", "'axiom_types'", ",", "lambda", ":", "store", ".", "executeSchemaSQL", "(", "CREATE_TYPES", ")", ")", "store", ".", "transact", "(", "_up...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
upgradeExplicitOid
Upgrade a store to use explicit oid columns. This allows VACUUMing the database without corrupting it. This requires copying all of axiom_objects and axiom_types, as well as all item tables that have not yet been upgraded. Consider VACUUMing the database afterwards to reclaim space.
axiom/upgrade.py
def upgradeExplicitOid(store): """ Upgrade a store to use explicit oid columns. This allows VACUUMing the database without corrupting it. This requires copying all of axiom_objects and axiom_types, as well as all item tables that have not yet been upgraded. Consider VACUUMing the database...
def upgradeExplicitOid(store): """ Upgrade a store to use explicit oid columns. This allows VACUUMing the database without corrupting it. This requires copying all of axiom_objects and axiom_types, as well as all item tables that have not yet been upgraded. Consider VACUUMing the database...
[ "Upgrade", "a", "store", "to", "use", "explicit", "oid", "columns", ".", "This", "allows", "VACUUMing", "the", "database", "without", "corrupting", "it", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L301-L330
[ "def", "upgradeExplicitOid", "(", "store", ")", ":", "upgradeSystemOid", "(", "store", ")", "for", "typename", ",", "version", "in", "store", ".", "querySchemaSQL", "(", "LATEST_TYPES", ")", ":", "cls", "=", "_typeNameToMostRecentClass", "[", "typename", "]", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_StoreUpgrade.checkUpgradePaths
Check that all of the accumulated old Item types have a way to get from their current version to the latest version. @raise axiom.errors.NoUpgradePathAvailable: for any, and all, Items that do not have a valid upgrade path
axiom/upgrade.py
def checkUpgradePaths(self): """ Check that all of the accumulated old Item types have a way to get from their current version to the latest version. @raise axiom.errors.NoUpgradePathAvailable: for any, and all, Items that do not have a valid upgrade path """ ...
def checkUpgradePaths(self): """ Check that all of the accumulated old Item types have a way to get from their current version to the latest version. @raise axiom.errors.NoUpgradePathAvailable: for any, and all, Items that do not have a valid upgrade path """ ...
[ "Check", "that", "all", "of", "the", "accumulated", "old", "Item", "types", "have", "a", "way", "to", "get", "from", "their", "current", "version", "to", "the", "latest", "version", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L51-L96
[ "def", "checkUpgradePaths", "(", "self", ")", ":", "cantUpgradeErrors", "=", "[", "]", "for", "oldVersion", "in", "self", ".", "_oldTypesRemaining", ":", "# We have to be able to get from oldVersion.schemaVersion to", "# the most recent type.", "currentType", "=", "_typeNam...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_StoreUpgrade.queueTypeUpgrade
Queue a type upgrade for C{oldtype}.
axiom/upgrade.py
def queueTypeUpgrade(self, oldtype): """ Queue a type upgrade for C{oldtype}. """ if oldtype not in self._oldTypesRemaining: self._oldTypesRemaining.append(oldtype)
def queueTypeUpgrade(self, oldtype): """ Queue a type upgrade for C{oldtype}. """ if oldtype not in self._oldTypesRemaining: self._oldTypesRemaining.append(oldtype)
[ "Queue", "a", "type", "upgrade", "for", "C", "{", "oldtype", "}", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L99-L104
[ "def", "queueTypeUpgrade", "(", "self", ",", "oldtype", ")", ":", "if", "oldtype", "not", "in", "self", ".", "_oldTypesRemaining", ":", "self", ".", "_oldTypesRemaining", ".", "append", "(", "oldtype", ")" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_StoreUpgrade.upgradeItem
Upgrade a legacy item. @raise axiom.errors.UpgraderRecursion: If the given item is already in the process of being upgraded.
axiom/upgrade.py
def upgradeItem(self, thisItem): """ Upgrade a legacy item. @raise axiom.errors.UpgraderRecursion: If the given item is already in the process of being upgraded. """ sid = thisItem.storeID if sid in self._currentlyUpgrading: raise UpgraderRecursio...
def upgradeItem(self, thisItem): """ Upgrade a legacy item. @raise axiom.errors.UpgraderRecursion: If the given item is already in the process of being upgraded. """ sid = thisItem.storeID if sid in self._currentlyUpgrading: raise UpgraderRecursio...
[ "Upgrade", "a", "legacy", "item", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L107-L121
[ "def", "upgradeItem", "(", "self", ",", "thisItem", ")", ":", "sid", "=", "thisItem", ".", "storeID", "if", "sid", "in", "self", ".", "_currentlyUpgrading", ":", "raise", "UpgraderRecursion", "(", ")", "self", ".", "_currentlyUpgrading", "[", "sid", "]", "...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_StoreUpgrade.upgradeBatch
Upgrade the entire store in batches, yielding after each batch. @param n: Number of upgrades to perform per transaction @type n: C{int} @raise axiom.errors.ItemUpgradeError: if an item upgrade failed @return: A generator that yields after each batch upgrade. This needs to ...
axiom/upgrade.py
def upgradeBatch(self, n): """ Upgrade the entire store in batches, yielding after each batch. @param n: Number of upgrades to perform per transaction @type n: C{int} @raise axiom.errors.ItemUpgradeError: if an item upgrade failed @return: A generator that yields after...
def upgradeBatch(self, n): """ Upgrade the entire store in batches, yielding after each batch. @param n: Number of upgrades to perform per transaction @type n: C{int} @raise axiom.errors.ItemUpgradeError: if an item upgrade failed @return: A generator that yields after...
[ "Upgrade", "the", "entire", "store", "in", "batches", "yielding", "after", "each", "batch", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/upgrade.py#L135-L183
[ "def", "upgradeBatch", "(", "self", ",", "n", ")", ":", "store", "=", "self", ".", "store", "def", "_doBatch", "(", "itemType", ")", ":", "upgradedAnything", "=", "False", "for", "theItem", "in", "store", ".", "query", "(", "itemType", ",", "limit", "=...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
LogicalVolume.open
Obtains the lvm, vg_t and lv_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
lvm2py/lv.py
def open(self): """ Obtains the lvm, vg_t and lv_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ self.vg.open() self._...
def open(self): """ Obtains the lvm, vg_t and lv_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ self.vg.open() self._...
[ "Obtains", "the", "lvm", "vg_t", "and", "lv_t", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "doing", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", "."...
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L65-L78
[ "def", "open", "(", "self", ")", ":", "self", ".", "vg", ".", "open", "(", ")", "self", ".", "__lvh", "=", "lvm_lv_from_uuid", "(", "self", ".", "vg", ".", "handle", ",", "self", ".", "uuid", ")", "if", "not", "bool", "(", "self", ".", "__lvh", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LogicalVolume.name
Returns the logical volume name.
lvm2py/lv.py
def name(self): """ Returns the logical volume name. """ self.open() name = lvm_lv_get_name(self.__lvh) self.close() return name
def name(self): """ Returns the logical volume name. """ self.open() name = lvm_lv_get_name(self.__lvh) self.close() return name
[ "Returns", "the", "logical", "volume", "name", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L107-L114
[ "def", "name", "(", "self", ")", ":", "self", ".", "open", "(", ")", "name", "=", "lvm_lv_get_name", "(", "self", ".", "__lvh", ")", "self", ".", "close", "(", ")", "return", "name" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LogicalVolume.is_active
Returns True if the logical volume is active, False otherwise.
lvm2py/lv.py
def is_active(self): """ Returns True if the logical volume is active, False otherwise. """ self.open() active = lvm_lv_is_active(self.__lvh) self.close() return bool(active)
def is_active(self): """ Returns True if the logical volume is active, False otherwise. """ self.open() active = lvm_lv_is_active(self.__lvh) self.close() return bool(active)
[ "Returns", "True", "if", "the", "logical", "volume", "is", "active", "False", "otherwise", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L124-L131
[ "def", "is_active", "(", "self", ")", ":", "self", ".", "open", "(", ")", "active", "=", "lvm_lv_is_active", "(", "self", ".", "__lvh", ")", "self", ".", "close", "(", ")", "return", "bool", "(", "active", ")" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LogicalVolume.is_suspended
Returns True if the logical volume is suspended, False otherwise.
lvm2py/lv.py
def is_suspended(self): """ Returns True if the logical volume is suspended, False otherwise. """ self.open() susp = lvm_lv_is_suspended(self.__lvh) self.close() return bool(susp)
def is_suspended(self): """ Returns True if the logical volume is suspended, False otherwise. """ self.open() susp = lvm_lv_is_suspended(self.__lvh) self.close() return bool(susp)
[ "Returns", "True", "if", "the", "logical", "volume", "is", "suspended", "False", "otherwise", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L134-L141
[ "def", "is_suspended", "(", "self", ")", ":", "self", ".", "open", "(", ")", "susp", "=", "lvm_lv_is_suspended", "(", "self", ".", "__lvh", ")", "self", ".", "close", "(", ")", "return", "bool", "(", "susp", ")" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LogicalVolume.size
Returns the logical volume size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
lvm2py/lv.py
def size(self, units="MiB"): """ Returns the logical volume size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_lv_get_size(self.__lvh) self.close(...
def size(self, units="MiB"): """ Returns the logical volume size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_lv_get_size(self.__lvh) self.close(...
[ "Returns", "the", "logical", "volume", "size", "in", "the", "given", "units", ".", "Default", "units", "are", "MiB", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L143-L154
[ "def", "size", "(", "self", ",", "units", "=", "\"MiB\"", ")", ":", "self", ".", "open", "(", ")", "size", "=", "lvm_lv_get_size", "(", "self", ".", "__lvh", ")", "self", ".", "close", "(", ")", "return", "size_convert", "(", "size", ",", "units", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LogicalVolume.activate
Activates the logical volume. *Raises:* * HandleError
lvm2py/lv.py
def activate(self): """ Activates the logical volume. *Raises:* * HandleError """ self.open() a = lvm_lv_activate(self.handle) self.close() if a != 0: raise CommitError("Failed to activate LV.")
def activate(self): """ Activates the logical volume. *Raises:* * HandleError """ self.open() a = lvm_lv_activate(self.handle) self.close() if a != 0: raise CommitError("Failed to activate LV.")
[ "Activates", "the", "logical", "volume", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L156-L168
[ "def", "activate", "(", "self", ")", ":", "self", ".", "open", "(", ")", "a", "=", "lvm_lv_activate", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "if", "a", "!=", "0", ":", "raise", "CommitError", "(", "\"Failed to activate LV.\"",...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LogicalVolume.deactivate
Deactivates the logical volume. *Raises:* * HandleError
lvm2py/lv.py
def deactivate(self): """ Deactivates the logical volume. *Raises:* * HandleError """ self.open() d = lvm_lv_deactivate(self.handle) self.close() if d != 0: raise CommitError("Failed to deactivate LV.")
def deactivate(self): """ Deactivates the logical volume. *Raises:* * HandleError """ self.open() d = lvm_lv_deactivate(self.handle) self.close() if d != 0: raise CommitError("Failed to deactivate LV.")
[ "Deactivates", "the", "logical", "volume", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lv.py#L170-L182
[ "def", "deactivate", "(", "self", ")", ":", "self", ".", "open", "(", ")", "d", "=", "lvm_lv_deactivate", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "if", "d", "!=", "0", ":", "raise", "CommitError", "(", "\"Failed to deactivate L...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
PhysicalVolume.open
Obtains the lvm, vg_t and pv_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
lvm2py/pv.py
def open(self): """ Obtains the lvm, vg_t and pv_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ self.vg.open() self._...
def open(self): """ Obtains the lvm, vg_t and pv_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ self.vg.open() self._...
[ "Obtains", "the", "lvm", "vg_t", "and", "pv_t", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "doing", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", "."...
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L69-L82
[ "def", "open", "(", "self", ")", ":", "self", ".", "vg", ".", "open", "(", ")", "self", ".", "__pvh", "=", "lvm_pv_from_uuid", "(", "self", ".", "vg", ".", "handle", ",", "self", ".", "uuid", ")", "if", "not", "bool", "(", "self", ".", "__pvh", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
PhysicalVolume.name
Returns the physical volume device path.
lvm2py/pv.py
def name(self): """ Returns the physical volume device path. """ self.open() name = lvm_pv_get_name(self.handle) self.close() return name
def name(self): """ Returns the physical volume device path. """ self.open() name = lvm_pv_get_name(self.handle) self.close() return name
[ "Returns", "the", "physical", "volume", "device", "path", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L111-L118
[ "def", "name", "(", "self", ")", ":", "self", ".", "open", "(", ")", "name", "=", "lvm_pv_get_name", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "name" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
PhysicalVolume.mda_count
Returns the physical volume mda count.
lvm2py/pv.py
def mda_count(self): """ Returns the physical volume mda count. """ self.open() mda = lvm_pv_get_mda_count(self.handle) self.close() return mda
def mda_count(self): """ Returns the physical volume mda count. """ self.open() mda = lvm_pv_get_mda_count(self.handle) self.close() return mda
[ "Returns", "the", "physical", "volume", "mda", "count", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L128-L135
[ "def", "mda_count", "(", "self", ")", ":", "self", ".", "open", "(", ")", "mda", "=", "lvm_pv_get_mda_count", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "mda" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
PhysicalVolume.size
Returns the physical volume size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
lvm2py/pv.py
def size(self, units="MiB"): """ Returns the physical volume size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_pv_get_size(self.handle) self.clos...
def size(self, units="MiB"): """ Returns the physical volume size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_pv_get_size(self.handle) self.clos...
[ "Returns", "the", "physical", "volume", "size", "in", "the", "given", "units", ".", "Default", "units", "are", "MiB", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/pv.py#L137-L148
[ "def", "size", "(", "self", ",", "units", "=", "\"MiB\"", ")", ":", "self", ".", "open", "(", ")", "size", "=", "lvm_pv_get_size", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "size_convert", "(", "size", ",", "units", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6