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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | preserve | Preserve fields in deposit.
:param method: Function to execute. (Default: ``None``)
:param result: If `True` returns the result of method execution,
otherwise `self`. (Default: ``True``)
:param fields: List of fields to preserve (default: ``('_deposit',)``). | invenio_deposit/api.py | def preserve(method=None, result=True, fields=None):
"""Preserve fields in deposit.
:param method: Function to execute. (Default: ``None``)
:param result: If `True` returns the result of method execution,
otherwise `self`. (Default: ``True``)
:param fields: List of fields to preserve (default: ... | def preserve(method=None, result=True, fields=None):
"""Preserve fields in deposit.
:param method: Function to execute. (Default: ``None``)
:param result: If `True` returns the result of method execution,
otherwise `self`. (Default: ``True``)
:param fields: List of fields to preserve (default: ... | [
"Preserve",
"fields",
"in",
"deposit",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L104-L126 | [
"def",
"preserve",
"(",
"method",
"=",
"None",
",",
"result",
"=",
"True",
",",
"fields",
"=",
"None",
")",
":",
"if",
"method",
"is",
"None",
":",
"return",
"partial",
"(",
"preserve",
",",
"result",
"=",
"result",
",",
"fields",
"=",
"fields",
")",... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.pid | Return an instance of deposit PID. | invenio_deposit/api.py | def pid(self):
"""Return an instance of deposit PID."""
pid = self.deposit_fetcher(self.id, self)
return PersistentIdentifier.get(pid.pid_type,
pid.pid_value) | def pid(self):
"""Return an instance of deposit PID."""
pid = self.deposit_fetcher(self.id, self)
return PersistentIdentifier.get(pid.pid_type,
pid.pid_value) | [
"Return",
"an",
"instance",
"of",
"deposit",
"PID",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L145-L149 | [
"def",
"pid",
"(",
"self",
")",
":",
"pid",
"=",
"self",
".",
"deposit_fetcher",
"(",
"self",
".",
"id",
",",
"self",
")",
"return",
"PersistentIdentifier",
".",
"get",
"(",
"pid",
".",
"pid_type",
",",
"pid",
".",
"pid_value",
")"
] | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.record_schema | Convert deposit schema to a valid record schema. | invenio_deposit/api.py | def record_schema(self):
"""Convert deposit schema to a valid record schema."""
schema_path = current_jsonschemas.url_to_path(self['$schema'])
schema_prefix = current_app.config['DEPOSIT_JSONSCHEMAS_PREFIX']
if schema_path and schema_path.startswith(schema_prefix):
return cur... | def record_schema(self):
"""Convert deposit schema to a valid record schema."""
schema_path = current_jsonschemas.url_to_path(self['$schema'])
schema_prefix = current_app.config['DEPOSIT_JSONSCHEMAS_PREFIX']
if schema_path and schema_path.startswith(schema_prefix):
return cur... | [
"Convert",
"deposit",
"schema",
"to",
"a",
"valid",
"record",
"schema",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L152-L159 | [
"def",
"record_schema",
"(",
"self",
")",
":",
"schema_path",
"=",
"current_jsonschemas",
".",
"url_to_path",
"(",
"self",
"[",
"'$schema'",
"]",
")",
"schema_prefix",
"=",
"current_app",
".",
"config",
"[",
"'DEPOSIT_JSONSCHEMAS_PREFIX'",
"]",
"if",
"schema_path"... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.build_deposit_schema | Convert record schema to a valid deposit schema.
:param record: The record used to build deposit schema.
:returns: The absolute URL to the schema or `None`. | invenio_deposit/api.py | def build_deposit_schema(self, record):
"""Convert record schema to a valid deposit schema.
:param record: The record used to build deposit schema.
:returns: The absolute URL to the schema or `None`.
"""
schema_path = current_jsonschemas.url_to_path(record['$schema'])
sc... | def build_deposit_schema(self, record):
"""Convert record schema to a valid deposit schema.
:param record: The record used to build deposit schema.
:returns: The absolute URL to the schema or `None`.
"""
schema_path = current_jsonschemas.url_to_path(record['$schema'])
sc... | [
"Convert",
"record",
"schema",
"to",
"a",
"valid",
"deposit",
"schema",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L161-L172 | [
"def",
"build_deposit_schema",
"(",
"self",
",",
"record",
")",
":",
"schema_path",
"=",
"current_jsonschemas",
".",
"url_to_path",
"(",
"record",
"[",
"'$schema'",
"]",
")",
"schema_prefix",
"=",
"current_app",
".",
"config",
"[",
"'DEPOSIT_JSONSCHEMAS_PREFIX'",
... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.fetch_published | Return a tuple with PID and published record. | invenio_deposit/api.py | def fetch_published(self):
"""Return a tuple with PID and published record."""
pid_type = self['_deposit']['pid']['type']
pid_value = self['_deposit']['pid']['value']
resolver = Resolver(
pid_type=pid_type, object_type='rec',
getter=partial(self.published_record_... | def fetch_published(self):
"""Return a tuple with PID and published record."""
pid_type = self['_deposit']['pid']['type']
pid_value = self['_deposit']['pid']['value']
resolver = Resolver(
pid_type=pid_type, object_type='rec',
getter=partial(self.published_record_... | [
"Return",
"a",
"tuple",
"with",
"PID",
"and",
"published",
"record",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L174-L184 | [
"def",
"fetch_published",
"(",
"self",
")",
":",
"pid_type",
"=",
"self",
"[",
"'_deposit'",
"]",
"[",
"'pid'",
"]",
"[",
"'type'",
"]",
"pid_value",
"=",
"self",
"[",
"'_deposit'",
"]",
"[",
"'pid'",
"]",
"[",
"'value'",
"]",
"resolver",
"=",
"Resolve... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.merge_with_published | Merge changes with latest published version. | invenio_deposit/api.py | def merge_with_published(self):
"""Merge changes with latest published version."""
pid, first = self.fetch_published()
lca = first.revisions[self['_deposit']['pid']['revision_id']]
# ignore _deposit and $schema field
args = [lca.dumps(), first.dumps(), self.dumps()]
for a... | def merge_with_published(self):
"""Merge changes with latest published version."""
pid, first = self.fetch_published()
lca = first.revisions[self['_deposit']['pid']['revision_id']]
# ignore _deposit and $schema field
args = [lca.dumps(), first.dumps(), self.dumps()]
for a... | [
"Merge",
"changes",
"with",
"latest",
"published",
"version",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L187-L201 | [
"def",
"merge_with_published",
"(",
"self",
")",
":",
"pid",
",",
"first",
"=",
"self",
".",
"fetch_published",
"(",
")",
"lca",
"=",
"first",
".",
"revisions",
"[",
"self",
"[",
"'_deposit'",
"]",
"[",
"'pid'",
"]",
"[",
"'revision_id'",
"]",
"]",
"# ... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.commit | Store changes on current instance in database and index it. | invenio_deposit/api.py | def commit(self, *args, **kwargs):
"""Store changes on current instance in database and index it."""
return super(Deposit, self).commit(*args, **kwargs) | def commit(self, *args, **kwargs):
"""Store changes on current instance in database and index it."""
return super(Deposit, self).commit(*args, **kwargs) | [
"Store",
"changes",
"on",
"current",
"instance",
"in",
"database",
"and",
"index",
"it",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L204-L206 | [
"def",
"commit",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"Deposit",
",",
"self",
")",
".",
"commit",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.create | Create a deposit.
Initialize the follow information inside the deposit:
.. code-block:: python
deposit['_deposit'] = {
'id': pid_value,
'status': 'draft',
'owners': [user_id],
'created_by': user_id,
}
The... | invenio_deposit/api.py | def create(cls, data, id_=None):
"""Create a deposit.
Initialize the follow information inside the deposit:
.. code-block:: python
deposit['_deposit'] = {
'id': pid_value,
'status': 'draft',
'owners': [user_id],
'crea... | def create(cls, data, id_=None):
"""Create a deposit.
Initialize the follow information inside the deposit:
.. code-block:: python
deposit['_deposit'] = {
'id': pid_value,
'status': 'draft',
'owners': [user_id],
'crea... | [
"Create",
"a",
"deposit",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L210-L246 | [
"def",
"create",
"(",
"cls",
",",
"data",
",",
"id_",
"=",
"None",
")",
":",
"data",
".",
"setdefault",
"(",
"'$schema'",
",",
"current_jsonschemas",
".",
"path_to_url",
"(",
"current_app",
".",
"config",
"[",
"'DEPOSIT_DEFAULT_JSONSCHEMA'",
"]",
")",
")",
... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit._process_files | Snapshot bucket and add files in record during first publishing. | invenio_deposit/api.py | def _process_files(self, record_id, data):
"""Snapshot bucket and add files in record during first publishing."""
if self.files:
assert not self.files.bucket.locked
self.files.bucket.locked = True
snapshot = self.files.bucket.snapshot(lock=True)
data['_fil... | def _process_files(self, record_id, data):
"""Snapshot bucket and add files in record during first publishing."""
if self.files:
assert not self.files.bucket.locked
self.files.bucket.locked = True
snapshot = self.files.bucket.snapshot(lock=True)
data['_fil... | [
"Snapshot",
"bucket",
"and",
"add",
"files",
"in",
"record",
"during",
"first",
"publishing",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L249-L261 | [
"def",
"_process_files",
"(",
"self",
",",
"record_id",
",",
"data",
")",
":",
"if",
"self",
".",
"files",
":",
"assert",
"not",
"self",
".",
"files",
".",
"bucket",
".",
"locked",
"self",
".",
"files",
".",
"bucket",
".",
"locked",
"=",
"True",
"sna... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit._publish_new | Publish new deposit.
:param id_: The forced record UUID. | invenio_deposit/api.py | def _publish_new(self, id_=None):
"""Publish new deposit.
:param id_: The forced record UUID.
"""
minter = current_pidstore.minters[
current_app.config['DEPOSIT_PID_MINTER']
]
id_ = id_ or uuid.uuid4()
record_pid = minter(id_, self)
self['_de... | def _publish_new(self, id_=None):
"""Publish new deposit.
:param id_: The forced record UUID.
"""
minter = current_pidstore.minters[
current_app.config['DEPOSIT_PID_MINTER']
]
id_ = id_ or uuid.uuid4()
record_pid = minter(id_, self)
self['_de... | [
"Publish",
"new",
"deposit",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L263-L286 | [
"def",
"_publish_new",
"(",
"self",
",",
"id_",
"=",
"None",
")",
":",
"minter",
"=",
"current_pidstore",
".",
"minters",
"[",
"current_app",
".",
"config",
"[",
"'DEPOSIT_PID_MINTER'",
"]",
"]",
"id_",
"=",
"id_",
"or",
"uuid",
".",
"uuid4",
"(",
")",
... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit._publish_edited | Publish the deposit after for editing. | invenio_deposit/api.py | def _publish_edited(self):
"""Publish the deposit after for editing."""
record_pid, record = self.fetch_published()
if record.revision_id == self['_deposit']['pid']['revision_id']:
data = dict(self.dumps())
else:
data = self.merge_with_published()
data['$... | def _publish_edited(self):
"""Publish the deposit after for editing."""
record_pid, record = self.fetch_published()
if record.revision_id == self['_deposit']['pid']['revision_id']:
data = dict(self.dumps())
else:
data = self.merge_with_published()
data['$... | [
"Publish",
"the",
"deposit",
"after",
"for",
"editing",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L288-L299 | [
"def",
"_publish_edited",
"(",
"self",
")",
":",
"record_pid",
",",
"record",
"=",
"self",
".",
"fetch_published",
"(",
")",
"if",
"record",
".",
"revision_id",
"==",
"self",
"[",
"'_deposit'",
"]",
"[",
"'pid'",
"]",
"[",
"'revision_id'",
"]",
":",
"dat... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.publish | Publish a deposit.
If it's the first time:
* it calls the minter and set the following meta information inside
the deposit:
.. code-block:: python
deposit['_deposit'] = {
'type': pid_type,
'value': pid_value,
'revision_i... | invenio_deposit/api.py | def publish(self, pid=None, id_=None):
"""Publish a deposit.
If it's the first time:
* it calls the minter and set the following meta information inside
the deposit:
.. code-block:: python
deposit['_deposit'] = {
'type': pid_type,
... | def publish(self, pid=None, id_=None):
"""Publish a deposit.
If it's the first time:
* it calls the minter and set the following meta information inside
the deposit:
.. code-block:: python
deposit['_deposit'] = {
'type': pid_type,
... | [
"Publish",
"a",
"deposit",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L303-L348 | [
"def",
"publish",
"(",
"self",
",",
"pid",
"=",
"None",
",",
"id_",
"=",
"None",
")",
":",
"pid",
"=",
"pid",
"or",
"self",
".",
"pid",
"if",
"not",
"pid",
".",
"is_registered",
"(",
")",
":",
"raise",
"PIDInvalidAction",
"(",
")",
"self",
"[",
"... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit._prepare_edit | Update selected keys.
:param record: The record to prepare. | invenio_deposit/api.py | def _prepare_edit(self, record):
"""Update selected keys.
:param record: The record to prepare.
"""
data = record.dumps()
# Keep current record revision for merging.
data['_deposit']['pid']['revision_id'] = record.revision_id
data['_deposit']['status'] = 'draft'
... | def _prepare_edit(self, record):
"""Update selected keys.
:param record: The record to prepare.
"""
data = record.dumps()
# Keep current record revision for merging.
data['_deposit']['pid']['revision_id'] = record.revision_id
data['_deposit']['status'] = 'draft'
... | [
"Update",
"selected",
"keys",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L350-L360 | [
"def",
"_prepare_edit",
"(",
"self",
",",
"record",
")",
":",
"data",
"=",
"record",
".",
"dumps",
"(",
")",
"# Keep current record revision for merging.",
"data",
"[",
"'_deposit'",
"]",
"[",
"'pid'",
"]",
"[",
"'revision_id'",
"]",
"=",
"record",
".",
"rev... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.edit | Edit deposit.
#. The signal :data:`invenio_records.signals.before_record_update`
is sent before the edit execution.
#. The following meta information are saved inside the deposit:
.. code-block:: python
deposit['_deposit']['pid'] = record.revision_id
deposi... | invenio_deposit/api.py | def edit(self, pid=None):
"""Edit deposit.
#. The signal :data:`invenio_records.signals.before_record_update`
is sent before the edit execution.
#. The following meta information are saved inside the deposit:
.. code-block:: python
deposit['_deposit']['pid'] = ... | def edit(self, pid=None):
"""Edit deposit.
#. The signal :data:`invenio_records.signals.before_record_update`
is sent before the edit execution.
#. The following meta information are saved inside the deposit:
.. code-block:: python
deposit['_deposit']['pid'] = ... | [
"Edit",
"deposit",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L365-L409 | [
"def",
"edit",
"(",
"self",
",",
"pid",
"=",
"None",
")",
":",
"pid",
"=",
"pid",
"or",
"self",
".",
"pid",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"before_record_update",
".",
"send",
"(",
"current_app",
".",
"_get_current_ob... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.discard | Discard deposit changes.
#. The signal :data:`invenio_records.signals.before_record_update` is
sent before the edit execution.
#. It restores the last published version.
#. The following meta information are saved inside the deposit:
.. code-block:: python
de... | invenio_deposit/api.py | def discard(self, pid=None):
"""Discard deposit changes.
#. The signal :data:`invenio_records.signals.before_record_update` is
sent before the edit execution.
#. It restores the last published version.
#. The following meta information are saved inside the deposit:
... | def discard(self, pid=None):
"""Discard deposit changes.
#. The signal :data:`invenio_records.signals.before_record_update` is
sent before the edit execution.
#. It restores the last published version.
#. The following meta information are saved inside the deposit:
... | [
"Discard",
"deposit",
"changes",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L414-L453 | [
"def",
"discard",
"(",
"self",
",",
"pid",
"=",
"None",
")",
":",
"pid",
"=",
"pid",
"or",
"self",
".",
"pid",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"before_record_update",
".",
"send",
"(",
"current_app",
".",
"_get_current... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.delete | Delete deposit.
Status required: ``'draft'``.
:param force: Force deposit delete. (Default: ``True``)
:param pid: Force pid object. (Default: ``None``)
:returns: A new Deposit object. | invenio_deposit/api.py | def delete(self, force=True, pid=None):
"""Delete deposit.
Status required: ``'draft'``.
:param force: Force deposit delete. (Default: ``True``)
:param pid: Force pid object. (Default: ``None``)
:returns: A new Deposit object.
"""
pid = pid or self.pid
... | def delete(self, force=True, pid=None):
"""Delete deposit.
Status required: ``'draft'``.
:param force: Force deposit delete. (Default: ``True``)
:param pid: Force pid object. (Default: ``None``)
:returns: A new Deposit object.
"""
pid = pid or self.pid
... | [
"Delete",
"deposit",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L457-L472 | [
"def",
"delete",
"(",
"self",
",",
"force",
"=",
"True",
",",
"pid",
"=",
"None",
")",
":",
"pid",
"=",
"pid",
"or",
"self",
".",
"pid",
"if",
"self",
"[",
"'_deposit'",
"]",
".",
"get",
"(",
"'pid'",
")",
":",
"raise",
"PIDInvalidAction",
"(",
"... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.clear | Clear only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved. | invenio_deposit/api.py | def clear(self, *args, **kwargs):
"""Clear only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved.
"""
super(Deposit, self).clear(*args, **kwargs) | def clear(self, *args, **kwargs):
"""Clear only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved.
"""
super(Deposit, self).clear(*args, **kwargs) | [
"Clear",
"only",
"drafts",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L476-L483 | [
"def",
"clear",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Deposit",
",",
"self",
")",
".",
"clear",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.update | Update only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved. | invenio_deposit/api.py | def update(self, *args, **kwargs):
"""Update only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved.
"""
super(Deposit, self).update(*args, **kwargs) | def update(self, *args, **kwargs):
"""Update only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved.
"""
super(Deposit, self).update(*args, **kwargs) | [
"Update",
"only",
"drafts",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L487-L494 | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Deposit",
",",
"self",
")",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.patch | Patch only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved. | invenio_deposit/api.py | def patch(self, *args, **kwargs):
"""Patch only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved.
"""
return super(Deposit, self).patch(*args, **kwargs) | def patch(self, *args, **kwargs):
"""Patch only drafts.
Status required: ``'draft'``.
Meta information inside `_deposit` are preserved.
"""
return super(Deposit, self).patch(*args, **kwargs) | [
"Patch",
"only",
"drafts",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L498-L505 | [
"def",
"patch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"Deposit",
",",
"self",
")",
".",
"patch",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | Deposit.files | List of Files inside the deposit.
Add validation on ``sort_by`` method: if, at the time of files access,
the record is not a ``'draft'`` then a
:exc:`invenio_pidstore.errors.PIDInvalidAction` is rised. | invenio_deposit/api.py | def files(self):
"""List of Files inside the deposit.
Add validation on ``sort_by`` method: if, at the time of files access,
the record is not a ``'draft'`` then a
:exc:`invenio_pidstore.errors.PIDInvalidAction` is rised.
"""
files_ = super(Deposit, self).files
... | def files(self):
"""List of Files inside the deposit.
Add validation on ``sort_by`` method: if, at the time of files access,
the record is not a ``'draft'`` then a
:exc:`invenio_pidstore.errors.PIDInvalidAction` is rised.
"""
files_ = super(Deposit, self).files
... | [
"List",
"of",
"Files",
"inside",
"the",
"deposit",
"."
] | inveniosoftware/invenio-deposit | python | https://github.com/inveniosoftware/invenio-deposit/blob/f243ea1d01ab0a3bc92ade3262d1abdd2bc32447/invenio_deposit/api.py#L519-L539 | [
"def",
"files",
"(",
"self",
")",
":",
"files_",
"=",
"super",
"(",
"Deposit",
",",
"self",
")",
".",
"files",
"if",
"files_",
":",
"sort_by_",
"=",
"files_",
".",
"sort_by",
"def",
"sort_by",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
... | f243ea1d01ab0a3bc92ade3262d1abdd2bc32447 |
valid | rst2node | Converts a reStructuredText into its node | pyramid_autodoc/__init__.py | def rst2node(doc_name, data):
"""Converts a reStructuredText into its node
"""
if not data:
return
parser = docutils.parsers.rst.Parser()
document = docutils.utils.new_document('<%s>' % doc_name)
document.settings = docutils.frontend.OptionParser().get_default_values()
document.setti... | def rst2node(doc_name, data):
"""Converts a reStructuredText into its node
"""
if not data:
return
parser = docutils.parsers.rst.Parser()
document = docutils.utils.new_document('<%s>' % doc_name)
document.settings = docutils.frontend.OptionParser().get_default_values()
document.setti... | [
"Converts",
"a",
"reStructuredText",
"into",
"its",
"node"
] | SurveyMonkey/pyramid_autodoc | python | https://github.com/SurveyMonkey/pyramid_autodoc/blob/8d669c7165de73cba5268bba97617c552d6b2185/pyramid_autodoc/__init__.py#L311-L330 | [
"def",
"rst2node",
"(",
"doc_name",
",",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"parser",
"=",
"docutils",
".",
"parsers",
".",
"rst",
".",
"Parser",
"(",
")",
"document",
"=",
"docutils",
".",
"utils",
".",
"new_document",
"(",
"'<%s>'"... | 8d669c7165de73cba5268bba97617c552d6b2185 |
valid | setup | Hook the directives when Sphinx ask for it. | pyramid_autodoc/__init__.py | def setup(app):
"""Hook the directives when Sphinx ask for it."""
if 'http' not in app.domains:
httpdomain.setup(app)
app.add_directive('autopyramid', RouteDirective) | def setup(app):
"""Hook the directives when Sphinx ask for it."""
if 'http' not in app.domains:
httpdomain.setup(app)
app.add_directive('autopyramid', RouteDirective) | [
"Hook",
"the",
"directives",
"when",
"Sphinx",
"ask",
"for",
"it",
"."
] | SurveyMonkey/pyramid_autodoc | python | https://github.com/SurveyMonkey/pyramid_autodoc/blob/8d669c7165de73cba5268bba97617c552d6b2185/pyramid_autodoc/__init__.py#L333-L338 | [
"def",
"setup",
"(",
"app",
")",
":",
"if",
"'http'",
"not",
"in",
"app",
".",
"domains",
":",
"httpdomain",
".",
"setup",
"(",
"app",
")",
"app",
".",
"add_directive",
"(",
"'autopyramid'",
",",
"RouteDirective",
")"
] | 8d669c7165de73cba5268bba97617c552d6b2185 |
valid | api._parse_response | Parses the API response and raises appropriate errors if
raise_errors was set to True | sendwithus/__init__.py | def _parse_response(self, response):
"""Parses the API response and raises appropriate errors if
raise_errors was set to True
"""
if not self._raise_errors:
return response
is_4xx_error = str(response.status_code)[0] == '4'
is_5xx_error = str(response.status_... | def _parse_response(self, response):
"""Parses the API response and raises appropriate errors if
raise_errors was set to True
"""
if not self._raise_errors:
return response
is_4xx_error = str(response.status_code)[0] == '4'
is_5xx_error = str(response.status_... | [
"Parses",
"the",
"API",
"response",
"and",
"raises",
"appropriate",
"errors",
"if",
"raise_errors",
"was",
"set",
"to",
"True"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L142-L160 | [
"def",
"_parse_response",
"(",
"self",
",",
"response",
")",
":",
"if",
"not",
"self",
".",
"_raise_errors",
":",
"return",
"response",
"is_4xx_error",
"=",
"str",
"(",
"response",
".",
"status_code",
")",
"[",
"0",
"]",
"==",
"'4'",
"is_5xx_error",
"=",
... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api._api_request | Private method for api requests | sendwithus/__init__.py | def _api_request(self, endpoint, http_method, *args, **kwargs):
"""Private method for api requests"""
logger.debug(' > Sending API request to endpoint: %s' % endpoint)
auth = self._build_http_auth()
headers = self._build_request_headers(kwargs.get('headers'))
logger.debug('\the... | def _api_request(self, endpoint, http_method, *args, **kwargs):
"""Private method for api requests"""
logger.debug(' > Sending API request to endpoint: %s' % endpoint)
auth = self._build_http_auth()
headers = self._build_request_headers(kwargs.get('headers'))
logger.debug('\the... | [
"Private",
"method",
"for",
"api",
"requests"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L162-L207 | [
"def",
"_api_request",
"(",
"self",
",",
"endpoint",
",",
"http_method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"' > Sending API request to endpoint: %s'",
"%",
"endpoint",
")",
"auth",
"=",
"self",
".",
"_build_htt... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.get_log | API call to get a specific log entry | sendwithus/__init__.py | def get_log(self, log_id, timeout=None):
""" API call to get a specific log entry """
return self._api_request(
self.GET_LOG_ENDPOINT % log_id,
self.HTTP_GET,
timeout=timeout
) | def get_log(self, log_id, timeout=None):
""" API call to get a specific log entry """
return self._api_request(
self.GET_LOG_ENDPOINT % log_id,
self.HTTP_GET,
timeout=timeout
) | [
"API",
"call",
"to",
"get",
"a",
"specific",
"log",
"entry"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L209-L215 | [
"def",
"get_log",
"(",
"self",
",",
"log_id",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_api_request",
"(",
"self",
".",
"GET_LOG_ENDPOINT",
"%",
"log_id",
",",
"self",
".",
"HTTP_GET",
",",
"timeout",
"=",
"timeout",
")"
] | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.get_log_events | API call to get a specific log entry | sendwithus/__init__.py | def get_log_events(self, log_id, timeout=None):
""" API call to get a specific log entry """
return self._api_request(
self.GET_LOG_EVENTS_ENDPOINT % log_id,
self.HTTP_GET,
timeout=timeout
) | def get_log_events(self, log_id, timeout=None):
""" API call to get a specific log entry """
return self._api_request(
self.GET_LOG_EVENTS_ENDPOINT % log_id,
self.HTTP_GET,
timeout=timeout
) | [
"API",
"call",
"to",
"get",
"a",
"specific",
"log",
"entry"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L217-L223 | [
"def",
"get_log_events",
"(",
"self",
",",
"log_id",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_api_request",
"(",
"self",
".",
"GET_LOG_EVENTS_ENDPOINT",
"%",
"log_id",
",",
"self",
".",
"HTTP_GET",
",",
"timeout",
"=",
"timeout",
")"... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.templates | API call to get a list of templates | sendwithus/__init__.py | def templates(self, timeout=None):
""" API call to get a list of templates """
return self._api_request(
self.TEMPLATES_ENDPOINT,
self.HTTP_GET,
timeout=timeout
) | def templates(self, timeout=None):
""" API call to get a list of templates """
return self._api_request(
self.TEMPLATES_ENDPOINT,
self.HTTP_GET,
timeout=timeout
) | [
"API",
"call",
"to",
"get",
"a",
"list",
"of",
"templates"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L229-L235 | [
"def",
"templates",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_api_request",
"(",
"self",
".",
"TEMPLATES_ENDPOINT",
",",
"self",
".",
"HTTP_GET",
",",
"timeout",
"=",
"timeout",
")"
] | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.get_template | API call to get a specific template | sendwithus/__init__.py | def get_template(self, template_id, version=None, timeout=None):
""" API call to get a specific template """
if (version):
return self._api_request(
self.TEMPLATES_VERSION_ENDPOINT % (template_id, version),
self.HTTP_GET,
timeout=timeout
... | def get_template(self, template_id, version=None, timeout=None):
""" API call to get a specific template """
if (version):
return self._api_request(
self.TEMPLATES_VERSION_ENDPOINT % (template_id, version),
self.HTTP_GET,
timeout=timeout
... | [
"API",
"call",
"to",
"get",
"a",
"specific",
"template"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L237-L250 | [
"def",
"get_template",
"(",
"self",
",",
"template_id",
",",
"version",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"(",
"version",
")",
":",
"return",
"self",
".",
"_api_request",
"(",
"self",
".",
"TEMPLATES_VERSION_ENDPOINT",
"%",
"(",
"... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.create_email | [DECPRECATED] API call to create an email | sendwithus/__init__.py | def create_email(self, name, subject, html, text=''):
""" [DECPRECATED] API call to create an email """
return self.create_template(name, subject, html, text) | def create_email(self, name, subject, html, text=''):
""" [DECPRECATED] API call to create an email """
return self.create_template(name, subject, html, text) | [
"[",
"DECPRECATED",
"]",
"API",
"call",
"to",
"create",
"an",
"email"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L252-L254 | [
"def",
"create_email",
"(",
"self",
",",
"name",
",",
"subject",
",",
"html",
",",
"text",
"=",
"''",
")",
":",
"return",
"self",
".",
"create_template",
"(",
"name",
",",
"subject",
",",
"html",
",",
"text",
")"
] | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.create_template | API call to create a template | sendwithus/__init__.py | def create_template(
self,
name,
subject,
html,
text='',
timeout=None
):
""" API call to create a template """
payload = {
'name': name,
'subject': subject,
'html': html,
'text': text
}
r... | def create_template(
self,
name,
subject,
html,
text='',
timeout=None
):
""" API call to create a template """
payload = {
'name': name,
'subject': subject,
'html': html,
'text': text
}
r... | [
"API",
"call",
"to",
"create",
"a",
"template"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L256-L277 | [
"def",
"create_template",
"(",
"self",
",",
"name",
",",
"subject",
",",
"html",
",",
"text",
"=",
"''",
",",
"timeout",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'name'",
":",
"name",
",",
"'subject'",
":",
"subject",
",",
"'html'",
":",
"html",
... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.create_new_locale | API call to create a new locale and version of a template | sendwithus/__init__.py | def create_new_locale(
self,
template_id,
locale,
version_name,
subject,
text='',
html='',
timeout=None
):
""" API call to create a new locale and version of a template """
payload = {
'locale': locale,
'name': v... | def create_new_locale(
self,
template_id,
locale,
version_name,
subject,
text='',
html='',
timeout=None
):
""" API call to create a new locale and version of a template """
payload = {
'locale': locale,
'name': v... | [
"API",
"call",
"to",
"create",
"a",
"new",
"locale",
"and",
"version",
"of",
"a",
"template"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L279-L306 | [
"def",
"create_new_locale",
"(",
"self",
",",
"template_id",
",",
"locale",
",",
"version_name",
",",
"subject",
",",
"text",
"=",
"''",
",",
"html",
"=",
"''",
",",
"timeout",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'locale'",
":",
"locale",
",",... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.create_new_version | API call to create a new version of a template | sendwithus/__init__.py | def create_new_version(
self,
name,
subject,
text='',
template_id=None,
html=None,
locale=None,
timeout=None
):
""" API call to create a new version of a template """
if(html):
payload = {
'name': name,
... | def create_new_version(
self,
name,
subject,
text='',
template_id=None,
html=None,
locale=None,
timeout=None
):
""" API call to create a new version of a template """
if(html):
payload = {
'name': name,
... | [
"API",
"call",
"to",
"create",
"a",
"new",
"version",
"of",
"a",
"template"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L308-L346 | [
"def",
"create_new_version",
"(",
"self",
",",
"name",
",",
"subject",
",",
"text",
"=",
"''",
",",
"template_id",
"=",
"None",
",",
"html",
"=",
"None",
",",
"locale",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"(",
"html",
")",
":"... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.update_template_version | API call to update a template version | sendwithus/__init__.py | def update_template_version(
self,
name,
subject,
template_id,
version_id,
text='',
html=None,
timeout=None
):
""" API call to update a template version """
if(html):
payload = {
'name': name,
... | def update_template_version(
self,
name,
subject,
template_id,
version_id,
text='',
html=None,
timeout=None
):
""" API call to update a template version """
if(html):
payload = {
'name': name,
... | [
"API",
"call",
"to",
"update",
"a",
"template",
"version"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L348-L378 | [
"def",
"update_template_version",
"(",
"self",
",",
"name",
",",
"subject",
",",
"template_id",
",",
"version_id",
",",
"text",
"=",
"''",
",",
"html",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"(",
"html",
")",
":",
"payload",
"=",
"... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.snippets | API call to get list of snippets | sendwithus/__init__.py | def snippets(self, timeout=None):
""" API call to get list of snippets """
return self._api_request(
self.SNIPPETS_ENDPOINT,
self.HTTP_GET,
timeout=timeout
) | def snippets(self, timeout=None):
""" API call to get list of snippets """
return self._api_request(
self.SNIPPETS_ENDPOINT,
self.HTTP_GET,
timeout=timeout
) | [
"API",
"call",
"to",
"get",
"list",
"of",
"snippets"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L380-L386 | [
"def",
"snippets",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_api_request",
"(",
"self",
".",
"SNIPPETS_ENDPOINT",
",",
"self",
".",
"HTTP_GET",
",",
"timeout",
"=",
"timeout",
")"
] | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.get_snippet | API call to get a specific Snippet | sendwithus/__init__.py | def get_snippet(self, snippet_id, timeout=None):
""" API call to get a specific Snippet """
return self._api_request(
self.SNIPPET_ENDPOINT % (snippet_id),
self.HTTP_GET,
timeout=timeout
) | def get_snippet(self, snippet_id, timeout=None):
""" API call to get a specific Snippet """
return self._api_request(
self.SNIPPET_ENDPOINT % (snippet_id),
self.HTTP_GET,
timeout=timeout
) | [
"API",
"call",
"to",
"get",
"a",
"specific",
"Snippet"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L388-L394 | [
"def",
"get_snippet",
"(",
"self",
",",
"snippet_id",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_api_request",
"(",
"self",
".",
"SNIPPET_ENDPOINT",
"%",
"(",
"snippet_id",
")",
",",
"self",
".",
"HTTP_GET",
",",
"timeout",
"=",
"tim... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.create_snippet | API call to create a Snippet | sendwithus/__init__.py | def create_snippet(self, name, body, timeout=None):
""" API call to create a Snippet """
payload = {
'name': name,
'body': body
}
return self._api_request(
self.SNIPPETS_ENDPOINT,
self.HTTP_POST,
payload=payload,
tim... | def create_snippet(self, name, body, timeout=None):
""" API call to create a Snippet """
payload = {
'name': name,
'body': body
}
return self._api_request(
self.SNIPPETS_ENDPOINT,
self.HTTP_POST,
payload=payload,
tim... | [
"API",
"call",
"to",
"create",
"a",
"Snippet"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L396-L407 | [
"def",
"create_snippet",
"(",
"self",
",",
"name",
",",
"body",
",",
"timeout",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'name'",
":",
"name",
",",
"'body'",
":",
"body",
"}",
"return",
"self",
".",
"_api_request",
"(",
"self",
".",
"SNIPPETS_ENDPO... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api._make_file_dict | Make a dictionary with filename and base64 file data | sendwithus/__init__.py | def _make_file_dict(self, f):
"""Make a dictionary with filename and base64 file data"""
if isinstance(f, dict):
file_obj = f['file']
if 'filename' in f:
file_name = f['filename']
else:
file_name = file_obj.name
else:
... | def _make_file_dict(self, f):
"""Make a dictionary with filename and base64 file data"""
if isinstance(f, dict):
file_obj = f['file']
if 'filename' in f:
file_name = f['filename']
else:
file_name = file_obj.name
else:
... | [
"Make",
"a",
"dictionary",
"with",
"filename",
"and",
"base64",
"file",
"data"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L452-L468 | [
"def",
"_make_file_dict",
"(",
"self",
",",
"f",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"dict",
")",
":",
"file_obj",
"=",
"f",
"[",
"'file'",
"]",
"if",
"'filename'",
"in",
"f",
":",
"file_name",
"=",
"f",
"[",
"'filename'",
"]",
"else",
":"... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | api.send | API call to send an email | sendwithus/__init__.py | def send(
self,
email_id,
recipient,
email_data=None,
sender=None,
cc=None,
bcc=None,
tags=[],
headers={},
esp_account=None,
locale=None,
email_version_name=None,
inline=None,
files=[],
timeout=None
... | def send(
self,
email_id,
recipient,
email_data=None,
sender=None,
cc=None,
bcc=None,
tags=[],
headers={},
esp_account=None,
locale=None,
email_version_name=None,
inline=None,
files=[],
timeout=None
... | [
"API",
"call",
"to",
"send",
"an",
"email"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L470-L566 | [
"def",
"send",
"(",
"self",
",",
"email_id",
",",
"recipient",
",",
"email_data",
"=",
"None",
",",
"sender",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"tags",
"=",
"[",
"]",
",",
"headers",
"=",
"{",
"}",
",",
"esp_accou... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | BatchAPI._api_request | Private method for api requests | sendwithus/__init__.py | def _api_request(self, endpoint, http_method, *args, **kwargs):
"""Private method for api requests"""
logger.debug(' > Queing batch api request for endpoint: %s' % endpoint)
path = self._build_request_path(endpoint, absolute=False)
logger.debug('\tpath: %s' % path)
data = None
... | def _api_request(self, endpoint, http_method, *args, **kwargs):
"""Private method for api requests"""
logger.debug(' > Queing batch api request for endpoint: %s' % endpoint)
path = self._build_request_path(endpoint, absolute=False)
logger.debug('\tpath: %s' % path)
data = None
... | [
"Private",
"method",
"for",
"api",
"requests"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L755-L774 | [
"def",
"_api_request",
"(",
"self",
",",
"endpoint",
",",
"http_method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"' > Queing batch api request for endpoint: %s'",
"%",
"endpoint",
")",
"path",
"=",
"self",
".",
"_bui... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | BatchAPI.execute | Execute all currently queued batch commands | sendwithus/__init__.py | def execute(self, timeout=None):
"""Execute all currently queued batch commands"""
logger.debug(' > Batch API request (length %s)' % len(self._commands))
auth = self._build_http_auth()
headers = self._build_request_headers()
logger.debug('\tbatch headers: %s' % headers)
... | def execute(self, timeout=None):
"""Execute all currently queued batch commands"""
logger.debug(' > Batch API request (length %s)' % len(self._commands))
auth = self._build_http_auth()
headers = self._build_request_headers()
logger.debug('\tbatch headers: %s' % headers)
... | [
"Execute",
"all",
"currently",
"queued",
"batch",
"commands"
] | sendwithus/sendwithus_python | python | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L776-L806 | [
"def",
"execute",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"' > Batch API request (length %s)'",
"%",
"len",
"(",
"self",
".",
"_commands",
")",
")",
"auth",
"=",
"self",
".",
"_build_http_auth",
"(",
")",
"headers",... | 8ae50d514febd44f7d9be3c838b4d92f99412832 |
valid | TabView.get_group_tabs | Return instances of all other tabs that are members of the tab's
tab group. | tabination/views.py | def get_group_tabs(self):
"""
Return instances of all other tabs that are members of the tab's
tab group.
"""
if self.tab_group is None:
raise ImproperlyConfigured(
"%s requires a definition of 'tab_group'" %
self.__class__.__name__)
... | def get_group_tabs(self):
"""
Return instances of all other tabs that are members of the tab's
tab group.
"""
if self.tab_group is None:
raise ImproperlyConfigured(
"%s requires a definition of 'tab_group'" %
self.__class__.__name__)
... | [
"Return",
"instances",
"of",
"all",
"other",
"tabs",
"that",
"are",
"members",
"of",
"the",
"tab",
"s",
"tab",
"group",
"."
] | dbrgn/django-tabination | python | https://github.com/dbrgn/django-tabination/blob/95c03a5e04e60641afef5520e8a87d20cbf1e821/tabination/views.py#L71-L81 | [
"def",
"get_group_tabs",
"(",
"self",
")",
":",
"if",
"self",
".",
"tab_group",
"is",
"None",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"%s requires a definition of 'tab_group'\"",
"%",
"self",
".",
"__class__",
".",
"__name__",
")",
"group_members",
"=",
"[",
... | 95c03a5e04e60641afef5520e8a87d20cbf1e821 |
valid | TabView._process_tabs | Process and prepare tabs.
This includes steps like updating references to the current tab,
filtering out hidden tabs, sorting tabs etc...
Args:
tabs:
The list of tabs to process.
current_tab:
The reference to the currently loaded tab.
... | tabination/views.py | def _process_tabs(self, tabs, current_tab, group_current_tab):
"""
Process and prepare tabs.
This includes steps like updating references to the current tab,
filtering out hidden tabs, sorting tabs etc...
Args:
tabs:
The list of tabs to process.
... | def _process_tabs(self, tabs, current_tab, group_current_tab):
"""
Process and prepare tabs.
This includes steps like updating references to the current tab,
filtering out hidden tabs, sorting tabs etc...
Args:
tabs:
The list of tabs to process.
... | [
"Process",
"and",
"prepare",
"tabs",
"."
] | dbrgn/django-tabination | python | https://github.com/dbrgn/django-tabination/blob/95c03a5e04e60641afef5520e8a87d20cbf1e821/tabination/views.py#L94-L125 | [
"def",
"_process_tabs",
"(",
"self",
",",
"tabs",
",",
"current_tab",
",",
"group_current_tab",
")",
":",
"# Update references to the current tab",
"for",
"t",
"in",
"tabs",
":",
"t",
".",
"current_tab",
"=",
"current_tab",
"t",
".",
"group_current_tab",
"=",
"g... | 95c03a5e04e60641afef5520e8a87d20cbf1e821 |
valid | TabView.get_context_data | Adds tab information to context.
To retrieve a list of all group tab instances, use
``{{ tabs }}`` in your template.
The id of the current tab is added as ``current_tab_id`` to the
template context.
If the current tab has a parent tab the parent's id is added to
the te... | tabination/views.py | def get_context_data(self, **kwargs):
"""
Adds tab information to context.
To retrieve a list of all group tab instances, use
``{{ tabs }}`` in your template.
The id of the current tab is added as ``current_tab_id`` to the
template context.
If the current tab h... | def get_context_data(self, **kwargs):
"""
Adds tab information to context.
To retrieve a list of all group tab instances, use
``{{ tabs }}`` in your template.
The id of the current tab is added as ``current_tab_id`` to the
template context.
If the current tab h... | [
"Adds",
"tab",
"information",
"to",
"context",
"."
] | dbrgn/django-tabination | python | https://github.com/dbrgn/django-tabination/blob/95c03a5e04e60641afef5520e8a87d20cbf1e821/tabination/views.py#L127-L187 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"TabView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"# Update the context with kwargs, TemplateView doesn't do this.",
"context... | 95c03a5e04e60641afef5520e8a87d20cbf1e821 |
valid | normalize_name | Convert a string into a valid python attribute name.
This function is called to convert ASCII strings to something that can pass as
python attribute name, to be used with namedtuples.
>>> str(normalize_name('class'))
'class_'
>>> str(normalize_name('a-name'))
'a_name'
>>> str(normalize_name... | src/csvw/utils.py | def normalize_name(s):
"""Convert a string into a valid python attribute name.
This function is called to convert ASCII strings to something that can pass as
python attribute name, to be used with namedtuples.
>>> str(normalize_name('class'))
'class_'
>>> str(normalize_name('a-name'))
'a_na... | def normalize_name(s):
"""Convert a string into a valid python attribute name.
This function is called to convert ASCII strings to something that can pass as
python attribute name, to be used with namedtuples.
>>> str(normalize_name('class'))
'class_'
>>> str(normalize_name('a-name'))
'a_na... | [
"Convert",
"a",
"string",
"into",
"a",
"valid",
"python",
"attribute",
"name",
".",
"This",
"function",
"is",
"called",
"to",
"convert",
"ASCII",
"strings",
"to",
"something",
"that",
"can",
"pass",
"as",
"python",
"attribute",
"name",
"to",
"be",
"used",
... | cldf/csvw | python | https://github.com/cldf/csvw/blob/181c94b6c599575945e52d370a415f12f3433eab/src/csvw/utils.py#L86-L112 | [
"def",
"normalize_name",
"(",
"s",
")",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
".",
"replace",
"(",
"'.'",
",",
"'_'",
")",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
"if",
"s",
"in",
"keyword",
".",
"kwlist",
":",
... | 181c94b6c599575945e52d370a415f12f3433eab |
valid | schema | Convert the table and column descriptions of a `TableGroup` into specifications for the
DB schema.
:param ds:
:return: A pair (tables, reference_tables). | src/csvw/db.py | def schema(tg):
"""
Convert the table and column descriptions of a `TableGroup` into specifications for the
DB schema.
:param ds:
:return: A pair (tables, reference_tables).
"""
tables = {}
for tname, table in tg.tabledict.items():
t = TableSpec.from_table_metadata(table)
... | def schema(tg):
"""
Convert the table and column descriptions of a `TableGroup` into specifications for the
DB schema.
:param ds:
:return: A pair (tables, reference_tables).
"""
tables = {}
for tname, table in tg.tabledict.items():
t = TableSpec.from_table_metadata(table)
... | [
"Convert",
"the",
"table",
"and",
"column",
"descriptions",
"of",
"a",
"TableGroup",
"into",
"specifications",
"for",
"the",
"DB",
"schema",
"."
] | cldf/csvw | python | https://github.com/cldf/csvw/blob/181c94b6c599575945e52d370a415f12f3433eab/src/csvw/db.py#L235-L266 | [
"def",
"schema",
"(",
"tg",
")",
":",
"tables",
"=",
"{",
"}",
"for",
"tname",
",",
"table",
"in",
"tg",
".",
"tabledict",
".",
"items",
"(",
")",
":",
"t",
"=",
"TableSpec",
".",
"from_table_metadata",
"(",
"table",
")",
"tables",
"[",
"t",
".",
... | 181c94b6c599575945e52d370a415f12f3433eab |
valid | Database.write | Creates a db file with the core schema.
:param force: If `True` an existing db file will be overwritten. | src/csvw/db.py | def write(self, _force=False, _exists_ok=False, **items):
"""
Creates a db file with the core schema.
:param force: If `True` an existing db file will be overwritten.
"""
if self.fname and self.fname.exists():
raise ValueError('db file already exists, use force=True ... | def write(self, _force=False, _exists_ok=False, **items):
"""
Creates a db file with the core schema.
:param force: If `True` an existing db file will be overwritten.
"""
if self.fname and self.fname.exists():
raise ValueError('db file already exists, use force=True ... | [
"Creates",
"a",
"db",
"file",
"with",
"the",
"core",
"schema",
"."
] | cldf/csvw | python | https://github.com/cldf/csvw/blob/181c94b6c599575945e52d370a415f12f3433eab/src/csvw/db.py#L373-L424 | [
"def",
"write",
"(",
"self",
",",
"_force",
"=",
"False",
",",
"_exists_ok",
"=",
"False",
",",
"*",
"*",
"items",
")",
":",
"if",
"self",
".",
"fname",
"and",
"self",
".",
"fname",
".",
"exists",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'db fil... | 181c94b6c599575945e52d370a415f12f3433eab |
valid | iterrows | Convenience factory function for csv reader.
:param lines_or_file: Content to be read. Either a file handle, a file path or a list\
of strings.
:param namedtuples: Yield namedtuples.
:param dicts: Yield dicts.
:param encoding: Encoding of the content.
:param kw: Keyword parameters are passed th... | src/csvw/dsv.py | def iterrows(lines_or_file, namedtuples=False, dicts=False, encoding='utf-8', **kw):
"""Convenience factory function for csv reader.
:param lines_or_file: Content to be read. Either a file handle, a file path or a list\
of strings.
:param namedtuples: Yield namedtuples.
:param dicts: Yield dicts.
... | def iterrows(lines_or_file, namedtuples=False, dicts=False, encoding='utf-8', **kw):
"""Convenience factory function for csv reader.
:param lines_or_file: Content to be read. Either a file handle, a file path or a list\
of strings.
:param namedtuples: Yield namedtuples.
:param dicts: Yield dicts.
... | [
"Convenience",
"factory",
"function",
"for",
"csv",
"reader",
"."
] | cldf/csvw | python | https://github.com/cldf/csvw/blob/181c94b6c599575945e52d370a415f12f3433eab/src/csvw/dsv.py#L333-L355 | [
"def",
"iterrows",
"(",
"lines_or_file",
",",
"namedtuples",
"=",
"False",
",",
"dicts",
"=",
"False",
",",
"encoding",
"=",
"'utf-8'",
",",
"*",
"*",
"kw",
")",
":",
"if",
"namedtuples",
"and",
"dicts",
":",
"raise",
"ValueError",
"(",
"'either namedtuple... | 181c94b6c599575945e52d370a415f12f3433eab |
valid | rewrite | Utility function to rewrite rows in tsv files.
:param fname: Path of the dsv file to operate on.
:param visitor: A callable that takes a line-number and a row as input and returns a \
(modified) row or None to filter out the row.
:param kw: Keyword parameters are passed through to csv.reader/csv.writer... | src/csvw/dsv.py | def rewrite(fname, visitor, **kw):
"""Utility function to rewrite rows in tsv files.
:param fname: Path of the dsv file to operate on.
:param visitor: A callable that takes a line-number and a row as input and returns a \
(modified) row or None to filter out the row.
:param kw: Keyword parameters a... | def rewrite(fname, visitor, **kw):
"""Utility function to rewrite rows in tsv files.
:param fname: Path of the dsv file to operate on.
:param visitor: A callable that takes a line-number and a row as input and returns a \
(modified) row or None to filter out the row.
:param kw: Keyword parameters a... | [
"Utility",
"function",
"to",
"rewrite",
"rows",
"in",
"tsv",
"files",
"."
] | cldf/csvw | python | https://github.com/cldf/csvw/blob/181c94b6c599575945e52d370a415f12f3433eab/src/csvw/dsv.py#L361-L383 | [
"def",
"rewrite",
"(",
"fname",
",",
"visitor",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"isinstance",
"(",
"fname",
",",
"pathlib",
".",
"Path",
")",
":",
"assert",
"isinstance",
"(",
"fname",
",",
"string_types",
")",
"fname",
"=",
"pathlib",
".... | 181c94b6c599575945e52d370a415f12f3433eab |
valid | filter_rows_as_dict | Rewrite a dsv file, filtering the rows.
:param fname: Path to dsv file
:param filter_: callable which accepts a `dict` with a row's data as single argument\
returning a `Boolean` indicating whether to keep the row (`True`) or to discard it \
`False`.
:param kw: Keyword arguments to be passed `Unico... | src/csvw/dsv.py | def filter_rows_as_dict(fname, filter_, **kw):
"""Rewrite a dsv file, filtering the rows.
:param fname: Path to dsv file
:param filter_: callable which accepts a `dict` with a row's data as single argument\
returning a `Boolean` indicating whether to keep the row (`True`) or to discard it \
`False`... | def filter_rows_as_dict(fname, filter_, **kw):
"""Rewrite a dsv file, filtering the rows.
:param fname: Path to dsv file
:param filter_: callable which accepts a `dict` with a row's data as single argument\
returning a `Boolean` indicating whether to keep the row (`True`) or to discard it \
`False`... | [
"Rewrite",
"a",
"dsv",
"file",
"filtering",
"the",
"rows",
"."
] | cldf/csvw | python | https://github.com/cldf/csvw/blob/181c94b6c599575945e52d370a415f12f3433eab/src/csvw/dsv.py#L402-L414 | [
"def",
"filter_rows_as_dict",
"(",
"fname",
",",
"filter_",
",",
"*",
"*",
"kw",
")",
":",
"filter_",
"=",
"DictFilter",
"(",
"filter_",
")",
"rewrite",
"(",
"fname",
",",
"filter_",
",",
"*",
"*",
"kw",
")",
"return",
"filter_",
".",
"removed"
] | 181c94b6c599575945e52d370a415f12f3433eab |
valid | dump_grid | Dump a single grid to its ZINC representation. | hszinc/zincdumper.py | def dump_grid(grid):
"""
Dump a single grid to its ZINC representation.
"""
header = 'ver:%s' % dump_str(str(grid._version), version=grid._version)
if bool(grid.metadata):
header += ' ' + dump_meta(grid.metadata, version=grid._version)
columns = dump_columns(grid.column, version=grid._ve... | def dump_grid(grid):
"""
Dump a single grid to its ZINC representation.
"""
header = 'ver:%s' % dump_str(str(grid._version), version=grid._version)
if bool(grid.metadata):
header += ' ' + dump_meta(grid.metadata, version=grid._version)
columns = dump_columns(grid.column, version=grid._ve... | [
"Dump",
"a",
"single",
"grid",
"to",
"its",
"ZINC",
"representation",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/zincdumper.py#L41-L50 | [
"def",
"dump_grid",
"(",
"grid",
")",
":",
"header",
"=",
"'ver:%s'",
"%",
"dump_str",
"(",
"str",
"(",
"grid",
".",
"_version",
")",
",",
"version",
"=",
"grid",
".",
"_version",
")",
"if",
"bool",
"(",
"grid",
".",
"metadata",
")",
":",
"header",
... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | parse | Parse the given Zinc text and return the equivalent data. | hszinc/parser.py | def parse(grid_str, mode=MODE_ZINC, charset='utf-8'):
'''
Parse the given Zinc text and return the equivalent data.
'''
# Decode incoming text (or python3 will whine!)
if isinstance(grid_str, six.binary_type):
grid_str = grid_str.decode(encoding=charset)
# Split the separate grids up, t... | def parse(grid_str, mode=MODE_ZINC, charset='utf-8'):
'''
Parse the given Zinc text and return the equivalent data.
'''
# Decode incoming text (or python3 will whine!)
if isinstance(grid_str, six.binary_type):
grid_str = grid_str.decode(encoding=charset)
# Split the separate grids up, t... | [
"Parse",
"the",
"given",
"Zinc",
"text",
"and",
"return",
"the",
"equivalent",
"data",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/parser.py#L25-L48 | [
"def",
"parse",
"(",
"grid_str",
",",
"mode",
"=",
"MODE_ZINC",
",",
"charset",
"=",
"'utf-8'",
")",
":",
"# Decode incoming text (or python3 will whine!)",
"if",
"isinstance",
"(",
"grid_str",
",",
"six",
".",
"binary_type",
")",
":",
"grid_str",
"=",
"grid_str... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | MetadataObject.append | Append the item to the metadata. | hszinc/metadata.py | def append(self, key, value=MARKER, replace=True):
'''
Append the item to the metadata.
'''
return self.add_item(key, value, replace=replace) | def append(self, key, value=MARKER, replace=True):
'''
Append the item to the metadata.
'''
return self.add_item(key, value, replace=replace) | [
"Append",
"the",
"item",
"to",
"the",
"metadata",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/metadata.py#L16-L20 | [
"def",
"append",
"(",
"self",
",",
"key",
",",
"value",
"=",
"MARKER",
",",
"replace",
"=",
"True",
")",
":",
"return",
"self",
".",
"add_item",
"(",
"key",
",",
"value",
",",
"replace",
"=",
"replace",
")"
] | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | MetadataObject.extend | Append the items to the metadata. | hszinc/metadata.py | def extend(self, items, replace=True):
'''
Append the items to the metadata.
'''
if isinstance(items, dict) or isinstance(items, SortableDict):
items = list(items.items())
for (key, value) in items:
self.append(key, value, replace=replace) | def extend(self, items, replace=True):
'''
Append the items to the metadata.
'''
if isinstance(items, dict) or isinstance(items, SortableDict):
items = list(items.items())
for (key, value) in items:
self.append(key, value, replace=replace) | [
"Append",
"the",
"items",
"to",
"the",
"metadata",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/metadata.py#L22-L30 | [
"def",
"extend",
"(",
"self",
",",
"items",
",",
"replace",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"items",
",",
"dict",
")",
"or",
"isinstance",
"(",
"items",
",",
"SortableDict",
")",
":",
"items",
"=",
"list",
"(",
"items",
".",
"items",
... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | Shape.regular_polygon | Construct a regular polygon.
Parameters
----------
center : array-like
radius : float
n_vertices : int
start_angle : float, optional
Where to put the first point, relative to `center`,
in radians counter-clockwise starting from the horizontal axis... | src/pyglet2d.py | def regular_polygon(cls, center, radius, n_vertices, start_angle=0, **kwargs):
"""Construct a regular polygon.
Parameters
----------
center : array-like
radius : float
n_vertices : int
start_angle : float, optional
Where to put the first point, relati... | def regular_polygon(cls, center, radius, n_vertices, start_angle=0, **kwargs):
"""Construct a regular polygon.
Parameters
----------
center : array-like
radius : float
n_vertices : int
start_angle : float, optional
Where to put the first point, relati... | [
"Construct",
"a",
"regular",
"polygon",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L89-L105 | [
"def",
"regular_polygon",
"(",
"cls",
",",
"center",
",",
"radius",
",",
"n_vertices",
",",
"start_angle",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"angles",
"=",
"(",
"np",
".",
"arange",
"(",
"n_vertices",
")",
"*",
"2",
"*",
"np",
".",
"pi",... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.circle | Construct a circle.
Parameters
----------
center : array-like
radius : float
n_vertices : int, optional
Number of points to draw.
Decrease for performance, increase for appearance.
kwargs
Other keyword arguments are passed to the |Shap... | src/pyglet2d.py | def circle(cls, center, radius, n_vertices=50, **kwargs):
"""Construct a circle.
Parameters
----------
center : array-like
radius : float
n_vertices : int, optional
Number of points to draw.
Decrease for performance, increase for appearance.
... | def circle(cls, center, radius, n_vertices=50, **kwargs):
"""Construct a circle.
Parameters
----------
center : array-like
radius : float
n_vertices : int, optional
Number of points to draw.
Decrease for performance, increase for appearance.
... | [
"Construct",
"a",
"circle",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L108-L122 | [
"def",
"circle",
"(",
"cls",
",",
"center",
",",
"radius",
",",
"n_vertices",
"=",
"50",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"cls",
".",
"regular_polygon",
"(",
"center",
",",
"radius",
",",
"n_vertices",
",",
"*",
"*",
"kwargs",
")"
] | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.rectangle | Shortcut for creating a rectangle aligned with the screen axes from only two corners.
Parameters
----------
vertices : array-like
An array containing the ``[x, y]`` positions of two corners.
kwargs
Other keyword arguments are passed to the |Shape| constructor. | src/pyglet2d.py | def rectangle(cls, vertices, **kwargs):
"""Shortcut for creating a rectangle aligned with the screen axes from only two corners.
Parameters
----------
vertices : array-like
An array containing the ``[x, y]`` positions of two corners.
kwargs
Other keyword ... | def rectangle(cls, vertices, **kwargs):
"""Shortcut for creating a rectangle aligned with the screen axes from only two corners.
Parameters
----------
vertices : array-like
An array containing the ``[x, y]`` positions of two corners.
kwargs
Other keyword ... | [
"Shortcut",
"for",
"creating",
"a",
"rectangle",
"aligned",
"with",
"the",
"screen",
"axes",
"from",
"only",
"two",
"corners",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L125-L139 | [
"def",
"rectangle",
"(",
"cls",
",",
"vertices",
",",
"*",
"*",
"kwargs",
")",
":",
"bottom_left",
",",
"top_right",
"=",
"vertices",
"top_left",
"=",
"[",
"bottom_left",
"[",
"0",
"]",
",",
"top_right",
"[",
"1",
"]",
"]",
"bottom_right",
"=",
"[",
... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.from_dict | Create a |Shape| from a dictionary specification.
Parameters
----------
spec : dict
A dictionary with either the fields ``'center'`` and ``'radius'`` (for a circle),
``'center'``, ``'radius'``, and ``'n_vertices'`` (for a regular polygon),
or ``'vertices'``.
... | src/pyglet2d.py | def from_dict(cls, spec):
"""Create a |Shape| from a dictionary specification.
Parameters
----------
spec : dict
A dictionary with either the fields ``'center'`` and ``'radius'`` (for a circle),
``'center'``, ``'radius'``, and ``'n_vertices'`` (for a regular poly... | def from_dict(cls, spec):
"""Create a |Shape| from a dictionary specification.
Parameters
----------
spec : dict
A dictionary with either the fields ``'center'`` and ``'radius'`` (for a circle),
``'center'``, ``'radius'``, and ``'n_vertices'`` (for a regular poly... | [
"Create",
"a",
"|Shape|",
"from",
"a",
"dictionary",
"specification",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L142-L165 | [
"def",
"from_dict",
"(",
"cls",
",",
"spec",
")",
":",
"spec",
"=",
"spec",
".",
"copy",
"(",
")",
"center",
"=",
"spec",
".",
"pop",
"(",
"'center'",
",",
"None",
")",
"radius",
"=",
"spec",
".",
"pop",
"(",
"'radius'",
",",
"None",
")",
"if",
... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape._kwargs | Keyword arguments for recreating the Shape from the vertices. | src/pyglet2d.py | def _kwargs(self):
"""Keyword arguments for recreating the Shape from the vertices.
"""
return dict(color=self.color, velocity=self.velocity, colors=self.colors) | def _kwargs(self):
"""Keyword arguments for recreating the Shape from the vertices.
"""
return dict(color=self.color, velocity=self.velocity, colors=self.colors) | [
"Keyword",
"arguments",
"for",
"recreating",
"the",
"Shape",
"from",
"the",
"vertices",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L186-L190 | [
"def",
"_kwargs",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"color",
"=",
"self",
".",
"color",
",",
"velocity",
"=",
"self",
".",
"velocity",
",",
"colors",
"=",
"self",
".",
"colors",
")"
] | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.scale | Resize the shape by a proportion (e.g., 1 is unchanged), in-place.
Parameters
----------
factor : float or array-like
If a scalar, the same factor will be applied in the x and y dimensions.
center : array-like, optional
Point around which to perform the scaling.
... | src/pyglet2d.py | def scale(self, factor, center=None):
"""Resize the shape by a proportion (e.g., 1 is unchanged), in-place.
Parameters
----------
factor : float or array-like
If a scalar, the same factor will be applied in the x and y dimensions.
center : array-like, optional
... | def scale(self, factor, center=None):
"""Resize the shape by a proportion (e.g., 1 is unchanged), in-place.
Parameters
----------
factor : float or array-like
If a scalar, the same factor will be applied in the x and y dimensions.
center : array-like, optional
... | [
"Resize",
"the",
"shape",
"by",
"a",
"proportion",
"(",
"e",
".",
"g",
".",
"1",
"is",
"unchanged",
")",
"in",
"-",
"place",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L230-L252 | [
"def",
"scale",
"(",
"self",
",",
"factor",
",",
"center",
"=",
"None",
")",
":",
"factor",
"=",
"np",
".",
"asarray",
"(",
"factor",
")",
"if",
"len",
"(",
"factor",
".",
"shape",
")",
":",
"args",
"=",
"list",
"(",
"factor",
")",
"else",
":",
... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.rotate | Rotate the shape, in-place.
Parameters
----------
angle : float
Angle to rotate, in radians counter-clockwise.
center : array-like, optional
Point about which to rotate.
If not passed, the center of the shape will be used. | src/pyglet2d.py | def rotate(self, angle, center=None):
"""Rotate the shape, in-place.
Parameters
----------
angle : float
Angle to rotate, in radians counter-clockwise.
center : array-like, optional
Point about which to rotate.
If not passed, the center of the... | def rotate(self, angle, center=None):
"""Rotate the shape, in-place.
Parameters
----------
angle : float
Angle to rotate, in radians counter-clockwise.
center : array-like, optional
Point about which to rotate.
If not passed, the center of the... | [
"Rotate",
"the",
"shape",
"in",
"-",
"place",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L264-L280 | [
"def",
"rotate",
"(",
"self",
",",
"angle",
",",
"center",
"=",
"None",
")",
":",
"args",
"=",
"[",
"angle",
"]",
"if",
"center",
"is",
"not",
"None",
":",
"args",
".",
"extend",
"(",
"center",
")",
"self",
".",
"poly",
".",
"rotate",
"(",
"*",
... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.flip_x | Flip the shape in the x direction, in-place.
Parameters
----------
center : array-like, optional
Point about which to flip.
If not passed, the center of the shape will be used. | src/pyglet2d.py | def flip_x(self, center=None):
"""Flip the shape in the x direction, in-place.
Parameters
----------
center : array-like, optional
Point about which to flip.
If not passed, the center of the shape will be used.
"""
if center is None:
... | def flip_x(self, center=None):
"""Flip the shape in the x direction, in-place.
Parameters
----------
center : array-like, optional
Point about which to flip.
If not passed, the center of the shape will be used.
"""
if center is None:
... | [
"Flip",
"the",
"shape",
"in",
"the",
"x",
"direction",
"in",
"-",
"place",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L282-L295 | [
"def",
"flip_x",
"(",
"self",
",",
"center",
"=",
"None",
")",
":",
"if",
"center",
"is",
"None",
":",
"self",
".",
"poly",
".",
"flip",
"(",
")",
"else",
":",
"self",
".",
"poly",
".",
"flip",
"(",
"center",
"[",
"0",
"]",
")"
] | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.flip_y | Flip the shape in the y direction, in-place.
Parameters
----------
center : array-like, optional
Point about which to flip.
If not passed, the center of the shape will be used. | src/pyglet2d.py | def flip_y(self, center=None):
"""Flip the shape in the y direction, in-place.
Parameters
----------
center : array-like, optional
Point about which to flip.
If not passed, the center of the shape will be used.
"""
if center is None:
... | def flip_y(self, center=None):
"""Flip the shape in the y direction, in-place.
Parameters
----------
center : array-like, optional
Point about which to flip.
If not passed, the center of the shape will be used.
"""
if center is None:
... | [
"Flip",
"the",
"shape",
"in",
"the",
"y",
"direction",
"in",
"-",
"place",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L297-L311 | [
"def",
"flip_y",
"(",
"self",
",",
"center",
"=",
"None",
")",
":",
"if",
"center",
"is",
"None",
":",
"self",
".",
"poly",
".",
"flop",
"(",
")",
"else",
":",
"self",
".",
"poly",
".",
"flop",
"(",
"center",
"[",
"1",
"]",
")",
"return",
"self... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.flip | Flip the shape in an arbitrary direction.
Parameters
----------
angle : array-like
The angle, in radians counter-clockwise from the horizontal axis,
defining the angle about which to flip the shape (of a line through `center`).
center : array-like, optional
... | src/pyglet2d.py | def flip(self, angle, center=None):
""" Flip the shape in an arbitrary direction.
Parameters
----------
angle : array-like
The angle, in radians counter-clockwise from the horizontal axis,
defining the angle about which to flip the shape (of a line through `cente... | def flip(self, angle, center=None):
""" Flip the shape in an arbitrary direction.
Parameters
----------
angle : array-like
The angle, in radians counter-clockwise from the horizontal axis,
defining the angle about which to flip the shape (of a line through `cente... | [
"Flip",
"the",
"shape",
"in",
"an",
"arbitrary",
"direction",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L313-L326 | [
"def",
"flip",
"(",
"self",
",",
"angle",
",",
"center",
"=",
"None",
")",
":",
"return",
"self",
".",
"rotate",
"(",
"-",
"angle",
",",
"center",
"=",
"center",
")",
".",
"flip_y",
"(",
"center",
"=",
"center",
")",
".",
"rotate",
"(",
"angle",
... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.draw | Draw the shape in the current OpenGL context. | src/pyglet2d.py | def draw(self):
"""Draw the shape in the current OpenGL context.
"""
if self.enabled:
self._vertex_list.colors = self._gl_colors
self._vertex_list.vertices = self._gl_vertices
self._vertex_list.draw(pyglet.gl.GL_TRIANGLES) | def draw(self):
"""Draw the shape in the current OpenGL context.
"""
if self.enabled:
self._vertex_list.colors = self._gl_colors
self._vertex_list.vertices = self._gl_vertices
self._vertex_list.draw(pyglet.gl.GL_TRIANGLES) | [
"Draw",
"the",
"shape",
"in",
"the",
"current",
"OpenGL",
"context",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L336-L343 | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"self",
".",
"enabled",
":",
"self",
".",
"_vertex_list",
".",
"colors",
"=",
"self",
".",
"_gl_colors",
"self",
".",
"_vertex_list",
".",
"vertices",
"=",
"self",
".",
"_gl_vertices",
"self",
".",
"_vertex_lis... | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | Shape.update | Update the shape's position by moving it forward according to its velocity.
Parameters
----------
dt : float | src/pyglet2d.py | def update(self, dt):
"""Update the shape's position by moving it forward according to its velocity.
Parameters
----------
dt : float
"""
self.translate(dt * self.velocity)
self.rotate(dt * self.angular_velocity) | def update(self, dt):
"""Update the shape's position by moving it forward according to its velocity.
Parameters
----------
dt : float
"""
self.translate(dt * self.velocity)
self.rotate(dt * self.angular_velocity) | [
"Update",
"the",
"shape",
"s",
"position",
"by",
"moving",
"it",
"forward",
"according",
"to",
"its",
"velocity",
"."
] | hsharrison/pyglet2d | python | https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L345-L354 | [
"def",
"update",
"(",
"self",
",",
"dt",
")",
":",
"self",
".",
"translate",
"(",
"dt",
"*",
"self",
".",
"velocity",
")",
"self",
".",
"rotate",
"(",
"dt",
"*",
"self",
".",
"angular_velocity",
")"
] | 46f610b3c76221bff19e5c0cf3d35d7875ce37a0 |
valid | _map_timezones | Map the official Haystack timezone list to those recognised by pytz. | hszinc/zoneinfo.py | def _map_timezones():
"""
Map the official Haystack timezone list to those recognised by pytz.
"""
tz_map = {}
todo = HAYSTACK_TIMEZONES_SET.copy()
for full_tz in pytz.all_timezones:
# Finished case:
if not bool(todo): # pragma: no cover
# This is nearly impossible fo... | def _map_timezones():
"""
Map the official Haystack timezone list to those recognised by pytz.
"""
tz_map = {}
todo = HAYSTACK_TIMEZONES_SET.copy()
for full_tz in pytz.all_timezones:
# Finished case:
if not bool(todo): # pragma: no cover
# This is nearly impossible fo... | [
"Map",
"the",
"official",
"Haystack",
"timezone",
"list",
"to",
"those",
"recognised",
"by",
"pytz",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/zoneinfo.py#L406-L438 | [
"def",
"_map_timezones",
"(",
")",
":",
"tz_map",
"=",
"{",
"}",
"todo",
"=",
"HAYSTACK_TIMEZONES_SET",
".",
"copy",
"(",
")",
"for",
"full_tz",
"in",
"pytz",
".",
"all_timezones",
":",
"# Finished case:",
"if",
"not",
"bool",
"(",
"todo",
")",
":",
"# p... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | timezone | Retrieve the Haystack timezone | hszinc/zoneinfo.py | def timezone(haystack_tz, version=LATEST_VER):
"""
Retrieve the Haystack timezone
"""
tz_map = get_tz_map(version=version)
try:
tz_name = tz_map[haystack_tz]
except KeyError:
raise ValueError('%s is not a recognised timezone on this host' \
% haystack_tz)
retu... | def timezone(haystack_tz, version=LATEST_VER):
"""
Retrieve the Haystack timezone
"""
tz_map = get_tz_map(version=version)
try:
tz_name = tz_map[haystack_tz]
except KeyError:
raise ValueError('%s is not a recognised timezone on this host' \
% haystack_tz)
retu... | [
"Retrieve",
"the",
"Haystack",
"timezone"
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/zoneinfo.py#L461-L471 | [
"def",
"timezone",
"(",
"haystack_tz",
",",
"version",
"=",
"LATEST_VER",
")",
":",
"tz_map",
"=",
"get_tz_map",
"(",
"version",
"=",
"version",
")",
"try",
":",
"tz_name",
"=",
"tz_map",
"[",
"haystack_tz",
"]",
"except",
"KeyError",
":",
"raise",
"ValueE... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | timezone_name | Determine an appropriate timezone for the given date/time object | hszinc/zoneinfo.py | def timezone_name(dt, version=LATEST_VER):
"""
Determine an appropriate timezone for the given date/time object
"""
tz_rmap = get_tz_rmap(version=version)
if dt.tzinfo is None:
raise ValueError('%r has no timezone' % dt)
# Easy case: pytz timezone.
try:
tz_name = dt.tzinfo.z... | def timezone_name(dt, version=LATEST_VER):
"""
Determine an appropriate timezone for the given date/time object
"""
tz_rmap = get_tz_rmap(version=version)
if dt.tzinfo is None:
raise ValueError('%r has no timezone' % dt)
# Easy case: pytz timezone.
try:
tz_name = dt.tzinfo.z... | [
"Determine",
"an",
"appropriate",
"timezone",
"for",
"the",
"given",
"date",
"/",
"time",
"object"
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/zoneinfo.py#L473-L506 | [
"def",
"timezone_name",
"(",
"dt",
",",
"version",
"=",
"LATEST_VER",
")",
":",
"tz_rmap",
"=",
"get_tz_rmap",
"(",
"version",
"=",
"version",
")",
"if",
"dt",
".",
"tzinfo",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'%r has no timezone'",
"%",
"dt",... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | _unescape | Iterative parser for string escapes. | hszinc/zincparser.py | def _unescape(s, uri=False):
"""
Iterative parser for string escapes.
"""
out = ''
while len(s) > 0:
c = s[0]
if c == '\\':
# Backslash escape
esc_c = s[1]
if esc_c in ('u', 'U'):
# Unicode escape
out += six.unichr(... | def _unescape(s, uri=False):
"""
Iterative parser for string escapes.
"""
out = ''
while len(s) > 0:
c = s[0]
if c == '\\':
# Backslash escape
esc_c = s[1]
if esc_c in ('u', 'U'):
# Unicode escape
out += six.unichr(... | [
"Iterative",
"parser",
"for",
"string",
"escapes",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/zincparser.py#L154-L192 | [
"def",
"_unescape",
"(",
"s",
",",
"uri",
"=",
"False",
")",
":",
"out",
"=",
"''",
"while",
"len",
"(",
"s",
")",
">",
"0",
":",
"c",
"=",
"s",
"[",
"0",
"]",
"if",
"c",
"==",
"'\\\\'",
":",
"# Backslash escape",
"esc_c",
"=",
"s",
"[",
"1",... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | parse_grid | Parse the incoming grid. | hszinc/zincparser.py | def parse_grid(grid_data):
"""
Parse the incoming grid.
"""
try:
# Split the grid up.
grid_parts = NEWLINE_RE.split(grid_data)
if len(grid_parts) < 2:
raise ZincParseException('Malformed grid received',
grid_data, 1, 1)
# Grid and column m... | def parse_grid(grid_data):
"""
Parse the incoming grid.
"""
try:
# Split the grid up.
grid_parts = NEWLINE_RE.split(grid_data)
if len(grid_parts) < 2:
raise ZincParseException('Malformed grid received',
grid_data, 1, 1)
# Grid and column m... | [
"Parse",
"the",
"incoming",
"grid",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/zincparser.py#L497-L572 | [
"def",
"parse_grid",
"(",
"grid_data",
")",
":",
"try",
":",
"# Split the grid up.",
"grid_parts",
"=",
"NEWLINE_RE",
".",
"split",
"(",
"grid_data",
")",
"if",
"len",
"(",
"grid_parts",
")",
"<",
"2",
":",
"raise",
"ZincParseException",
"(",
"'Malformed grid ... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | parse_scalar | Parse a Project Haystack scalar in ZINC format. | hszinc/zincparser.py | def parse_scalar(scalar_data, version):
"""
Parse a Project Haystack scalar in ZINC format.
"""
try:
return hs_scalar[version].parseString(scalar_data, parseAll=True)[0]
except pp.ParseException as pe:
# Raise a new exception with the appropriate line number.
raise ZincParseE... | def parse_scalar(scalar_data, version):
"""
Parse a Project Haystack scalar in ZINC format.
"""
try:
return hs_scalar[version].parseString(scalar_data, parseAll=True)[0]
except pp.ParseException as pe:
# Raise a new exception with the appropriate line number.
raise ZincParseE... | [
"Parse",
"a",
"Project",
"Haystack",
"scalar",
"in",
"ZINC",
"format",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/zincparser.py#L575-L588 | [
"def",
"parse_scalar",
"(",
"scalar_data",
",",
"version",
")",
":",
"try",
":",
"return",
"hs_scalar",
"[",
"version",
"]",
".",
"parseString",
"(",
"scalar_data",
",",
"parseAll",
"=",
"True",
")",
"[",
"0",
"]",
"except",
"pp",
".",
"ParseException",
... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | SortableDict.add_item | Add an item at a specific location, possibly replacing the
existing item.
If after is True, we insert *after* the given index, otherwise we
insert before.
The position is specified using either index or pos_key, the former
specifies the position from the start of the array (bas... | hszinc/sortabledict.py | def add_item(self, key, value, after=False, index=None, pos_key=None,
replace=True):
"""
Add an item at a specific location, possibly replacing the
existing item.
If after is True, we insert *after* the given index, otherwise we
insert before.
The position i... | def add_item(self, key, value, after=False, index=None, pos_key=None,
replace=True):
"""
Add an item at a specific location, possibly replacing the
existing item.
If after is True, we insert *after* the given index, otherwise we
insert before.
The position i... | [
"Add",
"an",
"item",
"at",
"a",
"specific",
"location",
"possibly",
"replacing",
"the",
"existing",
"item",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/sortabledict.py#L52-L102 | [
"def",
"add_item",
"(",
"self",
",",
"key",
",",
"value",
",",
"after",
"=",
"False",
",",
"index",
"=",
"None",
",",
"pos_key",
"=",
"None",
",",
"replace",
"=",
"True",
")",
":",
"if",
"self",
".",
"_validate_fn",
":",
"self",
".",
"_validate_fn",
... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | dump | Dump the given grids in the specified over-the-wire format. | hszinc/dumper.py | def dump(grids, mode=MODE_ZINC):
"""
Dump the given grids in the specified over-the-wire format.
"""
if isinstance(grids, Grid):
return dump_grid(grids, mode=mode)
_dump = functools.partial(dump_grid, mode=mode)
if mode == MODE_ZINC:
return '\n'.join(map(_dump, grids))
elif m... | def dump(grids, mode=MODE_ZINC):
"""
Dump the given grids in the specified over-the-wire format.
"""
if isinstance(grids, Grid):
return dump_grid(grids, mode=mode)
_dump = functools.partial(dump_grid, mode=mode)
if mode == MODE_ZINC:
return '\n'.join(map(_dump, grids))
elif m... | [
"Dump",
"the",
"given",
"grids",
"in",
"the",
"specified",
"over",
"-",
"the",
"-",
"wire",
"format",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/dumper.py#L18-L30 | [
"def",
"dump",
"(",
"grids",
",",
"mode",
"=",
"MODE_ZINC",
")",
":",
"if",
"isinstance",
"(",
"grids",
",",
"Grid",
")",
":",
"return",
"dump_grid",
"(",
"grids",
",",
"mode",
"=",
"mode",
")",
"_dump",
"=",
"functools",
".",
"partial",
"(",
"dump_g... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | to_haystack | Some parsing tweaks to fit pint units / handling of edge cases. | hszinc/pintutil.py | def to_haystack(unit):
"""
Some parsing tweaks to fit pint units / handling of edge cases.
"""
unit = str(unit)
global HAYSTACK_CONVERSION
global PINT_CONVERSION
if unit == 'per_minute' or \
unit == '/min' or \
unit == 'per_second' or \
unit == '/s' or \
unit ... | def to_haystack(unit):
"""
Some parsing tweaks to fit pint units / handling of edge cases.
"""
unit = str(unit)
global HAYSTACK_CONVERSION
global PINT_CONVERSION
if unit == 'per_minute' or \
unit == '/min' or \
unit == 'per_second' or \
unit == '/s' or \
unit ... | [
"Some",
"parsing",
"tweaks",
"to",
"fit",
"pint",
"units",
"/",
"handling",
"of",
"edge",
"cases",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/pintutil.py#L127-L150 | [
"def",
"to_haystack",
"(",
"unit",
")",
":",
"unit",
"=",
"str",
"(",
"unit",
")",
"global",
"HAYSTACK_CONVERSION",
"global",
"PINT_CONVERSION",
"if",
"unit",
"==",
"'per_minute'",
"or",
"unit",
"==",
"'/min'",
"or",
"unit",
"==",
"'per_second'",
"or",
"unit... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | to_pint | Some parsing tweaks to fit pint units / handling of edge cases. | hszinc/pintutil.py | def to_pint(unit):
"""
Some parsing tweaks to fit pint units / handling of edge cases.
"""
global HAYSTACK_CONVERSION
if unit == 'per_minute' or \
unit == '/min' or \
unit == 'per_second' or \
unit == '/s' or \
unit == 'per_hour' or \
unit == '/h' or \
... | def to_pint(unit):
"""
Some parsing tweaks to fit pint units / handling of edge cases.
"""
global HAYSTACK_CONVERSION
if unit == 'per_minute' or \
unit == '/min' or \
unit == 'per_second' or \
unit == '/s' or \
unit == 'per_hour' or \
unit == '/h' or \
... | [
"Some",
"parsing",
"tweaks",
"to",
"fit",
"pint",
"units",
"/",
"handling",
"of",
"edge",
"cases",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/pintutil.py#L152-L168 | [
"def",
"to_pint",
"(",
"unit",
")",
":",
"global",
"HAYSTACK_CONVERSION",
"if",
"unit",
"==",
"'per_minute'",
"or",
"unit",
"==",
"'/min'",
"or",
"unit",
"==",
"'per_second'",
"or",
"unit",
"==",
"'/s'",
"or",
"unit",
"==",
"'per_hour'",
"or",
"unit",
"=="... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | define_haystack_units | Missing units found in project-haystack
Added to the registry | hszinc/pintutil.py | def define_haystack_units():
"""
Missing units found in project-haystack
Added to the registry
"""
ureg = UnitRegistry()
ureg.define('% = [] = percent')
ureg.define('pixel = [] = px = dot = picture_element = pel')
ureg.define('decibel = [] = dB')
ureg.define('ppu = [] = parts_per_uni... | def define_haystack_units():
"""
Missing units found in project-haystack
Added to the registry
"""
ureg = UnitRegistry()
ureg.define('% = [] = percent')
ureg.define('pixel = [] = px = dot = picture_element = pel')
ureg.define('decibel = [] = dB')
ureg.define('ppu = [] = parts_per_uni... | [
"Missing",
"units",
"found",
"in",
"project",
"-",
"haystack",
"Added",
"to",
"the",
"registry"
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/pintutil.py#L171-L236 | [
"def",
"define_haystack_units",
"(",
")",
":",
"ureg",
"=",
"UnitRegistry",
"(",
")",
"ureg",
".",
"define",
"(",
"'% = [] = percent'",
")",
"ureg",
".",
"define",
"(",
"'pixel = [] = px = dot = picture_element = pel'",
")",
"ureg",
".",
"define",
"(",
"'decibel =... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | Grid._detect_or_validate | Detect the version used from the row content, or validate against
the version if given. | hszinc/grid.py | def _detect_or_validate(self, val):
'''
Detect the version used from the row content, or validate against
the version if given.
'''
if isinstance(val, list) \
or isinstance(val, dict) \
or isinstance(val, SortableDict) \
or isinstan... | def _detect_or_validate(self, val):
'''
Detect the version used from the row content, or validate against
the version if given.
'''
if isinstance(val, list) \
or isinstance(val, dict) \
or isinstance(val, SortableDict) \
or isinstan... | [
"Detect",
"the",
"version",
"used",
"from",
"the",
"row",
"content",
"or",
"validate",
"against",
"the",
"version",
"if",
"given",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/grid.py#L152-L162 | [
"def",
"_detect_or_validate",
"(",
"self",
",",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"list",
")",
"or",
"isinstance",
"(",
"val",
",",
"dict",
")",
"or",
"isinstance",
"(",
"val",
",",
"SortableDict",
")",
"or",
"isinstance",
"(",
"val... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | Grid._assert_version | Assert that the grid version is equal to or above the given value.
If no version is set, set the version. | hszinc/grid.py | def _assert_version(self, version):
'''
Assert that the grid version is equal to or above the given value.
If no version is set, set the version.
'''
if self.nearest_version < version:
if self._version_given:
raise ValueError(
'... | def _assert_version(self, version):
'''
Assert that the grid version is equal to or above the given value.
If no version is set, set the version.
'''
if self.nearest_version < version:
if self._version_given:
raise ValueError(
'... | [
"Assert",
"that",
"the",
"grid",
"version",
"is",
"equal",
"to",
"or",
"above",
"the",
"given",
"value",
".",
"If",
"no",
"version",
"is",
"set",
"set",
"the",
"version",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/grid.py#L164-L175 | [
"def",
"_assert_version",
"(",
"self",
",",
"version",
")",
":",
"if",
"self",
".",
"nearest_version",
"<",
"version",
":",
"if",
"self",
".",
"_version_given",
":",
"raise",
"ValueError",
"(",
"'Data type requires version %s'",
"%",
"version",
")",
"else",
":... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | Version._cmp | Compare two Project Haystack version strings, then return
-1 if self < other,
0 if self == other
or 1 if self > other. | hszinc/version.py | def _cmp(self, other):
"""
Compare two Project Haystack version strings, then return
-1 if self < other,
0 if self == other
or 1 if self > other.
"""
if not isinstance(other, Version):
other = Version(other)
num1 = self.version_num... | def _cmp(self, other):
"""
Compare two Project Haystack version strings, then return
-1 if self < other,
0 if self == other
or 1 if self > other.
"""
if not isinstance(other, Version):
other = Version(other)
num1 = self.version_num... | [
"Compare",
"two",
"Project",
"Haystack",
"version",
"strings",
"then",
"return",
"-",
"1",
"if",
"self",
"<",
"other",
"0",
"if",
"self",
"==",
"other",
"or",
"1",
"if",
"self",
">",
"other",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/version.py#L62-L101 | [
"def",
"_cmp",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Version",
")",
":",
"other",
"=",
"Version",
"(",
"other",
")",
"num1",
"=",
"self",
".",
"version_nums",
"num2",
"=",
"other",
".",
"version_nums",
"#... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | Version.nearest | Retrieve the official version nearest the one given. | hszinc/version.py | def nearest(self, ver):
"""
Retrieve the official version nearest the one given.
"""
if not isinstance(ver, Version):
ver = Version(ver)
if ver in OFFICIAL_VERSIONS:
return ver
# We might not have an exact match for that.
# See if we have... | def nearest(self, ver):
"""
Retrieve the official version nearest the one given.
"""
if not isinstance(ver, Version):
ver = Version(ver)
if ver in OFFICIAL_VERSIONS:
return ver
# We might not have an exact match for that.
# See if we have... | [
"Retrieve",
"the",
"official",
"version",
"nearest",
"the",
"one",
"given",
"."
] | vrtsystems/hszinc | python | https://github.com/vrtsystems/hszinc/blob/d52a7c6b5bc466f3c1a77b71814c8c0776aba995/hszinc/version.py#L127-L169 | [
"def",
"nearest",
"(",
"self",
",",
"ver",
")",
":",
"if",
"not",
"isinstance",
"(",
"ver",
",",
"Version",
")",
":",
"ver",
"=",
"Version",
"(",
"ver",
")",
"if",
"ver",
"in",
"OFFICIAL_VERSIONS",
":",
"return",
"ver",
"# We might not have an exact match ... | d52a7c6b5bc466f3c1a77b71814c8c0776aba995 |
valid | encrypt_files | Encrypts file with gpg and random generated password | limf/encrypter.py | def encrypt_files(selected_host, only_link, file_name):
"""
Encrypts file with gpg and random generated password
"""
if ENCRYPTION_DISABLED:
print('For encryption please install gpg')
exit()
passphrase = '%030x' % random.randrange(16**30)
source_filename = file_name
cmd = 'gp... | def encrypt_files(selected_host, only_link, file_name):
"""
Encrypts file with gpg and random generated password
"""
if ENCRYPTION_DISABLED:
print('For encryption please install gpg')
exit()
passphrase = '%030x' % random.randrange(16**30)
source_filename = file_name
cmd = 'gp... | [
"Encrypts",
"file",
"with",
"gpg",
"and",
"random",
"generated",
"password"
] | lc-guy/limf | python | https://github.com/lc-guy/limf/blob/ad380feb70ef8e579a91ca09c807efec9e8af565/limf/encrypter.py#L13-L26 | [
"def",
"encrypt_files",
"(",
"selected_host",
",",
"only_link",
",",
"file_name",
")",
":",
"if",
"ENCRYPTION_DISABLED",
":",
"print",
"(",
"'For encryption please install gpg'",
")",
"exit",
"(",
")",
"passphrase",
"=",
"'%030x'",
"%",
"random",
".",
"randrange",... | ad380feb70ef8e579a91ca09c807efec9e8af565 |
valid | check_max_filesize | Checks file sizes for host | limf/parse_arguments.py | def check_max_filesize(chosen_file, max_size):
"""
Checks file sizes for host
"""
if os.path.getsize(chosen_file) > max_size:
return False
else:
return True | def check_max_filesize(chosen_file, max_size):
"""
Checks file sizes for host
"""
if os.path.getsize(chosen_file) > max_size:
return False
else:
return True | [
"Checks",
"file",
"sizes",
"for",
"host"
] | lc-guy/limf | python | https://github.com/lc-guy/limf/blob/ad380feb70ef8e579a91ca09c807efec9e8af565/limf/parse_arguments.py#L11-L18 | [
"def",
"check_max_filesize",
"(",
"chosen_file",
",",
"max_size",
")",
":",
"if",
"os",
".",
"path",
".",
"getsize",
"(",
"chosen_file",
")",
">",
"max_size",
":",
"return",
"False",
"else",
":",
"return",
"True"
] | ad380feb70ef8e579a91ca09c807efec9e8af565 |
valid | parse_arguments | Makes parsing arguments a function. | limf/parse_arguments.py | def parse_arguments(args, clone_list):
"""
Makes parsing arguments a function.
"""
returned_string=""
host_number = args.host
if args.show_list:
print(generate_host_string(clone_list, "Available hosts: "))
exit()
if args.decrypt:
for i in args.files:
print... | def parse_arguments(args, clone_list):
"""
Makes parsing arguments a function.
"""
returned_string=""
host_number = args.host
if args.show_list:
print(generate_host_string(clone_list, "Available hosts: "))
exit()
if args.decrypt:
for i in args.files:
print... | [
"Makes",
"parsing",
"arguments",
"a",
"function",
"."
] | lc-guy/limf | python | https://github.com/lc-guy/limf/blob/ad380feb70ef8e579a91ca09c807efec9e8af565/limf/parse_arguments.py#L20-L84 | [
"def",
"parse_arguments",
"(",
"args",
",",
"clone_list",
")",
":",
"returned_string",
"=",
"\"\"",
"host_number",
"=",
"args",
".",
"host",
"if",
"args",
".",
"show_list",
":",
"print",
"(",
"generate_host_string",
"(",
"clone_list",
",",
"\"Available hosts: \"... | ad380feb70ef8e579a91ca09c807efec9e8af565 |
valid | upload_files | Uploads selected file to the host, thanks to the fact that
every pomf.se based site has pretty much the same architecture. | limf/uploader.py | def upload_files(selected_file, selected_host, only_link, file_name):
"""
Uploads selected file to the host, thanks to the fact that
every pomf.se based site has pretty much the same architecture.
"""
try:
answer = requests.post(
url=selected_host[0]+"upload.php",
fil... | def upload_files(selected_file, selected_host, only_link, file_name):
"""
Uploads selected file to the host, thanks to the fact that
every pomf.se based site has pretty much the same architecture.
"""
try:
answer = requests.post(
url=selected_host[0]+"upload.php",
fil... | [
"Uploads",
"selected",
"file",
"to",
"the",
"host",
"thanks",
"to",
"the",
"fact",
"that",
"every",
"pomf",
".",
"se",
"based",
"site",
"has",
"pretty",
"much",
"the",
"same",
"architecture",
"."
] | lc-guy/limf | python | https://github.com/lc-guy/limf/blob/ad380feb70ef8e579a91ca09c807efec9e8af565/limf/uploader.py#L10-L26 | [
"def",
"upload_files",
"(",
"selected_file",
",",
"selected_host",
",",
"only_link",
",",
"file_name",
")",
":",
"try",
":",
"answer",
"=",
"requests",
".",
"post",
"(",
"url",
"=",
"selected_host",
"[",
"0",
"]",
"+",
"\"upload.php\"",
",",
"files",
"=",
... | ad380feb70ef8e579a91ca09c807efec9e8af565 |
valid | swagger_ui_template_view | Serves Swagger UI page, default Swagger UI config is used but you can
override the callable that generates the `<script>` tag by setting
`cornice_swagger.swagger_ui_script_generator` in pyramid config, it defaults
to 'cornice_swagger.views:swagger_ui_script_template'
:param request:
:return: | cornice_swagger/views.py | def swagger_ui_template_view(request):
"""
Serves Swagger UI page, default Swagger UI config is used but you can
override the callable that generates the `<script>` tag by setting
`cornice_swagger.swagger_ui_script_generator` in pyramid config, it defaults
to 'cornice_swagger.views:swagger_ui_script... | def swagger_ui_template_view(request):
"""
Serves Swagger UI page, default Swagger UI config is used but you can
override the callable that generates the `<script>` tag by setting
`cornice_swagger.swagger_ui_script_generator` in pyramid config, it defaults
to 'cornice_swagger.views:swagger_ui_script... | [
"Serves",
"Swagger",
"UI",
"page",
"default",
"Swagger",
"UI",
"config",
"is",
"used",
"but",
"you",
"can",
"override",
"the",
"callable",
"that",
"generates",
"the",
"<script",
">",
"tag",
"by",
"setting",
"cornice_swagger",
".",
"swagger_ui_script_generator",
... | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/views.py#L19-L44 | [
"def",
"swagger_ui_template_view",
"(",
"request",
")",
":",
"script_generator",
"=",
"request",
".",
"registry",
".",
"settings",
".",
"get",
"(",
"'cornice_swagger.swagger_ui_script_generator'",
",",
"'cornice_swagger.views:swagger_ui_script_template'",
")",
"package",
",... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | open_api_json_view | :param request:
:return:
Generates JSON representation of Swagger spec | cornice_swagger/views.py | def open_api_json_view(request):
"""
:param request:
:return:
Generates JSON representation of Swagger spec
"""
doc = cornice_swagger.CorniceSwagger(
cornice.service.get_services(), pyramid_registry=request.registry)
kwargs = request.registry.settings['cornice_swagger.spec_kwargs']
... | def open_api_json_view(request):
"""
:param request:
:return:
Generates JSON representation of Swagger spec
"""
doc = cornice_swagger.CorniceSwagger(
cornice.service.get_services(), pyramid_registry=request.registry)
kwargs = request.registry.settings['cornice_swagger.spec_kwargs']
... | [
":",
"param",
"request",
":",
":",
"return",
":"
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/views.py#L47-L58 | [
"def",
"open_api_json_view",
"(",
"request",
")",
":",
"doc",
"=",
"cornice_swagger",
".",
"CorniceSwagger",
"(",
"cornice",
".",
"service",
".",
"get_services",
"(",
")",
",",
"pyramid_registry",
"=",
"request",
".",
"registry",
")",
"kwargs",
"=",
"request",... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | swagger_ui_script_template | :param request:
:return:
Generates the <script> code that bootstraps Swagger UI, it will be injected
into index template | cornice_swagger/views.py | def swagger_ui_script_template(request, **kwargs):
"""
:param request:
:return:
Generates the <script> code that bootstraps Swagger UI, it will be injected
into index template
"""
swagger_spec_url = request.route_url('cornice_swagger.open_api_path')
template = pkg_resources.resource_str... | def swagger_ui_script_template(request, **kwargs):
"""
:param request:
:return:
Generates the <script> code that bootstraps Swagger UI, it will be injected
into index template
"""
swagger_spec_url = request.route_url('cornice_swagger.open_api_path')
template = pkg_resources.resource_str... | [
":",
"param",
"request",
":",
":",
"return",
":"
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/views.py#L61-L76 | [
"def",
"swagger_ui_script_template",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"swagger_spec_url",
"=",
"request",
".",
"route_url",
"(",
"'cornice_swagger.open_api_path'",
")",
"template",
"=",
"pkg_resources",
".",
"resource_string",
"(",
"'cornice_swagger'... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | decrypt_files | Decrypts file from entered links | limf/decrypter.py | def decrypt_files(file_link):
"""
Decrypts file from entered links
"""
if ENCRYPTION_DISABLED:
print('For decryption please install gpg')
exit()
try:
parsed_link = re.findall(r'(.*/(.*))#(.{30})', file_link)[0]
req = urllib.request.Request(
parsed_link[0],... | def decrypt_files(file_link):
"""
Decrypts file from entered links
"""
if ENCRYPTION_DISABLED:
print('For decryption please install gpg')
exit()
try:
parsed_link = re.findall(r'(.*/(.*))#(.{30})', file_link)[0]
req = urllib.request.Request(
parsed_link[0],... | [
"Decrypts",
"file",
"from",
"entered",
"links"
] | lc-guy/limf | python | https://github.com/lc-guy/limf/blob/ad380feb70ef8e579a91ca09c807efec9e8af565/limf/decrypter.py#L14-L46 | [
"def",
"decrypt_files",
"(",
"file_link",
")",
":",
"if",
"ENCRYPTION_DISABLED",
":",
"print",
"(",
"'For decryption please install gpg'",
")",
"exit",
"(",
")",
"try",
":",
"parsed_link",
"=",
"re",
".",
"findall",
"(",
"r'(.*/(.*))#(.{30})'",
",",
"file_link",
... | ad380feb70ef8e579a91ca09c807efec9e8af565 |
valid | MyValueApi.set_value | Set the value and returns *True* or *False*. | examples/minimalist.py | def set_value(request):
"""Set the value and returns *True* or *False*."""
key = request.matchdict['key']
_VALUES[key] = request.json_body
return _VALUES.get(key) | def set_value(request):
"""Set the value and returns *True* or *False*."""
key = request.matchdict['key']
_VALUES[key] = request.json_body
return _VALUES.get(key) | [
"Set",
"the",
"value",
"and",
"returns",
"*",
"True",
"*",
"or",
"*",
"False",
"*",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/examples/minimalist.py#L46-L51 | [
"def",
"set_value",
"(",
"request",
")",
":",
"key",
"=",
"request",
".",
"matchdict",
"[",
"'key'",
"]",
"_VALUES",
"[",
"key",
"]",
"=",
"request",
".",
"json_body",
"return",
"_VALUES",
".",
"get",
"(",
"key",
")"
] | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | DefinitionHandler.from_schema | Creates a Swagger definition from a colander schema.
:param schema_node:
Colander schema to be transformed into a Swagger definition.
:param base_name:
Schema alternative title.
:rtype: dict
:returns: Swagger schema. | cornice_swagger/swagger.py | def from_schema(self, schema_node, base_name=None):
"""
Creates a Swagger definition from a colander schema.
:param schema_node:
Colander schema to be transformed into a Swagger definition.
:param base_name:
Schema alternative title.
:rtype: dict
... | def from_schema(self, schema_node, base_name=None):
"""
Creates a Swagger definition from a colander schema.
:param schema_node:
Colander schema to be transformed into a Swagger definition.
:param base_name:
Schema alternative title.
:rtype: dict
... | [
"Creates",
"a",
"Swagger",
"definition",
"from",
"a",
"colander",
"schema",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L36-L48 | [
"def",
"from_schema",
"(",
"self",
",",
"schema_node",
",",
"base_name",
"=",
"None",
")",
":",
"return",
"self",
".",
"_ref_recursive",
"(",
"self",
".",
"type_converter",
"(",
"schema_node",
")",
",",
"self",
".",
"ref",
",",
"base_name",
")"
] | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | DefinitionHandler._ref_recursive | Dismantle nested swagger schemas into several definitions using JSON pointers.
Note: This can be dangerous since definition titles must be unique.
:param schema:
Base swagger schema.
:param depth:
How many levels of the swagger object schemas should be split into
... | cornice_swagger/swagger.py | def _ref_recursive(self, schema, depth, base_name=None):
"""
Dismantle nested swagger schemas into several definitions using JSON pointers.
Note: This can be dangerous since definition titles must be unique.
:param schema:
Base swagger schema.
:param depth:
... | def _ref_recursive(self, schema, depth, base_name=None):
"""
Dismantle nested swagger schemas into several definitions using JSON pointers.
Note: This can be dangerous since definition titles must be unique.
:param schema:
Base swagger schema.
:param depth:
... | [
"Dismantle",
"nested",
"swagger",
"schemas",
"into",
"several",
"definitions",
"using",
"JSON",
"pointers",
".",
"Note",
":",
"This",
"can",
"be",
"dangerous",
"since",
"definition",
"titles",
"must",
"be",
"unique",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L50-L85 | [
"def",
"_ref_recursive",
"(",
"self",
",",
"schema",
",",
"depth",
",",
"base_name",
"=",
"None",
")",
":",
"if",
"depth",
"==",
"0",
":",
"return",
"schema",
"if",
"schema",
"[",
"'type'",
"]",
"!=",
"'object'",
":",
"return",
"schema",
"name",
"=",
... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | ParameterHandler.from_schema | Creates a list of Swagger params from a colander request schema.
:param schema_node:
Request schema to be transformed into Swagger.
:param validators:
Validators used in colander with the schema.
:rtype: list
:returns: List of Swagger parameters. | cornice_swagger/swagger.py | def from_schema(self, schema_node):
"""
Creates a list of Swagger params from a colander request schema.
:param schema_node:
Request schema to be transformed into Swagger.
:param validators:
Validators used in colander with the schema.
:rtype: list
... | def from_schema(self, schema_node):
"""
Creates a list of Swagger params from a colander request schema.
:param schema_node:
Request schema to be transformed into Swagger.
:param validators:
Validators used in colander with the schema.
:rtype: list
... | [
"Creates",
"a",
"list",
"of",
"Swagger",
"params",
"from",
"a",
"colander",
"request",
"schema",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L110-L145 | [
"def",
"from_schema",
"(",
"self",
",",
"schema_node",
")",
":",
"params",
"=",
"[",
"]",
"for",
"param_schema",
"in",
"schema_node",
".",
"children",
":",
"location",
"=",
"param_schema",
".",
"name",
"if",
"location",
"is",
"'body'",
":",
"name",
"=",
... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | ParameterHandler.from_path | Create a list of Swagger path params from a cornice service path.
:type path: string
:rtype: list | cornice_swagger/swagger.py | def from_path(self, path):
"""
Create a list of Swagger path params from a cornice service path.
:type path: string
:rtype: list
"""
path_components = path.split('/')
param_names = [comp[1:-1] for comp in path_components
if comp.startswith(... | def from_path(self, path):
"""
Create a list of Swagger path params from a cornice service path.
:type path: string
:rtype: list
"""
path_components = path.split('/')
param_names = [comp[1:-1] for comp in path_components
if comp.startswith(... | [
"Create",
"a",
"list",
"of",
"Swagger",
"path",
"params",
"from",
"a",
"cornice",
"service",
"path",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L147-L166 | [
"def",
"from_path",
"(",
"self",
",",
"path",
")",
":",
"path_components",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"param_names",
"=",
"[",
"comp",
"[",
"1",
":",
"-",
"1",
"]",
"for",
"comp",
"in",
"path_components",
"if",
"comp",
".",
"startswi... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | ParameterHandler._ref | Store a parameter schema and return a reference to it.
:param schema:
Swagger parameter definition.
:param base_name:
Name that should be used for the reference.
:rtype: dict
:returns: JSON pointer to the original parameter definition. | cornice_swagger/swagger.py | def _ref(self, param, base_name=None):
"""
Store a parameter schema and return a reference to it.
:param schema:
Swagger parameter definition.
:param base_name:
Name that should be used for the reference.
:rtype: dict
:returns: JSON pointer to th... | def _ref(self, param, base_name=None):
"""
Store a parameter schema and return a reference to it.
:param schema:
Swagger parameter definition.
:param base_name:
Name that should be used for the reference.
:rtype: dict
:returns: JSON pointer to th... | [
"Store",
"a",
"parameter",
"schema",
"and",
"return",
"a",
"reference",
"to",
"it",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L168-L186 | [
"def",
"_ref",
"(",
"self",
",",
"param",
",",
"base_name",
"=",
"None",
")",
":",
"name",
"=",
"base_name",
"or",
"param",
".",
"get",
"(",
"'title'",
",",
"''",
")",
"or",
"param",
".",
"get",
"(",
"'name'",
",",
"''",
")",
"pointer",
"=",
"sel... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | ResponseHandler.from_schema_mapping | Creates a Swagger response object from a dict of response schemas.
:param schema_mapping:
Dict with entries matching ``{status_code: response_schema}``.
:rtype: dict
:returns: Response schema. | cornice_swagger/swagger.py | def from_schema_mapping(self, schema_mapping):
"""
Creates a Swagger response object from a dict of response schemas.
:param schema_mapping:
Dict with entries matching ``{status_code: response_schema}``.
:rtype: dict
:returns: Response schema.
"""
re... | def from_schema_mapping(self, schema_mapping):
"""
Creates a Swagger response object from a dict of response schemas.
:param schema_mapping:
Dict with entries matching ``{status_code: response_schema}``.
:rtype: dict
:returns: Response schema.
"""
re... | [
"Creates",
"a",
"Swagger",
"response",
"object",
"from",
"a",
"dict",
"of",
"response",
"schemas",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L209-L254 | [
"def",
"from_schema_mapping",
"(",
"self",
",",
"schema_mapping",
")",
":",
"responses",
"=",
"{",
"}",
"for",
"status",
",",
"response_schema",
"in",
"schema_mapping",
".",
"items",
"(",
")",
":",
"response",
"=",
"{",
"}",
"if",
"response_schema",
".",
"... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | ResponseHandler._ref | Store a response schema and return a reference to it.
:param schema:
Swagger response definition.
:param base_name:
Name that should be used for the reference.
:rtype: dict
:returns: JSON pointer to the original response definition. | cornice_swagger/swagger.py | def _ref(self, resp, base_name=None):
"""
Store a response schema and return a reference to it.
:param schema:
Swagger response definition.
:param base_name:
Name that should be used for the reference.
:rtype: dict
:returns: JSON pointer to the o... | def _ref(self, resp, base_name=None):
"""
Store a response schema and return a reference to it.
:param schema:
Swagger response definition.
:param base_name:
Name that should be used for the reference.
:rtype: dict
:returns: JSON pointer to the o... | [
"Store",
"a",
"response",
"schema",
"and",
"return",
"a",
"reference",
"to",
"it",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L256-L274 | [
"def",
"_ref",
"(",
"self",
",",
"resp",
",",
"base_name",
"=",
"None",
")",
":",
"name",
"=",
"base_name",
"or",
"resp",
".",
"get",
"(",
"'title'",
",",
"''",
")",
"or",
"resp",
".",
"get",
"(",
"'name'",
",",
"''",
")",
"pointer",
"=",
"self",... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | CorniceSwagger.generate | Generate a Swagger 2.0 documentation. Keyword arguments may be used
to provide additional information to build methods as such ignores.
:param title:
The name presented on the swagger document.
:param version:
The version of the API presented on the swagger document.
... | cornice_swagger/swagger.py | def generate(self, title=None, version=None, base_path=None,
info=None, swagger=None, **kwargs):
"""Generate a Swagger 2.0 documentation. Keyword arguments may be used
to provide additional information to build methods as such ignores.
:param title:
The name present... | def generate(self, title=None, version=None, base_path=None,
info=None, swagger=None, **kwargs):
"""Generate a Swagger 2.0 documentation. Keyword arguments may be used
to provide additional information to build methods as such ignores.
:param title:
The name present... | [
"Generate",
"a",
"Swagger",
"2",
".",
"0",
"documentation",
".",
"Keyword",
"arguments",
"may",
"be",
"used",
"to",
"provide",
"additional",
"information",
"to",
"build",
"methods",
"as",
"such",
"ignores",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L398-L457 | [
"def",
"generate",
"(",
"self",
",",
"title",
"=",
"None",
",",
"version",
"=",
"None",
",",
"base_path",
"=",
"None",
",",
"info",
"=",
"None",
",",
"swagger",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"title",
"=",
"title",
"or",
"self",
... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | CorniceSwagger._build_paths | Build the Swagger "paths" and "tags" attributes from cornice service
definitions. | cornice_swagger/swagger.py | def _build_paths(self):
"""
Build the Swagger "paths" and "tags" attributes from cornice service
definitions.
"""
paths = {}
tags = []
for service in self.services:
path, path_obj = self._extract_path_from_service(service)
service_tags = ... | def _build_paths(self):
"""
Build the Swagger "paths" and "tags" attributes from cornice service
definitions.
"""
paths = {}
tags = []
for service in self.services:
path, path_obj = self._extract_path_from_service(service)
service_tags = ... | [
"Build",
"the",
"Swagger",
"paths",
"and",
"tags",
"attributes",
"from",
"cornice",
"service",
"definitions",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L480-L552 | [
"def",
"_build_paths",
"(",
"self",
")",
":",
"paths",
"=",
"{",
"}",
"tags",
"=",
"[",
"]",
"for",
"service",
"in",
"self",
".",
"services",
":",
"path",
",",
"path_obj",
"=",
"self",
".",
"_extract_path_from_service",
"(",
"service",
")",
"service_tags... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | CorniceSwagger._extract_path_from_service | Extract path object and its parameters from service definitions.
:param service:
Cornice service to extract information from.
:rtype: dict
:returns: Path definition. | cornice_swagger/swagger.py | def _extract_path_from_service(self, service):
"""
Extract path object and its parameters from service definitions.
:param service:
Cornice service to extract information from.
:rtype: dict
:returns: Path definition.
"""
path_obj = {}
path =... | def _extract_path_from_service(self, service):
"""
Extract path object and its parameters from service definitions.
:param service:
Cornice service to extract information from.
:rtype: dict
:returns: Path definition.
"""
path_obj = {}
path =... | [
"Extract",
"path",
"object",
"and",
"its",
"parameters",
"from",
"service",
"definitions",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L554-L592 | [
"def",
"_extract_path_from_service",
"(",
"self",
",",
"service",
")",
":",
"path_obj",
"=",
"{",
"}",
"path",
"=",
"service",
".",
"path",
"route_name",
"=",
"getattr",
"(",
"service",
",",
"'pyramid_route'",
",",
"None",
")",
"# handle services that don't crea... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
valid | CorniceSwagger._extract_operation_from_view | Extract swagger operation details from colander view definitions.
:param view:
View to extract information from.
:param args:
Arguments from the view decorator.
:rtype: dict
:returns: Operation definition. | cornice_swagger/swagger.py | def _extract_operation_from_view(self, view, args):
"""
Extract swagger operation details from colander view definitions.
:param view:
View to extract information from.
:param args:
Arguments from the view decorator.
:rtype: dict
:returns: Operat... | def _extract_operation_from_view(self, view, args):
"""
Extract swagger operation details from colander view definitions.
:param view:
View to extract information from.
:param args:
Arguments from the view decorator.
:rtype: dict
:returns: Operat... | [
"Extract",
"swagger",
"operation",
"details",
"from",
"colander",
"view",
"definitions",
"."
] | Cornices/cornice.ext.swagger | python | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L594-L679 | [
"def",
"_extract_operation_from_view",
"(",
"self",
",",
"view",
",",
"args",
")",
":",
"op",
"=",
"{",
"'responses'",
":",
"{",
"'default'",
":",
"{",
"'description'",
":",
"'UNDOCUMENTED RESPONSE'",
"}",
"}",
",",
"}",
"# If 'produces' are not defined in the vie... | c31a5cc8d5dd112b11dc41ccb6d09b423b537abc |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.