id stringlengths 24 24 | repo stringlengths 7 52 | path stringlengths 5 138 | func_name stringlengths 1 134 | url stringlengths 89 242 | split stringclasses 3
values | language stringclasses 1
value | docstring stringlengths 1 46.9k | code stringlengths 87 104k | text stringlengths 100 112k | token_count int32 25 38.1k | doc_chars int32 1 46.9k | code_chars int32 87 104k | license_basis stringclasses 1
value | source stringclasses 1
value | added stringdate 2026-12-05 00:00:00 2026-12-05 00:00:00 | record_sha256 stringlengths 64 64 | license stringclasses 9
values | license_class stringclasses 1
value | license_source stringlengths 46 99 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f3932b58925636f0eb15f882 | alefnula/tea | tea/msg/mail.py | make_msgid | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L75-L100 | train | python | Return a string suitable for RFC 2822 compliant Message-ID.
E.g: <20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
uniqueness of the message id. | def make_msgid(idstring=None, utc=False):
"""Return a string suitable for RFC 2822 compliant Message-ID.
E.g: <20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
uniqueness of the message id.
"""
if utc:
timesta... | Return a string suitable for RFC 2822 compliant Message-ID.
E.g: <20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
uniqueness of the message id.
def make_msgid(idstring=None, utc=False):
"""Return a string suitable for RFC 2822... | 278 | 231 | 823 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | fe141a096af116fe60a1cbe85e2f22147fc48f7dddc2655a3b7631af5c5023c8 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
8516b361d63968630ba11ea7 | alefnula/tea | tea/msg/mail.py | forbid_multi_line_headers | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L107-L130 | train | python | Forbid multi-line headers, to prevent header injection. | def forbid_multi_line_headers(name, val):
"""Forbid multi-line headers, to prevent header injection."""
val = smart_text(val)
if "\n" in val or "\r" in val:
raise BadHeaderError(
"Header values can't contain newlines "
"(got %r for header %r)" % (val, name)
)
... | Forbid multi-line headers, to prevent header injection.
def forbid_multi_line_headers(name, val):
"""Forbid multi-line headers, to prevent header injection."""
val = smart_text(val)
if "\n" in val or "\r" in val:
raise BadHeaderError(
"Header values can't contain newlines "
... | 210 | 55 | 874 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 9eb8ab0d0cfb7384952a0fb965ba7f8f9ccc24b35943842a69cea8a3db7bb757 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
debdb420cf130f641da4f24c | alefnula/tea | tea/msg/mail.py | send_mail | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L432-L494 | train | python | Send a single email to a recipient list.
All members of the recipient list will see the other recipients in the 'To'
field.
Note: The API for this method is frozen. New code wanting to extend the
functionality should use the EmailMessage class directly. | def send_mail(
subject,
sender,
to,
message,
html_message=None,
cc=None,
bcc=None,
attachments=None,
host=None,
port=None,
auth_user=None,
auth_password=None,
use_tls=False,
fail_silently=False,
):
"""Send a single email to a recipient list.
... | Send a single email to a recipient list.
All members of the recipient list will see the other recipients in the 'To'
field.
Note: The API for this method is frozen. New code wanting to extend the
functionality should use the EmailMessage class directly.
def send_mail(
subject,
sender,... | 420 | 277 | 1,740 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 6318e6dac3473a538b5eca74a17735d341d56d3094d1a519be7e181753b2b662 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
85a4a8f320ba08acaa726ed2 | alefnula/tea | tea/msg/mail.py | send_mass_mail | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L497-L517 | train | python | Send multiple emails to multiple recipients.
Given a datatuple of (subject, message, sender, recipient_list), sends
each message to each recipient list. Returns the number of e-mails sent.
If auth_user and auth_password are set, they're used to log in.
Note: The API for this method is frozen. ... | def send_mass_mail(
datatuple, fail_silently=False, auth_user=None, auth_password=None
):
"""Send multiple emails to multiple recipients.
Given a datatuple of (subject, message, sender, recipient_list), sends
each message to each recipient list. Returns the number of e-mails sent.
If auth_... | Send multiple emails to multiple recipients.
Given a datatuple of (subject, message, sender, recipient_list), sends
each message to each recipient list. Returns the number of e-mails sent.
If auth_user and auth_password are set, they're used to log in.
Note: The API for this method is frozen. ... | 270 | 413 | 841 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 3b0c9ec1d319006591a115231f18679bd4d93a1f7398b1f151afde0328f27a39 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
cfdd47f5226513139bde7f70 | alefnula/tea | tea/msg/mail.py | SMTPConnection.open | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L165-L194 | train | python | Ensure we have a connection to the email server.
Returns whether or not a new connection was required (True or False). | def open(self):
"""Ensure we have a connection to the email server.
Returns whether or not a new connection was required (True or False).
"""
if self.connection:
# Nothing to do if the connection is already open.
return False
try:
# I... | Ensure we have a connection to the email server.
Returns whether or not a new connection was required (True or False).
def open(self):
"""Ensure we have a connection to the email server.
Returns whether or not a new connection was required (True or False).
"""
if self.c... | 241 | 129 | 1,165 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 6a659b6cf58dcf2eeda54012b0c0f66c50cb1f7e3b1628770f35496373d82185 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
63c07ced181bc0eca8a8c892 | alefnula/tea | tea/msg/mail.py | SMTPConnection.close | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L196-L216 | train | python | Close the connection to the email server. | def close(self):
"""Close the connection to the email server."""
try:
try:
self.connection.quit()
except socket.sslerror:
# This happens when calling quit() on a TLS connection
# sometimes.
self.connection.cl... | Close the connection to the email server.
def close(self):
"""Close the connection to the email server."""
try:
try:
self.connection.quit()
except socket.sslerror:
# This happens when calling quit() on a TLS connection
# som... | 125 | 41 | 724 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d15570aa48bcf429514f8c9987da70f9327224b63011bc9b70a214eb47ac2f2f | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
3ebc0ed96496c99704cd4035 | alefnula/tea | tea/msg/mail.py | SMTPConnection.send_messages | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L218-L237 | train | python | Send one or more EmailMessage objects.
Returns:
int: Number of email messages sent. | def send_messages(self, messages):
"""Send one or more EmailMessage objects.
Returns:
int: Number of email messages sent.
"""
if not messages:
return
new_conn_created = self.open()
if not self.connection:
# We failed silentl... | Send one or more EmailMessage objects.
Returns:
int: Number of email messages sent.
def send_messages(self, messages):
"""Send one or more EmailMessage objects.
Returns:
int: Number of email messages sent.
"""
if not messages:
re... | 137 | 108 | 617 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 8f1b2203314efd88befebbd1888e80365c542d234aa5c15c39bb41c56b948199 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
974373c5d8233b8a0d3c8254 | alefnula/tea | tea/msg/mail.py | SMTPConnection._send | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L239-L262 | train | python | Send an email.
Helper method that does the actual sending. | def _send(self, message):
"""Send an email.
Helper method that does the actual sending.
"""
if not message.recipients():
return False
try:
self.connection.sendmail(
message.sender,
message.recipients(),
... | Send an email.
Helper method that does the actual sending.
def _send(self, message):
"""Send an email.
Helper method that does the actual sending.
"""
if not message.recipients():
return False
try:
self.connection.sendmail(
... | 133 | 69 | 696 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | fbf8eb6b0118f07e10557d5ee8ba0d5ae4db782b341b6cc06e851d5392ecdb29 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
b341d78d4908718ce24ee49a | alefnula/tea | tea/msg/mail.py | EmailMessage.attach | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L370-L386 | train | python | Attache a file with the given filename and content.
The filename can be omitted (useful for multipart/alternative messages)
and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the resulting message attachments. | def attach(self, filename=None, content=None, mimetype=None):
"""Attache a file with the given filename and content.
The filename can be omitted (useful for multipart/alternative messages)
and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass... | Attache a file with the given filename and content.
The filename can be omitted (useful for multipart/alternative messages)
and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the resulting message attachments.
... | 201 | 319 | 787 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 495b50578cf50cc0e23b6952a44c9b56fb35bd8c84db4132ee11fd1b613079c2 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
967499af6e903a6e51f0b835 | alefnula/tea | tea/msg/mail.py | EmailMessage.attach_file | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L388-L392 | train | python | Attache a file from the filesystem. | def attach_file(self, path, mimetype=None):
"""Attache a file from the filesystem."""
filename = os.path.basename(path)
content = open(path, "rb").read()
self.attach(filename, content, mimetype) | Attache a file from the filesystem.
def attach_file(self, path, mimetype=None):
"""Attache a file from the filesystem."""
filename = os.path.basename(path)
content = open(path, "rb").read()
self.attach(filename, content, mimetype) | 57 | 35 | 230 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d1cca941724fbced262f5f7e86422da86309b6483f87d9605bd1504a93291df4 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
1085ebedb9127fcc5ab3836f | alefnula/tea | tea/msg/mail.py | EmailMessage._create_attachment | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L394-L414 | train | python | Convert the filename, content, mimetype triple to attachment. | def _create_attachment(self, filename, content, mimetype=None):
"""Convert the filename, content, mimetype triple to attachment."""
if mimetype is None:
mimetype, _ = mimetypes.guess_type(filename)
if mimetype is None:
mimetype = DEFAULT_ATTACHMENT_MIME_TYPE
... | Convert the filename, content, mimetype triple to attachment.
def _create_attachment(self, filename, content, mimetype=None):
"""Convert the filename, content, mimetype triple to attachment."""
if mimetype is None:
mimetype, _ = mimetypes.guess_type(filename)
if mimetype is ... | 177 | 61 | 920 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 22e5b21015050e9ccc4fdab8eaa70489b07c207fa94ca807be9dd0661454b710 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
26b29990629050a4a37ef928 | alefnula/tea | tea/msg/mail.py | EmailMultiAlternatives.attach_alternative | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L427-L429 | train | python | Attach an alternative content representation. | def attach_alternative(self, content, mimetype=None):
"""Attach an alternative content representation."""
self.attach(content=content, mimetype=mimetype) | Attach an alternative content representation.
def attach_alternative(self, content, mimetype=None):
"""Attach an alternative content representation."""
self.attach(content=content, mimetype=mimetype) | 37 | 45 | 171 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 24797a041bfb4738aa8e3e7c46c804d32749745092a1a3afddb66ebbee2f5e28 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
3ffd306bbcdd8d040f57f6c2 | pyout/pyout | pyout/common.py | _safe_get | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L214-L226 | train | python | Helper for accessing style values.
It exists to avoid checking whether `mapping` is indeed a mapping before
trying to get a key. In the context of style dicts, this eliminates "is
this a mapping" checks in two common situations: 1) a style argument is
None, and 2) a style key's value (e.g., width) can... | def _safe_get(mapping, key, default=None):
"""Helper for accessing style values.
It exists to avoid checking whether `mapping` is indeed a mapping before
trying to get a key. In the context of style dicts, this eliminates "is
this a mapping" checks in two common situations: 1) a style argument is
... | Helper for accessing style values.
It exists to avoid checking whether `mapping` is indeed a mapping before
trying to get a key. In the context of style dicts, this eliminates "is
this a mapping" checks in two common situations: 1) a style argument is
None, and 2) a style key's value (e.g., width) can... | 215 | 362 | 520 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | b8b0a50693d17dcf39923ea1e882a767d381867c022c6c12d70712c8a193d469 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
3b369bc77e6c0942e45ea231 | pyout/pyout | pyout/common.py | RowNormalizer.strip_callables | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L150-L198 | train | python | Extract callable values from `row`.
Replace the callable values with the initial value (if specified) or
an empty string.
Parameters
----------
row : mapping
A data row. The keys are either a single column name or a tuple of
column names. The values ta... | def strip_callables(row):
"""Extract callable values from `row`.
Replace the callable values with the initial value (if specified) or
an empty string.
Parameters
----------
row : mapping
A data row. The keys are either a single column name or a tuple of
... | Extract callable values from `row`.
Replace the callable values with the initial value (if specified) or
an empty string.
Parameters
----------
row : mapping
A data row. The keys are either a single column name or a tuple of
column names. The values ta... | 466 | 594 | 1,714 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 147d27797936bfc0969b222f11aea8053c57b4a2fc2bc15618dedd3793280a2a | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
897f0776c3467672adf4ee45 | pyout/pyout | pyout/common.py | StyleFields.build | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L252-L281 | train | python | Build the style and fields.
Parameters
----------
columns : list of str
Column names. | def build(self, columns):
"""Build the style and fields.
Parameters
----------
columns : list of str
Column names.
"""
self.columns = columns
default = dict(elements.default("default_"),
**_safe_get(self.init_style, "default_", ... | Build the style and fields.
Parameters
----------
columns : list of str
Column names.
def build(self, columns):
"""Build the style and fields.
Parameters
----------
columns : list of str
Column names.
"""
self.columns = c... | 299 | 122 | 1,357 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | c8405711e459490d9cf1d1d1c9e93d255360aa124e5a6eab0c0529833311f63e | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
0da9f87c886a338165c41f06 | pyout/pyout | pyout/common.py | StyleFields._compose | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L283-L304 | train | python | Construct a style taking `attributes` from the column styles.
Parameters
----------
name : str
Name of main style (e.g., "header_").
attributes : set of str
Adopt these elements from the column styles.
Returns
-------
The composite style ... | def _compose(self, name, attributes):
"""Construct a style taking `attributes` from the column styles.
Parameters
----------
name : str
Name of main style (e.g., "header_").
attributes : set of str
Adopt these elements from the column styles.
Ret... | Construct a style taking `attributes` from the column styles.
Parameters
----------
name : str
Name of main style (e.g., "header_").
attributes : set of str
Adopt these elements from the column styles.
Returns
-------
The composite style ... | 225 | 331 | 794 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 833dea68fedb6968f9fe8baf78584087e4d7dfaac8a7e5b7a47b6ce15461e51a | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
124e9cd3a1452a366d2626fa | pyout/pyout | pyout/common.py | StyleFields._set_widths | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L361-L434 | train | python | Update auto-width Fields based on `row`.
Parameters
----------
row : dict
proc_group : {'default', 'override'}
Whether to consider 'default' or 'override' key for pre- and
post-format processors.
Returns
-------
True if any widths require... | def _set_widths(self, row, proc_group):
"""Update auto-width Fields based on `row`.
Parameters
----------
row : dict
proc_group : {'default', 'override'}
Whether to consider 'default' or 'override' key for pre- and
post-format processors.
Returns... | Update auto-width Fields based on `row`.
Parameters
----------
row : dict
proc_group : {'default', 'override'}
Whether to consider 'default' or 'override' key for pre- and
post-format processors.
Returns
-------
True if any widths require... | 704 | 333 | 3,429 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d38401bc1b04f8fadb85c14b80697b90e19ac6a687dea97f687f3e03c5c1a35b | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
e76b206374219d6659176642 | pyout/pyout | pyout/common.py | StyleFields._proc_group | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L436-L466 | train | python | Return whether group is "default" or "override".
In the case of "override", the self.fields pre-format and post-format
processors will be set under the "override" key.
Parameters
----------
style : dict
A style that follows the schema defined in pyout.elements.
... | def _proc_group(self, style, adopt=True):
"""Return whether group is "default" or "override".
In the case of "override", the self.fields pre-format and post-format
processors will be set under the "override" key.
Parameters
----------
style : dict
A style th... | Return whether group is "default" or "override".
In the case of "override", the self.fields pre-format and post-format
processors will be set under the "override" key.
Parameters
----------
style : dict
A style that follows the schema defined in pyout.elements.
... | 334 | 525 | 1,166 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 246e06413dfd9f34c3095cae1ca4e1df1542c3c9730c17129a7fb26f158cc3ae | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
828c56f2dde8413a18df2319 | pyout/pyout | pyout/common.py | StyleFields.render | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L468-L499 | train | python | Render fields with values from `row`.
Parameters
----------
row : dict
A normalized row.
style : dict, optional
A style that follows the schema defined in pyout.elements. If
None, `self.style` is used.
adopt : bool, optional
Merge... | def render(self, row, style=None, adopt=True):
"""Render fields with values from `row`.
Parameters
----------
row : dict
A normalized row.
style : dict, optional
A style that follows the schema defined in pyout.elements. If
None, `self.style`... | Render fields with values from `row`.
Parameters
----------
row : dict
A normalized row.
style : dict, optional
A style that follows the schema defined in pyout.elements. If
None, `self.style` is used.
adopt : bool, optional
Merge... | 393 | 634 | 1,228 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 17850b9d8a2566cc10b0536dd1f419e51077094aaefc9a6789c08adebc24ca1b | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
1d74a43de4b92d5af1c023fa | night-crawler/django-docker-helpers | django_docker_helpers/config/backends/base.py | BaseParser.get | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/base.py#L47-L63 | train | python | Inherited method should take all specified arguments.
:param variable_path: a delimiter-separated path to a nested value
:param default: default value if there's no object by specified path
:param coerce_type: cast a type of a value to a specified one
:param coercer: perform a type cast... | def get(self,
variable_path: str,
default: t.Optional[t.Any] = None,
coerce_type: t.Optional[t.Type] = None,
coercer: t.Optional[t.Callable] = None,
**kwargs):
"""
Inherited method should take all specified arguments.
:param variable_p... | Inherited method should take all specified arguments.
:param variable_path: a delimiter-separated path to a nested value
:param default: default value if there's no object by specified path
:param coerce_type: cast a type of a value to a specified one
:param coercer: perform a type cast... | 240 | 451 | 737 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 4840f95cd93b7becf523ae3b580966e607227d066d0df0421199acaa1662d5d2 | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
dc2802207b9cb3522f27b596 | night-crawler/django-docker-helpers | django_docker_helpers/config/backends/base.py | BaseParser.coerce | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/base.py#L66-L92 | train | python | Casts a type of ``val`` to ``coerce_type`` with ``coercer``.
If ``coerce_type`` is bool and no ``coercer`` specified it uses
:func:`~django_docker_helpers.utils.coerce_str_to_bool` by default.
:param val: a value of any type
:param coerce_type: any type
:param coercer: provide ... | def coerce(val: t.Any,
coerce_type: t.Optional[t.Type] = None,
coercer: t.Optional[t.Callable] = None) -> t.Any:
"""
Casts a type of ``val`` to ``coerce_type`` with ``coercer``.
If ``coerce_type`` is bool and no ``coercer`` specified it uses
:func:`~django_... | Casts a type of ``val`` to ``coerce_type`` with ``coercer``.
If ``coerce_type`` is bool and no ``coercer`` specified it uses
:func:`~django_docker_helpers.utils.coerce_str_to_bool` by default.
:param val: a value of any type
:param coerce_type: any type
:param coercer: provide ... | 334 | 422 | 939 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 994a3f41a803d06afabaa80ddbc5dcc95bb189dc28396eacd75fd675cd84f788 | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
021f11d1d168c6db9809639f | night-crawler/django-docker-helpers | django_docker_helpers/config/backends/base.py | BaseParser.client | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/base.py#L95-L106 | train | python | Helper property to lazy initialize and cache client. Runs
:meth:`~django_docker_helpers.config.backends.base.BaseParser.get_client`.
:return: an instance of backend-specific client | def client(self):
"""
Helper property to lazy initialize and cache client. Runs
:meth:`~django_docker_helpers.config.backends.base.BaseParser.get_client`.
:return: an instance of backend-specific client
"""
if self._client is not None:
return self._client
... | Helper property to lazy initialize and cache client. Runs
:meth:`~django_docker_helpers.config.backends.base.BaseParser.get_client`.
:return: an instance of backend-specific client
def client(self):
"""
Helper property to lazy initialize and cache client. Runs
:meth:`~django_do... | 114 | 197 | 386 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | f1887b84f88bdd93bd116fdb5d419acbddb1662bc7e1a1bc98fbaa684b7b2627 | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
bd1db3fcc8dfb1e8150ddca7 | pyout/pyout | pyout/truncate.py | _splice | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/truncate.py#L27-L54 | train | python | Splice `value` at its center, retaining a total of `n` characters.
Parameters
----------
value : str
n : int
The total length of the returned ends will not be greater than this
value. Characters will be dropped from the center to reach this limit.
Returns
-------
A tuple o... | def _splice(value, n):
"""Splice `value` at its center, retaining a total of `n` characters.
Parameters
----------
value : str
n : int
The total length of the returned ends will not be greater than this
value. Characters will be dropped from the center to reach this limit.
Ret... | Splice `value` at its center, retaining a total of `n` characters.
Parameters
----------
value : str
n : int
The total length of the returned ends will not be greater than this
value. Characters will be dropped from the center to reach this limit.
Returns
-------
A tuple o... | 278 | 340 | 743 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 31a051b69f4ec4fb1992085ca068db1e60e2b06be6f266278715a3d64ecbf039 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
1ce88d86902f63d9b3dde6a6 | night-crawler/django-docker-helpers | django_docker_helpers/cli/django/management/commands/run_configured_uwsgi.py | write_uwsgi_ini_cfg | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/cli/django/management/commands/run_configured_uwsgi.py#L9-L40 | train | python | Writes into IO stream the uwsgi.ini file content (actually it does smth strange, just look below).
uWSGI configs are likely to break INI (YAML, etc) specification (double key definition)
so it writes `cfg` object (dict) in "uWSGI Style".
>>> import sys
>>> cfg = {
... 'static-map': [
... '/sta... | def write_uwsgi_ini_cfg(fp: t.IO, cfg: dict):
"""
Writes into IO stream the uwsgi.ini file content (actually it does smth strange, just look below).
uWSGI configs are likely to break INI (YAML, etc) specification (double key definition)
so it writes `cfg` object (dict) in "uWSGI Style".
>>> import... | Writes into IO stream the uwsgi.ini file content (actually it does smth strange, just look below).
uWSGI configs are likely to break INI (YAML, etc) specification (double key definition)
so it writes `cfg` object (dict) in "uWSGI Style".
>>> import sys
>>> cfg = {
... 'static-map': [
... '/sta... | 429 | 645 | 1,004 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 79da8d09b0f11375cddaad8565df06b18e1a50245e409709f811e342e39a1a7e | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
e2254b3c002b377ca380cdd5 | night-crawler/django-docker-helpers | django_docker_helpers/config/backends/mpt_consul_parser.py | MPTConsulParser.get | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/mpt_consul_parser.py#L76-L119 | train | python | :param variable_path: a delimiter-separated path to a nested value
:param default: default value if there's no object by specified path
:param coerce_type: cast a type of a value to a specified one
:param coercer: perform a type casting with specified callback
:param kwargs: additional a... | def get(self,
variable_path: str,
default: t.Optional[t.Any] = None,
coerce_type: t.Optional[t.Type] = None,
coercer: t.Optional[t.Callable] = None,
**kwargs):
"""
:param variable_path: a delimiter-separated path to a nested value
:para... | :param variable_path: a delimiter-separated path to a nested value
:param default: default value if there's no object by specified path
:param coerce_type: cast a type of a value to a specified one
:param coercer: perform a type casting with specified callback
:param kwargs: additional a... | 460 | 388 | 1,815 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | bda86f5312007f15c334b47872f68fcfa147a8d2714683d4085de14c387a3259 | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
50cd7d12a6cda8fc06ff0ae1 | pyout/pyout | pyout/field.py | Field.add | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L84-L106 | train | python | Add processor functions.
Any previous list of processors for `kind` and `key` will be
overwritten.
Parameters
----------
kind : {"pre", "post"}
key : str
A registered key. Add the functions (in order) to this key's list
of processors.
*v... | def add(self, kind, key, *values):
"""Add processor functions.
Any previous list of processors for `kind` and `key` will be
overwritten.
Parameters
----------
kind : {"pre", "post"}
key : str
A registered key. Add the functions (in order) to this ke... | Add processor functions.
Any previous list of processors for `kind` and `key` will be
overwritten.
Parameters
----------
kind : {"pre", "post"}
key : str
A registered key. Add the functions (in order) to this key's list
of processors.
*v... | 233 | 368 | 681 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 3c620b2ba3d5482080c8eda83bb06a74ee984d4119cd936a1a834f100cf3bbe4 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
9ca15b56f4b2b4b9f7a6d1a7 | pyout/pyout | pyout/field.py | Field._format | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L121-L124 | train | python | Wrap format call as a two-argument processor function. | def _format(self, _, result):
"""Wrap format call as a two-argument processor function.
"""
return self._fmt.format(six.text_type(result)) | Wrap format call as a two-argument processor function.
def _format(self, _, result):
"""Wrap format call as a two-argument processor function.
"""
return self._fmt.format(six.text_type(result)) | 46 | 54 | 162 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 31922385e9f059d1c5f94622a751bc03f073e454b21152285aa33abded11aa39 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
b221aaa0e5534bbcfb0eec29 | pyout/pyout | pyout/field.py | StyleProcessors.transform | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L240-L262 | train | python | Return a processor for a style's "transform" function. | def transform(function):
"""Return a processor for a style's "transform" function.
"""
def transform_fn(_, result):
if isinstance(result, Nothing):
return result
lgr.debug("Transforming %r with %r", result, function)
try:
retur... | Return a processor for a style's "transform" function.
def transform(function):
"""Return a processor for a style's "transform" function.
"""
def transform_fn(_, result):
if isinstance(result, Nothing):
return result
lgr.debug("Transforming %r with %r", ... | 186 | 54 | 942 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 982d12a4261e8f5ce99a255a2a85c79cc72cbbf2663eb3927b25e8722b0e8d7e | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
58d1e1924ea52f0a1c796c80 | pyout/pyout | pyout/field.py | StyleProcessors.by_key | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L264-L287 | train | python | Return a processor for a "simple" style value.
Parameters
----------
style_key : str
A style key.
style_value : bool or str
A "simple" style value that is either a style attribute (str) and a
boolean flag indicating to use the style attribute named by... | def by_key(self, style_key, style_value):
"""Return a processor for a "simple" style value.
Parameters
----------
style_key : str
A style key.
style_value : bool or str
A "simple" style value that is either a style attribute (str) and a
boolea... | Return a processor for a "simple" style value.
Parameters
----------
style_key : str
A style key.
style_value : bool or str
A "simple" style value that is either a style attribute (str) and a
boolean flag indicating to use the style attribute named by... | 222 | 398 | 698 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 8678ba1f2e3e7ce7c0dafcfef43fc414c76e935faea91df79978aa15ab9b90a2 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
83af1009f63cc73332074401 | pyout/pyout | pyout/field.py | StyleProcessors.by_lookup | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L289-L320 | train | python | Return a processor that extracts the style from `mapping`.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with a "lookup" key whose value is a "mapping" style
value that maps a field value to either a style attribut... | def by_lookup(self, style_key, style_value):
"""Return a processor that extracts the style from `mapping`.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with a "lookup" key whose value is a "mapping" style
... | Return a processor that extracts the style from `mapping`.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with a "lookup" key whose value is a "mapping" style
value that maps a field value to either a style attribut... | 305 | 483 | 1,096 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 58f6536cd91a131aaf4fe9c4a6c1cc975de351ff06e580fad8a2a482789a23e5 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
5d61f5b205999a5dab30c8e7 | pyout/pyout | pyout/field.py | StyleProcessors.by_re_lookup | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L322-L355 | train | python | Return a processor for a "re_lookup" style value.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with a "re_lookup" style value that consists of a
sequence of items where each item should have the form `(regexp,
... | def by_re_lookup(self, style_key, style_value, re_flags=0):
"""Return a processor for a "re_lookup" style value.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with a "re_lookup" style value that consists of a
... | Return a processor for a "re_lookup" style value.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with a "re_lookup" style value that consists of a
sequence of items where each item should have the form `(regexp,
... | 404 | 682 | 1,356 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | e191528c05c428499627d27ab25b28877a704df8239ff3def64ffa1e9ebba9bc | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
cce055a82ea020795cb5ee05 | pyout/pyout | pyout/field.py | StyleProcessors.by_interval_lookup | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L357-L396 | train | python | Return a processor for an "interval" style value.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with an "interval" key whose value consists of a
sequence of tuples where each tuple should have the form `(start,
... | def by_interval_lookup(self, style_key, style_value):
"""Return a processor for an "interval" style value.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with an "interval" key whose value consists of a
sequ... | Return a processor for an "interval" style value.
Parameters
----------
style_key : str
A style key.
style_value : dict
A dictionary with an "interval" key whose value consists of a
sequence of tuples where each tuple should have the form `(start,
... | 395 | 632 | 1,426 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d3c9ec9b61175e77c2ec30e2d85ce04765d5c01c60c2a75954757534fa376fb4 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
36db76da3d30f224327344a3 | pyout/pyout | pyout/field.py | StyleProcessors.post_from_style | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L414-L447 | train | python | Yield post-format processors based on `column_style`.
Parameters
----------
column_style : dict
A style where the top-level keys correspond to style attributes
such as "bold" or "color".
Returns
-------
A generator object. | def post_from_style(self, column_style):
"""Yield post-format processors based on `column_style`.
Parameters
----------
column_style : dict
A style where the top-level keys correspond to style attributes
such as "bold" or "color".
Returns
-------... | Yield post-format processors based on `column_style`.
Parameters
----------
column_style : dict
A style where the top-level keys correspond to style attributes
such as "bold" or "color".
Returns
-------
A generator object.
def post_from_style(se... | 268 | 296 | 1,047 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 5a4d16bb5ac8a1136afb1ce5bd23f851d0de28259d0c777726a6fc2482d15d37 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
df2ee0152b90a660bc59b4d4 | pyout/pyout | pyout/field.py | Flanks.split_flanks | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L459-L469 | train | python | Return `result` without flanking whitespace. | def split_flanks(self, _, result):
"""Return `result` without flanking whitespace.
"""
if not result.strip():
self.left, self.right = "", ""
return result
match = self.flank_re.match(result)
assert match, "This regexp should always match"
self.lef... | Return `result` without flanking whitespace.
def split_flanks(self, _, result):
"""Return `result` without flanking whitespace.
"""
if not result.strip():
self.left, self.right = "", ""
return result
match = self.flank_re.match(result)
assert match, "Thi... | 95 | 44 | 396 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 787bb9bf251894d59f455889299e4b071fb620114a9230b38eb229e1a223536d | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
73dcabadbc6e79b4ac886286 | pyout/pyout | pyout/field.py | TermProcessors.render | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L495-L514 | train | python | Prepend terminal code for `key` to `value`.
Parameters
----------
style_attr : str
A style attribute (e.g., "bold" or "blue").
value : str
The value to render.
Returns
-------
The code for `key` (e.g., "\x1b[1m" for bold) plus the
... | def render(self, style_attr, value):
"""Prepend terminal code for `key` to `value`.
Parameters
----------
style_attr : str
A style attribute (e.g., "bold" or "blue").
value : str
The value to render.
Returns
-------
The code for `... | Prepend terminal code for `key` to `value`.
Parameters
----------
style_attr : str
A style attribute (e.g., "bold" or "blue").
value : str
The value to render.
Returns
-------
The code for `key` (e.g., "\x1b[1m" for bold) plus the
... | 224 | 336 | 607 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 7a5c6f5ed8d9b100fb8595e77cc588335500f3bd17ba10f51f047682e5380415 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
dcc400524262bcf94b5886f0 | pyout/pyout | pyout/field.py | TermProcessors.post_from_style | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L523-L530 | train | python | A Terminal-specific reset to StyleProcessors.post_from_style. | def post_from_style(self, column_style):
"""A Terminal-specific reset to StyleProcessors.post_from_style.
"""
for proc in super(TermProcessors, self).post_from_style(column_style):
if proc.__name__ == "join_flanks":
# Reset any codes before adding back whitespace.
... | A Terminal-specific reset to StyleProcessors.post_from_style.
def post_from_style(self, column_style):
"""A Terminal-specific reset to StyleProcessors.post_from_style.
"""
for proc in super(TermProcessors, self).post_from_style(column_style):
if proc.__name__ == "join_flanks":
... | 87 | 61 | 381 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | e1aed458ce40f4a653781ea12192052d3118a48006746e08469b02d894f6aef4 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
d82bb0e93e2dc5a77faa14da | alefnula/tea | tea/logger/log.py | configure_logging | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/logger/log.py#L31-L98 | train | python | Configure logging module.
Args:
filename (str): Specifies a filename to log to.
filemode (str): Specifies the mode to open the log file.
Values: ``'a'``, ``'w'``. *Default:* ``a``.
datefmt (str): Use the specified date/time format.
fmt (str): Format string for the file h... | def configure_logging(
filename=None,
filemode="a",
datefmt=FMT_DATE,
fmt=FMT,
stdout_fmt=FMT_STDOUT,
level=logging.DEBUG,
stdout_level=logging.WARNING,
initial_file_message="",
max_size=1048576,
rotations_number=5,
remove_handlers=True,
):
"""Configure logging module.
... | Configure logging module.
Args:
filename (str): Specifies a filename to log to.
filemode (str): Specifies the mode to open the log file.
Values: ``'a'``, ``'w'``. *Default:* ``a``.
datefmt (str): Use the specified date/time format.
fmt (str): Format string for the file h... | 851 | 1,105 | 2,873 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 942f5664635686c461597d5f3ecd5e75478b823be4ddd4e160a7bdf09d7adba8 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
507e86e80b27966f04b3a71c | jonhadfield/creds | lib/creds/plan.py | create_plan | https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/plan.py#L13-L70 | train | python | Determine what changes are required.
args:
existing_users (Users): List of discovered users
proposed_users (Users): List of proposed users
purge_undefined (bool): Remove discovered users that have not been defined in proposed users list
protected_users (list): List of users' names t... | def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None,
allow_non_unique_id=None, manage_home=True, manage_keys=True):
"""Determine what changes are required.
args:
existing_users (Users): List of discovered users
proposed_users (Use... | Determine what changes are required.
args:
existing_users (Users): List of discovered users
proposed_users (Users): List of proposed users
purge_undefined (bool): Remove discovered users that have not been defined in proposed users list
protected_users (list): List of users' names t... | 783 | 775 | 3,199 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 2a146c41b5acf789007fdb4acccf4f65bde2135886db347a27bd5308b5a4159c | MIT | permissive | https://github.com/jonhadfield/creds/blob/master/LICENSE |
8ae454855b1066efd2e7cbaa | jonhadfield/creds | lib/creds/plan.py | execute_plan | https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/plan.py#L73-L113 | train | python | Create, Modify or Delete, depending on plan item. | def execute_plan(plan=None):
"""Create, Modify or Delete, depending on plan item."""
execution_result = list()
for task in plan:
action = task['action']
if action == 'delete':
command = generate_delete_user_command(username=task.get('username'), manage_home=task['manage_home'])
... | Create, Modify or Delete, depending on plan item.
def execute_plan(plan=None):
"""Create, Modify or Delete, depending on plan item."""
execution_result = list()
for task in plan:
action = task['action']
if action == 'delete':
command = generate_delete_user_command(username=task.... | 518 | 49 | 2,590 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 87e9a162c30e82a8b5eb7db882514f519d93ef6b3dac8be75e4cf5cc7183a5f9 | MIT | permissive | https://github.com/jonhadfield/creds/blob/master/LICENSE |
5ace50256f5098a5a4d4596b | night-crawler/django-docker-helpers | django_docker_helpers/config/backends/environment_parser.py | EnvironmentParser.get | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/environment_parser.py#L69-L98 | train | python | Reads a value of ``variable_path`` from environment.
If ``coerce_type`` is ``bool`` and no ``coercer`` specified, ``coerces`` forced to be
:func:`~django_docker_helpers.utils.coerce_str_to_bool`
:param variable_path: a delimiter-separated path to a nested value
:param default: default ... | def get(self,
variable_path: str,
default: t.Optional[t.Any] = None,
coerce_type: t.Optional[t.Type] = None,
coercer: t.Optional[t.Callable] = None,
**kwargs):
"""
Reads a value of ``variable_path`` from environment.
If ``coerce_type``... | Reads a value of ``variable_path`` from environment.
If ``coerce_type`` is ``bool`` and no ``coercer`` specified, ``coerces`` forced to be
:func:`~django_docker_helpers.utils.coerce_str_to_bool`
:param variable_path: a delimiter-separated path to a nested value
:param default: default ... | 427 | 609 | 1,285 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | b52e636b1e2e542d8ab20c68ef170b74f79e39d8bcea40adc53aef9d22746911 | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
312f5f90e301ad9ec661f989 | alefnula/tea | tea/utils/compress.py | unzip | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/compress.py#L40-L89 | train | python | Unzip a zip archive into destination directory.
It unzips either the whole archive or specific file(s) from the archive.
Usage:
>>> output = os.path.join(os.getcwd(), 'output')
>>> # Archive can be an instance of a ZipFile class
>>> archive = zipfile.ZipFile('test.zip', 'r')
>>... | def unzip(archive, destination, filenames=None):
"""Unzip a zip archive into destination directory.
It unzips either the whole archive or specific file(s) from the archive.
Usage:
>>> output = os.path.join(os.getcwd(), 'output')
>>> # Archive can be an instance of a ZipFile class
>... | Unzip a zip archive into destination directory.
It unzips either the whole archive or specific file(s) from the archive.
Usage:
>>> output = os.path.join(os.getcwd(), 'output')
>>> # Archive can be an instance of a ZipFile class
>>> archive = zipfile.ZipFile('test.zip', 'r')
>>... | 689 | 1,011 | 2,057 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 6f5c19174af4f34230f63fd8d4dba7140e2eab5a6d1386f14024b3b51d5920c0 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
e822055e116180dc1d5fbc33 | alefnula/tea | tea/utils/compress.py | mkzip | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/compress.py#L92-L137 | train | python | Recursively zip a directory.
Args:
archive (zipfile.ZipFile or str): ZipFile object add to or path to the
output zip archive.
items (str or list of str): Single item or list of items (files and
directories) to be added to zipfile.
mode (str): w for create new and wri... | def mkzip(archive, items, mode="w", save_full_paths=False):
"""Recursively zip a directory.
Args:
archive (zipfile.ZipFile or str): ZipFile object add to or path to the
output zip archive.
items (str or list of str): Single item or list of items (files and
directories) t... | Recursively zip a directory.
Args:
archive (zipfile.ZipFile or str): ZipFile object add to or path to the
output zip archive.
items (str or list of str): Single item or list of items (files and
directories) to be added to zipfile.
mode (str): w for create new and wri... | 485 | 392 | 1,961 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | a1a7343f5fdf600dc3197278d0a5f4eef1376d05e0f09154ce5d928d3e104de3 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
65dcd8216a0fea78356e55fc | alefnula/tea | tea/utils/compress.py | seven_zip | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/compress.py#L158-L165 | train | python | Create a 7z archive. | def seven_zip(archive, items, self_extracting=False):
"""Create a 7z archive."""
if not isinstance(items, (list, tuple)):
items = [items]
if self_extracting:
return er(_get_sz(), "a", "-ssw", "-sfx", archive, *items)
else:
return er(_get_sz(), "a", "-ssw", archive, *items) | Create a 7z archive.
def seven_zip(archive, items, self_extracting=False):
"""Create a 7z archive."""
if not isinstance(items, (list, tuple)):
items = [items]
if self_extracting:
return er(_get_sz(), "a", "-ssw", "-sfx", archive, *items)
else:
return er(_get_sz(), "a", "-ssw", a... | 97 | 20 | 313 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | e23484e3a205e1918692d8510f6991ef2b10a46a9a58b6b95b6ea320bac7a6b7 | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
3c53e2befc4826bfed8c8559 | night-crawler/django-docker-helpers | django_docker_helpers/db.py | ensure_caches_alive | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/db.py#L12-L45 | train | python | Checks every cache backend alias in ``settings.CACHES`` until it becomes available. After ``max_retries``
attempts to reach any backend are failed it returns ``False``. If ``exit_on_failure`` is set it shuts down with
``exit(1)``.
It sets the ``django-docker-helpers:available-check`` key for every cache ba... | def ensure_caches_alive(max_retries: int = 100,
retry_timeout: int = 5,
exit_on_failure: bool = True) -> bool:
"""
Checks every cache backend alias in ``settings.CACHES`` until it becomes available. After ``max_retries``
attempts to reach any backend are faile... | Checks every cache backend alias in ``settings.CACHES`` until it becomes available. After ``max_retries``
attempts to reach any backend are failed it returns ``False``. If ``exit_on_failure`` is set it shuts down with
``exit(1)``.
It sets the ``django-docker-helpers:available-check`` key for every cache ba... | 569 | 751 | 1,709 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | cffbf08e1a9ca247107a8932e9074611792184658738f0a5aa517e439fb3a706 | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
ae2fac7d23bea87c97b5dfda | night-crawler/django-docker-helpers | django_docker_helpers/db.py | ensure_databases_alive | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/db.py#L49-L98 | train | python | Checks every database alias in ``settings.DATABASES`` until it becomes available. After ``max_retries``
attempts to reach any backend are failed it returns ``False``. If ``exit_on_failure`` is set it shuts down with
``exit(1)``.
For every database alias it tries to ``SELECT 1``. If no errors raised it chec... | def ensure_databases_alive(max_retries: int = 100,
retry_timeout: int = 5,
exit_on_failure: bool = True) -> bool:
"""
Checks every database alias in ``settings.DATABASES`` until it becomes available. After ``max_retries``
attempts to reach any backend ar... | Checks every database alias in ``settings.DATABASES`` until it becomes available. After ``max_retries``
attempts to reach any backend are failed it returns ``False``. If ``exit_on_failure`` is set it shuts down with
``exit(1)``.
For every database alias it tries to ``SELECT 1``. If no errors raised it chec... | 605 | 663 | 2,055 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | f5ae84537a5fa8e1e246da29ed129aff5681d791d1a059ae879e2788044312d6 | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
f034fd4bd735fd0b27e37756 | night-crawler/django-docker-helpers | django_docker_helpers/db.py | migrate | https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/db.py#L102-L111 | train | python | Runs Django migrate command.
:return: always ``True`` | def migrate(*argv) -> bool:
"""
Runs Django migrate command.
:return: always ``True``
"""
wf('Applying migrations... ', False)
execute_from_command_line(['./manage.py', 'migrate'] + list(argv))
wf('[+]\n')
return True | Runs Django migrate command.
:return: always ``True``
def migrate(*argv) -> bool:
"""
Runs Django migrate command.
:return: always ``True``
"""
wf('Applying migrations... ', False)
execute_from_command_line(['./manage.py', 'migrate'] + list(argv))
wf('[+]\n')
return True | 78 | 58 | 250 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 2163f63d72c8793b53074f7eb5796b0dde9a7d8071967c9288380a06c469b11c | MIT | permissive | https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE |
ec37805ec5448e43a3b35803 | letuananh/chirptext | chirptext/arsenal.py | JiCache.__retrieve | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/arsenal.py#L85-L103 | train | python | Retrieve file location from cache DB | def __retrieve(self, key):
''' Retrieve file location from cache DB
'''
with self.get_conn() as conn:
try:
c = conn.cursor()
if key is None:
c.execute("SELECT value FROM cache_entries WHERE key IS NULL")
else:
... | Retrieve file location from cache DB
def __retrieve(self, key):
''' Retrieve file location from cache DB
'''
with self.get_conn() as conn:
try:
c = conn.cursor()
if key is None:
c.execute("SELECT value FROM cache_entries WHERE key ... | 146 | 36 | 777 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 817c3ce260d5d7d35a63902b7e464b96a8acca168ffd79e9035e22582dfbcb53 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
ee636ba1f282b1b3abf1d22c | letuananh/chirptext | chirptext/arsenal.py | JiCache.__insert | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/arsenal.py#L111-L127 | train | python | Insert a new key to database | def __insert(self, key, value):
'''
Insert a new key to database
'''
if key in self:
getLogger().warning("Cache entry exists, cannot insert a new entry with key='{key}'".format(key=key))
return False
with self.get_conn() as conn:
try:
... | Insert a new key to database
def __insert(self, key, value):
'''
Insert a new key to database
'''
if key in self:
getLogger().warning("Cache entry exists, cannot insert a new entry with key='{key}'".format(key=key))
return False
with self.get_conn() as co... | 152 | 28 | 705 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | aedce5504d6dde103eed53ddb5096657424fadb8b5548aa56b47a03547d241f4 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
4e08e457e4bde750f5380cda | letuananh/chirptext | chirptext/arsenal.py | JiCache.__delete | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/arsenal.py#L129-L139 | train | python | Delete file key from database | def __delete(self, key):
''' Delete file key from database
'''
with self.get_conn() as conn:
try:
c = conn.cursor()
c.execute("DELETE FROM cache_entries WHERE key = ?", (key,))
conn.commit()
except:
getLogger... | Delete file key from database
def __delete(self, key):
''' Delete file key from database
'''
with self.get_conn() as conn:
try:
c = conn.cursor()
c.execute("DELETE FROM cache_entries WHERE key = ?", (key,))
conn.commit()
ex... | 74 | 29 | 377 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 9d60a70b18a257898452c21c707309a2c715d061ec49842b0d5b93810f33385f | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
ea9146d5fbf488df7224bb60 | letuananh/chirptext | chirptext/arsenal.py | JiCache.__insert_internal_blob | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/arsenal.py#L143-L160 | train | python | This method will insert blob data to blob table | def __insert_internal_blob(self, key, blob, compressed=True):
''' This method will insert blob data to blob table
'''
with self.get_conn() as conn:
conn.isolation_level = None
c = conn.cursor()
try:
compressed_flag = 1 if compressed else 0
... | This method will insert blob data to blob table
def __insert_internal_blob(self, key, blob, compressed=True):
''' This method will insert blob data to blob table
'''
with self.get_conn() as conn:
conn.isolation_level = None
c = conn.cursor()
try:
... | 177 | 47 | 848 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | cddd6e25de969c844171703cb01f2a5326a205e013e3105e601d539a11a3cf00 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
72dfab7ed7a09c209d5f9d0d | letuananh/chirptext | chirptext/arsenal.py | JiCache.__delete_internal_blob | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/arsenal.py#L162-L180 | train | python | This method will insert blob data to blob table | def __delete_internal_blob(self, key):
''' This method will insert blob data to blob table
'''
with self.get_conn() as conn:
conn.isolation_level = None
try:
c = conn.cursor()
c.execute("BEGIN")
if key is None:
... | This method will insert blob data to blob table
def __delete_internal_blob(self, key):
''' This method will insert blob data to blob table
'''
with self.get_conn() as conn:
conn.isolation_level = None
try:
c = conn.cursor()
c.execute("BEGI... | 155 | 47 | 802 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | ef8fd3c86d49c7123b37aa0c66a36af6fa5c8c6c0a2722c99a47b1281ab189ae | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
706170dd6291ff790798ea86 | letuananh/chirptext | chirptext/arsenal.py | JiCache.__retrieve_internal_blob | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/arsenal.py#L182-L205 | train | python | Retrieve file location from cache DB | def __retrieve_internal_blob(self, key):
''' Retrieve file location from cache DB
'''
logger = getLogger()
with self.get_conn() as conn:
try:
c = conn.cursor()
if key is None:
c.execute("SELECT compressed, blob_data FROM blo... | Retrieve file location from cache DB
def __retrieve_internal_blob(self, key):
''' Retrieve file location from cache DB
'''
logger = getLogger()
with self.get_conn() as conn:
try:
c = conn.cursor()
if key is None:
c.execute(... | 232 | 36 | 1,207 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 9c77fe8003d8721647189fcd938db2d783c994ca8c7802346e98df3e2168e7c3 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
292c223259176246bb7b180f | letuananh/chirptext | chirptext/arsenal.py | JiCache.retrieve_blob | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/arsenal.py#L233-L246 | train | python | Retrieve blob in binary format (or string format if encoding is provided) | def retrieve_blob(self, key, encoding=None):
''' Retrieve blob in binary format (or string format if encoding is provided) '''
blob_key = self.__retrieve(key)
if blob_key is None:
return None
if not blob_key:
raise Exception("Invalid blob_key")
elif blob_k... | Retrieve blob in binary format (or string format if encoding is provided)
def retrieve_blob(self, key, encoding=None):
''' Retrieve blob in binary format (or string format if encoding is provided) '''
blob_key = self.__retrieve(key)
if blob_key is None:
return None
if not bl... | 160 | 73 | 706 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | be85437565b0e1b5acd15208656b21d6cd9c35802be8cf8d6a8d1ab719810212 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
82202b3df4056cd56a529713 | pyout/pyout | pyout/summary.py | Summary.summarize | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/summary.py#L33-L82 | train | python | Return summary rows for `rows`.
Parameters
----------
rows : list of dicts
Normalized rows to summarize.
Returns
-------
A list of summary rows. Each row is a tuple where the first item is
the data and the second is a dict of keyword arguments that ... | def summarize(self, rows):
"""Return summary rows for `rows`.
Parameters
----------
rows : list of dicts
Normalized rows to summarize.
Returns
-------
A list of summary rows. Each row is a tuple where the first item is
the data and the secon... | Return summary rows for `rows`.
Parameters
----------
rows : list of dicts
Normalized rows to summarize.
Returns
-------
A list of summary rows. Each row is a tuple where the first item is
the data and the second is a dict of keyword arguments that ... | 465 | 364 | 1,974 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | e5153e2f61f45c6b689ca3da680fda6a9dd38f0a2ed071f6b6a982569728617a | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
72fe7d214f59a973664b5a2b | pyout/pyout | pyout/interface.py | Writer._init | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/interface.py#L109-L135 | train | python | Do writer-specific setup.
Parameters
----------
style : dict
Style, as passed to __init__.
streamer : interface.Stream
A stream interface that takes __init__'s `stream` and `interactive`
arguments into account.
processors : field.StyleProcesso... | def _init(self, style, streamer, processors=None):
"""Do writer-specific setup.
Parameters
----------
style : dict
Style, as passed to __init__.
streamer : interface.Stream
A stream interface that takes __init__'s `stream` and `interactive`
ar... | Do writer-specific setup.
Parameters
----------
style : dict
Style, as passed to __init__.
streamer : interface.Stream
A stream interface that takes __init__'s `stream` and `interactive`
arguments into account.
processors : field.StyleProcesso... | 283 | 433 | 983 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 2852ec5528726414bdf2adc22e4c3eb534319bdc301e8b6e75e3da7fd34a9d70 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
b019ce9cf7e17883e1aa770f | pyout/pyout | pyout/interface.py | Writer.ids | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/interface.py#L188-L199 | train | python | A list of unique IDs used to identify a row.
If not explicitly set, it defaults to the first column name. | def ids(self):
"""A list of unique IDs used to identify a row.
If not explicitly set, it defaults to the first column name.
"""
if self._ids is None:
if self._columns:
if isinstance(self._columns, OrderedDict):
return [list(self._columns.k... | A list of unique IDs used to identify a row.
If not explicitly set, it defaults to the first column name.
def ids(self):
"""A list of unique IDs used to identify a row.
If not explicitly set, it defaults to the first column name.
"""
if self._ids is None:
if self._... | 109 | 114 | 415 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 020082f3195c684cc09dddfea5c562b55842fd6e785a12e7fd652b528207544f | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
d99f41a20538a92dd8ea7128 | pyout/pyout | pyout/interface.py | Writer.wait | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/interface.py#L205-L211 | train | python | Wait for asynchronous calls to return. | def wait(self):
"""Wait for asynchronous calls to return.
"""
if self._pool is None:
return
self._pool.close()
self._pool.join() | Wait for asynchronous calls to return.
def wait(self):
"""Wait for asynchronous calls to return.
"""
if self._pool is None:
return
self._pool.close()
self._pool.join() | 45 | 38 | 180 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 82ba412806bed927c8785d1c667afa1a7a4765f10d37d2cd70f25c5fdd96932c | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
be010b0ddc9397509f1ff984 | pyout/pyout | pyout/interface.py | Writer._write_lock | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/interface.py#L214-L229 | train | python | Acquire and release the lock around output calls.
This should allow multiple threads or processes to write output
reliably. Code that modifies the `_content` attribute should also do
so within this context. | def _write_lock(self):
"""Acquire and release the lock around output calls.
This should allow multiple threads or processes to write output
reliably. Code that modifies the `_content` attribute should also do
so within this context.
"""
if self._lock:
lgr.de... | Acquire and release the lock around output calls.
This should allow multiple threads or processes to write output
reliably. Code that modifies the `_content` attribute should also do
so within this context.
def _write_lock(self):
"""Acquire and release the lock around output calls.
... | 151 | 232 | 542 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 3317565e177cdb7c59cafa10670d255be0241ef16e94ae46b4a761c671a75ee0 | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
6571535b2829908b75dac9d3 | pyout/pyout | pyout/interface.py | Writer._start_callables | https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/interface.py#L292-L329 | train | python | Start running `callables` asynchronously. | def _start_callables(self, row, callables):
"""Start running `callables` asynchronously.
"""
id_vals = {c: row[c] for c in self.ids}
def callback(tab, cols, result):
if isinstance(result, Mapping):
pass
elif isinstance(result, tuple):
... | Start running `callables` asynchronously.
def _start_callables(self, row, callables):
"""Start running `callables` asynchronously.
"""
id_vals = {c: row[c] for c in self.ids}
def callback(tab, cols, result):
if isinstance(result, Mapping):
pass
e... | 267 | 41 | 1,286 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | edc1076b30858716c53d086d07b2995567bb2d5c2370ce98b65352cbcf86f00f | MIT | permissive | https://github.com/pyout/pyout/blob/master/COPYING |
17dc97756d2c9394f4f4571c | smnorris/pgdata | pgdata/database.py | Database.schemas | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L47-L55 | train | python | Get a listing of all non-system schemas (prefixed with 'pg_') that
exist in the database. | def schemas(self):
"""
Get a listing of all non-system schemas (prefixed with 'pg_') that
exist in the database.
"""
sql = """SELECT schema_name FROM information_schema.schemata
ORDER BY schema_name"""
schemas = self.query(sql).fetchall()
return [... | Get a listing of all non-system schemas (prefixed with 'pg_') that
exist in the database.
def schemas(self):
"""
Get a listing of all non-system schemas (prefixed with 'pg_') that
exist in the database.
"""
sql = """SELECT schema_name FROM information_schema.schemata
... | 110 | 97 | 363 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 8cd13ec2bccb03ef9418a414370658484155e1e7ee3d9e8feb63b7d8b6a87b45 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
6f61bc4bc17003594f1fbfde | smnorris/pgdata | pgdata/database.py | Database.tables | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L58-L74 | train | python | Get a listing of all tables
- if schema specified on connect, return unqualifed table names in
that schema
- in no schema specified on connect, return all tables, with schema
prefixes | def tables(self):
"""
Get a listing of all tables
- if schema specified on connect, return unqualifed table names in
that schema
- in no schema specified on connect, return all tables, with schema
prefixes
"""
if self.schema:
return... | Get a listing of all tables
- if schema specified on connect, return unqualifed table names in
that schema
- in no schema specified on connect, return all tables, with schema
prefixes
def tables(self):
"""
Get a listing of all tables
- if schema spe... | 158 | 227 | 589 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d9bc1877cfcab150742afcc686cc88d978526ce8247d73d313117c9a8295a1bc | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
7ce48f5a2b30a3721c7c4246 | smnorris/pgdata | pgdata/database.py | Database._valid_table_name | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L87-L92 | train | python | Check if the table name is obviously invalid. | def _valid_table_name(self, table):
"""Check if the table name is obviously invalid.
"""
if table is None or not len(table.strip()):
raise ValueError("Invalid table name: %r" % table)
return table.strip() | Check if the table name is obviously invalid.
def _valid_table_name(self, table):
"""Check if the table name is obviously invalid.
"""
if table is None or not len(table.strip()):
raise ValueError("Invalid table name: %r" % table)
return table.strip() | 61 | 45 | 248 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 76b4b6399a309873d1e1ce6ea70e2d3a025d1a0ffceddde5a21cb7dd0f4c4ba0 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
d646b7bbdfdf8315d4058725 | smnorris/pgdata | pgdata/database.py | Database.build_query | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L94-L109 | train | python | Modify table and field name variables in a sql string with a dict.
This seems to be discouraged by psycopg2 docs but it makes small
adjustments to large sql strings much easier, making prepped queries
much more versatile.
USAGE
sql = 'SELECT $myInputField FROM $myInputTable'
... | def build_query(self, sql, lookup):
"""
Modify table and field name variables in a sql string with a dict.
This seems to be discouraged by psycopg2 docs but it makes small
adjustments to large sql strings much easier, making prepped queries
much more versatile.
USAGE
... | Modify table and field name variables in a sql string with a dict.
This seems to be discouraged by psycopg2 docs but it makes small
adjustments to large sql strings much easier, making prepped queries
much more versatile.
USAGE
sql = 'SELECT $myInputField FROM $myInputTable'
... | 228 | 434 | 615 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 8e6542a21a525d7124559436d1fc0e70c488a2687ef5706d0311c0b4f2e01d3c | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
c0ddfb5d81a83b7d5499b877 | smnorris/pgdata | pgdata/database.py | Database.tables_in_schema | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L111-L117 | train | python | Get a listing of all tables in given schema | def tables_in_schema(self, schema):
"""Get a listing of all tables in given schema
"""
sql = """SELECT table_name
FROM information_schema.tables
WHERE table_schema = %s"""
return [t[0] for t in self.query(sql, (schema,)).fetchall()] | Get a listing of all tables in given schema
def tables_in_schema(self, schema):
"""Get a listing of all tables in given schema
"""
sql = """SELECT table_name
FROM information_schema.tables
WHERE table_schema = %s"""
return [t[0] for t in self.query(sql,... | 75 | 43 | 298 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 6316e238eec028879eb0adbde7962f2e243d51cd165eee492a06f395c489cc59 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
784c310698c5a5322294f99a | smnorris/pgdata | pgdata/database.py | Database.parse_table_name | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L119-L126 | train | python | Parse schema qualified table name | def parse_table_name(self, table):
"""Parse schema qualified table name
"""
if "." in table:
schema, table = table.split(".")
else:
schema = None
return (schema, table) | Parse schema qualified table name
def parse_table_name(self, table):
"""Parse schema qualified table name
"""
if "." in table:
schema, table = table.split(".")
else:
schema = None
return (schema, table) | 54 | 33 | 232 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 757e63dceb14f1ce4b2e5b2c9e26121c7d6df7475889324309e523a7be5a7375 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
107c473fba4d145cdbc52a02 | smnorris/pgdata | pgdata/database.py | Database.load_table | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L128-L141 | train | python | Loads a table. Returns None if the table does not already exist in db | def load_table(self, table):
"""Loads a table. Returns None if the table does not already exist in db
"""
table = self._valid_table_name(table)
schema, table = self.parse_table_name(table)
if not schema:
schema = self.schema
tables = self.tables
el... | Loads a table. Returns None if the table does not already exist in db
def load_table(self, table):
"""Loads a table. Returns None if the table does not already exist in db
"""
table = self._valid_table_name(table)
schema, table = self.parse_table_name(table)
if not schema:
... | 114 | 69 | 486 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 83cdaa1bf9145719737f318672062402f21f28ea09fc67387875eb5add2c4000 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
b2dcc7d9df8df4e9cba11da8 | smnorris/pgdata | pgdata/database.py | Database.mogrify | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L143-L148 | train | python | Return the query string with parameters added | def mogrify(self, sql, params):
"""Return the query string with parameters added
"""
conn = self.engine.raw_connection()
cursor = conn.cursor()
return cursor.mogrify(sql, params) | Return the query string with parameters added
def mogrify(self, sql, params):
"""Return the query string with parameters added
"""
conn = self.engine.raw_connection()
cursor = conn.cursor()
return cursor.mogrify(sql, params) | 54 | 45 | 218 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | b782ade9e30467c69e1a082d3375701f0566841928b704f75ab7de3fdfe34e7a | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
78bbf8e7a8c8444dd8cb17b0 | smnorris/pgdata | pgdata/database.py | Database.execute | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L150-L157 | train | python | Just a pointer to engine.execute | def execute(self, sql, params=None):
"""Just a pointer to engine.execute
"""
# wrap in a transaction to ensure things are committed
# https://github.com/smnorris/pgdata/issues/3
with self.engine.begin() as conn:
result = conn.execute(sql, params)
return result | Just a pointer to engine.execute
def execute(self, sql, params=None):
"""Just a pointer to engine.execute
"""
# wrap in a transaction to ensure things are committed
# https://github.com/smnorris/pgdata/issues/3
with self.engine.begin() as conn:
result = conn.execute(... | 75 | 32 | 320 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 17b0a6bd487a6554689bb4df7e7efe616a8e914c43d02b8b924ac5f9b69aa897 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
048cbc5a2d6e8b5e8a436812 | smnorris/pgdata | pgdata/database.py | Database.query_one | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L169-L173 | train | python | Grab just one record | def query_one(self, sql, params=None):
"""Grab just one record
"""
r = self.engine.execute(sql, params)
return r.fetchone() | Grab just one record
def query_one(self, sql, params=None):
"""Grab just one record
"""
r = self.engine.execute(sql, params)
return r.fetchone() | 39 | 20 | 155 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 3a16bb297b2733c7ca7297c057f6281a61a39446031908caa61a6cc400d623b8 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
39599570d2f6062983ff2219 | smnorris/pgdata | pgdata/database.py | Database.create_schema | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L175-L180 | train | python | Create specified schema if it does not already exist | def create_schema(self, schema):
"""Create specified schema if it does not already exist
"""
if schema not in self.schemas:
sql = "CREATE SCHEMA " + schema
self.execute(sql) | Create specified schema if it does not already exist
def create_schema(self, schema):
"""Create specified schema if it does not already exist
"""
if schema not in self.schemas:
sql = "CREATE SCHEMA " + schema
self.execute(sql) | 56 | 52 | 221 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 8ba35be42e5037cd1daf64513fbb21b648cba379e8be8e66b29ba7ded0d2f6b8 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
2fc00626426b12cdf9169cd1 | smnorris/pgdata | pgdata/database.py | Database.drop_schema | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L182-L189 | train | python | Drop specified schema | def drop_schema(self, schema, cascade=False):
"""Drop specified schema
"""
if schema in self.schemas:
sql = "DROP SCHEMA " + schema
if cascade:
sql = sql + " CASCADE"
self.execute(sql) | Drop specified schema
def drop_schema(self, schema, cascade=False):
"""Drop specified schema
"""
if schema in self.schemas:
sql = "DROP SCHEMA " + schema
if cascade:
sql = sql + " CASCADE"
self.execute(sql) | 58 | 21 | 260 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 82a2564fa777d8e765142118f83c8214463a27d9b8eb73d63f476eb4642e66e5 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
9b88f7926afce875b801f61e | smnorris/pgdata | pgdata/database.py | Database.create_table | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L197-L207 | train | python | Creates a table | def create_table(self, table, columns):
"""Creates a table
"""
schema, table = self.parse_table_name(table)
table = self._valid_table_name(table)
if not schema:
schema = self.schema
if table in self.tables:
return Table(self, schema, table)
... | Creates a table
def create_table(self, table, columns):
"""Creates a table
"""
schema, table = self.parse_table_name(table)
table = self._valid_table_name(table)
if not schema:
schema = self.schema
if table in self.tables:
return Table(self, schem... | 83 | 15 | 381 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 9b9bc80cd9a784143c608f72e5c7af0ada52c4b602d8328c865af42d5b855644 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
bed75a61cd7a65877aa112f9 | smnorris/pgdata | pgdata/database.py | Database.ogr2pg | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L209-L284 | train | python | Load a layer to provided pgdata database connection using OGR2OGR
-sql option is like an ESRI where_clause or the ogr2ogr -where option,
but to increase flexibility, it is in SQLITE dialect:
SELECT * FROM <in_layer> WHERE <sql> | def ogr2pg(
self,
in_file,
in_layer=None,
out_layer=None,
schema="public",
s_srs=None,
t_srs="EPSG:3005",
sql=None,
dim=2,
cmd_only=False,
index=True
):
"""
Load a layer to provided pgdata database connection usi... | Load a layer to provided pgdata database connection using OGR2OGR
-sql option is like an ESRI where_clause or the ogr2ogr -where option,
but to increase flexibility, it is in SQLITE dialect:
SELECT * FROM <in_layer> WHERE <sql>
def ogr2pg(
self,
in_file,
in_layer=None,
... | 570 | 252 | 2,335 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 5392b0470fa7962f9d7931809f6e71a268075dc358a18ab33044bb64b40ba3f3 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
201bd74462955c59cb57c650 | smnorris/pgdata | pgdata/database.py | Database.pg2ogr | https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/database.py#L286-L391 | train | python | A wrapper around ogr2ogr, for quickly dumping a postgis query to file.
Suppported formats are ["ESRI Shapefile", "GeoJSON", "FileGDB", "GPKG"]
- for GeoJSON, transforms to EPSG:4326
- for Shapefile, consider supplying a column_remap dict
- for FileGDB, geom_type is required
... | def pg2ogr(
self,
sql,
driver,
outfile,
outlayer=None,
column_remap=None,
s_srs="EPSG:3005",
t_srs=None,
geom_type=None,
append=False,
):
"""
A wrapper around ogr2ogr, for quickly dumping a postgis query to file.
... | A wrapper around ogr2ogr, for quickly dumping a postgis query to file.
Suppported formats are ["ESRI Shapefile", "GeoJSON", "FileGDB", "GPKG"]
- for GeoJSON, transforms to EPSG:4326
- for Shapefile, consider supplying a column_remap dict
- for FileGDB, geom_type is required
... | 955 | 370 | 3,705 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 1faee3052359067becbf167e44c81b928cb7a7307c69ac65cac62cce6355eeb8 | MIT | permissive | https://github.com/smnorris/pgdata/blob/master/LICENSE.txt |
a2136cb6df2fc0fdefc43843 | letuananh/chirptext | chirptext/cli.py | setup_logging | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L35-L55 | train | python | Try to load logging configuration from a file. Set level to INFO if failed. | def setup_logging(filename, log_dir=None, force_setup=False):
''' Try to load logging configuration from a file. Set level to INFO if failed.
'''
if not force_setup and ChirpCLI.SETUP_COMPLETED:
logging.debug("Master logging has been setup. This call will be ignored.")
return
if log_dir ... | Try to load logging configuration from a file. Set level to INFO if failed.
def setup_logging(filename, log_dir=None, force_setup=False):
''' Try to load logging configuration from a file. Set level to INFO if failed.
'''
if not force_setup and ChirpCLI.SETUP_COMPLETED:
logging.debug("Master loggin... | 196 | 75 | 954 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | b3b6af59fd38513b4ea7a9b9c7ea2c487a03eecc39869a65bb82eb02a33bb454 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
ae28bae824c03d6069712688 | letuananh/chirptext | chirptext/cli.py | config_logging | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L58-L63 | train | python | Override root logger's level | def config_logging(args):
''' Override root logger's level '''
if args.quiet:
logging.getLogger().setLevel(logging.CRITICAL)
elif args.verbose:
logging.getLogger().setLevel(logging.DEBUG) | Override root logger's level
def config_logging(args):
''' Override root logger's level '''
if args.quiet:
logging.getLogger().setLevel(logging.CRITICAL)
elif args.verbose:
logging.getLogger().setLevel(logging.DEBUG) | 49 | 28 | 215 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | e5dfbf5efe5bb162b7a4b22663ce1df13ca0feb36d3d02f6a1e9c4a12fe4b42a | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
e82b850af5416df187274e8e | letuananh/chirptext | chirptext/cli.py | CLIApp.add_task | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L92-L104 | train | python | Add a task parser | def add_task(self, task, func=None, **kwargs):
''' Add a task parser '''
if not self.__tasks:
raise Exception("Tasks subparsers is disabled")
if 'help' not in kwargs:
if func.__doc__:
kwargs['help'] = func.__doc__
task_parser = self.__tasks.add_par... | Add a task parser
def add_task(self, task, func=None, **kwargs):
''' Add a task parser '''
if not self.__tasks:
raise Exception("Tasks subparsers is disabled")
if 'help' not in kwargs:
if func.__doc__:
kwargs['help'] = func.__doc__
task_parser = s... | 118 | 17 | 506 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d59b19633d0c4cfe3eacfc104b46925cf43ed6c6c874e9127187254350931610 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
8d44cd9f49352d4ab3db2c35 | letuananh/chirptext | chirptext/cli.py | CLIApp.add_vq | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L106-L110 | train | python | Add verbose & quiet options | def add_vq(self, parser):
''' Add verbose & quiet options '''
group = parser.add_mutually_exclusive_group()
group.add_argument("-v", "--verbose", action="store_true")
group.add_argument("-q", "--quiet", action="store_true") | Add verbose & quiet options
def add_vq(self, parser):
''' Add verbose & quiet options '''
group = parser.add_mutually_exclusive_group()
group.add_argument("-v", "--verbose", action="store_true")
group.add_argument("-q", "--quiet", action="store_true") | 63 | 27 | 255 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 23ba841f397c5a3f3f60d373a2508bead8251c9a7ab472086153bd951a0915a5 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
ff683c443d31a402561adeff | letuananh/chirptext | chirptext/cli.py | CLIApp.add_version_func | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L112-L118 | train | python | Enable --version and -V to show version information | def add_version_func(self, show_version):
''' Enable --version and -V to show version information '''
if callable(show_version):
self.__show_version_func = show_version
else:
self.__show_version_func = lambda cli, args: print(show_version)
self.parser.add_argument... | Enable --version and -V to show version information
def add_version_func(self, show_version):
''' Enable --version and -V to show version information '''
if callable(show_version):
self.__show_version_func = show_version
else:
self.__show_version_func = lambda cli, args:... | 84 | 51 | 360 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 4fff76b54781deaab433727ff2fc84a27ae216415af5edd4576016ed425cc267 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
88811821a110bed80a67e0ce | letuananh/chirptext | chirptext/cli.py | CLIApp.logger | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L121-L125 | train | python | Lazy logger | def logger(self):
''' Lazy logger '''
if self.__logger is None:
self.__logger = logging.getLogger(self.__name)
return self.__logger | Lazy logger
def logger(self):
''' Lazy logger '''
if self.__logger is None:
self.__logger = logging.getLogger(self.__name)
return self.__logger | 36 | 11 | 167 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 103e0fb1ca6479074aa570b6b412534e4e026d2feccdbbb454c0e888961a1da0 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
e44d0d8b7ff32b9193363d97 | letuananh/chirptext | chirptext/cli.py | CLIApp.run | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/cli.py#L127-L139 | train | python | Run the app | def run(self, func=None):
''' Run the app '''
args = self.parser.parse_args()
if self.__add_vq is not None and self.__config_logging:
self.__config_logging(args)
if self.__show_version_func and args.version and callable(self.__show_version_func):
self.__show_versi... | Run the app
def run(self, func=None):
''' Run the app '''
args = self.parser.parse_args()
if self.__add_vq is not None and self.__config_logging:
self.__config_logging(args)
if self.__show_version_func and args.version and callable(self.__show_version_func):
self... | 113 | 11 | 520 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 2b1aea776c0475bbd30082cbf85ac325abb7fdcba6f0c65aef8e8ea25956ca20 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
6bf8497f39a8c4c6dd8ca847 | letuananh/chirptext | chirptext/leutile.py | header | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L49-L68 | train | python | Print header block in text mode | def header(*msg, level='h1', separator=" ", print_out=print):
''' Print header block in text mode
'''
out_string = separator.join(str(x) for x in msg)
if level == 'h0':
# box_len = 80 if len(msg) < 80 else len(msg)
box_len = 80
print_out('+' + '-' * (box_len + 2))
print_o... | Print header block in text mode
def header(*msg, level='h1', separator=" ", print_out=print):
''' Print header block in text mode
'''
out_string = separator.join(str(x) for x in msg)
if level == 'h0':
# box_len = 80 if len(msg) < 80 else len(msg)
box_len = 80
print_out('+' + '-'... | 212 | 31 | 682 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 99f85d35edcde2f77759afb6e2b155ed47c42cd6e2f183d03cf2759bc1ac1004 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
02cae6defb9889e62bfb3c98 | letuananh/chirptext | chirptext/leutile.py | piter.fetch | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L109-L120 | train | python | Fetch the next two values | def fetch(self, value_obj=None):
''' Fetch the next two values '''
val = None
try:
val = next(self.__iterable)
except StopIteration:
return None
if value_obj is None:
value_obj = Value(value=val)
else:
value_obj.value = val
... | Fetch the next two values
def fetch(self, value_obj=None):
''' Fetch the next two values '''
val = None
try:
val = next(self.__iterable)
except StopIteration:
return None
if value_obj is None:
value_obj = Value(value=val)
else:
... | 77 | 25 | 344 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | a262fe00a9a7d5cc1e2d45d03bed3f2f65ec50302ab36f252162c7724a74e892 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
920f6100b452535f13ac0fe3 | letuananh/chirptext | chirptext/leutile.py | Counter.get_report_order | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L157-L167 | train | python | Keys are sorted based on report order (i.e. some keys to be shown first)
Related: see sorted_by_count | def get_report_order(self):
''' Keys are sorted based on report order (i.e. some keys to be shown first)
Related: see sorted_by_count
'''
order_list = []
for x in self.__priority:
order_list.append([x, self[x]])
for x in sorted(list(self.keys())):
... | Keys are sorted based on report order (i.e. some keys to be shown first)
Related: see sorted_by_count
def get_report_order(self):
''' Keys are sorted based on report order (i.e. some keys to be shown first)
Related: see sorted_by_count
'''
order_list = []
for x i... | 118 | 113 | 426 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 1b33e77e20e072ff715e74aa3802b2c57d5467a148e3d7c6da62943be40a033c | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
2a87401fbac02efafceefb7b | letuananh/chirptext | chirptext/leutile.py | TextReport.content | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L317-L322 | train | python | Return report content as a string if mode == STRINGIO else an empty string | def content(self):
''' Return report content as a string if mode == STRINGIO else an empty string '''
if isinstance(self.__report_file, io.StringIO):
return self.__report_file.getvalue()
else:
return '' | Return report content as a string if mode == STRINGIO else an empty string
def content(self):
''' Return report content as a string if mode == STRINGIO else an empty string '''
if isinstance(self.__report_file, io.StringIO):
return self.__report_file.getvalue()
else:
ret... | 64 | 74 | 250 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 5b0febecc33e736c40bad76a7ce43802f6e0b2093d70a5e9cd0c4073d5283ec9 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
fa177a77bdd66904064df05a | letuananh/chirptext | chirptext/leutile.py | Table.format | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L446-L457 | train | python | Format table to print out | def format(self):
''' Format table to print out
'''
self.max_lengths = []
for row in self.rows:
if len(self.max_lengths) < len(row):
self.max_lengths += [0] * (len(row) - len(self.max_lengths))
for idx, val in enumerate(row):
len_ce... | Format table to print out
def format(self):
''' Format table to print out
'''
self.max_lengths = []
for row in self.rows:
if len(self.max_lengths) < len(row):
self.max_lengths += [0] * (len(row) - len(self.max_lengths))
for idx, val in enumerate(r... | 112 | 25 | 490 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d8990cc698c7f2cb87d2ad1d93d3de8c38c2ffe8e083c59bd644ef5cdb788a2e | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
8b2f12385cf75038d4a36307 | letuananh/chirptext | chirptext/leutile.py | FileHelper.getfullfilename | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L499-L506 | train | python | Get full filename (with extension) | def getfullfilename(file_path):
''' Get full filename (with extension)
'''
warnings.warn("getfullfilename() is deprecated and will be removed in near future. Use chirptext.io.write_file() instead", DeprecationWarning)
if file_path:
return os.path.basename(file_path)
e... | Get full filename (with extension)
def getfullfilename(file_path):
''' Get full filename (with extension)
'''
warnings.warn("getfullfilename() is deprecated and will be removed in near future. Use chirptext.io.write_file() instead", DeprecationWarning)
if file_path:
return o... | 77 | 34 | 346 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | b2e5adb4d3921baf8c1ab0b279a95c33419ba7c730d1afafb2b0e921718e6c24 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
3dc61afb732cb8a53a18f762 | letuananh/chirptext | chirptext/leutile.py | FileHelper.replace_ext | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L509-L517 | train | python | Change extension of a file_path to something else (provide None to remove) | def replace_ext(file_path, ext):
''' Change extension of a file_path to something else (provide None to remove) '''
if not file_path:
raise Exception("File path cannot be empty")
dirname = os.path.dirname(file_path)
filename = FileHelper.getfilename(file_path)
if ext:... | Change extension of a file_path to something else (provide None to remove)
def replace_ext(file_path, ext):
''' Change extension of a file_path to something else (provide None to remove) '''
if not file_path:
raise Exception("File path cannot be empty")
dirname = os.path.dirname(fil... | 98 | 74 | 411 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 953997160f0a5c7ac48452b22c7d5d06229a67ab2a440c0724c9f8c84ec6b36b | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
ce7f120c00db1fd182d77788 | letuananh/chirptext | chirptext/leutile.py | FileHelper.replace_name | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L520-L528 | train | python | Change the file name in a path but keep the extension | def replace_name(file_path, new_name):
''' Change the file name in a path but keep the extension '''
if not file_path:
raise Exception("File path cannot be empty")
elif not new_name:
raise Exception("New name cannot be empty")
dirname = os.path.dirname(file_path)
... | Change the file name in a path but keep the extension
def replace_name(file_path, new_name):
''' Change the file name in a path but keep the extension '''
if not file_path:
raise Exception("File path cannot be empty")
elif not new_name:
raise Exception("New name cannot b... | 102 | 53 | 435 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | e8926ccba0d7efbda8d89eba42d061c584a67015a833c12f44bfc7ccada4410d | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
369084195143adaa4aebb2c8 | letuananh/chirptext | chirptext/leutile.py | FileHelper.get_child_folders | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L544-L547 | train | python | Get all child folders of a folder | def get_child_folders(path):
''' Get all child folders of a folder '''
path = FileHelper.abspath(path)
return [dirname for dirname in os.listdir(path) if os.path.isdir(os.path.join(path, dirname))] | Get all child folders of a folder
def get_child_folders(path):
''' Get all child folders of a folder '''
path = FileHelper.abspath(path)
return [dirname for dirname in os.listdir(path) if os.path.isdir(os.path.join(path, dirname))] | 54 | 33 | 221 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 0c50e20ddc66ac6db0d3380f782436c1bb54b93a974ecec036ed3a96379cf198 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
43d748d71ca746efc4bfa5f5 | letuananh/chirptext | chirptext/leutile.py | FileHelper.get_child_files | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L550-L553 | train | python | Get all child files of a folder | def get_child_files(path):
''' Get all child files of a folder '''
path = FileHelper.abspath(path)
return [filename for filename in os.listdir(path) if os.path.isfile(os.path.join(path, filename))] | Get all child files of a folder
def get_child_files(path):
''' Get all child files of a folder '''
path = FileHelper.abspath(path)
return [filename for filename in os.listdir(path) if os.path.isfile(os.path.join(path, filename))] | 54 | 31 | 221 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 90f06ad1e5493e54e00a52fdff696fea9f2270fcad8d45641593cf899944f377 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
6462e66b4a8a581ff04a7574 | letuananh/chirptext | chirptext/leutile.py | FileHelper.remove_file | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L556-L562 | train | python | Delete a file | def remove_file(filepath):
''' Delete a file '''
try:
os.remove(os.path.abspath(os.path.expanduser(filepath)))
except OSError as e:
if e.errno != errno.ENOENT:
raise | Delete a file
def remove_file(filepath):
''' Delete a file '''
try:
os.remove(os.path.abspath(os.path.expanduser(filepath)))
except OSError as e:
if e.errno != errno.ENOENT:
raise | 49 | 13 | 229 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 42530da2a7a721ba2e104b021532db7e5ba3a25f565edb828dc7ea31845b762a | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
49275d38f8e675cfe20a3e86 | letuananh/chirptext | chirptext/leutile.py | AppConfig._ptn2fn | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L601-L604 | train | python | Pattern to filename | def _ptn2fn(self, pattern):
''' Pattern to filename '''
return [pattern.format(wd=self.working_dir, n=self.__name, mode=self.__mode),
pattern.format(wd=self.working_dir, n='{}.{}'.format(self.__name, self.__mode), mode=self.__mode)] | Pattern to filename
def _ptn2fn(self, pattern):
''' Pattern to filename '''
return [pattern.format(wd=self.working_dir, n=self.__name, mode=self.__mode),
pattern.format(wd=self.working_dir, n='{}.{}'.format(self.__name, self.__mode), mode=self.__mode)] | 70 | 19 | 264 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 4831559b19320301daa9b6d3173720600b8fd4ed577590181e660b900da027bd | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
d7f4c0bc42880c30011e6eda | letuananh/chirptext | chirptext/leutile.py | AppConfig.add_potential | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L606-L609 | train | python | Add a potential config file pattern | def add_potential(self, *patterns):
''' Add a potential config file pattern '''
for ptn in patterns:
self.__potential.extend(self._ptn2fn(ptn)) | Add a potential config file pattern
def add_potential(self, *patterns):
''' Add a potential config file pattern '''
for ptn in patterns:
self.__potential.extend(self._ptn2fn(ptn)) | 46 | 35 | 171 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 54a9bf5b818ab341550c752d0fd5a64a5f2c8c4f88393a06a148d427f2511396 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
3b090a2957a0d85f9e53dc42 | letuananh/chirptext | chirptext/leutile.py | AppConfig.locate_config | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L611-L617 | train | python | Locate config file | def locate_config(self):
''' Locate config file '''
for f in self.__potential:
f = FileHelper.abspath(f)
if os.path.isfile(f):
return f
return None | Locate config file
def locate_config(self):
''' Locate config file '''
for f in self.__potential:
f = FileHelper.abspath(f)
if os.path.isfile(f):
return f
return None | 46 | 18 | 211 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | d64ee9ef94898bb00a705a670ac1204fe2978ea16a362de899a6345cdb51e5cd | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
7df544ff8df592134ffa8efc | letuananh/chirptext | chirptext/leutile.py | AppConfig.config | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L620-L627 | train | python | Read config automatically if required | def config(self):
''' Read config automatically if required '''
if self.__config is None:
config_path = self.locate_config()
if config_path:
self.__config = self.read_file(config_path)
self.__config_path = config_path
return self.__config | Read config automatically if required
def config(self):
''' Read config automatically if required '''
if self.__config is None:
config_path = self.locate_config()
if config_path:
self.__config = self.read_file(config_path)
self.__config_path = con... | 65 | 37 | 318 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 388f7610eda191b2c5cf4d7d7e47fae13d7773b6fe1baf4bab75c55a1d558ca6 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
94d885cee70d65b8f7f17cd9 | letuananh/chirptext | chirptext/leutile.py | AppConfig.read_file | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L629-L637 | train | python | Read a configuration file and return configuration data | def read_file(self, file_path):
''' Read a configuration file and return configuration data '''
getLogger().info("Loading app config from {} file: {}".format(self.__mode, file_path))
if self.__mode == AppConfig.JSON:
return json.loads(FileHelper.read(file_path), object_pairs_hook=Ord... | Read a configuration file and return configuration data
def read_file(self, file_path):
''' Read a configuration file and return configuration data '''
getLogger().info("Loading app config from {} file: {}".format(self.__mode, file_path))
if self.__mode == AppConfig.JSON:
return jso... | 106 | 55 | 501 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 1935313d24a25de2dee48d346d89e1a72e82f1e4934d1157116adcc0cbf326d5 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
0d427e938cc6c03742f2a640 | letuananh/chirptext | chirptext/leutile.py | AppConfig.load | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/leutile.py#L639-L642 | train | python | Load configuration from a specific file | def load(self, file_path):
''' Load configuration from a specific file '''
self.clear()
self.__config = self.read_file(file_path) | Load configuration from a specific file
def load(self, file_path):
''' Load configuration from a specific file '''
self.clear()
self.__config = self.read_file(file_path) | 38 | 39 | 153 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | 274fefd0297ab7396cea4a652500118586dde9fabfb17553f271e6f1ce24b2e1 | MIT | permissive | https://github.com/letuananh/chirptext/blob/main/LICENSE |
fbc35bb858632980d9e868ea | alefnula/tea | tea/process/wrapper.py | get_processes | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/process/wrapper.py#L36-L59 | train | python | Retrieve a list of processes sorted by name.
Args:
sort_by_name (bool): Sort the list by name or by process ID's.
Returns:
list of (int, str) or list of (int, str, str): List of process id,
process name and optional cmdline tuples. | def get_processes(sort_by_name=True):
"""Retrieve a list of processes sorted by name.
Args:
sort_by_name (bool): Sort the list by name or by process ID's.
Returns:
list of (int, str) or list of (int, str, str): List of process id,
process name and optional cmdline tuple... | Retrieve a list of processes sorted by name.
Args:
sort_by_name (bool): Sort the list by name or by process ID's.
Returns:
list of (int, str) or list of (int, str, str): List of process id,
process name and optional cmdline tuples.
def get_processes(sort_by_name=True):
... | 245 | 276 | 746 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | eaebf186d54085bd77a4c8eb13c55383c1da7b034d035f40a226f238ce0ae4bd | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
e67ca5ff357aa7aa3d08370b | alefnula/tea | tea/process/wrapper.py | find | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/process/wrapper.py#L62-L80 | train | python | Find process by name or by argument in command line.
Args:
name (str): Process name to search for.
arg (str): Command line argument for a process to search for.
Returns:
tea.process.base.IProcess: Process object if found. | def find(name, arg=None):
"""Find process by name or by argument in command line.
Args:
name (str): Process name to search for.
arg (str): Command line argument for a process to search for.
Returns:
tea.process.base.IProcess: Process object if found.
"""
for p in ... | Find process by name or by argument in command line.
Args:
name (str): Process name to search for.
arg (str): Command line argument for a process to search for.
Returns:
tea.process.base.IProcess: Process object if found.
def find(name, arg=None):
"""Find process by name o... | 186 | 262 | 620 | CodeSearchNet permissive-repo filter (dataset-level) | code_search_net | 2026-12-05 | ad92ea44e49ae3e4854036043e22fe91d0452322a9d8ef5c819a647d37f3f29d | Apache-2.0 | permissive | https://github.com/alefnula/tea/blob/develop/LICENSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.