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
8b9721cc923cadc3be4dfa26
alefnula/tea
tea/process/wrapper.py
execute
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/process/wrapper.py#L83-L109
train
python
Execute a command with arguments and wait for output. Arguments should not be quoted! Keyword arguments: env (dict): Dictionary of additional environment variables. wait (bool): Wait for the process to finish. Example:: >>> code = 'import sys;sys.stdout.write('out');sys...
def execute(command, *args, **kwargs): """Execute a command with arguments and wait for output. Arguments should not be quoted! Keyword arguments: env (dict): Dictionary of additional environment variables. wait (bool): Wait for the process to finish. Example:: >>>...
Execute a command with arguments and wait for output. Arguments should not be quoted! Keyword arguments: env (dict): Dictionary of additional environment variables. wait (bool): Wait for the process to finish. Example:: >>> code = 'import sys;sys.stdout.write('out');sys...
476
757
1,063
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
81389edc5b95592f36cc45244544683a489f4f81dfeadd671b68fdb385589568
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
661b7cc117b639da435e2f44
alefnula/tea
tea/process/wrapper.py
execute_and_report
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/process/wrapper.py#L112-L152
train
python
Execute a command with arguments and wait for output. If execution was successful function will return True, if not, it will log the output using standard logging and return False.
def execute_and_report(command, *args, **kwargs): """Execute a command with arguments and wait for output. If execution was successful function will return True, if not, it will log the output using standard logging and return False. """ logging.info("Execute: %s %s" % (command, " ".join(args...
Execute a command with arguments and wait for output. If execution was successful function will return True, if not, it will log the output using standard logging and return False. def execute_and_report(command, *args, **kwargs): """Execute a command with arguments and wait for output. If exec...
314
192
1,494
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
737fadcc72edf9798b5715cdeb6ebed7c1005cd2f20a45ff0a2bab4316f8e5d9
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
5d544c5c3bae48c043aa6fed
jonhadfield/creds
lib/creds/ssh.py
read_authorized_keys
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/ssh.py#L63-L87
train
python
Read public keys from specified user's authorized_keys file. args: username (str): username. returns: list: Authorised keys for the specified user.
def read_authorized_keys(username=None): """Read public keys from specified user's authorized_keys file. args: username (str): username. returns: list: Authorised keys for the specified user. """ authorized_keys_path = '{0}/.ssh/authorized_keys'.format(os.path.expanduser('~{0}'.for...
Read public keys from specified user's authorized_keys file. args: username (str): username. returns: list: Authorised keys for the specified user. def read_authorized_keys(username=None): """Read public keys from specified user's authorized_keys file. args: username (str): u...
349
173
1,344
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
df3ce519aecaa966d1a29dd976349c5592f64f68eaee75e2cfa0b724c431a4de
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
f895af86b91fd4290f3fc356
jonhadfield/creds
lib/creds/ssh.py
write_authorized_keys
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/ssh.py#L90-L116
train
python
Write public keys back to authorized_keys file. Create keys directory if it doesn't already exist. args: user (User): Instance of User containing keys. returns: list: Authorised keys for the specified user.
def write_authorized_keys(user=None): """Write public keys back to authorized_keys file. Create keys directory if it doesn't already exist. args: user (User): Instance of User containing keys. returns: list: Authorised keys for the specified user. """ authorized_keys = list() a...
Write public keys back to authorized_keys file. Create keys directory if it doesn't already exist. args: user (User): Instance of User containing keys. returns: list: Authorised keys for the specified user. def write_authorized_keys(user=None): """Write public keys back to authorized_keys...
417
232
1,547
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
842c7a53589864d533c5b17257cef192e02ce0ea5758dfe445c1128b2c6e8b98
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
ea218e0e849258197e4ec4d3
jonhadfield/creds
lib/creds/ssh.py
PublicKey.b64encoded
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/ssh.py#L31-L40
train
python
Return a base64 encoding of the key. returns: str: base64 encoding of the public key
def b64encoded(self): """Return a base64 encoding of the key. returns: str: base64 encoding of the public key """ if self._b64encoded: return text_type(self._b64encoded).strip("\r\n") else: return base64encode(self.raw)
Return a base64 encoding of the key. returns: str: base64 encoding of the public key def b64encoded(self): """Return a base64 encoding of the key. returns: str: base64 encoding of the public key """ if self._b64encoded: return text_type(self...
90
105
296
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
add6f7fb859102ae335160641ee642965a35c09a74c4487455dfbdbd3a3f0fd7
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
4b39d07daa51a94a0592f528
jonhadfield/creds
lib/creds/ssh.py
PublicKey.raw
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/ssh.py#L43-L52
train
python
Return raw key. returns: str: raw key
def raw(self): """Return raw key. returns: str: raw key """ if self._raw: return text_type(self._raw).strip("\r\n") else: return text_type(base64decode(self._b64encoded)).strip("\r\n")
Return raw key. returns: str: raw key def raw(self): """Return raw key. returns: str: raw key """ if self._raw: return text_type(self._raw).strip("\r\n") else: return text_type(base64decode(self._b64encoded)).strip("\r\n"...
74
58
261
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
bca96c94d1fdfbb1f6d8ca2b053e9c04730b066af85d1cec635541deaa85d3e2
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
68cf467489450c0dd542c2dc
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/consul_parser.py
ConsulParser.inner_parser
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/consul_parser.py#L80-L108
train
python
Prepares inner config parser for config stored at ``endpoint``. :return: an instance of :class:`~django_docker_helpers.config.backends.base.BaseParser` :raises config.exceptions.KVStorageKeyDoestNotExist: if specified ``endpoint`` does not exists :raises config.exceptions.KVStorageValueIsEmpt...
def inner_parser(self) -> BaseParser: """ Prepares inner config parser for config stored at ``endpoint``. :return: an instance of :class:`~django_docker_helpers.config.backends.base.BaseParser` :raises config.exceptions.KVStorageKeyDoestNotExist: if specified ``endpoint`` does not exis...
Prepares inner config parser for config stored at ``endpoint``. :return: an instance of :class:`~django_docker_helpers.config.backends.base.BaseParser` :raises config.exceptions.KVStorageKeyDoestNotExist: if specified ``endpoint`` does not exists :raises config.exceptions.KVStorageValueIsEmpt...
319
374
1,175
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a04572a75358934b9a3b894a50ebee90974acfca46a25cadc19aa0a47476f7c0
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
03025c1caddb61f207b8f553
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/consul_parser.py
ConsulParser.get
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/consul_parser.py#L110-L137
train
python
Reads a value of ``variable_path`` from consul kv storage. :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...
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 consul kv storage. :param varia...
Reads a value of ``variable_path`` from consul kv storage. :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...
371
670
1,115
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
ed32a4d18bde915ebfedd3bc590445e07e722805b7f89cd7c564dd6be8c94fd9
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
307d41bede0c23bf62f4f4e3
jonhadfield/creds
lib/creds/utils.py
get_missing_commands
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/utils.py#L32-L52
train
python
Check I can identify the necessary commands for managing users.
def get_missing_commands(_platform): """Check I can identify the necessary commands for managing users.""" missing = list() if _platform in ('Linux', 'OpenBSD'): if not LINUX_CMD_USERADD: missing.append('useradd') if not LINUX_CMD_USERMOD: missing.append('usermod') ...
Check I can identify the necessary commands for managing users. def get_missing_commands(_platform): """Check I can identify the necessary commands for managing users.""" missing = list() if _platform in ('Linux', 'OpenBSD'): if not LINUX_CMD_USERADD: missing.append('useradd') i...
180
63
766
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
9facd1981d6951fede0afca55bfe8c799a9f0f7a10585abff7cb5e33536e3859
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
53f28f3c2e5d828f3f931d80
jonhadfield/creds
lib/creds/utils.py
execute_command
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/utils.py#L55-L60
train
python
Execute a command and return the stdout and stderr.
def execute_command(command=None): """Execute a command and return the stdout and stderr.""" process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stdin = process.communicate() process.wait() return (stdout, stdin), process.returncode
Execute a command and return the stdout and stderr. def execute_command(command=None): """Execute a command and return the stdout and stderr.""" process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stdin = process.communicate() process.wait() return (stdout, s...
66
51
292
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
e47ee4219157c422508602cb6539e4a9d8d6b7176df5424169d7633477969ed7
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
d8ea631e8e117dfb05af35b1
jonhadfield/creds
lib/creds/utils.py
base64encode
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/utils.py#L69-L77
train
python
Return base64 encoded representation of a string.
def base64encode(_input=None): """Return base64 encoded representation of a string.""" if PY2: # pragma: no cover return base64.b64encode(_input) elif PY3: # pragma: no cover if isinstance(_input, bytes): return base64.b64encode(_input).decode('UTF-8') elif isinstance(_...
Return base64 encoded representation of a string. def base64encode(_input=None): """Return base64 encoded representation of a string.""" if PY2: # pragma: no cover return base64.b64encode(_input) elif PY3: # pragma: no cover if isinstance(_input, bytes): return base64.b64encod...
118
49
421
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
82987be12b335ae405afde06689463806ee70ae433f8f9042519c450ff2b684e
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
3c3dbed94433e9e5cebbd501
jonhadfield/creds
lib/creds/utils.py
base64decode
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/utils.py#L80-L91
train
python
Take a base64 encoded string and return the decoded string.
def base64decode(_input=None): """Take a base64 encoded string and return the decoded string.""" missing_padding = 4 - len(_input) % 4 if missing_padding: _input += '=' * missing_padding if PY2: # pragma: no cover return base64.decodestring(_input) elif PY3: # pragma: no cover ...
Take a base64 encoded string and return the decoded string. def base64decode(_input=None): """Take a base64 encoded string and return the decoded string.""" missing_padding = 4 - len(_input) % 4 if missing_padding: _input += '=' * missing_padding if PY2: # pragma: no cover return base6...
153
59
540
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
d713b5002edff2f5c58a7cfbe47fb40566b73b85ab74d99a3037e716e6816da6
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
5256cd9f3f64c01d8436a559
jonhadfield/creds
lib/creds/utils.py
read_sudoers
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/utils.py#L94-L118
train
python
Read the sudoers entry for the specified user. args: username (str): username. returns:`r str: sudoers entry for the specified user.
def read_sudoers(): """ Read the sudoers entry for the specified user. args: username (str): username. returns:`r str: sudoers entry for the specified user. """ sudoers_path = '/etc/sudoers' rnd_chars = random_string(length=RANDOM_FILE_EXT_LENGTH) tmp_sudoers_path = '/tmp/s...
Read the sudoers entry for the specified user. args: username (str): username. returns:`r str: sudoers entry for the specified user. def read_sudoers(): """ Read the sudoers entry for the specified user. args: username (str): username. returns:`r str: sudoers ent...
314
158
1,125
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
7afedc28bd7c07a2270cc22d37503b432079ed90c5cae75d2a3ffde3ee363667
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
0441aeb1b8ca2b6fcfb5fef7
jonhadfield/creds
lib/creds/utils.py
write_sudoers_entry
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/utils.py#L121-L157
train
python
Write sudoers entry. args: user (User): Instance of User containing sudoers entry. returns: str: sudoers entry for the specified user.
def write_sudoers_entry(username=None, sudoers_entry=None): """Write sudoers entry. args: user (User): Instance of User containing sudoers entry. returns: str: sudoers entry for the specified user. """ sudoers_path = '/etc/sudoers' rnd_chars = random_string(length=RANDOM_FILE_...
Write sudoers entry. args: user (User): Instance of User containing sudoers entry. returns: str: sudoers entry for the specified user. def write_sudoers_entry(username=None, sudoers_entry=None): """Write sudoers entry. args: user (User): Instance of User containing sudoers en...
506
160
1,797
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
cb0ea7a9821feca15cbd956d8ea7f263abaeeeb5e3b9d61bed56c947d33040f2
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
8565e782c43d21e3b2ae21b9
jonhadfield/creds
lib/creds/utils.py
get_sudoers_entry
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/utils.py#L191-L203
train
python
Find the sudoers entry in the sudoers file for the specified user. args: username (str): username. sudoers_entries (list): list of lines from the sudoers file. returns:`r str: sudoers entry for the specified user.
def get_sudoers_entry(username=None, sudoers_entries=None): """ Find the sudoers entry in the sudoers file for the specified user. args: username (str): username. sudoers_entries (list): list of lines from the sudoers file. returns:`r str: sudoers entry for the specified user. ...
Find the sudoers entry in the sudoers file for the specified user. args: username (str): username. sudoers_entries (list): list of lines from the sudoers file. returns:`r str: sudoers entry for the specified user. def get_sudoers_entry(username=None, sudoers_entries=None): """ Fin...
155
247
451
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
b1f7b02c026921421c17dea821d6b8e2ffac7837e2494b66d065148ae02c08c6
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
62934df9f964125abd96852d
alefnula/tea
tea/decorators/__init__.py
docstring
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/decorators/__init__.py#L10-L53
train
python
r"""Prepend or append a string to the current documentation of the function. This decorator should be robust even if ``func.__doc__`` is None (for example, if -OO was passed to the interpreter). Usage:: @docstring('Appended this line') def func(): "This docstring will have a l...
def docstring(documentation, prepend=False, join=""): r"""Prepend or append a string to the current documentation of the function. This decorator should be robust even if ``func.__doc__`` is None (for example, if -OO was passed to the interpreter). Usage:: @docstring('Appended this line') ...
r"""Prepend or append a string to the current documentation of the function. This decorator should be robust even if ``func.__doc__`` is None (for example, if -OO was passed to the interpreter). Usage:: @docstring('Appended this line') def func(): "This docstring will have a l...
497
820
1,499
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
16558914d3027b45536e27ec3dc1988666200ff7de93c8f4b372b1945e5704d8
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
b5d4fb07b82a59deb540e1d6
night-crawler/django-docker-helpers
django_docker_helpers/management.py
create_admin
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/management.py#L8-L69
train
python
Creates a superuser from a specified dict/object bundle located at ``user_config_path``. Skips if the specified object contains no email or no username. If a user with the specified username already exists and has no usable password it updates user's password with a specified one. ``user_config_path`` ...
def create_admin(user_config_path: str = 'CONFIG.superuser') -> bool: """ Creates a superuser from a specified dict/object bundle located at ``user_config_path``. Skips if the specified object contains no email or no username. If a user with the specified username already exists and has no usable passwo...
Creates a superuser from a specified dict/object bundle located at ``user_config_path``. Skips if the specified object contains no email or no username. If a user with the specified username already exists and has no usable password it updates user's password with a specified one. ``user_config_path`` ...
729
1,035
2,306
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
eef0d25972d6526e4cf6e5807cf06b36ae71801c49fb81c8bfd2fd263b5ff6f5
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
74f3c14fff4717faa66fadce
night-crawler/django-docker-helpers
django_docker_helpers/management.py
run_gunicorn
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/management.py#L72-L96
train
python
Runs gunicorn with a specified config. :param application: Django uwsgi application :param gunicorn_module_name: gunicorn settings module name :return: ``Application().run()``
def run_gunicorn(application: WSGIHandler, gunicorn_module_name: str = 'gunicorn_prod'): """ Runs gunicorn with a specified config. :param application: Django uwsgi application :param gunicorn_module_name: gunicorn settings module name :return: ``Application().run()`` """ from gunicorn.app....
Runs gunicorn with a specified config. :param application: Django uwsgi application :param gunicorn_module_name: gunicorn settings module name :return: ``Application().run()`` def run_gunicorn(application: WSGIHandler, gunicorn_module_name: str = 'gunicorn_prod'): """ Runs gunicorn with a specifie...
221
188
861
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
24f41eb21dd7ce594d6950ace0dbc4d7969a911a18270cb106a1a6e15169e6ad
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
df8fe68c8cca8c50f5d3f332
alefnula/tea
tea/console/color.py
set_color
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/console/color.py#L171-L184
train
python
Set the console color. >>> set_color(Color.red, Color.blue) >>> set_color('red', 'blue') >>> set_color() # returns back to normal
def set_color( fg=Color.normal, bg=Color.normal, fg_dark=False, bg_dark=False, underlined=False, ): """Set the console color. >>> set_color(Color.red, Color.blue) >>> set_color('red', 'blue') >>> set_color() # returns back to normal """ _set_color(fg, bg, fg_dar...
Set the console color. >>> set_color(Color.red, Color.blue) >>> set_color('red', 'blue') >>> set_color() # returns back to normal def set_color( fg=Color.normal, bg=Color.normal, fg_dark=False, bg_dark=False, underlined=False, ): """Set the console color. >>> set_...
126
146
343
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
eb3fbf9724b5b9e99d37057a4e9ba41a82ef1b99b72c9d69dcc78bcbcef2208f
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
0f112c2012226193d208afcf
alefnula/tea
tea/console/color.py
cprint
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/console/color.py#L202-L239
train
python
Print string in to stdout using colored font. See L{set_color} for more details about colors. Args: text (str): Text that needs to be printed.
def cprint( text, fg=Color.normal, bg=Color.normal, fg_dark=False, bg_dark=False, underlined=False, parse=False, ): """Print string in to stdout using colored font. See L{set_color} for more details about colors. Args: text (str): Text that needs to be pri...
Print string in to stdout using colored font. See L{set_color} for more details about colors. Args: text (str): Text that needs to be printed. def cprint( text, fg=Color.normal, bg=Color.normal, fg_dark=False, bg_dark=False, underlined=False, parse=False, ): ...
291
165
1,145
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
ec19d3fe69ac82796850e6c260ac6423916bb7d7fd2316aff64f96cca31e57ef
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
5841547eb1d01bedea82ac73
alefnula/tea
tea/console/color.py
colorize_output
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/console/color.py#L242-L283
train
python
r"""Print output to console using provided color mappings. Color mapping is dict with regular expressions as key and tuple of two as values. Key is used to match if line should be colorized and tuple contains color to be used and boolean value that indicates if dark foreground is used. For ex...
def colorize_output(output, colors, indent=0): r"""Print output to console using provided color mappings. Color mapping is dict with regular expressions as key and tuple of two as values. Key is used to match if line should be colorized and tuple contains color to be used and boolean value that in...
r"""Print output to console using provided color mappings. Color mapping is dict with regular expressions as key and tuple of two as values. Key is used to match if line should be colorized and tuple contains color to be used and boolean value that indicates if dark foreground is used. For ex...
628
1,145
1,580
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
790f80eee5b5c71c486e80693b69315a6bf94e25d22a4e7f7af49f7c258efaf7
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
77beec81a942376dd37e31c2
alefnula/tea
tea/console/color.py
_colorize_single_line
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/console/color.py#L286-L308
train
python
Print single line to console with ability to colorize parts of it.
def _colorize_single_line(line, regexp, color_def): """Print single line to console with ability to colorize parts of it.""" match = regexp.match(line) groupdict = match.groupdict() groups = match.groups() if not groupdict: # no named groups, just colorize whole line color = c...
Print single line to console with ability to colorize parts of it. def _colorize_single_line(line, regexp, color_def): """Print single line to console with ability to colorize parts of it.""" match = regexp.match(line) groupdict = match.groupdict() groups = match.groups() if not groupdict: ...
209
66
872
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
065ca513a7222fb1331e2869f42e181367ce55831ea3353ad75d79b1629608bf
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
fdf5f533b2adca74d2a3cee4
pyout/pyout
pyout/tabular.py
TerminalStream.height
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/tabular.py#L39-L45
train
python
Terminal height.
def height(self): """Terminal height. """ if self.interactive: if self._height is None: self._height = self.term.height return self._height
Terminal height. def height(self): """Terminal height. """ if self.interactive: if self._height is None: self._height = self.term.height return self._height
42
16
203
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
b34275c11249ec0066f7d5a88bd377688b72d64b4903373179ff91eea8297a62
MIT
permissive
https://github.com/pyout/pyout/blob/master/COPYING
e690dcc78d6ea531017b74b3
pyout/pyout
pyout/tabular.py
TerminalStream.clear_last_lines
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/tabular.py#L52-L57
train
python
Clear last N lines of terminal output.
def clear_last_lines(self, n): """Clear last N lines of terminal output. """ self.term.stream.write( self.term.move_up * n + self.term.clear_eos) self.term.stream.flush()
Clear last N lines of terminal output. def clear_last_lines(self, n): """Clear last N lines of terminal output. """ self.term.stream.write( self.term.move_up * n + self.term.clear_eos) self.term.stream.flush()
54
38
214
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
1343a777629f833815d7a779882de4a7d057f7b9fb08c6d41085a079d849506d
MIT
permissive
https://github.com/pyout/pyout/blob/master/COPYING
832e83bdafd2343383639137
pyout/pyout
pyout/tabular.py
TerminalStream.overwrite_line
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/tabular.py#L68-L72
train
python
Move back N lines and overwrite line with `text`.
def overwrite_line(self, n, text): """Move back N lines and overwrite line with `text`. """ with self._moveback(n): self.term.stream.write(text)
Move back N lines and overwrite line with `text`. def overwrite_line(self, n, text): """Move back N lines and overwrite line with `text`. """ with self._moveback(n): self.term.stream.write(text)
50
49
180
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a52a977345359fcc482b7acb14e83fb2a2549804840f0a588069ab672f287a2a
MIT
permissive
https://github.com/pyout/pyout/blob/master/COPYING
1323728a2ff3e62ef989c9dc
pyout/pyout
pyout/tabular.py
TerminalStream.move_to
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/tabular.py#L74-L77
train
python
Move back N lines in terminal.
def move_to(self, n): """Move back N lines in terminal. """ self.term.stream.write(self.term.move_up * n)
Move back N lines in terminal. def move_to(self, n): """Move back N lines in terminal. """ self.term.stream.write(self.term.move_up * n)
37
30
129
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
37c7c4a3078be2a7ea84ccd1c9dfaef5b4d572edd9f40ae4e53056ddbfa226ae
MIT
permissive
https://github.com/pyout/pyout/blob/master/COPYING
481cb139f5b20dfc0548c583
night-crawler/django-docker-helpers
django_docker_helpers/config/__init__.py
ConfigLoader.get
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/__init__.py#L118-L169
train
python
Tries to read a ``variable_path`` from each of the passed parsers. It stops if read was successful and returns a retrieved value. If none of the parsers contain a value for the specified path it returns ``default``. :param variable_path: a path to variable in config :param default: a de...
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, required: bool = False, **kwargs): """ Tries to read a ``variable_path`` from each ...
Tries to read a ``variable_path`` from each of the passed parsers. It stops if read was successful and returns a retrieved value. If none of the parsers contain a value for the specified path it returns ``default``. :param variable_path: a path to variable in config :param default: a de...
620
908
2,192
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
c86453ab2cbabe5f0283419ea20bdd577b7d50cce57d4eaf0cb09a3ac25eb849
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
cb0533e4939eb2cd7c89afa0
night-crawler/django-docker-helpers
django_docker_helpers/config/__init__.py
ConfigLoader.import_parsers
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/__init__.py#L172-L197
train
python
Resolves and imports all modules specified in ``parser_modules``. Short names from the local scope are supported (the scope is ``django_docker_helpers.config.backends``). :param parser_modules: a list of dot-separated module paths :return: a generator of [probably] :class:`~django_docker_helper...
def import_parsers(parser_modules: t.Iterable[str]) -> t.Generator[t.Type[BaseParser], None, None]: """ Resolves and imports all modules specified in ``parser_modules``. Short names from the local scope are supported (the scope is ``django_docker_helpers.config.backends``). :param parse...
Resolves and imports all modules specified in ``parser_modules``. Short names from the local scope are supported (the scope is ``django_docker_helpers.config.backends``). :param parser_modules: a list of dot-separated module paths :return: a generator of [probably] :class:`~django_docker_helper...
345
623
1,124
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
417ee0e3dae4c5734ef68a8fdc6ba1e5a13c4a4afe9ccf4ebf89023f4ac3ee25
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
26acfef8e6f1c1a82c647132
night-crawler/django-docker-helpers
django_docker_helpers/config/__init__.py
ConfigLoader.load_parser_options_from_env
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/__init__.py#L200-L266
train
python
Extracts arguments from ``parser_class.__init__`` and populates them from environment variables. Uses ``__init__`` argument type annotations for correct type casting. .. note:: Environment variables should be prefixed with ``<UPPERCASEPARSERCLASSNAME>__``. :param parser_class: a ...
def load_parser_options_from_env( parser_class: t.Type[BaseParser], env: t.Optional[t.Dict[str, str]] = None) -> t.Dict[str, t.Any]: """ Extracts arguments from ``parser_class.__init__`` and populates them from environment variables. Uses ``__init__`` argument type annot...
Extracts arguments from ``parser_class.__init__`` and populates them from environment variables. Uses ``__init__`` argument type annotations for correct type casting. .. note:: Environment variables should be prefixed with ``<UPPERCASEPARSERCLASSNAME>__``. :param parser_class: a ...
722
905
2,493
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
459fee1bb61e2e457cb4acf5efe04b2a7ad8e925c25ccf1a03fabe137c4332ae
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
efaf279245cb6bb6605e3d3c
night-crawler/django-docker-helpers
django_docker_helpers/config/__init__.py
ConfigLoader.from_env
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/__init__.py#L269-L339
train
python
Creates an instance of :class:`~django_docker_helpers.config.ConfigLoader` with parsers initialized from environment variables. By default it tries to initialize all bundled parsers. Parsers may be customized with ``parser_modules`` argument or ``CONFIG__PARSERS`` environment variable. ...
def from_env(parser_modules: t.Optional[t.Union[t.List[str], t.Tuple[str]]] = DEFAULT_PARSER_MODULES, env: t.Optional[t.Dict[str, str]] = None, silent: bool = False, suppress_logs: bool = False, extra: t.Optional[dict] = None) -> 'ConfigLoader': ...
Creates an instance of :class:`~django_docker_helpers.config.ConfigLoader` with parsers initialized from environment variables. By default it tries to initialize all bundled parsers. Parsers may be customized with ``parser_modules`` argument or ``CONFIG__PARSERS`` environment variable. ...
1,016
1,553
3,316
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
033217684ddceca6a983a098efe69d9d366aabab6ddd9f1e3b0007bbf03bd485
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
b1cf3893bcce7f534eb1e3ce
night-crawler/django-docker-helpers
django_docker_helpers/config/__init__.py
ConfigLoader.print_config_read_queue
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/__init__.py#L361-L373
train
python
Prints all read (in call order) options. :param max_col_width: limit column width, ``50`` by default :param use_color: use terminal colors :return: nothing
def print_config_read_queue( self, use_color: bool = False, max_col_width: int = 50): """ Prints all read (in call order) options. :param max_col_width: limit column width, ``50`` by default :param use_color: use terminal colors :return: nothi...
Prints all read (in call order) options. :param max_col_width: limit column width, ``50`` by default :param use_color: use terminal colors :return: nothing def print_config_read_queue( self, use_color: bool = False, max_col_width: int = 50): """ ...
144
180
443
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
bc6aca0aa794f485e9fe6a91b4f8c9d58ff25eae93e1cdcccf04ea222efcbb4a
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
994fef2c65b3c904adf1eef3
night-crawler/django-docker-helpers
django_docker_helpers/config/__init__.py
ConfigLoader.format_config_read_queue
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/__init__.py#L375-L417
train
python
Prepares a string with pretty printed config read queue. :param use_color: use terminal colors :param max_col_width: limit column width, ``50`` by default :return:
def format_config_read_queue(self, use_color: bool = False, max_col_width: int = 50) -> str: """ Prepares a string with pretty printed config read queue. :param use_color: use terminal colors :param max_col_width: limit c...
Prepares a string with pretty printed config read queue. :param use_color: use terminal colors :param max_col_width: limit column width, ``50`` by default :return: def format_config_read_queue(self, use_color: bool = False, max_...
398
188
1,797
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f4041abab3caa50529eac6000d5343f1f25b4e7e53bfabc4f37bb635e083fe9e
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
340d07ae018c357d96ef21c0
alefnula/tea
tea/utils/crypto.py
_from_hex_digest
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/crypto.py#L112-L116
train
python
Convert hex digest to sequence of bytes.
def _from_hex_digest(digest): """Convert hex digest to sequence of bytes.""" return "".join( [chr(int(digest[x : x + 2], 16)) for x in range(0, len(digest), 2)] )
Convert hex digest to sequence of bytes. def _from_hex_digest(digest): """Convert hex digest to sequence of bytes.""" return "".join( [chr(int(digest[x : x + 2], 16)) for x in range(0, len(digest), 2)] )
63
40
182
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
cb77295fc7de6d1c7172595da302a804887a90164164d4585899977bc197d607
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
f723b200eea35b2c87ce1653
alefnula/tea
tea/utils/crypto.py
encrypt
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/crypto.py#L428-L434
train
python
Perform encryption of provided data.
def encrypt(data, digest=True): """Perform encryption of provided data.""" alg = get_best_algorithm() enc = implementations["encryption"][alg]( data, implementations["get_key"]() ) return "%s$%s" % (alg, (_to_hex_digest(enc) if digest else enc))
Perform encryption of provided data. def encrypt(data, digest=True): """Perform encryption of provided data.""" alg = get_best_algorithm() enc = implementations["encryption"][alg]( data, implementations["get_key"]() ) return "%s$%s" % (alg, (_to_hex_digest(enc) if digest else enc))
71
36
273
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
72cd9ceea2c4e7f389db6bdcaa349d359454c19045f39b280771fbc91632a016
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
d01efd9b3f790ba574a92ade
alefnula/tea
tea/utils/crypto.py
decrypt
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/crypto.py#L437-L448
train
python
Decrypt provided data.
def decrypt(data, digest=True): """Decrypt provided data.""" alg, _, data = data.rpartition("$") if not alg: return data data = _from_hex_digest(data) if digest else data try: return implementations["decryption"][alg]( data, implementations["get_key"]() ) exce...
Decrypt provided data. def decrypt(data, digest=True): """Decrypt provided data.""" alg, _, data = data.rpartition("$") if not alg: return data data = _from_hex_digest(data) if digest else data try: return implementations["decryption"][alg]( data, implementations["get_ke...
96
22
404
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
ccf8ac3ba0330b00059e9a416eae251dd9ae9854f0631326569943b8eee75e1c
Apache-2.0
permissive
https://github.com/alefnula/tea/blob/develop/LICENSE
4f2c36d84e93ce7ce23cefb9
letuananh/chirptext
chirp.py
gen_vocab
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirp.py#L70-L101
train
python
Generate vocabulary list from a tokenized file
def gen_vocab(cli, args): ''' Generate vocabulary list from a tokenized file ''' if args.topk and args.topk <= 0: topk = None cli.logger.warning("Invalid k will be ignored (k should be greater than or equal to 1)") else: topk = args.topk if args.stopwords: with open(args....
Generate vocabulary list from a tokenized file def gen_vocab(cli, args): ''' Generate vocabulary list from a tokenized file ''' if args.topk and args.topk <= 0: topk = None cli.logger.warning("Invalid k will be ignored (k should be greater than or equal to 1)") else: topk = args.top...
318
46
1,362
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
342f3ec930840f3ba7de9658f1810661dd25993657ca2e465b4eefabf414c9d4
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
f4405f3360356d957c028548
letuananh/chirptext
chirp.py
main
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirp.py#L112-L122
train
python
ChirpText Tools main function
def main(): ''' ChirpText Tools main function ''' app = CLIApp(desc='ChirpText Tools', logger=__name__, show_version=show_version) # add tasks vocab_task = app.add_task('vocab', func=gen_vocab) vocab_task.add_argument('input', help='Input file') vocab_task.add_argument('--output', help='Output f...
ChirpText Tools main function def main(): ''' ChirpText Tools main function ''' app = CLIApp(desc='ChirpText Tools', logger=__name__, show_version=show_version) # add tasks vocab_task = app.add_task('vocab', func=gen_vocab) vocab_task.add_argument('input', help='Input file') vocab_task.add_argu...
149
29
568
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a43c2229bcd105e373938c3e5b72abb09b31c7e8825b14847c547eb9f2183fb4
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
c89351a449553bd0904600fb
smnorris/pgdata
pgdata/table.py
Table.column_types
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L74-L80
train
python
Return a dict mapping column name to type for all columns in table
def column_types(self): """Return a dict mapping column name to type for all columns in table """ column_types = {} for c in self.sqla_columns: column_types[c.name] = c.type return column_types
Return a dict mapping column name to type for all columns in table def column_types(self): """Return a dict mapping column name to type for all columns in table """ column_types = {} for c in self.sqla_columns: column_types[c.name] = c.type return column_types
65
66
245
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
d233c65baefd9e50fdb4e8cea3df79ee1b75162360d4fe0a638a36d1eada39b7
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
163f87993750ea2eb477560f
smnorris/pgdata
pgdata/table.py
Table._valid_table_name
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L93-L98
train
python
Check if the table name is obviously invalid.
def _valid_table_name(self, table_name): """Check if the table name is obviously invalid. """ if table_name is None or not len(table_name.strip()): raise ValueError("Invalid table name: %r" % table_name) return table_name.strip()
Check if the table name is obviously invalid. def _valid_table_name(self, table_name): """Check if the table name is obviously invalid. """ if table_name is None or not len(table_name.strip()): raise ValueError("Invalid table name: %r" % table_name) return table_name.strip()
66
45
273
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
4e37c7e47801faf9f9cc38e4ccf97cd086514db025ef4dca093c22baac651f16
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
489e86620258925a892b0209
smnorris/pgdata
pgdata/table.py
Table.add_primary_key
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L105-L114
train
python
Add primary key constraint to specified column
def add_primary_key(self, column="id"): """Add primary key constraint to specified column """ if not self.primary_key: sql = """ALTER TABLE {s}.{t} ADD PRIMARY KEY ({c}) """.format( s=self.schema, t=self.name, c=column ...
Add primary key constraint to specified column def add_primary_key(self, column="id"): """Add primary key constraint to specified column """ if not self.primary_key: sql = """ALTER TABLE {s}.{t} ADD PRIMARY KEY ({c}) """.format( ...
80
46
356
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
4cd27d041464abc77656185a6743fa338227a32a1e73ddf4e9946902b11c4e5c
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
ae70bea294f9006df73560e2
smnorris/pgdata
pgdata/table.py
Table.drop
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L116-L121
train
python
Drop the table from the database
def drop(self): """Drop the table from the database """ if self._is_dropped is False: self.table.drop(self.engine) self._is_dropped = True
Drop the table from the database def drop(self): """Drop the table from the database """ if self._is_dropped is False: self.table.drop(self.engine) self._is_dropped = True
47
32
182
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
5e870b364b4f64491301f149c57090073a56d9f747abb5e6dedb31bbd61671c3
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
a69158b94798419e74e52781
smnorris/pgdata
pgdata/table.py
Table.create_column
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L138-L149
train
python
Explicitely create a new column ``name`` of a specified type. ``type`` must be a `SQLAlchemy column type <http://docs.sqlalchemy.org/en/rel_0_8/core/types.html>`_. :: table.create_column('created_at', sqlalchemy.DateTime)
def create_column(self, name, type): """ Explicitely create a new column ``name`` of a specified type. ``type`` must be a `SQLAlchemy column type <http://docs.sqlalchemy.org/en/rel_0_8/core/types.html>`_. :: table.create_column('created_at', sqlalchemy.DateTime) """ ...
Explicitely create a new column ``name`` of a specified type. ``type`` must be a `SQLAlchemy column type <http://docs.sqlalchemy.org/en/rel_0_8/core/types.html>`_. :: table.create_column('created_at', sqlalchemy.DateTime) def create_column(self, name, type): """ Explicitely...
185
250
569
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
1f5dcdb9b77dd22918e386351fdf698eff1cb7e90d8ae30a85f4c3845de33972
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
bf38a6ac61b2b252cc151f66
smnorris/pgdata
pgdata/table.py
Table.drop_column
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L151-L161
train
python
Drop the column ``name`` :: table.drop_column('created_at')
def drop_column(self, name): """ Drop the column ``name`` :: table.drop_column('created_at') """ self._check_dropped() if name in list(self.table.columns.keys()): self.op.drop_column(self.table.name, name, schema=self.schema) self.tabl...
Drop the column ``name`` :: table.drop_column('created_at') def drop_column(self, name): """ Drop the column ``name`` :: table.drop_column('created_at') """ self._check_dropped() if name in list(self.table.columns.keys()): se...
90
80
359
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
795e535c9a54bb71cb331d1ecb565d84cf283c70b0a10052239829be72b4d887
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
31b7174be257da8c43795986
smnorris/pgdata
pgdata/table.py
Table.create_index
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L163-L190
train
python
Create an index to speed up queries on a table. If no ``name`` is given a random name is created. :: table.create_index(['name', 'country'])
def create_index(self, columns, name=None, index_type="btree"): """ Create an index to speed up queries on a table. If no ``name`` is given a random name is created. :: table.create_index(['name', 'country']) """ self._check_dropped() if not name: ...
Create an index to speed up queries on a table. If no ``name`` is given a random name is created. :: table.create_index(['name', 'country']) def create_index(self, columns, name=None, index_type="btree"): """ Create an index to speed up queries on a table. If no ``na...
311
168
1,148
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
458531b89575d4356cb0bfaaa501c72a839278570d13a50e7a4f0318d8f84aac
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
788543e52c058ff3fe49ffe4
smnorris/pgdata
pgdata/table.py
Table.distinct
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L197-L230
train
python
Returns all rows of a table, but removes rows in with duplicate values in ``columns``. Interally this creates a `DISTINCT statement <http://www.w3schools.com/sql/sql_distinct.asp>`_. :: # returns only one row per year, ignoring the rest table.distinct('year') # works...
def distinct(self, *columns, **_filter): """ Returns all rows of a table, but removes rows in with duplicate values in ``columns``. Interally this creates a `DISTINCT statement <http://www.w3schools.com/sql/sql_distinct.asp>`_. :: # returns only one row per year, ignoring th...
Returns all rows of a table, but removes rows in with duplicate values in ``columns``. Interally this creates a `DISTINCT statement <http://www.w3schools.com/sql/sql_distinct.asp>`_. :: # returns only one row per year, ignoring the rest table.distinct('year') # works...
391
499
1,321
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
5a1b98249b30f1750a7460c5434c0dab029b6bbf75a9542afc2718d681fb0a28
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
57c5580bb179f70fa9539f35
smnorris/pgdata
pgdata/table.py
Table.insert
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L232-L244
train
python
Add a row (type: dict) by inserting it into the table. Columns must exist. :: data = dict(title='I am a banana!') table.insert(data) Returns the inserted row's primary key.
def insert(self, row): """ Add a row (type: dict) by inserting it into the table. Columns must exist. :: data = dict(title='I am a banana!') table.insert(data) Returns the inserted row's primary key. """ self._check_dropped() res = ...
Add a row (type: dict) by inserting it into the table. Columns must exist. :: data = dict(title='I am a banana!') table.insert(data) Returns the inserted row's primary key. def insert(self, row): """ Add a row (type: dict) by inserting it into the table. ...
146
220
456
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
507aca687042708709df9e17080e6b3c87055afc68c1c555b91ac915cd2ea22f
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
8cee0cd7e496aebac77e4f50
smnorris/pgdata
pgdata/table.py
Table.insert_many
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L246-L270
train
python
Add many rows at a time, which is significantly faster than adding them one by one. Per default the rows are processed in chunks of 1000 per commit, unless you specify a different ``chunk_size``. See :py:meth:`insert() <dataset.Table.insert>` for details on the other parameters. ...
def insert_many(self, rows, chunk_size=1000): """ Add many rows at a time, which is significantly faster than adding them one by one. Per default the rows are processed in chunks of 1000 per commit, unless you specify a different ``chunk_size``. See :py:meth:`insert() <dataset.Ta...
Add many rows at a time, which is significantly faster than adding them one by one. Per default the rows are processed in chunks of 1000 per commit, unless you specify a different ``chunk_size``. See :py:meth:`insert() <dataset.Table.insert>` for details on the other parameters. ...
278
406
849
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
6698839cfbdf08cd682c0f82cee5a3316e8ebad43bc679cc2f4d1190e6076738
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
0b50b7028e729e0569b84e8b
smnorris/pgdata
pgdata/table.py
Table.rename
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L272-L280
train
python
Rename the table
def rename(self, name): """Rename the table """ sql = """ALTER TABLE {s}.{t} RENAME TO {name} """.format( s=self.schema, t=self.name, name=name ) self.engine.execute(sql) self.table = SQLATable(name, self.metadata, schema=self.schema, autoload=Tr...
Rename the table def rename(self, name): """Rename the table """ sql = """ALTER TABLE {s}.{t} RENAME TO {name} """.format( s=self.schema, t=self.name, name=name ) self.engine.execute(sql) self.table = SQLATable(name, self.metadata, schema=self.s...
78
16
323
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f9589fbea59d9f824f89fe37b91a331082a314aad7f68ae0675095a6e24aa0c7
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
b018117794cb53e8c69b0280
smnorris/pgdata
pgdata/table.py
Table.find_one
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L282-L293
train
python
Works just like :py:meth:`find() <dataset.Table.find>` but returns one result, or None. :: row = table.find_one(country='United States')
def find_one(self, **kwargs): """ Works just like :py:meth:`find() <dataset.Table.find>` but returns one result, or None. :: row = table.find_one(country='United States') """ kwargs["_limit"] = 1 iterator = self.find(**kwargs) try: return n...
Works just like :py:meth:`find() <dataset.Table.find>` but returns one result, or None. :: row = table.find_one(country='United States') def find_one(self, **kwargs): """ Works just like :py:meth:`find() <dataset.Table.find>` but returns one result, or None. :: r...
118
156
387
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
fe9935ba0e238683a8e9b6513272517d4960d267117fb630545f0b46fe11593a
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
411be31e2d041e7829ea8fbb
smnorris/pgdata
pgdata/table.py
Table.find
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/table.py#L301-L377
train
python
Performs a simple search on the table. Simply pass keyword arguments as ``filter``. :: results = table.find(country='France') results = table.find(country='France', year=1980) Using ``_limit``:: # just return the first 10 rows results = table.find(country=...
def find( self, _limit=None, _offset=0, _step=5000, order_by="id", return_count=False, **_filter ): """ Performs a simple search on the table. Simply pass keyword arguments as ``filter``. :: results = table.find(country='Fra...
Performs a simple search on the table. Simply pass keyword arguments as ``filter``. :: results = table.find(country='France') results = table.find(country='France', year=1980) Using ``_limit``:: # just return the first 10 rows results = table.find(country=...
832
1,010
2,793
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
61c8045c669d24c14bbaa3d78d70744e24d032dfdacd1f75a2de04c61a4f601d
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
2996499c8e7b1908574bf7f8
smnorris/pgdata
pgdata/__init__.py
connect
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/__init__.py#L15-L20
train
python
Open a new connection to postgres via psycopg2/sqlalchemy
def connect(url=None, schema=None, sql_path=None, multiprocessing=False): """Open a new connection to postgres via psycopg2/sqlalchemy """ if url is None: url = os.environ.get("DATABASE_URL") return Database(url, schema, sql_path=sql_path, multiprocessing=multiprocessing)
Open a new connection to postgres via psycopg2/sqlalchemy def connect(url=None, schema=None, sql_path=None, multiprocessing=False): """Open a new connection to postgres via psycopg2/sqlalchemy """ if url is None: url = os.environ.get("DATABASE_URL") return Database(url, schema, sql_path=sql_pat...
77
57
296
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
9223cfdb8dbde3ecc9b960cc1e27f2770fe3c96dc9a99e5b8765ac16eafdc169
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
63e0cf2e7c8910d58348fb0e
smnorris/pgdata
pgdata/__init__.py
create_db
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/__init__.py#L23-L44
train
python
Create a new database
def create_db(url=None): """Create a new database """ if url is None: url = os.environ.get("DATABASE_URL") parsed_url = urlparse(url) db_name = parsed_url.path db_name = db_name.strip("/") db = connect("postgresql://" + parsed_url.netloc) # check that db does not exist q = ""...
Create a new database def create_db(url=None): """Create a new database """ if url is None: url = os.environ.get("DATABASE_URL") parsed_url = urlparse(url) db_name = parsed_url.path db_name = db_name.strip("/") db = connect("postgresql://" + parsed_url.netloc) # check that db do...
189
21
783
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
69e0ea69ece6c158b8155b201837f4dc4ae3ee8e3eb26e12d360a9f941e5a17c
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
bf1a7ecf8d07e9c3adf684eb
smnorris/pgdata
pgdata/__init__.py
drop_db
https://github.com/smnorris/pgdata/blob/8b0294024d5ef30b4ae9184888e2cc7004d1784e/pgdata/__init__.py#L47-L65
train
python
Drop specified database
def drop_db(url): """Drop specified database """ parsed_url = urlparse(url) db_name = parsed_url.path db_name = db_name.strip("/") db = connect("postgresql://" + parsed_url.netloc) # check that db exists q = """SELECT 1 as exists FROM pg_database WHERE datname = '{d...
Drop specified database def drop_db(url): """Drop specified database """ parsed_url = urlparse(url) db_name = parsed_url.path db_name = db_name.strip("/") db = connect("postgresql://" + parsed_url.netloc) # check that db exists q = """SELECT 1 as exists FROM pg_database ...
144
23
597
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a5f8b01ed3a03848a47d69cb77d5c4b974ecbc78243fe02971a46119da2eb6ab
MIT
permissive
https://github.com/smnorris/pgdata/blob/master/LICENSE.txt
178c68ba929fc729523d5c42
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
shred
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L46-L67
train
python
Replaces sensitive data in ``value`` with ``*`` if ``key_name`` contains something that looks like a secret. :param field_names: a list of key names that can possibly contain sensitive data :param key_name: a key name to check :param value: a value to mask :return: an unchanged value if nothing to hide...
def shred(key_name: str, value: t.Any, field_names: t.Iterable[str] = SHRED_DATA_FIELD_NAMES) -> t.Union[t.Any, str]: """ Replaces sensitive data in ``value`` with ``*`` if ``key_name`` contains something that looks like a secret. :param field_names: a list of key names that can possibl...
Replaces sensitive data in ``value`` with ``*`` if ``key_name`` contains something that looks like a secret. :param field_names: a list of key names that can possibly contain sensitive data :param key_name: a key name to check :param value: a value to mask :return: an unchanged value if nothing to hide...
281
357
777
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2f3004a861636eb90c54aebc8208bdb08281d8c1505033d5dd108bef54e0553c
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
9199e68a7017144f342469fd
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
dot_path
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L97-L140
train
python
Provides an access to elements of a mixed dict/object type by a delimiter-separated path. :: class O1: my_dict = {'a': {'b': 1}} class O2: def __init__(self): self.nested = O1() class O3: final = O2() o = O3() assert uti...
def dot_path(obj: t.Union[t.Dict, object], path: str, default: t.Any = None, separator: str = '.'): """ Provides an access to elements of a mixed dict/object type by a delimiter-separated path. :: class O1: my_dict = {'a': {'b': 1}} class ...
Provides an access to elements of a mixed dict/object type by a delimiter-separated path. :: class O1: my_dict = {'a': {'b': 1}} class O2: def __init__(self): self.nested = O1() class O3: final = O2() o = O3() assert uti...
419
592
1,134
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
071c2f8a7d1497b14b6fa878a60e043340c9503f5874fe660dff0096e14b8282
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
22db1a30f67a338d32f1b9a9
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
dotkey
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L143-L156
train
python
Provides an interface to traverse nested dict values by dot-separated paths. Wrapper for ``dpath.util.get``. :param obj: dict like ``{'some': {'value': 3}}`` :param path: ``'some.value'`` :param separator: ``'.'`` or ``'/'`` or whatever :param default: default for KeyError :return: dict value or de...
def dotkey(obj: dict, path: str, default=None, separator='.'): """ Provides an interface to traverse nested dict values by dot-separated paths. Wrapper for ``dpath.util.get``. :param obj: dict like ``{'some': {'value': 3}}`` :param path: ``'some.value'`` :param separator: ``'.'`` or ``'/'`` or what...
Provides an interface to traverse nested dict values by dot-separated paths. Wrapper for ``dpath.util.get``. :param obj: dict like ``{'some': {'value': 3}}`` :param path: ``'some.value'`` :param separator: ``'.'`` or ``'/'`` or whatever :param default: default for KeyError :return: dict value or de...
217
331
518
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
03457a56192c1851fc2ffc83ff33af0df900d7f1800047f1e8ec1f212b53583f
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
fe673c4b029f1e41b180e618
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
_materialize_dict
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L159-L177
train
python
Traverses and transforms a given dict ``bundle`` into tuples of ``(key_path, value)``. :param bundle: a dict to traverse :param separator: build paths with a given separator :return: a generator of tuples ``(materialized_path, value)`` Example: >>> list(_materialize_dict({'test': {'path': 1}, 'key...
def _materialize_dict(bundle: dict, separator: str = '.') -> t.Generator[t.Tuple[str, t.Any], None, None]: """ Traverses and transforms a given dict ``bundle`` into tuples of ``(key_path, value)``. :param bundle: a dict to traverse :param separator: build paths with a given separator :return: a gen...
Traverses and transforms a given dict ``bundle`` into tuples of ``(key_path, value)``. :param bundle: a dict to traverse :param separator: build paths with a given separator :return: a generator of tuples ``(materialized_path, value)`` Example: >>> list(_materialize_dict({'test': {'path': 1}, 'key...
308
379
812
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
6ce5b927942aa80c6d2a6c32e5b50f2bf3063d61cd23cce5933bc439b60e3e47
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
fa627955d38803ce26faa05d
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
materialize_dict
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L180-L220
train
python
Transforms a given ``bundle`` into a *sorted* list of tuples with materialized value paths and values: ``('path.to.value', <value>)``. Output is ordered by depth: the deepest element first. :param bundle: a dict to materialize :param separator: build paths with a given separator :return: a depth descen...
def materialize_dict(bundle: dict, separator: str = '.') -> t.List[t.Tuple[str, t.Any]]: """ Transforms a given ``bundle`` into a *sorted* list of tuples with materialized value paths and values: ``('path.to.value', <value>)``. Output is ordered by depth: the deepest element first. :param bundle: a dic...
Transforms a given ``bundle`` into a *sorted* list of tuples with materialized value paths and values: ``('path.to.value', <value>)``. Output is ordered by depth: the deepest element first. :param bundle: a dict to materialize :param separator: build paths with a given separator :return: a depth descen...
557
903
1,242
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f31eef8f038f97945ed6e1b4fb0407358092df26f2ba9db42506c74f80a0e2c1
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
f3c887755fba6bf76b9a2ade
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
mp_serialize_dict
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L223-L294
train
python
Transforms a given ``bundle`` into a *sorted* list of tuples with materialized value paths and values: ``('path.to.value', b'<some>')``. If the ``<some>`` value is not an instance of a basic type, it's serialized with ``serialize`` callback. If this value is an empty string, it's serialized anyway to enforce co...
def mp_serialize_dict( bundle: dict, separator: str = '.', serialize: t.Optional[t.Callable] = dump_yaml, value_prefix: str = '::YAML::\n') -> t.List[t.Tuple[str, bytes]]: """ Transforms a given ``bundle`` into a *sorted* list of tuples with materialized value paths and values: ...
Transforms a given ``bundle`` into a *sorted* list of tuples with materialized value paths and values: ``('path.to.value', b'<some>')``. If the ``<some>`` value is not an instance of a basic type, it's serialized with ``serialize`` callback. If this value is an empty string, it's serialized anyway to enforce co...
1,108
1,610
2,691
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
b4c3f4d831d60966dc2ab9ffc9cb5460d0b725b271c1f5191bd73842b8e8cb8a
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
26ecffa4f8c1d873cea057ad
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
wf
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L297-L315
train
python
Writes a given ``raw_str`` into a ``stream``. Ignores output if ``prevent_completion_polluting`` is set and there's no extra ``sys.argv`` arguments present (a bash completion issue). :param raw_str: a raw string to print :param flush: execute ``flush()`` :param prevent_completion_polluting: don't write...
def wf(raw_str: str, flush: bool = True, prevent_completion_polluting: bool = True, stream: t.TextIO = sys.stdout): """ Writes a given ``raw_str`` into a ``stream``. Ignores output if ``prevent_completion_polluting`` is set and there's no extra ``sys.argv`` arguments present (a bash com...
Writes a given ``raw_str`` into a ``stream``. Ignores output if ``prevent_completion_polluting`` is set and there's no extra ``sys.argv`` arguments present (a bash completion issue). :param raw_str: a raw string to print :param flush: execute ``flush()`` :param prevent_completion_polluting: don't write...
290
418
735
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
8ea54778809030b67878cdef8014cba42f6a5ab148bf26ccd84f842fb5fb5f40
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
e0fc10623344d7a80236f04a
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
coerce_str_to_bool
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L318-L340
train
python
Converts a given string ``val`` into a boolean. :param val: any string representation of boolean :param strict: raise ``ValueError`` if ``val`` does not look like a boolean-like object :return: ``True`` if ``val`` is thruthy, ``False`` otherwise. :raises ValueError: if ``strict`` specified and ``val``...
def coerce_str_to_bool(val: t.Union[str, int, bool, None], strict: bool = False) -> bool: """ Converts a given string ``val`` into a boolean. :param val: any string representation of boolean :param strict: raise ``ValueError`` if ``val`` does not look like a boolean-like object :return: ``True`` if...
Converts a given string ``val`` into a boolean. :param val: any string representation of boolean :param strict: raise ``ValueError`` if ``val`` does not look like a boolean-like object :return: ``True`` if ``val`` is thruthy, ``False`` otherwise. :raises ValueError: if ``strict`` specified and ``val``...
313
395
770
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
ab2209bf6ca979303f98002872b1b529ba3ecac8de57b4c52794e9a218128804
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
0bb285252f67ee4aaf382187
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
env_bool_flag
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L343-L361
train
python
Converts an environment variable into a boolean. Empty string (presence in env) is treated as ``True``. :param flag_name: an environment variable name :param strict: raise ``ValueError`` if a ``flag_name`` value connot be coerced into a boolean in obvious way :param env: a dict with environment variables, ...
def env_bool_flag(flag_name: str, strict: bool = False, env: t.Optional[t.Dict[str, str]] = None) -> bool: """ Converts an environment variable into a boolean. Empty string (presence in env) is treated as ``True``. :param flag_name: an environment variable name :param strict: raise ``ValueError`` if a ...
Converts an environment variable into a boolean. Empty string (presence in env) is treated as ``True``. :param flag_name: an environment variable name :param strict: raise ``ValueError`` if a ``flag_name`` value connot be coerced into a boolean in obvious way :param env: a dict with environment variables, ...
355
539
854
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
01bef6d49f7b41ce6b7206bbb5cb38e34635b2b0fcfb87a8103a1fa777d20cfe
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
6b331f8fc1236c3cea92e47a
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
run_env_once
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L364-L382
train
python
A decorator to prevent ``manage.py`` from running code twice for everything. (https://stackoverflow.com/questions/16546652/why-does-django-run-everything-twice) :param f: function or method to decorate :return: callable
def run_env_once(f: t.Callable) -> t.Callable: """ A decorator to prevent ``manage.py`` from running code twice for everything. (https://stackoverflow.com/questions/16546652/why-does-django-run-everything-twice) :param f: function or method to decorate :return: callable """ @wraps(f) d...
A decorator to prevent ``manage.py`` from running code twice for everything. (https://stackoverflow.com/questions/16546652/why-does-django-run-everything-twice) :param f: function or method to decorate :return: callable def run_env_once(f: t.Callable) -> t.Callable: """ A decorator to prevent ``ma...
199
232
566
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2b3a2dd50775064ec2254904c0d47f4bfa670878889424a9cb134dd2c03ecce9
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
0b4dc4f393a5e44bca7bf994
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
is_dockerized
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L385-L393
train
python
Reads env ``DOCKERIZED`` variable as a boolean. :param flag_name: environment variable name :param strict: raise a ``ValueError`` if variable does not look like a normal boolean :return: ``True`` if has truthy ``DOCKERIZED`` env, ``False`` otherwise
def is_dockerized(flag_name: str = 'DOCKERIZED', strict: bool = False): """ Reads env ``DOCKERIZED`` variable as a boolean. :param flag_name: environment variable name :param strict: raise a ``ValueError`` if variable does not look like a normal boolean :return: ``True`` if has truthy ``DOCKERIZED`...
Reads env ``DOCKERIZED`` variable as a boolean. :param flag_name: environment variable name :param strict: raise a ``ValueError`` if variable does not look like a normal boolean :return: ``True`` if has truthy ``DOCKERIZED`` env, ``False`` otherwise def is_dockerized(flag_name: str = 'DOCKERIZED', strict:...
166
262
405
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
df57c7871ce240f305bae207717733e3115a8ade31f6ecaa756d06df17d889f6
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
0af767db2d657af3af434f24
night-crawler/django-docker-helpers
django_docker_helpers/utils.py
is_production
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/utils.py#L396-L404
train
python
Reads env ``PRODUCTION`` variable as a boolean. :param flag_name: environment variable name :param strict: raise a ``ValueError`` if variable does not look like a normal boolean :return: ``True`` if has truthy ``PRODUCTION`` env, ``False`` otherwise
def is_production(flag_name: str = 'PRODUCTION', strict: bool = False): """ Reads env ``PRODUCTION`` variable as a boolean. :param flag_name: environment variable name :param strict: raise a ``ValueError`` if variable does not look like a normal boolean :return: ``True`` if has truthy ``PRODUCTION`...
Reads env ``PRODUCTION`` variable as a boolean. :param flag_name: environment variable name :param strict: raise a ``ValueError`` if variable does not look like a normal boolean :return: ``True`` if has truthy ``PRODUCTION`` env, ``False`` otherwise def is_production(flag_name: str = 'PRODUCTION', strict:...
164
262
405
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
d7ee4b14b9308a1e005501fc9140c1df9f0cef6d1d32e5cb6b836006bfcc3082
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
029aac088df13f781f31a78f
jonhadfield/creds
lib/creds/constants.py
login_defs
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/constants.py#L33-L54
train
python
Discover the minimum and maximum UID number.
def login_defs(): """Discover the minimum and maximum UID number.""" uid_min = None uid_max = None login_defs_path = '/etc/login.defs' if os.path.exists(login_defs_path): with io.open(text_type(login_defs_path), encoding=text_type('utf-8')) as log_defs_file: login_data = log_defs...
Discover the minimum and maximum UID number. def login_defs(): """Discover the minimum and maximum UID number.""" uid_min = None uid_max = None login_defs_path = '/etc/login.defs' if os.path.exists(login_defs_path): with io.open(text_type(login_defs_path), encoding=text_type('utf-8')) as lo...
233
44
920
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
74447237462f18653695cb5e03274d1bd48b17f302d3586601ca39e9ca3b00a9
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
864821069d465e4885036e03
night-crawler/django-docker-helpers
django_docker_helpers/files.py
collect_static
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/files.py#L5-L17
train
python
Runs Django ``collectstatic`` command in silent mode. :return: always ``True``
def collect_static() -> bool: """ Runs Django ``collectstatic`` command in silent mode. :return: always ``True`` """ from django.core.management import execute_from_command_line # from django.conf import settings # if not os.listdir(settings.STATIC_ROOT): wf('Collecting static files... ...
Runs Django ``collectstatic`` command in silent mode. :return: always ``True`` def collect_static() -> bool: """ Runs Django ``collectstatic`` command in silent mode. :return: always ``True`` """ from django.core.management import execute_from_command_line # from django.conf import settin...
127
83
451
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
c93b694654c0ff75827fee690872f5142e1c6f6b520a4bd7a734ac142aa9a9fa
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
9741755157853ce2f458d52d
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/redis_parser.py
RedisParser.inner_parser
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/redis_parser.py#L72-L94
train
python
Prepares inner config parser for config stored at ``endpoint``. :return: an instance of :class:`~django_docker_helpers.config.backends.base.BaseParser` :raises config.exceptions.KVStorageValueIsEmpty: if specified ``endpoint`` does not contain a config
def inner_parser(self) -> BaseParser: """ Prepares inner config parser for config stored at ``endpoint``. :return: an instance of :class:`~django_docker_helpers.config.backends.base.BaseParser` :raises config.exceptions.KVStorageValueIsEmpty: if specified ``endpoint`` does not contain ...
Prepares inner config parser for config stored at ``endpoint``. :return: an instance of :class:`~django_docker_helpers.config.backends.base.BaseParser` :raises config.exceptions.KVStorageValueIsEmpty: if specified ``endpoint`` does not contain a config def inner_parser(self) -> BaseParser: ""...
223
270
845
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2fea2adbf95b4f442c2f6aefa3cea50f63a07d3a244f21869fafdfcdccd1ca09
MIT
permissive
https://github.com/night-crawler/django-docker-helpers/blob/master/LICENSE
c3446bb599ccdbb92869187e
jonhadfield/creds
lib/creds/users.py
generate_add_user_command
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L245-L291
train
python
Generate command to add a user. args: proposed_user (User): User manage_home: bool returns: list: The command string split into shell-like syntax
def generate_add_user_command(proposed_user=None, manage_home=None): """Generate command to add a user. args: proposed_user (User): User manage_home: bool returns: list: The command string split into shell-like syntax """ command = None if get_platform() in ('Linux', 'O...
Generate command to add a user. args: proposed_user (User): User manage_home: bool returns: list: The command string split into shell-like syntax def generate_add_user_command(proposed_user=None, manage_home=None): """Generate command to add a user. args: proposed_use...
540
179
2,084
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
8e9b494482ef8e35db89fe22b1ebb6b50bf10f930344b5166e6a192e4e93c16c
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
a098aabd0ff115fb5612f20d
jonhadfield/creds
lib/creds/users.py
generate_modify_user_command
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L294-L333
train
python
Generate command to modify existing user to become the proposed user. args: task (dict): A proposed user and the differences between it and the existing user returns: list: The command string split into shell-like syntax
def generate_modify_user_command(task=None, manage_home=None): """Generate command to modify existing user to become the proposed user. args: task (dict): A proposed user and the differences between it and the existing user returns: list: The command string split into shell-like syntax ...
Generate command to modify existing user to become the proposed user. args: task (dict): A proposed user and the differences between it and the existing user returns: list: The command string split into shell-like syntax def generate_modify_user_command(task=None, manage_home=None): """Ge...
585
246
2,494
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
4bc50c0f3756f5f60067524b0905b1ba957569dd2983f01dac3523e770a25713
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
02b42e9caada3bfa606cabea
jonhadfield/creds
lib/creds/users.py
generate_delete_user_command
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L336-L354
train
python
Generate command to delete a user. args: username (str): user name manage_home (bool): manage home directory returns: list: The user delete command string split into shell-like syntax
def generate_delete_user_command(username=None, manage_home=None): """Generate command to delete a user. args: username (str): user name manage_home (bool): manage home directory returns: list: The user delete command string split into shell-like syntax """ command = None ...
Generate command to delete a user. args: username (str): user name manage_home (bool): manage home directory returns: list: The user delete command string split into shell-like syntax def generate_delete_user_command(username=None, manage_home=None): """Generate command to delete ...
228
217
732
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
34dd99fe66c85a52d2c2c084a2b783a60183edcebcf11914d04d95d9def80819
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
89a01e7389bcd250e50b22ae
jonhadfield/creds
lib/creds/users.py
compare_user
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L370-L428
train
python
Check if supplied User instance exists in supplied Users list and, if so, return the differences. args: passed_user (User): the user instance to check for differences user_list (Users): the Users instance containing a list of Users instances returns: dict: Details of the matching user ...
def compare_user(passed_user=None, user_list=None): """Check if supplied User instance exists in supplied Users list and, if so, return the differences. args: passed_user (User): the user instance to check for differences user_list (Users): the Users instance containing a list of Users instance...
Check if supplied User instance exists in supplied Users list and, if so, return the differences. args: passed_user (User): the user instance to check for differences user_list (Users): the Users instance containing a list of Users instances returns: dict: Details of the matching user ...
816
345
3,387
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
2cb9f48bef7a8f868c00be2be72d37895a8c3ea29a3fdc723d50b08fe14d1672
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
2a26df89829e8e42f646bf14
jonhadfield/creds
lib/creds/users.py
User.gecos
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L49-L63
train
python
Force double quoted gecos. returns: str: The double quoted gecos.
def gecos(self): """Force double quoted gecos. returns: str: The double quoted gecos. """ if not self._gecos: return None if self._gecos.startswith(text_type('\'')) and self._gecos.endswith(text_type('\'')): self._gecos = '\"{0}\"'.format(self...
Force double quoted gecos. returns: str: The double quoted gecos. def gecos(self): """Force double quoted gecos. returns: str: The double quoted gecos. """ if not self._gecos: return None if self._gecos.startswith(text_type('\'')) an...
159
86
555
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
476b50c7dbae5f3d1744313b5396ad096327065ffec1437db160f6df82a818c9
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
d00cb4ede7ea2caebd2ff505
jonhadfield/creds
lib/creds/users.py
User.to_dict
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L71-L75
train
python
Return the user as a dict.
def to_dict(self): """ Return the user as a dict. """ public_keys = [public_key.b64encoded for public_key in self.public_keys] return dict(name=self.name, passwd=self.passwd, uid=self.uid, gid=self.gid, gecos=self.gecos, home_dir=self.home_dir, shell=self.shell, public_keys=p...
Return the user as a dict. def to_dict(self): """ Return the user as a dict. """ public_keys = [public_key.b64encoded for public_key in self.public_keys] return dict(name=self.name, passwd=self.passwd, uid=self.uid, gid=self.gid, gecos=self.gecos, home_dir=self.home_dir, she...
85
26
331
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
16f9fc5b426c4b739d64f1ca12d78dd03e5c41a59d8bdc978184e0d72b3a4ff9
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
93ced37774fd92e465fbcd9e
jonhadfield/creds
lib/creds/users.py
Users.insert
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L117-L120
train
python
Insert an instance of User into the collection.
def insert(self, index, value): """Insert an instance of User into the collection.""" self.check(value) self._user_list.insert(index, value)
Insert an instance of User into the collection. def insert(self, index, value): """Insert an instance of User into the collection.""" self.check(value) self._user_list.insert(index, value)
43
47
164
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
942e40c1e39dd5876490aeb24b5e5667570d007dde86b58203039134dd6f594c
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
c221f5213066e0e926fe28ed
jonhadfield/creds
lib/creds/users.py
Users.remove
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L134-L136
train
python
Remove User instance based on supplied user name.
def remove(self, username=None): """Remove User instance based on supplied user name.""" self._user_list = [user for user in self._user_list if user.name != username]
Remove User instance based on supplied user name. def remove(self, username=None): """Remove User instance based on supplied user name.""" self._user_list = [user for user in self._user_list if user.name != username]
48
49
182
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
c45725ca15ac7b7139e393434443dbb41f195ee47082262f64ae4666ae6a758e
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
f9bef4aebe1ee45dfbfb6177
jonhadfield/creds
lib/creds/users.py
Users.describe_users
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L138-L144
train
python
Return a list of users matching a filter (if provided).
def describe_users(self, users_filter=None): """Return a list of users matching a filter (if provided).""" user_list = Users(oktypes=User) for user in self._user_list: if users_filter and (users_filter.get('name') == user.name or users_filter.get('uid') == user.uid): ...
Return a list of users matching a filter (if provided). def describe_users(self, users_filter=None): """Return a list of users matching a filter (if provided).""" user_list = Users(oktypes=User) for user in self._user_list: if users_filter and (users_filter.get('name') == user.name ...
90
55
367
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
40489fddc3e274e2fcc08d6b15ba1bca843faf081bf746c6bf51d09ddb7cc878
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
4dd45bd03a1ea20d8cca30b5
jonhadfield/creds
lib/creds/users.py
Users.from_yaml
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L152-L169
train
python
Create collection from a YAML file.
def from_yaml(cls, file_path=None): """Create collection from a YAML file.""" try: import yaml except ImportError: # pragma: no cover yaml = None if not yaml: import sys sys.exit('PyYAML is not installed, but is required in order to parse ...
Create collection from a YAML file. def from_yaml(cls, file_path=None): """Create collection from a YAML file.""" try: import yaml except ImportError: # pragma: no cover yaml = None if not yaml: import sys sys.exit('PyYAML is not installe...
176
35
813
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f65da2230b775c7486cbede03dc30778fc8dd05cc8a47ffdd83d5195352d1a7e
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
bad474958055d371bbf2e988
jonhadfield/creds
lib/creds/users.py
Users.from_json
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L172-L179
train
python
Create collection from a JSON file.
def from_json(cls, file_path=None): """Create collection from a JSON file.""" with io.open(file_path, encoding=text_type('utf-8')) as stream: try: users_json = json.load(stream) except ValueError: raise ValueError('No JSON object could be decoded')...
Create collection from a JSON file. def from_json(cls, file_path=None): """Create collection from a JSON file.""" with io.open(file_path, encoding=text_type('utf-8')) as stream: try: users_json = json.load(stream) except ValueError: raise ValueErr...
84
35
398
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
496819f78233872c5a4ab6f02361da052342472c3e8970fd5409925d0a429249
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
21b522a511c68e0143a36ef6
jonhadfield/creds
lib/creds/users.py
Users.from_passwd
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L182-L205
train
python
Create collection from locally discovered data, e.g. /etc/passwd.
def from_passwd(uid_min=None, uid_max=None): """Create collection from locally discovered data, e.g. /etc/passwd.""" import pwd users = Users(oktypes=User) passwd_list = pwd.getpwall() if not uid_min: uid_min = UID_MIN if not uid_max: uid_max = UID...
Create collection from locally discovered data, e.g. /etc/passwd. def from_passwd(uid_min=None, uid_max=None): """Create collection from locally discovered data, e.g. /etc/passwd.""" import pwd users = Users(oktypes=User) passwd_list = pwd.getpwall() if not uid_min: ...
246
65
1,212
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
ea6386cc45dae18e34225c4c18a74721cb21c2cdde75961bbcf54aabb9e497a0
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
694898626818a3bfbab624f9
jonhadfield/creds
lib/creds/users.py
Users.construct_user_list
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L208-L225
train
python
Construct a list of User objects from a list of dicts.
def construct_user_list(raw_users=None): """Construct a list of User objects from a list of dicts.""" users = Users(oktypes=User) for user_dict in raw_users: public_keys = None if user_dict.get('public_keys'): public_keys = [PublicKey(b64encoded=x, raw=Non...
Construct a list of User objects from a list of dicts. def construct_user_list(raw_users=None): """Construct a list of User objects from a list of dicts.""" users = Users(oktypes=User) for user_dict in raw_users: public_keys = None if user_dict.get('public_keys'): ...
176
54
963
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
0c445b84363ae4555c51c73407a4973f4e719aaedb7f27481f79a0217ec53082
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
ab5685ece665ddba63d14f46
jonhadfield/creds
lib/creds/users.py
Users.to_dict
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L227-L232
train
python
Return a dict of the users.
def to_dict(self): """ Return a dict of the users. """ users = dict(users=list()) for user in self: users['users'].append(user.to_dict()) return users
Return a dict of the users. def to_dict(self): """ Return a dict of the users. """ users = dict(users=list()) for user in self: users['users'].append(user.to_dict()) return users
48
27
194
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
823301074a7d209e5afdad6a32e878df47c5c755b9bf5291d9b5daa1a761002e
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
377a9f9a98f0918f9e654180
jonhadfield/creds
lib/creds/users.py
Users.export
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/users.py#L234-L242
train
python
Write the users to a file.
def export(self, file_path=None, export_format=None): """ Write the users to a file. """ with io.open(file_path, mode='w', encoding="utf-8") as export_file: if export_format == 'yaml': import yaml yaml.safe_dump(self.to_dict(), export_file, default_flow_style=...
Write the users to a file. def export(self, file_path=None, export_format=None): """ Write the users to a file. """ with io.open(file_path, mode='w', encoding="utf-8") as export_file: if export_format == 'yaml': import yaml yaml.safe_dump(self.to_dict(), expo...
105
26
485
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
185b6f85156f87953771a36e58869b8760ccac73f90a6410d960914a9042ff50
MIT
permissive
https://github.com/jonhadfield/creds/blob/master/LICENSE
014cab3e38250175c74d8eaa
letuananh/chirptext
chirptext/texttaglib.py
read
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L936-L945
train
python
Helper function to read Document in TTL-TXT format (i.e. ${docname}_*.txt) E.g. read('~/data/myfile') is the same as Document('myfile', '~/data/').read()
def read(path, mode='tsv'): ''' Helper function to read Document in TTL-TXT format (i.e. ${docname}_*.txt) E.g. read('~/data/myfile') is the same as Document('myfile', '~/data/').read() ''' if mode == 'tsv': return TxtReader.from_path(path).read() elif mode == 'json': return read_jso...
Helper function to read Document in TTL-TXT format (i.e. ${docname}_*.txt) E.g. read('~/data/myfile') is the same as Document('myfile', '~/data/').read() def read(path, mode='tsv'): ''' Helper function to read Document in TTL-TXT format (i.e. ${docname}_*.txt) E.g. read('~/data/myfile') is the same as Docu...
154
157
410
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
0284cfc2fba52d3117dd3275d7979f7098112d71d200cec0970ebdd515945232
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
5d35a57c13a109144347c518
letuananh/chirptext
chirptext/texttaglib.py
write
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L948-L954
train
python
Helper function to write doc to TTL-TXT format
def write(path, doc, mode=MODE_TSV, **kwargs): ''' Helper function to write doc to TTL-TXT format ''' if mode == MODE_TSV: with TxtWriter.from_path(path) as writer: writer.write_doc(doc) elif mode == MODE_JSON: write_json(path, doc, **kwargs)
Helper function to write doc to TTL-TXT format def write(path, doc, mode=MODE_TSV, **kwargs): ''' Helper function to write doc to TTL-TXT format ''' if mode == MODE_TSV: with TxtWriter.from_path(path) as writer: writer.write_doc(doc) elif mode == MODE_JSON: write_json(path, doc,...
81
46
282
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
92c47ddada4e83a36628fcdefb5ccc82f8f9f71412ecdaa3e206004cf2af9956
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
6d919cf4b954ed99bd9f2276
letuananh/chirptext
chirptext/texttaglib.py
Sentence.tcmap
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L195-L201
train
python
Create a tokens-concepts map
def tcmap(self): ''' Create a tokens-concepts map ''' tcmap = dd(list) for concept in self.__concept_map.values(): for w in concept.tokens: tcmap[w].append(concept) return tcmap
Create a tokens-concepts map def tcmap(self): ''' Create a tokens-concepts map ''' tcmap = dd(list) for concept in self.__concept_map.values(): for w in concept.tokens: tcmap[w].append(concept) return tcmap
58
28
237
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
4fc170dd26d86e9473f9bd2f4e64b1e1c566e0ddb8499f642a173e0388c1ab43
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
1e4745686a66fc73eac795c3
letuananh/chirptext
chirptext/texttaglib.py
Sentence.msw
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L207-L209
train
python
Return a generator of tokens with more than one sense.
def msw(self): ''' Return a generator of tokens with more than one sense. ''' return (t for t, c in self.tcmap().items() if len(c) > 1)
Return a generator of tokens with more than one sense. def msw(self): ''' Return a generator of tokens with more than one sense. ''' return (t for t, c in self.tcmap().items() if len(c) > 1)
53
54
151
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
714c71a33bcb00f61571ae7a42153bc356cc560fcc45a2006e7d8e21c0c7afe5
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
84923d22f6f596524b531a14
letuananh/chirptext
chirptext/texttaglib.py
Sentence.surface
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L211-L216
train
python
Get surface string that is associated with a tag object
def surface(self, tag): ''' Get surface string that is associated with a tag object ''' if tag.cfrom is not None and tag.cto is not None and tag.cfrom >= 0 and tag.cto >= 0: return self.text[tag.cfrom:tag.cto] else: return ''
Get surface string that is associated with a tag object def surface(self, tag): ''' Get surface string that is associated with a tag object ''' if tag.cfrom is not None and tag.cto is not None and tag.cfrom >= 0 and tag.cto >= 0: return self.text[tag.cfrom:tag.cto] else: ...
78
55
273
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
89fbbcc0308129482c89d0c67cfb07754604d59cddad564c63a81ea343f4d0cd
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
45d09dc8f9d842845349c7e2
letuananh/chirptext
chirptext/texttaglib.py
Sentence.new_tag
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L222-L225
train
python
Create a sentence-level tag
def new_tag(self, label, cfrom=-1, cto=-1, tagtype='', **kwargs): ''' Create a sentence-level tag ''' tag_obj = Tag(label, cfrom, cto, tagtype=tagtype, **kwargs) return self.add_tag(tag_obj)
Create a sentence-level tag def new_tag(self, label, cfrom=-1, cto=-1, tagtype='', **kwargs): ''' Create a sentence-level tag ''' tag_obj = Tag(label, cfrom, cto, tagtype=tagtype, **kwargs) return self.add_tag(tag_obj)
67
27
214
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
3d19484cbaab1c92d2f61282beb7dde39a076d363a0cf1a81c670a997ece6f4f
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
d24547178ec7440f0f5b99d0
letuananh/chirptext
chirptext/texttaglib.py
Sentence.get_tag
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L227-L232
train
python
Get the first tag of a particular type
def get_tag(self, tagtype): ''' Get the first tag of a particular type''' for tag in self.__tags: if tag.tagtype == tagtype: return tag return None
Get the first tag of a particular type def get_tag(self, tagtype): ''' Get the first tag of a particular type''' for tag in self.__tags: if tag.tagtype == tagtype: return tag return None
52
38
199
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
df63e0c8f85ae3c53def40095e5f92e091b810f3b8ff672d6733d5c48f6fc63c
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
e9325404a3103762683048ab
letuananh/chirptext
chirptext/texttaglib.py
Sentence.get_tags
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L234-L236
train
python
Get all tags of a type
def get_tags(self, tagtype): ''' Get all tags of a type ''' return [t for t in self.__tags if t.tagtype == tagtype]
Get all tags of a type def get_tags(self, tagtype): ''' Get all tags of a type ''' return [t for t in self.__tags if t.tagtype == tagtype]
42
22
131
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
62dcd7657c9e456398947a464956f5e465327f25feed55cb9b778d8b2d126947
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
1287516df6084f96f5cf4c4d
letuananh/chirptext
chirptext/texttaglib.py
Sentence.add_token_object
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L242-L246
train
python
Add a token object into this sentence
def add_token_object(self, token): ''' Add a token object into this sentence ''' token.sent = self # take ownership of given token self.__tokens.append(token) return token
Add a token object into this sentence def add_token_object(self, token): ''' Add a token object into this sentence ''' token.sent = self # take ownership of given token self.__tokens.append(token) return token
49
37
204
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
b17386d3ef25a2fc81080dfc6f81dd87c31c6d67463756f3cd5b0420c808615b
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
dfcf85aa8c9feabf343ccdd2
letuananh/chirptext
chirptext/texttaglib.py
Sentence.new_concept
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L254-L263
train
python
Create a new concept object and add it to concept list tokens can be a list of Token objects or token indices
def new_concept(self, tag, clemma="", tokens=None, cidx=None, **kwargs): ''' Create a new concept object and add it to concept list tokens can be a list of Token objects or token indices ''' if cidx is None: cidx = self.new_concept_id() if tokens: tokens =...
Create a new concept object and add it to concept list tokens can be a list of Token objects or token indices def new_concept(self, tag, clemma="", tokens=None, cidx=None, **kwargs): ''' Create a new concept object and add it to concept list tokens can be a list of Token objects or token indice...
152
117
503
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
13ca62f9782c38e3b3a81fe86f034ceaa145464868ff5c542253d5946ec82085
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
0da99a99f55b1b26ad41c7d6
letuananh/chirptext
chirptext/texttaglib.py
Sentence.add_concept
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L265-L276
train
python
Add a concept to current concept list
def add_concept(self, concept_obj): ''' Add a concept to current concept list ''' if concept_obj is None: raise Exception("Concept object cannot be None") elif concept_obj in self.__concepts: raise Exception("Concept object is already inside") elif concept_obj.cid...
Add a concept to current concept list def add_concept(self, concept_obj): ''' Add a concept to current concept list ''' if concept_obj is None: raise Exception("Concept object cannot be None") elif concept_obj in self.__concepts: raise Exception("Concept object is alread...
130
37
589
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
14bcf90a0a8a27a212c0d01c55c2ba392d91648c006c97798a99770f65dc1211
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
4c62d2e628818d1a35096a2c
letuananh/chirptext
chirptext/texttaglib.py
Sentence.concept
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L289-L297
train
python
Get concept by concept ID
def concept(self, cid, **kwargs): ''' Get concept by concept ID ''' if cid not in self.__concept_map: if 'default' in kwargs: return kwargs['default'] else: raise KeyError("Invalid cid") else: return self.__concept_map[cid]
Get concept by concept ID def concept(self, cid, **kwargs): ''' Get concept by concept ID ''' if cid not in self.__concept_map: if 'default' in kwargs: return kwargs['default'] else: raise KeyError("Invalid cid") else: return s...
69
25
315
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
c9244be8e78c53ba611b05881f5489181daf392df302ddc5ba7134f76d469b79
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
e4f53011df14f3dc8b2bd2cb
letuananh/chirptext
chirptext/texttaglib.py
Sentence.import_tokens
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L315-L345
train
python
Import a list of string as tokens
def import_tokens(self, tokens, import_hook=None, ignorecase=True): ''' Import a list of string as tokens ''' text = self.text.lower() if ignorecase else self.text has_hooker = import_hook and callable(import_hook) cfrom = 0 if self.__tokens: for tk in self.__tokens: ...
Import a list of string as tokens def import_tokens(self, tokens, import_hook=None, ignorecase=True): ''' Import a list of string as tokens ''' text = self.text.lower() if ignorecase else self.text has_hooker = import_hook and callable(import_hook) cfrom = 0 if self.__tokens: ...
368
33
1,467
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
267d6b1c989266a658da0773bd1149f70982afd42b6de34606036e765ec0dd93
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
210f300a11daf0c124c34831
letuananh/chirptext
chirptext/texttaglib.py
Token.tag_map
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L420-L425
train
python
Build a map from tagtype to list of tags
def tag_map(self): ''' Build a map from tagtype to list of tags ''' tm = dd(list) for tag in self.__tags: tm[tag.tagtype].append(tag) return tm
Build a map from tagtype to list of tags def tag_map(self): ''' Build a map from tagtype to list of tags ''' tm = dd(list) for tag in self.__tags: tm[tag.tagtype].append(tag) return tm
55
40
187
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a0e60e4541c5750829e6a3fe2bd73b137d4f711d19796b0b7b252e730698e76f
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
dde3b8ecdbc3fc8e83b8e714
letuananh/chirptext
chirptext/texttaglib.py
Token.find
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L430-L438
train
python
Get the first tag with a type in this token
def find(self, tagtype, **kwargs): '''Get the first tag with a type in this token ''' for t in self.__tags: if t.tagtype == tagtype: return t if 'default' in kwargs: return kwargs['default'] else: raise LookupError("Token {} is not tagg...
Get the first tag with a type in this token def find(self, tagtype, **kwargs): '''Get the first tag with a type in this token ''' for t in self.__tags: if t.tagtype == tagtype: return t if 'default' in kwargs: return kwargs['default'] else: ...
98
43
378
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
802cad9cff001aebf45d27ad6c7c15986860803fda9416cec5df848a1dcc7e14
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
a4d57befd7e947331213e4b4
letuananh/chirptext
chirptext/texttaglib.py
Token.find_all
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L440-L442
train
python
Find all token-level tags with the specified tagtype
def find_all(self, tagtype): ''' Find all token-level tags with the specified tagtype ''' return [t for t in self.__tags if t.tagtype == tagtype]
Find all token-level tags with the specified tagtype def find_all(self, tagtype): ''' Find all token-level tags with the specified tagtype ''' return [t for t in self.__tags if t.tagtype == tagtype]
50
52
161
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
f3014cd34a7afec45e85c5f6837240922de0b4c2844f42b9b853a75bce652059
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE
190fa022bee7bc6a71a2dcd7
letuananh/chirptext
chirptext/texttaglib.py
Token.new_tag
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L448-L455
train
python
Create a new tag on this token
def new_tag(self, label, cfrom=None, cto=None, tagtype=None, **kwargs): ''' Create a new tag on this token ''' if cfrom is None: cfrom = self.cfrom if cto is None: cto = self.cto tag = Tag(label=label, cfrom=cfrom, cto=cto, tagtype=tagtype, **kwargs) retur...
Create a new tag on this token def new_tag(self, label, cfrom=None, cto=None, tagtype=None, **kwargs): ''' Create a new tag on this token ''' if cfrom is None: cfrom = self.cfrom if cto is None: cto = self.cto tag = Tag(label=label, cfrom=cfrom, cto=cto, tagtype=...
104
30
339
CodeSearchNet permissive-repo filter (dataset-level)
code_search_net
2026-12-05
a0e63293ed220424535fadb3de51502febe64c1eb6fcf849585310033eb697bf
MIT
permissive
https://github.com/letuananh/chirptext/blob/main/LICENSE