Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
WalletStateManager.is_addition_relevant | (self, addition: Coin) |
Check whether we care about a new addition (puzzle_hash). Returns true if we
control this puzzle hash.
|
Check whether we care about a new addition (puzzle_hash). Returns true if we
control this puzzle hash.
| async def is_addition_relevant(self, addition: Coin):
"""
Check whether we care about a new addition (puzzle_hash). Returns true if we
control this puzzle hash.
"""
result = await self.puzzle_store.puzzle_hash_exists(addition.puzzle_hash)
return result | [
"async",
"def",
"is_addition_relevant",
"(",
"self",
",",
"addition",
":",
"Coin",
")",
":",
"result",
"=",
"await",
"self",
".",
"puzzle_store",
".",
"puzzle_hash_exists",
"(",
"addition",
".",
"puzzle_hash",
")",
"return",
"result"
] | [
907,
4
] | [
913,
21
] | python | en | ['en', 'error', 'th'] | False |
WalletStateManager.get_relevant_removals | (self, removals: List[Coin]) | Returns a list of our unspent coins that are in the passed list. | Returns a list of our unspent coins that are in the passed list. | async def get_relevant_removals(self, removals: List[Coin]) -> List[Coin]:
"""Returns a list of our unspent coins that are in the passed list."""
result: List[Coin] = []
wallet_coin_records = await self.coin_store.get_unspent_coins_at_height()
my_coins: Dict[bytes32, Coin] = {r.coin.nam... | [
"async",
"def",
"get_relevant_removals",
"(",
"self",
",",
"removals",
":",
"List",
"[",
"Coin",
"]",
")",
"->",
"List",
"[",
"Coin",
"]",
":",
"result",
":",
"List",
"[",
"Coin",
"]",
"=",
"[",
"]",
"wallet_coin_records",
"=",
"await",
"self",
".",
... | [
923,
4
] | [
934,
21
] | python | en | ['en', 'en', 'en'] | True |
WalletStateManager.reorg_rollback | (self, height: int) |
Rolls back and updates the coin_store and transaction store. It's possible this height
is the tip, or even beyond the tip.
|
Rolls back and updates the coin_store and transaction store. It's possible this height
is the tip, or even beyond the tip.
| async def reorg_rollback(self, height: int):
"""
Rolls back and updates the coin_store and transaction store. It's possible this height
is the tip, or even beyond the tip.
"""
await self.coin_store.rollback_to_block(height)
reorged: List[TransactionRecord] = await self.t... | [
"async",
"def",
"reorg_rollback",
"(",
"self",
",",
"height",
":",
"int",
")",
":",
"await",
"self",
".",
"coin_store",
".",
"rollback_to_block",
"(",
"height",
")",
"reorged",
":",
"List",
"[",
"TransactionRecord",
"]",
"=",
"await",
"self",
".",
"tx_stor... | [
936,
4
] | [
946,
53
] | python | en | ['en', 'error', 'th'] | False |
WalletStateManager.retry_sending_after_reorg | (self, records: List[TransactionRecord]) |
Retries sending spend_bundle to the Full_Node, after confirmed tx
get's excluded from chain because of the reorg.
|
Retries sending spend_bundle to the Full_Node, after confirmed tx
get's excluded from chain because of the reorg.
| async def retry_sending_after_reorg(self, records: List[TransactionRecord]):
"""
Retries sending spend_bundle to the Full_Node, after confirmed tx
get's excluded from chain because of the reorg.
"""
if len(records) == 0:
return None
for record in records:
... | [
"async",
"def",
"retry_sending_after_reorg",
"(",
"self",
",",
"records",
":",
"List",
"[",
"TransactionRecord",
"]",
")",
":",
"if",
"len",
"(",
"records",
")",
"==",
"0",
":",
"return",
"None",
"for",
"record",
"in",
"records",
":",
"if",
"record",
"."... | [
948,
4
] | [
964,
33
] | python | en | ['en', 'error', 'th'] | False |
WalletStateManager.get_start_height | (self) |
If we have coin use that as starting height next time,
otherwise use the peak
|
If we have coin use that as starting height next time,
otherwise use the peak
| async def get_start_height(self):
"""
If we have coin use that as starting height next time,
otherwise use the peak
"""
first_coin_height = await self.coin_store.get_first_coin_height()
if first_coin_height is None:
start_height = self.blockchain.get_peak()
... | [
"async",
"def",
"get_start_height",
"(",
"self",
")",
":",
"first_coin_height",
"=",
"await",
"self",
".",
"coin_store",
".",
"get_first_coin_height",
"(",
")",
"if",
"first_coin_height",
"is",
"None",
":",
"start_height",
"=",
"self",
".",
"blockchain",
".",
... | [
984,
4
] | [
996,
27
] | python | en | ['en', 'error', 'th'] | False |
ConfigSyncSchedules.__init__ | (self, api_uri: str, matchbox_path: str, ignition_dict: dict, extra_selector_dict=None) |
:param api_uri: http://1.1.1.1:5000
:param matchbox_path: /var/lib/matchbox
:param ignition_dict: ignition.yaml
|
:param api_uri: http://1.1.1.1:5000
:param matchbox_path: /var/lib/matchbox
:param ignition_dict: ignition.yaml
| def __init__(self, api_uri: str, matchbox_path: str, ignition_dict: dict, extra_selector_dict=None):
"""
:param api_uri: http://1.1.1.1:5000
:param matchbox_path: /var/lib/matchbox
:param ignition_dict: ignition.yaml
"""
self.api_uri = api_uri
os.environ["API_URI"... | [
"def",
"__init__",
"(",
"self",
",",
"api_uri",
":",
"str",
",",
"matchbox_path",
":",
"str",
",",
"ignition_dict",
":",
"dict",
",",
"extra_selector_dict",
"=",
"None",
")",
":",
"self",
".",
"api_uri",
"=",
"api_uri",
"os",
".",
"environ",
"[",
"\"API_... | [
27,
4
] | [
43,
43
] | python | en | ['en', 'error', 'th'] | False |
ConfigSyncSchedules.get_dns_attr | (fqdn: str) |
TODO: Use LLDP to avoid vendor specific usage
:param fqdn: e.g: r13-srv3.dc-1.foo.bar.cr
:return:
|
TODO: Use LLDP to avoid vendor specific usage
:param fqdn: e.g: r13-srv3.dc-1.foo.bar.cr
:return:
| def get_dns_attr(fqdn: str):
"""
TODO: Use LLDP to avoid vendor specific usage
:param fqdn: e.g: r13-srv3.dc-1.foo.bar.cr
:return:
"""
d = {
"shortname": "",
"dc": "",
"domain": "",
"rack": "",
"pos": "",
... | [
"def",
"get_dns_attr",
"(",
"fqdn",
":",
"str",
")",
":",
"d",
"=",
"{",
"\"shortname\"",
":",
"\"\"",
",",
"\"dc\"",
":",
"\"\"",
",",
"\"domain\"",
":",
"\"\"",
",",
"\"rack\"",
":",
"\"\"",
",",
"\"pos\"",
":",
"\"\"",
",",
"}",
"s",
"=",
"fqdn"... | [
64,
4
] | [
91,
16
] | python | en | ['en', 'error', 'th'] | False |
ConfigSyncSchedules._cni_ipam | (host_cidrv4: str, host_gateway: str) |
see: https://github.com/containernetworking/cni/blob/master/SPEC.md#ip-allocation
see: https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local
With the class variables provide a way to generate a static host-local ipam
:param host_cidrv4: an host IP with its C... |
see: https://github.com/containernetworking/cni/blob/master/SPEC.md#ip-allocation
see: https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local
With the class variables provide a way to generate a static host-local ipam
:param host_cidrv4: an host IP with its C... | def _cni_ipam(host_cidrv4: str, host_gateway: str):
"""
see: https://github.com/containernetworking/cni/blob/master/SPEC.md#ip-allocation
see: https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local
With the class variables provide a way to generate a static ho... | [
"def",
"_cni_ipam",
"(",
"host_cidrv4",
":",
"str",
",",
"host_gateway",
":",
"str",
")",
":",
"interface",
"=",
"IPv4Interface",
"(",
"host_cidrv4",
")",
"subnet",
"=",
"interface",
".",
"network",
"try",
":",
"assert",
"0",
"<=",
"ConfigSyncSchedules",
"."... | [
94,
4
] | [
133,
19
] | python | en | ['en', 'error', 'th'] | False |
ConfigSyncSchedules.get_extra_selectors | (extra_selectors: dict) |
Extra selectors are passed to Matchbox
:param extra_selectors: dict
:return:
|
Extra selectors are passed to Matchbox
:param extra_selectors: dict
:return:
| def get_extra_selectors(extra_selectors: dict):
"""
Extra selectors are passed to Matchbox
:param extra_selectors: dict
:return:
"""
if extra_selectors:
if type(extra_selectors) is dict:
logger.debug("extra selectors: %s" % extra_selectors)
... | [
"def",
"get_extra_selectors",
"(",
"extra_selectors",
":",
"dict",
")",
":",
"if",
"extra_selectors",
":",
"if",
"type",
"(",
"extra_selectors",
")",
"is",
"dict",
":",
"logger",
".",
"debug",
"(",
"\"extra selectors: %s\"",
"%",
"extra_selectors",
")",
"return"... | [
136,
4
] | [
151,
17
] | python | en | ['en', 'error', 'th'] | False |
ConfigSyncSchedules.notify | (self) |
TODO if we need to notify the API for any reason
:return:
|
TODO if we need to notify the API for any reason
:return:
| def notify(self):
"""
TODO if we need to notify the API for any reason
:return:
"""
req = requests.post("%s/sync-notify" % self.api_uri)
req.close()
logger.debug("notified API") | [
"def",
"notify",
"(",
"self",
")",
":",
"req",
"=",
"requests",
".",
"post",
"(",
"\"%s/sync-notify\"",
"%",
"self",
".",
"api_uri",
")",
"req",
".",
"close",
"(",
")",
"logger",
".",
"debug",
"(",
"\"notified API\"",
")"
] | [
393,
4
] | [
400,
36
] | python | en | ['en', 'error', 'th'] | False |
project_playbooks | () |
Return playbook_files as playbooks for manual projects when testing.
|
Return playbook_files as playbooks for manual projects when testing.
| def project_playbooks():
"""
Return playbook_files as playbooks for manual projects when testing.
"""
class PlaybooksMock(mock.PropertyMock):
def __get__(self, obj, obj_type):
return obj.playbook_files
mocked = mock.patch.object(Project, 'playbooks', new_callable=PlaybooksMock)... | [
"def",
"project_playbooks",
"(",
")",
":",
"class",
"PlaybooksMock",
"(",
"mock",
".",
"PropertyMock",
")",
":",
"def",
"__get__",
"(",
"self",
",",
"obj",
",",
"obj_type",
")",
":",
"return",
"obj",
".",
"playbook_files",
"mocked",
"=",
"mock",
".",
"pa... | [
96,
0
] | [
106,
18
] | python | en | ['en', 'error', 'th'] | False |
rando | (user) | Rando, the random user that doesn't have access to anything | Rando, the random user that doesn't have access to anything | def rando(user):
"Rando, the random user that doesn't have access to anything"
return user('rando', False) | [
"def",
"rando",
"(",
"user",
")",
":",
"return",
"user",
"(",
"'rando'",
",",
"False",
")"
] | [
443,
0
] | [
445,
31
] | python | en | ['en', 'en', 'en'] | True |
jt_linked | (organization, project, inventory, machine_credential, credential, net_credential, vault_credential) |
A job template with a reasonably complete set of related objects to
test RBAC and other functionality affected by related objects
|
A job template with a reasonably complete set of related objects to
test RBAC and other functionality affected by related objects
| def jt_linked(organization, project, inventory, machine_credential, credential, net_credential, vault_credential):
"""
A job template with a reasonably complete set of related objects to
test RBAC and other functionality affected by related objects
"""
jt = JobTemplate.objects.create(project=project... | [
"def",
"jt_linked",
"(",
"organization",
",",
"project",
",",
"inventory",
",",
"machine_credential",
",",
"credential",
",",
"net_credential",
",",
"vault_credential",
")",
":",
"jt",
"=",
"JobTemplate",
".",
"objects",
".",
"create",
"(",
"project",
"=",
"pr... | [
699,
0
] | [
706,
13
] | python | en | ['en', 'error', 'th'] | False |
get_db_prep_save | (self, value, connection, **kwargs) | Convert our JSON object to a string before we save | Convert our JSON object to a string before we save | def get_db_prep_save(self, value, connection, **kwargs):
"""Convert our JSON object to a string before we save"""
if value is None and self.null:
return None
# default values come in as strings; only non-strings should be
# run through `dumps`
if not isinstance(value, str):
value = d... | [
"def",
"get_db_prep_save",
"(",
"self",
",",
"value",
",",
"connection",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"value",
"is",
"None",
"and",
"self",
".",
"null",
":",
"return",
"None",
"# default values come in as strings; only non-strings should be",
"# run th... | [
745,
0
] | [
754,
16
] | python | en | ['en', 'en', 'en'] | True |
mem_data_to_dict | (inventory) |
Given an in-memory construct of an inventory, returns a dictionary that
follows Ansible guidelines on the structure of dynamic inventory sources
May be replaced by removing in-memory constructs within this file later
|
Given an in-memory construct of an inventory, returns a dictionary that
follows Ansible guidelines on the structure of dynamic inventory sources | def mem_data_to_dict(inventory):
"""
Given an in-memory construct of an inventory, returns a dictionary that
follows Ansible guidelines on the structure of dynamic inventory sources
May be replaced by removing in-memory constructs within this file later
"""
all_group = inventory.all_group
i... | [
"def",
"mem_data_to_dict",
"(",
"inventory",
")",
":",
"all_group",
"=",
"inventory",
".",
"all_group",
"inventory_data",
"=",
"OrderedDict",
"(",
"[",
"]",
")",
"# Save hostvars to _meta",
"inventory_data",
"[",
"'_meta'",
"]",
"=",
"OrderedDict",
"(",
"[",
"]"... | [
184,
0
] | [
223,
25
] | python | en | ['en', 'error', 'th'] | False |
dict_to_mem_data | (data, inventory=None) |
In-place operation on `inventory`, adds contents from `data` to the
in-memory representation of memory.
May be destructive on `data`
|
In-place operation on `inventory`, adds contents from `data` to the
in-memory representation of memory.
May be destructive on `data`
| def dict_to_mem_data(data, inventory=None):
"""
In-place operation on `inventory`, adds contents from `data` to the
in-memory representation of memory.
May be destructive on `data`
"""
assert isinstance(data, dict), 'Expected dict, received {}'.format(type(data))
if inventory is None:
... | [
"def",
"dict_to_mem_data",
"(",
"data",
",",
"inventory",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"dict",
")",
",",
"'Expected dict, received {}'",
".",
"format",
"(",
"type",
"(",
"data",
")",
")",
"if",
"inventory",
"is",
"None",... | [
226,
0
] | [
303,
20
] | python | en | ['en', 'error', 'th'] | False |
MemInventory.get_host | (self, name) |
Return a MemHost instance from host name, creating if needed. If name
contains brackets, they will NOT be interpreted as a host pattern.
|
Return a MemHost instance from host name, creating if needed. If name
contains brackets, they will NOT be interpreted as a host pattern.
| def get_host(self, name):
"""
Return a MemHost instance from host name, creating if needed. If name
contains brackets, they will NOT be interpreted as a host pattern.
"""
m = ipv6_port_re.match(name)
if m:
host_name = m.groups()[0]
port = int(m.gr... | [
"def",
"get_host",
"(",
"self",
",",
"name",
")",
":",
"m",
"=",
"ipv6_port_re",
".",
"match",
"(",
"name",
")",
"if",
"m",
":",
"host_name",
"=",
"m",
".",
"groups",
"(",
")",
"[",
"0",
"]",
"port",
"=",
"int",
"(",
"m",
".",
"groups",
"(",
... | [
123,
4
] | [
147,
50
] | python | en | ['en', 'error', 'th'] | False |
MemInventory.get_group | (self, name, all_group=None, child=False) |
Return a MemGroup instance from group name, creating if needed.
|
Return a MemGroup instance from group name, creating if needed.
| def get_group(self, name, all_group=None, child=False):
"""
Return a MemGroup instance from group name, creating if needed.
"""
all_group = all_group or self.all_group
if name in ['all', 'ungrouped']:
return all_group
if self.group_filter_re and not self.group... | [
"def",
"get_group",
"(",
"self",
",",
"name",
",",
"all_group",
"=",
"None",
",",
"child",
"=",
"False",
")",
":",
"all_group",
"=",
"all_group",
"or",
"self",
".",
"all_group",
"if",
"name",
"in",
"[",
"'all'",
",",
"'ungrouped'",
"]",
":",
"return",
... | [
155,
4
] | [
169,
46
] | python | en | ['en', 'error', 'th'] | False |
GroupMenuItem.is_shown | (self, request) |
If there aren't any visible items in the submenu, don't bother to show
this menu item
|
If there aren't any visible items in the submenu, don't bother to show
this menu item
| def is_shown(self, request):
"""
If there aren't any visible items in the submenu, don't bother to show
this menu item
"""
for menuitem in self.menu._registered_menu_items:
if menuitem.is_shown(request):
return True
return False | [
"def",
"is_shown",
"(",
"self",
",",
"request",
")",
":",
"for",
"menuitem",
"in",
"self",
".",
"menu",
".",
"_registered_menu_items",
":",
"if",
"menuitem",
".",
"is_shown",
"(",
"request",
")",
":",
"return",
"True",
"return",
"False"
] | [
44,
4
] | [
52,
20
] | python | en | ['en', 'error', 'th'] | False |
Base.silent_delete | (self) | Delete the object. If it's already deleted, ignore the error | Delete the object. If it's already deleted, ignore the error | def silent_delete(self):
"""Delete the object. If it's already deleted, ignore the error"""
try:
if not config.prevent_teardown:
return self.delete()
except (exc.NoContent, exc.NotFound, exc.Forbidden):
pass
except (exc.BadRequest, exc.Conflict) as... | [
"def",
"silent_delete",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"config",
".",
"prevent_teardown",
":",
"return",
"self",
".",
"delete",
"(",
")",
"except",
"(",
"exc",
".",
"NoContent",
",",
"exc",
".",
"NotFound",
",",
"exc",
".",
"Forbidden"... | [
15,
4
] | [
28,
23
] | python | en | ['en', 'en', 'en'] | True |
Base.get_object_role | (self, role, by_name=False) | Lookup and return a related object role by its role field or name.
Args:
----
role (str): The role's `role_field` or name
by_name (bool): Whether to retrieve the role by its name field (default: False)
Examples:
--------
>>> # get the description of ... | Lookup and return a related object role by its role field or name. | def get_object_role(self, role, by_name=False):
"""Lookup and return a related object role by its role field or name.
Args:
----
role (str): The role's `role_field` or name
by_name (bool): Whether to retrieve the role by its name field (default: False)
Examples:... | [
"def",
"get_object_role",
"(",
"self",
",",
"role",
",",
"by_name",
"=",
"False",
")",
":",
"if",
"by_name",
":",
"for",
"obj_role",
"in",
"self",
".",
"related",
".",
"object_roles",
".",
"get",
"(",
")",
".",
"results",
":",
"if",
"obj_role",
".",
... | [
30,
4
] | [
60,
38
] | python | en | ['en', 'en', 'en'] | True |
Base.set_object_roles | (self, agent, *role_names, **kw) | Associate related object roles to a User or Team by role names
Args:
----
agent (User or Team): The agent the role is to be (dis)associated with.
*role_names (str): an arbitrary number of role names ('Admin', 'Execute', 'Read', etc.)
**kw:
endpoint (s... | Associate related object roles to a User or Team by role names | def set_object_roles(self, agent, *role_names, **kw):
"""Associate related object roles to a User or Team by role names
Args:
----
agent (User or Team): The agent the role is to be (dis)associated with.
*role_names (str): an arbitrary number of role names ('Admin', 'Exec... | [
"def",
"set_object_roles",
"(",
"self",
",",
"agent",
",",
"*",
"role_names",
",",
"*",
"*",
"kw",
")",
":",
"from",
"awxkit",
".",
"api",
".",
"pages",
"import",
"User",
",",
"Team",
"endpoint",
"=",
"kw",
".",
"get",
"(",
"'endpoint'",
",",
"'relat... | [
62,
4
] | [
121,
19
] | python | en | ['en', 'en', 'en'] | True |
popen_wrapper | (args, os_err_exc_type=CommandError, stdout_encoding='utf-8') |
Friendly wrapper around Popen.
Returns stdout output, stderr output and OS status code.
|
Friendly wrapper around Popen. | def popen_wrapper(args, os_err_exc_type=CommandError, stdout_encoding='utf-8'):
"""
Friendly wrapper around Popen.
Returns stdout output, stderr output and OS status code.
"""
try:
p = Popen(args, shell=False, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt')
except OSError as e:
... | [
"def",
"popen_wrapper",
"(",
"args",
",",
"os_err_exc_type",
"=",
"CommandError",
",",
"stdout_encoding",
"=",
"'utf-8'",
")",
":",
"try",
":",
"p",
"=",
"Popen",
"(",
"args",
",",
"shell",
"=",
"False",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
... | [
14,
0
] | [
31,
5
] | python | en | ['en', 'error', 'th'] | False |
handle_extensions | (extensions) |
Organizes multiple extensions that are separated with commas or passed by
using --extension/-e multiple times.
For example: running 'django-admin makemessages -e js,txt -e xhtml -a'
would result in an extension list: ['.js', '.txt', '.xhtml']
>>> handle_extensions(['.html', 'html,js,py,py,py,.py'... |
Organizes multiple extensions that are separated with commas or passed by
using --extension/-e multiple times. | def handle_extensions(extensions):
"""
Organizes multiple extensions that are separated with commas or passed by
using --extension/-e multiple times.
For example: running 'django-admin makemessages -e js,txt -e xhtml -a'
would result in an extension list: ['.js', '.txt', '.xhtml']
>>> handle_e... | [
"def",
"handle_extensions",
"(",
"extensions",
")",
":",
"ext_list",
"=",
"[",
"]",
"for",
"ext",
"in",
"extensions",
":",
"ext_list",
".",
"extend",
"(",
"ext",
".",
"replace",
"(",
"' '",
",",
"''",
")",
".",
"split",
"(",
"','",
")",
")",
"for",
... | [
34,
0
] | [
53,
24
] | python | en | ['en', 'error', 'th'] | False |
get_random_secret_key | () |
Return a 50 character random string usable as a SECRET_KEY setting value.
|
Return a 50 character random string usable as a SECRET_KEY setting value.
| def get_random_secret_key():
"""
Return a 50 character random string usable as a SECRET_KEY setting value.
"""
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
return get_random_string(50, chars) | [
"def",
"get_random_secret_key",
"(",
")",
":",
"chars",
"=",
"'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'",
"return",
"get_random_string",
"(",
"50",
",",
"chars",
")"
] | [
81,
0
] | [
86,
39
] | python | en | ['en', 'error', 'th'] | False |
parse_apps_and_model_labels | (labels) |
Parse a list of "app_label.ModelName" or "app_label" strings into actual
objects and return a two-element tuple:
(set of model classes, set of app_configs).
Raise a CommandError if some specified models or apps don't exist.
|
Parse a list of "app_label.ModelName" or "app_label" strings into actual
objects and return a two-element tuple:
(set of model classes, set of app_configs).
Raise a CommandError if some specified models or apps don't exist.
| def parse_apps_and_model_labels(labels):
"""
Parse a list of "app_label.ModelName" or "app_label" strings into actual
objects and return a two-element tuple:
(set of model classes, set of app_configs).
Raise a CommandError if some specified models or apps don't exist.
"""
apps = set()
... | [
"def",
"parse_apps_and_model_labels",
"(",
"labels",
")",
":",
"apps",
"=",
"set",
"(",
")",
"models",
"=",
"set",
"(",
")",
"for",
"label",
"in",
"labels",
":",
"if",
"'.'",
"in",
"label",
":",
"try",
":",
"model",
"=",
"installed_apps",
".",
"get_mod... | [
89,
0
] | [
113,
23
] | python | en | ['en', 'error', 'th'] | False |
clear_duplicate_reactions | (apps: StateApps, schema_editor: DatabaseSchemaEditor) | Zulip's data model for reactions has enforced via code,
nontransactionally, that they can only react with one emoji_code
for a given reaction_type. This fixes any that were stored in the
database via a race; the next migration will add the appropriate
database-level unique constraint.
| Zulip's data model for reactions has enforced via code,
nontransactionally, that they can only react with one emoji_code
for a given reaction_type. This fixes any that were stored in the
database via a race; the next migration will add the appropriate
database-level unique constraint.
| def clear_duplicate_reactions(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
"""Zulip's data model for reactions has enforced via code,
nontransactionally, that they can only react with one emoji_code
for a given reaction_type. This fixes any that were stored in the
database via a race;... | [
"def",
"clear_duplicate_reactions",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"Reaction",
"=",
"apps",
".",
"get_model",
"(",
"\"zerver\"",
",",
"\"Reaction\"",
")",
"duplicate_reactions",
"=",
"(",
... | [
6,
0
] | [
25,
29
] | python | en | ['en', 'en', 'en'] | True |
media_embed_entity | (props) |
Helper to construct elements of the form
<embed embedtype="media" url="https://www.youtube.com/watch?v=y8Kyi0WNg40"/>
when converting from contentstate data
|
Helper to construct elements of the form
<embed embedtype="media" url="https://www.youtube.com/watch?v=y8Kyi0WNg40"/>
when converting from contentstate data
| def media_embed_entity(props):
"""
Helper to construct elements of the form
<embed embedtype="media" url="https://www.youtube.com/watch?v=y8Kyi0WNg40"/>
when converting from contentstate data
"""
return DOM.create_element('embed', {
'embedtype': 'media',
'url': props.get('url'),
... | [
"def",
"media_embed_entity",
"(",
"props",
")",
":",
"return",
"DOM",
".",
"create_element",
"(",
"'embed'",
",",
"{",
"'embedtype'",
":",
"'media'",
",",
"'url'",
":",
"props",
".",
"get",
"(",
"'url'",
")",
",",
"}",
")"
] | [
10,
0
] | [
19,
6
] | python | en | ['en', 'error', 'th'] | False |
Requirement.project_name | (self) | The "project name" of a requirement.
This is different from ``name`` if this requirement contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
| The "project name" of a requirement. | def project_name(self):
# type: () -> str
"""The "project name" of a requirement.
This is different from ``name`` if this requirement contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
"""
raise... | [
"def",
"project_name",
"(",
"self",
")",
":",
"# type: () -> str",
"raise",
"NotImplementedError",
"(",
"\"Subclass should override\"",
")"
] | [
70,
4
] | [
78,
61
] | python | en | ['en', 'en', 'en'] | True |
Requirement.name | (self) | The name identifying this requirement in the resolver.
This is different from ``project_name`` if this requirement contains
extras, where ``project_name`` would not contain the ``[...]`` part.
| The name identifying this requirement in the resolver. | def name(self):
# type: () -> str
"""The name identifying this requirement in the resolver.
This is different from ``project_name`` if this requirement contains
extras, where ``project_name`` would not contain the ``[...]`` part.
"""
raise NotImplementedError("Subclass s... | [
"def",
"name",
"(",
"self",
")",
":",
"# type: () -> str",
"raise",
"NotImplementedError",
"(",
"\"Subclass should override\"",
")"
] | [
81,
4
] | [
88,
61
] | python | en | ['en', 'en', 'en'] | True |
Candidate.project_name | (self) | The "project name" of the candidate.
This is different from ``name`` if this candidate contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
| The "project name" of the candidate. | def project_name(self):
# type: () -> str
"""The "project name" of the candidate.
This is different from ``name`` if this candidate contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
"""
raise N... | [
"def",
"project_name",
"(",
"self",
")",
":",
"# type: () -> str",
"raise",
"NotImplementedError",
"(",
"\"Override in subclass\"",
")"
] | [
105,
4
] | [
113,
57
] | python | en | ['en', 'en', 'en'] | True |
Candidate.name | (self) | The name identifying this candidate in the resolver.
This is different from ``project_name`` if this candidate contains
extras, where ``project_name`` would not contain the ``[...]`` part.
| The name identifying this candidate in the resolver. | def name(self):
# type: () -> str
"""The name identifying this candidate in the resolver.
This is different from ``project_name`` if this candidate contains
extras, where ``project_name`` would not contain the ``[...]`` part.
"""
raise NotImplementedError("Override in su... | [
"def",
"name",
"(",
"self",
")",
":",
"# type: () -> str",
"raise",
"NotImplementedError",
"(",
"\"Override in subclass\"",
")"
] | [
116,
4
] | [
123,
57
] | python | en | ['en', 'en', 'en'] | True |
_xml_escape | (data) | Escape &, <, >, ", ', etc. in a string of data. | Escape &, <, >, ", ', etc. in a string of data. | def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&' + s + ';' for s in "amp gt lt quot apos".split())
for from_, to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
re... | [
"def",
"_xml_escape",
"(",
"data",
")",
":",
"# ampersand must be replaced first",
"from_symbols",
"=",
"'&><\"\\''",
"to_symbols",
"=",
"(",
"'&'",
"+",
"s",
"+",
"';'",
"for",
"s",
"in",
"\"amp gt lt quot apos\"",
".",
"split",
"(",
")",
")",
"for",
"from_",... | [
269,
0
] | [
277,
15
] | python | en | ['en', 'en', 'en'] | True |
col | (loc, strg) | Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See
:class:`ParserElement.parseString` for more
information on parsing strings contai... | Returns current column within a string, counting newlines as line separators.
The first column is number 1. | def col (loc, strg):
"""Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See
:class:`ParserElement.parseString` for more
informati... | [
"def",
"col",
"(",
"loc",
",",
"strg",
")",
":",
"s",
"=",
"strg",
"return",
"1",
"if",
"0",
"<",
"loc",
"<",
"len",
"(",
"s",
")",
"and",
"s",
"[",
"loc",
"-",
"1",
"]",
"==",
"'\\n'",
"else",
"loc",
"-",
"s",
".",
"rfind",
"(",
"\"\\n\"",... | [
1210,
0
] | [
1222,
86
] | python | en | ['en', 'en', 'en'] | True |
lineno | (loc, strg) | Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note - the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See :class:`ParserElement.parseString`
for more information on parsing strings c... | Returns current line number within a string, counting newlines as line separators.
The first line is number 1. | def lineno(loc, strg):
"""Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note - the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See :class:`ParserElement.parseString`
for more in... | [
"def",
"lineno",
"(",
"loc",
",",
"strg",
")",
":",
"return",
"strg",
".",
"count",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"+",
"1"
] | [
1224,
0
] | [
1234,
39
] | python | en | ['en', 'en', 'en'] | True |
line | (loc, strg) | Returns the line of text containing loc within a string, counting newlines as line separators.
| Returns the line of text containing loc within a string, counting newlines as line separators.
| def line(loc, strg):
"""Returns the line of text containing loc within a string, counting newlines as line separators.
"""
lastCR = strg.rfind("\n", 0, loc)
nextCR = strg.find("\n", loc)
if nextCR >= 0:
return strg[lastCR + 1:nextCR]
else:
return strg[lastCR + 1:] | [
"def",
"line",
"(",
"loc",
",",
"strg",
")",
":",
"lastCR",
"=",
"strg",
".",
"rfind",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"nextCR",
"=",
"strg",
".",
"find",
"(",
"\"\\n\"",
",",
"loc",
")",
"if",
"nextCR",
">=",
"0",
":",
"return",
"st... | [
1236,
0
] | [
1244,
32
] | python | en | ['en', 'en', 'en'] | True |
nullDebugAction | (*args) | Do-nothing' debug action, to suppress debugging output during parsing. | Do-nothing' debug action, to suppress debugging output during parsing. | def nullDebugAction(*args):
"""'Do-nothing' debug action, to suppress debugging output during parsing."""
pass | [
"def",
"nullDebugAction",
"(",
"*",
"args",
")",
":",
"pass"
] | [
1255,
0
] | [
1257,
8
] | python | en | ['en', 'jv', 'en'] | True |
ParseBaseException._from_exception | (cls, pe) |
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
|
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
| def _from_exception(cls, pe):
"""
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
"""
return cls(pe.pstr, pe.loc, pe.msg, pe.parserElement) | [
"def",
"_from_exception",
"(",
"cls",
",",
"pe",
")",
":",
"return",
"cls",
"(",
"pe",
".",
"pstr",
",",
"pe",
".",
"loc",
",",
"pe",
".",
"msg",
",",
"pe",
".",
"parserElement",
")"
] | [
315,
4
] | [
320,
61
] | python | en | ['en', 'error', 'th'] | False |
ParseBaseException.__getattr__ | (self, aname) | supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| def __getattr__(self, aname):
"""supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
"""
if aname == "lineno":
... | [
"def",
"__getattr__",
"(",
"self",
",",
"aname",
")",
":",
"if",
"aname",
"==",
"\"lineno\"",
":",
"return",
"lineno",
"(",
"self",
".",
"loc",
",",
"self",
".",
"pstr",
")",
"elif",
"aname",
"in",
"(",
"\"col\"",
",",
"\"column\"",
")",
":",
"return... | [
322,
4
] | [
335,
39
] | python | en | ['en', 'en', 'en'] | True |
ParseBaseException.markInputline | (self, markerString=">!<") | Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| def markInputline(self, markerString=">!<"):
"""Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
"""
line_str = self.line
line_column = self.column - 1
if markerString:
line_str = "".join((lin... | [
"def",
"markInputline",
"(",
"self",
",",
"markerString",
"=",
"\">!<\"",
")",
":",
"line_str",
"=",
"self",
".",
"line",
"line_column",
"=",
"self",
".",
"column",
"-",
"1",
"if",
"markerString",
":",
"line_str",
"=",
"\"\"",
".",
"join",
"(",
"(",
"l... | [
349,
4
] | [
358,
31
] | python | en | ['en', 'en', 'en'] | True |
ParseException.explain | (exc, depth=16) |
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- exc - exception raised during parsing (need not be a ParseException, in support
of Python exceptions that ... |
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised. | def explain(exc, depth=16):
"""
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- exc - exception raised during parsing (need not be a ParseException, in suppor... | [
"def",
"explain",
"(",
"exc",
",",
"depth",
"=",
"16",
")",
":",
"import",
"inspect",
"if",
"depth",
"is",
"None",
":",
"depth",
"=",
"sys",
".",
"getrecursionlimit",
"(",
")",
"ret",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"exc",
",",
"ParseBaseExce... | [
386,
4
] | [
452,
29
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.haskeys | (self) | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | def haskeys(self):
"""Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names."""
return bool(self.__tokdict) | [
"def",
"haskeys",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"__tokdict",
")"
] | [
695,
4
] | [
698,
35
] | python | en | ['en', 'en', 'en'] | True |
ParseResults.pop | (self, *args, **kwargs) |
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed tokens. If passed
a non-integer argum... |
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed tokens. If passed
a non-integer argum... | def pop(self, *args, **kwargs):
"""
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed to... | [
"def",
"pop",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"[",
"-",
"1",
"]",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"'default'",
":",... | [
700,
4
] | [
753,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.get | (self, key, defaultValue=None) |
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified.
Similar to ``dict.get()``.
Example::
integer = Word(nums)
date_str = integer("year") + '/... |
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified. | def get(self, key, defaultValue=None):
"""
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified.
Similar to ``dict.get()``.
Example::
integer = Word... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"else",
":",
"return",
"defaultValue"
] | [
755,
4
] | [
776,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.insert | (self, index, insStr) |
Inserts new element at location index in the list of parsed tokens.
Similar to ``list.insert()``.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to insert the parse location in the front of the parsed res... |
Inserts new element at location index in the list of parsed tokens. | def insert(self, index, insStr):
"""
Inserts new element at location index in the list of parsed tokens.
Similar to ``list.insert()``.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to insert the p... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"insStr",
")",
":",
"self",
".",
"__toklist",
".",
"insert",
"(",
"index",
",",
"insStr",
")",
"# fixup indices in token dictionary",
"for",
"name",
",",
"occurrences",
"in",
"self",
".",
"__tokdict",
".",
"... | [
778,
4
] | [
797,
94
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.append | (self, item) |
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to the end
def append_sum(tokens):
... |
Add single element to end of ParseResults list of elements. | def append(self, item):
"""
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to the end
... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"__toklist",
".",
"append",
"(",
"item",
")"
] | [
799,
4
] | [
812,
35
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.extend | (self, itemseq) |
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
tokens.extend(reversed([... |
Add sequence of elements to end of ParseResults list of elements. | def extend(self, itemseq):
"""
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
... | [
"def",
"extend",
"(",
"self",
",",
"itemseq",
")",
":",
"if",
"isinstance",
"(",
"itemseq",
",",
"ParseResults",
")",
":",
"self",
".",
"__iadd__",
"(",
"itemseq",
")",
"else",
":",
"self",
".",
"__toklist",
".",
"extend",
"(",
"itemseq",
")"
] | [
814,
4
] | [
831,
42
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.clear | (self) |
Clear all elements and results names.
|
Clear all elements and results names.
| def clear(self):
"""
Clear all elements and results names.
"""
del self.__toklist[:]
self.__tokdict.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"del",
"self",
".",
"__toklist",
"[",
":",
"]",
"self",
".",
"__tokdict",
".",
"clear",
"(",
")"
] | [
833,
4
] | [
838,
30
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asList | (self) |
Returns the parse results as a nested list of matching tokens, all converted to strings.
Example::
patt = OneOrMore(Word(alphas))
result = patt.parseString("sldkj lsdkj sldkj")
# even though the result prints in string-like form, it is actually a pyparsing ParseRes... |
Returns the parse results as a nested list of matching tokens, all converted to strings. | def asList(self):
"""
Returns the parse results as a nested list of matching tokens, all converted to strings.
Example::
patt = OneOrMore(Word(alphas))
result = patt.parseString("sldkj lsdkj sldkj")
# even though the result prints in string-like form, it is ... | [
"def",
"asList",
"(",
"self",
")",
":",
"return",
"[",
"res",
".",
"asList",
"(",
")",
"if",
"isinstance",
"(",
"res",
",",
"ParseResults",
")",
"else",
"res",
"for",
"res",
"in",
"self",
".",
"__toklist",
"]"
] | [
892,
4
] | [
907,
97
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asDict | (self) |
Returns the named parse results as a nested dictionary.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
result = date_str.parseString('12/31/1999')
print(type(result), repr(result)) # -> <class ... |
Returns the named parse results as a nested dictionary. | def asDict(self):
"""
Returns the named parse results as a nested dictionary.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
result = date_str.parseString('12/31/1999')
print(type(result... | [
"def",
"asDict",
"(",
"self",
")",
":",
"if",
"PY_3",
":",
"item_fn",
"=",
"self",
".",
"items",
"else",
":",
"item_fn",
"=",
"self",
".",
"iteritems",
"def",
"toItem",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"ParseResults",
")",
... | [
909,
4
] | [
943,
57
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.copy | (self) |
Returns a new copy of a :class:`ParseResults` object.
|
Returns a new copy of a :class:`ParseResults` object.
| def copy(self):
"""
Returns a new copy of a :class:`ParseResults` object.
"""
ret = ParseResults(self.__toklist)
ret.__tokdict = dict(self.__tokdict.items())
ret.__parent = self.__parent
ret.__accumNames.update(self.__accumNames)
ret.__name = self.__name
... | [
"def",
"copy",
"(",
"self",
")",
":",
"ret",
"=",
"ParseResults",
"(",
"self",
".",
"__toklist",
")",
"ret",
".",
"__tokdict",
"=",
"dict",
"(",
"self",
".",
"__tokdict",
".",
"items",
"(",
")",
")",
"ret",
".",
"__parent",
"=",
"self",
".",
"__par... | [
945,
4
] | [
954,
18
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asXML | (self, doctag=None, namedItemsOnly=False, indent="", formatted=True) |
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
|
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
| def asXML(self, doctag=None, namedItemsOnly=False, indent="", formatted=True):
"""
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
"""
nl = "\n"
out = []
namedItems = dict((v[1], k) for (k, vlist) in se... | [
"def",
"asXML",
"(",
"self",
",",
"doctag",
"=",
"None",
",",
"namedItemsOnly",
"=",
"False",
",",
"indent",
"=",
"\"\"",
",",
"formatted",
"=",
"True",
")",
":",
"nl",
"=",
"\"\\n\"",
"out",
"=",
"[",
"]",
"namedItems",
"=",
"dict",
"(",
"(",
"v",... | [
956,
4
] | [
1015,
27
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.getName | (self) | r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location.
Example::
integer = Word(nums)
ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
house_number_expr = Suppress('#') + Word(nums, a... | r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location. | def getName(self):
r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location.
Example::
integer = Word(nums)
ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
house_number_expr = S... | [
"def",
"getName",
"(",
"self",
")",
":",
"if",
"self",
".",
"__name",
":",
"return",
"self",
".",
"__name",
"elif",
"self",
".",
"__parent",
":",
"par",
"=",
"self",
".",
"__parent",
"(",
")",
"if",
"par",
":",
"return",
"par",
".",
"__lookup",
"("... | [
1024,
4
] | [
1062,
23
] | python | cy | ['en', 'cy', 'hi'] | False |
ParseResults.dump | (self, indent='', full=True, include_list=True, _depth=0) |
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("... |
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data. | def dump(self, indent='', full=True, include_list=True, _depth=0):
"""
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data.
Example::
... | [
"def",
"dump",
"(",
"self",
",",
"indent",
"=",
"''",
",",
"full",
"=",
"True",
",",
"include_list",
"=",
"True",
",",
"_depth",
"=",
"0",
")",
":",
"out",
"=",
"[",
"]",
"NL",
"=",
"'\\n'",
"if",
"include_list",
":",
"out",
".",
"append",
"(",
... | [
1064,
4
] | [
1127,
27
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.pprint | (self, *args, **kwargs) |
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .
Example::
... |
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ . | def pprint(self, *args, **kwargs):
"""
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.ht... | [
"def",
"pprint",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pprint",
".",
"pprint",
"(",
"self",
".",
"asList",
"(",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
1129,
4
] | [
1154,
53
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.from_dict | (cls, other, name=None) |
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
|
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
| def from_dict(cls, other, name=None):
"""
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
"""
def is_iterable(obj):
... | [
"def",
"from_dict",
"(",
"cls",
",",
"other",
",",
"name",
"=",
"None",
")",
":",
"def",
"is_iterable",
"(",
"obj",
")",
":",
"try",
":",
"iter",
"(",
"obj",
")",
"except",
"Exception",
":",
"return",
"False",
"else",
":",
"if",
"PY_3",
":",
"retur... | [
1181,
4
] | [
1206,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setDefaultWhitespaceChars | (chars) | r"""
Overrides the default whitespace chars
Example::
# default whitespace chars are space, <TAB> and newline
OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
# change to just treat newline as significant
Parser... | r"""
Overrides the default whitespace chars | def setDefaultWhitespaceChars(chars):
r"""
Overrides the default whitespace chars
Example::
# default whitespace chars are space, <TAB> and newline
OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
# change to just t... | [
"def",
"setDefaultWhitespaceChars",
"(",
"chars",
")",
":",
"ParserElement",
".",
"DEFAULT_WHITE_CHARS",
"=",
"chars"
] | [
1356,
4
] | [
1369,
49
] | python | cy | ['en', 'cy', 'hi'] | False |
ParserElement.inlineLiteralsUsing | (cls) |
Set class to be used for inclusion of string literals into a parser.
Example::
# default literal class used is Literal
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
date_str.parseString("1999/12/31") #... |
Set class to be used for inclusion of string literals into a parser. | def inlineLiteralsUsing(cls):
"""
Set class to be used for inclusion of string literals into a parser.
Example::
# default literal class used is Literal
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
... | [
"def",
"inlineLiteralsUsing",
"(",
"cls",
")",
":",
"ParserElement",
".",
"_literalStringClass",
"=",
"cls"
] | [
1372,
4
] | [
1391,
47
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.copy | (self) |
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element.
Example::
integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
integerK = integer.copy()... |
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element. | def copy(self):
"""
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element.
Example::
integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
... | [
"def",
"copy",
"(",
"self",
")",
":",
"cpy",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"cpy",
".",
"parseAction",
"=",
"self",
".",
"parseAction",
"[",
":",
"]",
"cpy",
".",
"ignoreExprs",
"=",
"self",
".",
"ignoreExprs",
"[",
":",
"]",
"if",
"... | [
1422,
4
] | [
1449,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setName | (self, name) |
Define name for this expression, makes debugging and exception messages clearer.
Example::
Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1)
Word(nums).setName("integer").parseString("ABC") # -> Exception: Expected integer (at ch... |
Define name for this expression, makes debugging and exception messages clearer. | def setName(self, name):
"""
Define name for this expression, makes debugging and exception messages clearer.
Example::
Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1)
Word(nums).setName("integer").parseString("ABC") # -... | [
"def",
"setName",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"errmsg",
"=",
"\"Expected \"",
"+",
"self",
".",
"name",
"if",
"__diag__",
".",
"enable_debug_on_named_expressions",
":",
"self",
".",
"setDebug",
"(",
... | [
1451,
4
] | [
1464,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setResultsName | (self, name, listAllMatches=False) |
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple pla... |
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple pla... | def setResultsName(self, name, listAllMatches=False):
"""
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic elem... | [
"def",
"setResultsName",
"(",
"self",
",",
"name",
",",
"listAllMatches",
"=",
"False",
")",
":",
"return",
"self",
".",
"_setResultsName",
"(",
"name",
",",
"listAllMatches",
")"
] | [
1466,
4
] | [
1487,
57
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setBreak | (self, breakFlag=True) | Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
| Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
| def setBreak(self, breakFlag=True):
"""Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
"""
if breakFlag:
_parseMethod = self._parse
def breaker(instring, loc, do... | [
"def",
"setBreak",
"(",
"self",
",",
"breakFlag",
"=",
"True",
")",
":",
"if",
"breakFlag",
":",
"_parseMethod",
"=",
"self",
".",
"_parse",
"def",
"breaker",
"(",
"instring",
",",
"loc",
",",
"doActions",
"=",
"True",
",",
"callPreParse",
"=",
"True",
... | [
1498,
4
] | [
1515,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.setParseAction | (self, *fns, **kwargs) |
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:
- s = the original string being parsed (se... |
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where: | def setParseAction(self, *fns, **kwargs):
"""
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:
... | [
"def",
"setParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"list",
"(",
"fns",
")",
"==",
"[",
"None",
",",
"]",
":",
"self",
".",
"parseAction",
"=",
"[",
"]",
"else",
":",
"if",
"not",
"all",
"(",
"callabl... | [
1517,
4
] | [
1564,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.addParseAction | (self, *fns, **kwargs) |
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`.
See examples in :class:`copy`.
|
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`. | def addParseAction(self, *fns, **kwargs):
"""
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`.
See examples in :class:`copy`.
"""
self.parseAction += list(map(_trim_arity, list(fns)))
self.callDuringTry = self.callDuringTr... | [
"def",
"addParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"parseAction",
"+=",
"list",
"(",
"map",
"(",
"_trim_arity",
",",
"list",
"(",
"fns",
")",
")",
")",
"self",
".",
"callDuringTry",
"=",
"self",
"... | [
1566,
4
] | [
1574,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.addCondition | (self, *fns, **kwargs) | Add a boolean predicate function to expression's list of parse actions. See
:class:`setParseAction` for function call signatures. Unlike ``setParseAction``,
functions passed to ``addCondition`` need to return boolean success/fail of the condition.
Optional keyword arguments:
- message =... | Add a boolean predicate function to expression's list of parse actions. See
:class:`setParseAction` for function call signatures. Unlike ``setParseAction``,
functions passed to ``addCondition`` need to return boolean success/fail of the condition. | def addCondition(self, *fns, **kwargs):
"""Add a boolean predicate function to expression's list of parse actions. See
:class:`setParseAction` for function call signatures. Unlike ``setParseAction``,
functions passed to ``addCondition`` need to return boolean success/fail of the condition.
... | [
"def",
"addCondition",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"fn",
"in",
"fns",
":",
"self",
".",
"parseAction",
".",
"append",
"(",
"conditionAsParseAction",
"(",
"fn",
",",
"message",
"=",
"kwargs",
".",
"get",
"("... | [
1576,
4
] | [
1599,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.setFailAction | (self, fn) | Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
``fn(s, loc, expr, err)`` where:
- s = string being parsed
- loc = location where expression match was attempted and failed
- expr = the pars... | Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
``fn(s, loc, expr, err)`` where:
- s = string being parsed
- loc = location where expression match was attempted and failed
- expr = the pars... | def setFailAction(self, fn):
"""Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
``fn(s, loc, expr, err)`` where:
- s = string being parsed
- loc = location where expression match was attempted... | [
"def",
"setFailAction",
"(",
"self",
",",
"fn",
")",
":",
"self",
".",
"failAction",
"=",
"fn",
"return",
"self"
] | [
1601,
4
] | [
1612,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.enablePackrat | (cache_size_limit=128) | Enables "packrat" parsing, which adds memoizing to the parsing logic.
Repeated parse attempts at the same string location (which happens
often in many complex grammars) can immediately return a cached value,
instead of re-executing parsing/validating code. Memoizing is done of
... | Enables "packrat" parsing, which adds memoizing to the parsing logic.
Repeated parse attempts at the same string location (which happens
often in many complex grammars) can immediately return a cached value,
instead of re-executing parsing/validating code. Memoizing is done of
... | def enablePackrat(cache_size_limit=128):
"""Enables "packrat" parsing, which adds memoizing to the parsing logic.
Repeated parse attempts at the same string location (which happens
often in many complex grammars) can immediately return a cached value,
instead of re-executing par... | [
"def",
"enablePackrat",
"(",
"cache_size_limit",
"=",
"128",
")",
":",
"if",
"not",
"ParserElement",
".",
"_packratEnabled",
":",
"ParserElement",
".",
"_packratEnabled",
"=",
"True",
"if",
"cache_size_limit",
"is",
"None",
":",
"ParserElement",
".",
"packrat_cach... | [
1866,
4
] | [
1898,
60
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.parseString | (self, instring, parseAll=False) |
Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built.
Returns the parsed data as a :class:`ParseResults` object, which may be
accessed as a list, or as a dict or object with attributes if ... |
Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built. | def parseString(self, instring, parseAll=False):
"""
Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built.
Returns the parsed data as a :class:`ParseResults` object, which may be
ac... | [
"def",
"parseString",
"(",
"self",
",",
"instring",
",",
"parseAll",
"=",
"False",
")",
":",
"ParserElement",
".",
"resetCache",
"(",
")",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"# ~ self.saveAsList = True",
"for",... | [
1900,
4
] | [
1956,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.scanString | (self, instring, maxMatches=_MAX_INT, overlap=False) |
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
``maxMatches`` argument, to clip scanning after 'n' matches are found. If
``overlap`` is specified, then overlapping matches will be... |
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
``maxMatches`` argument, to clip scanning after 'n' matches are found. If
``overlap`` is specified, then overlapping matches will be... | def scanString(self, instring, maxMatches=_MAX_INT, overlap=False):
"""
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
``maxMatches`` argument, to clip scanning after 'n' matches ar... | [
"def",
"scanString",
"(",
"self",
",",
"instring",
",",
"maxMatches",
"=",
"_MAX_INT",
",",
"overlap",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"for",
"e",
"in",
"self",
".",
"ignoreExpr... | [
1958,
4
] | [
2030,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.transformString | (self, instring) |
Extension to :class:`scanString`, to modify matching text with modified tokens that may
be returned from a parse action. To use ``transformString``, define a grammar and
attach a parse action to it that modifies the returned token list.
Invoking ``transformString()`` on a target string... |
Extension to :class:`scanString`, to modify matching text with modified tokens that may
be returned from a parse action. To use ``transformString``, define a grammar and
attach a parse action to it that modifies the returned token list.
Invoking ``transformString()`` on a target string... | def transformString(self, instring):
"""
Extension to :class:`scanString`, to modify matching text with modified tokens that may
be returned from a parse action. To use ``transformString``, define a grammar and
attach a parse action to it that modifies the returned token list.
I... | [
"def",
"transformString",
"(",
"self",
",",
"instring",
")",
":",
"out",
"=",
"[",
"]",
"lastE",
"=",
"0",
"# force preservation of <TAB>s, to minimize unwanted transformation of string, and to",
"# keep string locs straight between transformString and scanString",
"self",
".",
... | [
2032,
4
] | [
2078,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.searchString | (self, instring, maxMatches=_MAX_INT) |
Another extension to :class:`scanString`, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
``maxMatches`` argument, to clip searching after 'n' matches are found.
Example::
# a capitalized word starts with an uppe... |
Another extension to :class:`scanString`, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
``maxMatches`` argument, to clip searching after 'n' matches are found. | def searchString(self, instring, maxMatches=_MAX_INT):
"""
Another extension to :class:`scanString`, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
``maxMatches`` argument, to clip searching after 'n' matches are found.
... | [
"def",
"searchString",
"(",
"self",
",",
"instring",
",",
"maxMatches",
"=",
"_MAX_INT",
")",
":",
"try",
":",
"return",
"ParseResults",
"(",
"[",
"t",
"for",
"t",
",",
"s",
",",
"e",
"in",
"self",
".",
"scanString",
"(",
"instring",
",",
"maxMatches",... | [
2080,
4
] | [
2110,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.split | (self, instring, maxsplit=_MAX_INT, includeSeparators=False) |
Generator method to split a string using the given expression as a separator.
May be called with optional ``maxsplit`` argument, to limit the number of splits;
and the optional ``includeSeparators`` argument (default= ``False``), if the separating
matching text should be included in the... |
Generator method to split a string using the given expression as a separator.
May be called with optional ``maxsplit`` argument, to limit the number of splits;
and the optional ``includeSeparators`` argument (default= ``False``), if the separating
matching text should be included in the... | def split(self, instring, maxsplit=_MAX_INT, includeSeparators=False):
"""
Generator method to split a string using the given expression as a separator.
May be called with optional ``maxsplit`` argument, to limit the number of splits;
and the optional ``includeSeparators`` argument (defa... | [
"def",
"split",
"(",
"self",
",",
"instring",
",",
"maxsplit",
"=",
"_MAX_INT",
",",
"includeSeparators",
"=",
"False",
")",
":",
"splits",
"=",
"0",
"last",
"=",
"0",
"for",
"t",
",",
"s",
",",
"e",
"in",
"self",
".",
"scanString",
"(",
"instring",
... | [
2112,
4
] | [
2135,
29
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__add__ | (self, other) |
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement
converts them to :class:`Literal`s by default.
Example::
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseString(hel... |
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement
converts them to :class:`Literal`s by default. | def __add__(self, other):
"""
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement
converts them to :class:`Literal`s by default.
Example::
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
prin... | [
"def",
"__add__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"return",
"_PendingSkip",
"(",
"self",
")",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",... | [
2137,
4
] | [
2173,
33
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__radd__ | (self, other) |
Implementation of + operator when left operand is not a :class:`ParserElement`
|
Implementation of + operator when left operand is not a :class:`ParserElement`
| def __radd__(self, other):
"""
Implementation of + operator when left operand is not a :class:`ParserElement`
"""
if other is Ellipsis:
return SkipTo(self)("_skipped*") + self
if isinstance(other, basestring):
other = self._literalStringClass(other)
... | [
"def",
"__radd__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"return",
"SkipTo",
"(",
"self",
")",
"(",
"\"_skipped*\"",
")",
"+",
"self",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"... | [
2175,
4
] | [
2188,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__sub__ | (self, other) |
Implementation of - operator, returns :class:`And` with error stop
|
Implementation of - operator, returns :class:`And` with error stop
| def __sub__(self, other):
"""
Implementation of - operator, returns :class:`And` with error stop
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combine element of... | [
"def",
"__sub__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2190,
4
] | [
2200,
46
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__rsub__ | (self, other) |
Implementation of - operator when left operand is not a :class:`ParserElement`
|
Implementation of - operator when left operand is not a :class:`ParserElement`
| def __rsub__(self, other):
"""
Implementation of - operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combi... | [
"def",
"__rsub__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")"... | [
2202,
4
] | [
2212,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__mul__ | (self, other) |
Implementation of * operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``. Expressions may also me multiplied by a 2-integer
tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples
may also include ``None`` as in:
- ``expr*(n, None)`` or ... |
Implementation of * operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``. Expressions may also me multiplied by a 2-integer
tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples
may also include ``None`` as in:
- ``expr*(n, None)`` or ... | def __mul__(self, other):
"""
Implementation of * operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``. Expressions may also me multiplied by a 2-integer
tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples
may also include ``None`` as ... | [
"def",
"__mul__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"other",
"=",
"(",
"0",
",",
"None",
")",
"elif",
"isinstance",
"(",
"other",
",",
"tuple",
")",
"and",
"other",
"[",
":",
"1",
"]",
"==",
"(",
"Ellipsis... | [
2214,
4
] | [
2286,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__or__ | (self, other) |
Implementation of | operator - returns :class:`MatchFirst`
|
Implementation of | operator - returns :class:`MatchFirst`
| def __or__(self, other):
"""
Implementation of | operator - returns :class:`MatchFirst`
"""
if other is Ellipsis:
return _PendingSkip(self, must_skip=True)
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance... | [
"def",
"__or__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"return",
"_PendingSkip",
"(",
"self",
",",
"must_skip",
"=",
"True",
")",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
... | [
2291,
4
] | [
2304,
40
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__ror__ | (self, other) |
Implementation of | operator when left operand is not a :class:`ParserElement`
|
Implementation of | operator when left operand is not a :class:`ParserElement`
| def __ror__(self, other):
"""
Implementation of | operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combin... | [
"def",
"__ror__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2306,
4
] | [
2316,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__xor__ | (self, other) |
Implementation of ^ operator - returns :class:`Or`
|
Implementation of ^ operator - returns :class:`Or`
| def __xor__(self, other):
"""
Implementation of ^ operator - returns :class:`Or`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combine element of type %s with Pa... | [
"def",
"__xor__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2318,
4
] | [
2328,
32
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__rxor__ | (self, other) |
Implementation of ^ operator when left operand is not a :class:`ParserElement`
|
Implementation of ^ operator when left operand is not a :class:`ParserElement`
| def __rxor__(self, other):
"""
Implementation of ^ operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combi... | [
"def",
"__rxor__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")"... | [
2330,
4
] | [
2340,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__and__ | (self, other) |
Implementation of & operator - returns :class:`Each`
|
Implementation of & operator - returns :class:`Each`
| def __and__(self, other):
"""
Implementation of & operator - returns :class:`Each`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combine element of type %s with ... | [
"def",
"__and__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2342,
4
] | [
2352,
34
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__rand__ | (self, other) |
Implementation of & operator when left operand is not a :class:`ParserElement`
|
Implementation of & operator when left operand is not a :class:`ParserElement`
| def __rand__(self, other):
"""
Implementation of & operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combi... | [
"def",
"__rand__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")"... | [
2354,
4
] | [
2364,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__invert__ | (self) |
Implementation of ~ operator - returns :class:`NotAny`
|
Implementation of ~ operator - returns :class:`NotAny`
| def __invert__(self):
"""
Implementation of ~ operator - returns :class:`NotAny`
"""
return NotAny(self) | [
"def",
"__invert__",
"(",
"self",
")",
":",
"return",
"NotAny",
"(",
"self",
")"
] | [
2366,
4
] | [
2370,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__getitem__ | (self, key) |
use ``[]`` indexing notation as a short form for expression repetition:
- ``expr[n]`` is equivalent to ``expr*n``
- ``expr[m, n]`` is equivalent to ``expr*(m, n)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + ZeroOrMore(expr)``
(read as "... |
use ``[]`` indexing notation as a short form for expression repetition:
- ``expr[n]`` is equivalent to ``expr*n``
- ``expr[m, n]`` is equivalent to ``expr*(m, n)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + ZeroOrMore(expr)``
(read as "... | def __getitem__(self, key):
"""
use ``[]`` indexing notation as a short form for expression repetition:
- ``expr[n]`` is equivalent to ``expr*n``
- ``expr[m, n]`` is equivalent to ``expr*(m, n)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + Zero... | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"# convert single arg keys to tuples",
"try",
":",
"if",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"key",
"=",
"(",
"key",
",",
")",
"iter",
"(",
"key",
")",
"except",
"TypeError",
":",
"ke... | [
2377,
4
] | [
2411,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__call__ | (self, name=None) |
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``.
If ``name`` is given with a trailing ``'*'`` character, then ``listAllMatches`` will be
passed as ``True``.
If ``name` is omitted, same as calling :class:`copy`.
Example::
# these are equivalent... |
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``. | def __call__(self, name=None):
"""
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``.
If ``name`` is given with a trailing ``'*'`` character, then ``listAllMatches`` will be
passed as ``True``.
If ``name` is omitted, same as calling :class:`copy`.
Exa... | [
"def",
"__call__",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_setResultsName",
"(",
"name",
")",
"else",
":",
"return",
"self",
".",
"copy",
"(",
")"
] | [
2413,
4
] | [
2431,
30
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.suppress | (self) |
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
cluttering up returned output.
|
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
cluttering up returned output.
| def suppress(self):
"""
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
cluttering up returned output.
"""
return Suppress(self) | [
"def",
"suppress",
"(",
"self",
")",
":",
"return",
"Suppress",
"(",
"self",
")"
] | [
2433,
4
] | [
2438,
29
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.leaveWhitespace | (self) |
Disables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern. This is normally only used internally by
the pyparsing module, but may be needed in some whitespace-sensitive grammars.
|
Disables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern. This is normally only used internally by
the pyparsing module, but may be needed in some whitespace-sensitive grammars.
| def leaveWhitespace(self):
"""
Disables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern. This is normally only used internally by
the pyparsing module, but may be needed in some whitespace-sensitive grammars.
"""
... | [
"def",
"leaveWhitespace",
"(",
"self",
")",
":",
"self",
".",
"skipWhitespace",
"=",
"False",
"return",
"self"
] | [
2440,
4
] | [
2447,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setWhitespaceChars | (self, chars) |
Overrides the default whitespace chars
|
Overrides the default whitespace chars
| def setWhitespaceChars(self, chars):
"""
Overrides the default whitespace chars
"""
self.skipWhitespace = True
self.whiteChars = chars
self.copyDefaultWhiteChars = False
return self | [
"def",
"setWhitespaceChars",
"(",
"self",
",",
"chars",
")",
":",
"self",
".",
"skipWhitespace",
"=",
"True",
"self",
".",
"whiteChars",
"=",
"chars",
"self",
".",
"copyDefaultWhiteChars",
"=",
"False",
"return",
"self"
] | [
2449,
4
] | [
2456,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.parseWithTabs | (self) |
Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string.
Must be called before ``parseString`` when the input grammar contains elements that
match ``<TAB>`` characters.
|
Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string.
Must be called before ``parseString`` when the input grammar contains elements that
match ``<TAB>`` characters.
| def parseWithTabs(self):
"""
Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string.
Must be called before ``parseString`` when the input grammar contains elements that
match ``<TAB>`` characters.
"""
self.keepTabs = True
return ... | [
"def",
"parseWithTabs",
"(",
"self",
")",
":",
"self",
".",
"keepTabs",
"=",
"True",
"return",
"self"
] | [
2458,
4
] | [
2465,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.ignore | (self, other) |
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.
Example::
patt = OneOrMore(Word(alphas))
patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj'... |
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns. | def ignore(self, other):
"""
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.
Example::
patt = OneOrMore(Word(alphas))
patt.parseString('ablaj... | [
"def",
"ignore",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"Suppress",
"(",
"other",
")",
"if",
"isinstance",
"(",
"other",
",",
"Suppress",
")",
":",
"if",
"other",
"not",
"in",... | [
2467,
4
] | [
2489,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setDebugActions | (self, startAction, successAction, exceptionAction) |
Enable display of debugging messages while doing pattern matching.
|
Enable display of debugging messages while doing pattern matching.
| def setDebugActions(self, startAction, successAction, exceptionAction):
"""
Enable display of debugging messages while doing pattern matching.
"""
self.debugActions = (startAction or _defaultStartDebugAction,
successAction or _defaultSuccessDebugAction,
... | [
"def",
"setDebugActions",
"(",
"self",
",",
"startAction",
",",
"successAction",
",",
"exceptionAction",
")",
":",
"self",
".",
"debugActions",
"=",
"(",
"startAction",
"or",
"_defaultStartDebugAction",
",",
"successAction",
"or",
"_defaultSuccessDebugAction",
",",
... | [
2491,
4
] | [
2499,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setDebug | (self, flag=True) |
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd | integer
# turn on debuggin... |
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to True to enable, False to disable. | def setDebug(self, flag=True):
"""
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd... | [
"def",
"setDebug",
"(",
"self",
",",
"flag",
"=",
"True",
")",
":",
"if",
"flag",
":",
"self",
".",
"setDebugActions",
"(",
"_defaultStartDebugAction",
",",
"_defaultSuccessDebugAction",
",",
"_defaultExceptionDebugAction",
")",
"else",
":",
"self",
".",
"debug"... | [
2501,
4
] | [
2542,
19
] | python | en | ['en', 'error', 'th'] | False |
Driver.__init__ | (self, dr_input) |
Initializes an GDAL/OGR driver on either a string or integer input.
|
Initializes an GDAL/OGR driver on either a string or integer input.
| def __init__(self, dr_input):
"""
Initializes an GDAL/OGR driver on either a string or integer input.
"""
if isinstance(dr_input, six.string_types):
# If a string name of the driver was passed in
self.ensure_registered()
# Checking the alias dictionar... | [
"def",
"__init__",
"(",
"self",
",",
"dr_input",
")",
":",
"if",
"isinstance",
"(",
"dr_input",
",",
"six",
".",
"string_types",
")",
":",
"# If a string name of the driver was passed in",
"self",
".",
"ensure_registered",
"(",
")",
"# Checking the alias dictionary (c... | [
34,
4
] | [
68,
25
] | python | en | ['en', 'error', 'th'] | False |
Driver.ensure_registered | (cls) |
Attempts to register all the data source drivers.
|
Attempts to register all the data source drivers.
| def ensure_registered(cls):
"""
Attempts to register all the data source drivers.
"""
# Only register all if the driver counts are 0 (or else all drivers
# will be registered over and over again)
if not vcapi.get_driver_count():
vcapi.register_all()
if... | [
"def",
"ensure_registered",
"(",
"cls",
")",
":",
"# Only register all if the driver counts are 0 (or else all drivers",
"# will be registered over and over again)",
"if",
"not",
"vcapi",
".",
"get_driver_count",
"(",
")",
":",
"vcapi",
".",
"register_all",
"(",
")",
"if",
... | [
74,
4
] | [
83,
32
] | python | en | ['en', 'error', 'th'] | False |
Driver.driver_count | (cls) |
Returns the number of GDAL/OGR data source drivers registered.
|
Returns the number of GDAL/OGR data source drivers registered.
| def driver_count(cls):
"""
Returns the number of GDAL/OGR data source drivers registered.
"""
return vcapi.get_driver_count() + rcapi.get_driver_count() | [
"def",
"driver_count",
"(",
"cls",
")",
":",
"return",
"vcapi",
".",
"get_driver_count",
"(",
")",
"+",
"rcapi",
".",
"get_driver_count",
"(",
")"
] | [
86,
4
] | [
90,
66
] | python | en | ['en', 'error', 'th'] | False |
Driver.name | (self) |
Returns description/name string for this driver.
|
Returns description/name string for this driver.
| def name(self):
"""
Returns description/name string for this driver.
"""
return force_text(rcapi.get_driver_description(self.ptr)) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"force_text",
"(",
"rcapi",
".",
"get_driver_description",
"(",
"self",
".",
"ptr",
")",
")"
] | [
93,
4
] | [
97,
65
] | python | en | ['en', 'error', 'th'] | False |
Command.handle_pip_version_check | (self, options) |
This is a no-op so that commands by default do not do the pip version
check.
|
This is a no-op so that commands by default do not do the pip version
check.
| def handle_pip_version_check(self, options):
# type: (Values) -> None
"""
This is a no-op so that commands by default do not do the pip version
check.
"""
# Make sure we do the pip version check if the index_group options
# are present.
assert not hasattr(... | [
"def",
"handle_pip_version_check",
"(",
"self",
",",
"options",
")",
":",
"# type: (Values) -> None",
"# Make sure we do the pip version check if the index_group options",
"# are present.",
"assert",
"not",
"hasattr",
"(",
"options",
",",
"'no_index'",
")"
] | [
93,
4
] | [
101,
47
] | python | en | ['en', 'error', 'th'] | False |
OpenAPIArgumentsTest.convert_regex_to_url_pattern | (self, regex_pattern: str) | Convert regular expressions style URL patterns to their
corresponding OpenAPI style formats. All patterns are
expected to start with ^ and end with $.
Examples:
1. /messages/{message_id} <-> r'^messages/(?P<message_id>[0-9]+)$'
2. /events <-> r'^events$'
3. '/... | Convert regular expressions style URL patterns to their
corresponding OpenAPI style formats. All patterns are
expected to start with ^ and end with $.
Examples:
1. /messages/{message_id} <-> r'^messages/(?P<message_id>[0-9]+)$'
2. /events <-> r'^events$'
3. '/... | def convert_regex_to_url_pattern(self, regex_pattern: str) -> str:
"""Convert regular expressions style URL patterns to their
corresponding OpenAPI style formats. All patterns are
expected to start with ^ and end with $.
Examples:
1. /messages/{message_id} <-> r'^messages/(?P... | [
"def",
"convert_regex_to_url_pattern",
"(",
"self",
",",
"regex_pattern",
":",
"str",
")",
"->",
"str",
":",
"# Handle the presence-email code which has a non-slashes syntax.",
"regex_pattern",
"=",
"regex_pattern",
".",
"replace",
"(",
"\"[^/]*\"",
",",
"\".*\"",
")",
... | [
293,
4
] | [
311,
26
] | python | en | ['en', 'en', 'en'] | True |
OpenAPIArgumentsTest.check_for_non_existant_openapi_endpoints | (self) | Here, we check to see if every endpoint documented in the OpenAPI
documentation actually exists in urls.py and thus in actual code.
Note: We define this as a helper called at the end of
test_openapi_arguments instead of as a separate test to ensure that
this test is only executed after t... | Here, we check to see if every endpoint documented in the OpenAPI
documentation actually exists in urls.py and thus in actual code.
Note: We define this as a helper called at the end of
test_openapi_arguments instead of as a separate test to ensure that
this test is only executed after t... | def check_for_non_existant_openapi_endpoints(self) -> None:
"""Here, we check to see if every endpoint documented in the OpenAPI
documentation actually exists in urls.py and thus in actual code.
Note: We define this as a helper called at the end of
test_openapi_arguments instead of as a ... | [
"def",
"check_for_non_existant_openapi_endpoints",
"(",
"self",
")",
"->",
"None",
":",
"openapi_paths",
"=",
"set",
"(",
"get_openapi_paths",
"(",
")",
")",
"undocumented_paths",
"=",
"openapi_paths",
"-",
"self",
".",
"checked_endpoints",
"undocumented_paths",
"-=",... | [
327,
4
] | [
344,
37
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.