id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
13,000 | ARMmbed/mbed-cloud-sdk-python | scripts/generate_ci_config.py | new_deploy | def new_deploy(py_ver: PyVer, release_target: ReleaseTarget):
"""Job for deploying package to pypi"""
cache_file = f'app_{py_ver.name}.tar'
template = yaml.safe_load(f"""
machine:
image: circleci/classic:201710-02
steps:
- attach_workspace:
at: {cache_dir}
- checkout
- run:
name: Install prerequisites
command: sudo pip install awscli
- run:
name: Load docker image layer cache
command: docker load -i {cache_dir}/{cache_file}
- run:
name: Start a named container
command: docker run --name=SDK {py_ver.tag}
- run:
name: Extract the documentation
command: 'docker cp SDK:/build/built_docs ./built_docs'
- run:
name: Upload the documentation
command: >-
aws s3 sync --delete --cache-control
max-age=3600 built_docs s3://mbed-cloud-sdk-python
- run:
name: Tag and release
command: >-
docker run --env-file=scripts/templates/envvars.env
-e TWINE_REPOSITORY={release_target.twine_repo}
{py_ver.tag}
sh -c "source .venv/bin/activate && python scripts/tag_and_release.py --mode={release_target.mode}"
- run:
name: Start the release party!
command: >-
docker run --env-file=scripts/templates/envvars.env
{py_ver.tag}
sh -c "source .venv/bin/activate && python scripts/notify.py"
""")
return deploy_name(py_ver, release_target), template | python | def new_deploy(py_ver: PyVer, release_target: ReleaseTarget):
cache_file = f'app_{py_ver.name}.tar'
template = yaml.safe_load(f"""
machine:
image: circleci/classic:201710-02
steps:
- attach_workspace:
at: {cache_dir}
- checkout
- run:
name: Install prerequisites
command: sudo pip install awscli
- run:
name: Load docker image layer cache
command: docker load -i {cache_dir}/{cache_file}
- run:
name: Start a named container
command: docker run --name=SDK {py_ver.tag}
- run:
name: Extract the documentation
command: 'docker cp SDK:/build/built_docs ./built_docs'
- run:
name: Upload the documentation
command: >-
aws s3 sync --delete --cache-control
max-age=3600 built_docs s3://mbed-cloud-sdk-python
- run:
name: Tag and release
command: >-
docker run --env-file=scripts/templates/envvars.env
-e TWINE_REPOSITORY={release_target.twine_repo}
{py_ver.tag}
sh -c "source .venv/bin/activate && python scripts/tag_and_release.py --mode={release_target.mode}"
- run:
name: Start the release party!
command: >-
docker run --env-file=scripts/templates/envvars.env
{py_ver.tag}
sh -c "source .venv/bin/activate && python scripts/notify.py"
""")
return deploy_name(py_ver, release_target), template | [
"def",
"new_deploy",
"(",
"py_ver",
":",
"PyVer",
",",
"release_target",
":",
"ReleaseTarget",
")",
":",
"cache_file",
"=",
"f'app_{py_ver.name}.tar'",
"template",
"=",
"yaml",
".",
"safe_load",
"(",
"f\"\"\"\n machine:\n image: circleci/classic:201710-02\n steps... | Job for deploying package to pypi | [
"Job",
"for",
"deploying",
"package",
"to",
"pypi"
] | c0af86fb2cdd4dc7ed26f236139241067d293509 | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/scripts/generate_ci_config.py#L322-L363 |
13,001 | ARMmbed/mbed-cloud-sdk-python | scripts/generate_ci_config.py | generate_docker_file | def generate_docker_file(py_ver: PyVer):
"""Templated docker files"""
with open(os.path.join(script_templates_root, 'Dockerfile')) as fh:
return fh.read().format(py_ver=py_ver, author=author_file) | python | def generate_docker_file(py_ver: PyVer):
with open(os.path.join(script_templates_root, 'Dockerfile')) as fh:
return fh.read().format(py_ver=py_ver, author=author_file) | [
"def",
"generate_docker_file",
"(",
"py_ver",
":",
"PyVer",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"script_templates_root",
",",
"'Dockerfile'",
")",
")",
"as",
"fh",
":",
"return",
"fh",
".",
"read",
"(",
")",
".",
"format... | Templated docker files | [
"Templated",
"docker",
"files"
] | c0af86fb2cdd4dc7ed26f236139241067d293509 | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/scripts/generate_ci_config.py#L481-L484 |
13,002 | ARMmbed/mbed-cloud-sdk-python | scripts/generate_ci_config.py | generate_docker_targets | def generate_docker_targets():
"""Write all templated container engine files"""
output = {}
for py_ver in python_versions.values():
filepath = os.path.join(container_config_root, py_ver.docker_file)
output[filepath] = generate_docker_file(py_ver)
filepath = os.path.join(container_config_root, py_ver.compose_file)
output[filepath] = generate_compose_file(py_ver)
return output | python | def generate_docker_targets():
output = {}
for py_ver in python_versions.values():
filepath = os.path.join(container_config_root, py_ver.docker_file)
output[filepath] = generate_docker_file(py_ver)
filepath = os.path.join(container_config_root, py_ver.compose_file)
output[filepath] = generate_compose_file(py_ver)
return output | [
"def",
"generate_docker_targets",
"(",
")",
":",
"output",
"=",
"{",
"}",
"for",
"py_ver",
"in",
"python_versions",
".",
"values",
"(",
")",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"container_config_root",
",",
"py_ver",
".",
"docker_fil... | Write all templated container engine files | [
"Write",
"all",
"templated",
"container",
"engine",
"files"
] | c0af86fb2cdd4dc7ed26f236139241067d293509 | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/scripts/generate_ci_config.py#L493-L501 |
13,003 | ARMmbed/mbed-cloud-sdk-python | scripts/generate_ci_config.py | main | def main(output_path=None):
"""Writes out new python build system
This is needed because CircleCI does not support build matrices
nor parameterisation of cache paths or other aspects of their
config
There's also the added bonus of validating the yaml as we go.
Additionally, we template and write Docker and docker-compose files
for multiple python versions, as Docker `FROM` statements are also
un-templatable using environment variables or similar.
The bulk of the config structure is parsed templated yaml, which
seems the most succinct way of building deeply nested dictionaries and lists,
and also cleanly maps to the appearance of config.yml before & after templating.
The main job blocks (build, test, deploy) are expanded as the product of python versions
and mbed cloud environments, before being recombined into the job listing.
Jobs are chained into a CircleCI workflow using a graph
(in which nodes are job identifiers, and edges describe the dependencies
and any additional parameters)
"""
config_output_file = output_path or os.path.join(PROJECT_ROOT, '.circleci', 'config.yml')
yaml_structure = generate_circle_output()
with open(config_output_file, 'w') as fh:
yaml_content = yaml.safe_dump(data=yaml_structure, default_flow_style=False)
fh.write(
f'#\n'
f'# This file is autogenerated, do not modify manually. '
f'See {author_file} for instructions.\n'
f'#\n'
f'{yaml_content}'
)
for path, content in generate_docker_targets().items():
LOG.info('writing %s', path)
with open(path, 'w') as fh:
fh.write(content) | python | def main(output_path=None):
config_output_file = output_path or os.path.join(PROJECT_ROOT, '.circleci', 'config.yml')
yaml_structure = generate_circle_output()
with open(config_output_file, 'w') as fh:
yaml_content = yaml.safe_dump(data=yaml_structure, default_flow_style=False)
fh.write(
f'#\n'
f'# This file is autogenerated, do not modify manually. '
f'See {author_file} for instructions.\n'
f'#\n'
f'{yaml_content}'
)
for path, content in generate_docker_targets().items():
LOG.info('writing %s', path)
with open(path, 'w') as fh:
fh.write(content) | [
"def",
"main",
"(",
"output_path",
"=",
"None",
")",
":",
"config_output_file",
"=",
"output_path",
"or",
"os",
".",
"path",
".",
"join",
"(",
"PROJECT_ROOT",
",",
"'.circleci'",
",",
"'config.yml'",
")",
"yaml_structure",
"=",
"generate_circle_output",
"(",
"... | Writes out new python build system
This is needed because CircleCI does not support build matrices
nor parameterisation of cache paths or other aspects of their
config
There's also the added bonus of validating the yaml as we go.
Additionally, we template and write Docker and docker-compose files
for multiple python versions, as Docker `FROM` statements are also
un-templatable using environment variables or similar.
The bulk of the config structure is parsed templated yaml, which
seems the most succinct way of building deeply nested dictionaries and lists,
and also cleanly maps to the appearance of config.yml before & after templating.
The main job blocks (build, test, deploy) are expanded as the product of python versions
and mbed cloud environments, before being recombined into the job listing.
Jobs are chained into a CircleCI workflow using a graph
(in which nodes are job identifiers, and edges describe the dependencies
and any additional parameters) | [
"Writes",
"out",
"new",
"python",
"build",
"system"
] | c0af86fb2cdd4dc7ed26f236139241067d293509 | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/scripts/generate_ci_config.py#L504-L543 |
13,004 | ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/external_ca/models/global_sign_credentials.py | GlobalSignCredentials.passphrase | def passphrase(self, passphrase):
"""
Sets the passphrase of this GlobalSignCredentials.
The passphrase to decrypt the private key in case it is encrypted. Empty if the private key is not encrypted.
:param passphrase: The passphrase of this GlobalSignCredentials.
:type: str
"""
if passphrase is not None and len(passphrase) > 1000:
raise ValueError("Invalid value for `passphrase`, length must be less than or equal to `1000`")
self._passphrase = passphrase | python | def passphrase(self, passphrase):
if passphrase is not None and len(passphrase) > 1000:
raise ValueError("Invalid value for `passphrase`, length must be less than or equal to `1000`")
self._passphrase = passphrase | [
"def",
"passphrase",
"(",
"self",
",",
"passphrase",
")",
":",
"if",
"passphrase",
"is",
"not",
"None",
"and",
"len",
"(",
"passphrase",
")",
">",
"1000",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `passphrase`, length must be less than or equal to `1000`\"... | Sets the passphrase of this GlobalSignCredentials.
The passphrase to decrypt the private key in case it is encrypted. Empty if the private key is not encrypted.
:param passphrase: The passphrase of this GlobalSignCredentials.
:type: str | [
"Sets",
"the",
"passphrase",
"of",
"this",
"GlobalSignCredentials",
".",
"The",
"passphrase",
"to",
"decrypt",
"the",
"private",
"key",
"in",
"case",
"it",
"is",
"encrypted",
".",
"Empty",
"if",
"the",
"private",
"key",
"is",
"not",
"encrypted",
"."
] | c0af86fb2cdd4dc7ed26f236139241067d293509 | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/external_ca/models/global_sign_credentials.py#L154-L165 |
13,005 | ARMmbed/mbed-cloud-sdk-python | scripts/tag_and_release.py | git_url_ssh_to_https | def git_url_ssh_to_https(url):
"""Convert a git url
url will look like
https://github.com/ARMmbed/mbed-cloud-sdk-python.git
or
git@github.com:ARMmbed/mbed-cloud-sdk-python.git
we want:
https://${GITHUB_TOKEN}@github.com/ARMmbed/mbed-cloud-sdk-python-private.git
"""
path = url.split('github.com', 1)[1][1:].strip()
new = 'https://{GITHUB_TOKEN}@github.com/%s' % path
print('rewriting git url to: %s' % new)
return new.format(GITHUB_TOKEN=os.getenv('GITHUB_TOKEN')) | python | def git_url_ssh_to_https(url):
path = url.split('github.com', 1)[1][1:].strip()
new = 'https://{GITHUB_TOKEN}@github.com/%s' % path
print('rewriting git url to: %s' % new)
return new.format(GITHUB_TOKEN=os.getenv('GITHUB_TOKEN')) | [
"def",
"git_url_ssh_to_https",
"(",
"url",
")",
":",
"path",
"=",
"url",
".",
"split",
"(",
"'github.com'",
",",
"1",
")",
"[",
"1",
"]",
"[",
"1",
":",
"]",
".",
"strip",
"(",
")",
"new",
"=",
"'https://{GITHUB_TOKEN}@github.com/%s'",
"%",
"path",
"pr... | Convert a git url
url will look like
https://github.com/ARMmbed/mbed-cloud-sdk-python.git
or
git@github.com:ARMmbed/mbed-cloud-sdk-python.git
we want:
https://${GITHUB_TOKEN}@github.com/ARMmbed/mbed-cloud-sdk-python-private.git | [
"Convert",
"a",
"git",
"url"
] | c0af86fb2cdd4dc7ed26f236139241067d293509 | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/scripts/tag_and_release.py#L32-L45 |
13,006 | facelessuser/backrefs | tools/unidatadownload.py | zip_unicode | def zip_unicode(output, version):
"""Zip the Unicode files."""
zipper = zipfile.ZipFile(os.path.join(output, 'unicodedata', '%s.zip' % version), 'w', zipfile.ZIP_DEFLATED)
target = os.path.join(output, 'unicodedata', version)
print('Zipping %s.zip...' % version)
for root, dirs, files in os.walk(target):
for file in files:
if file.endswith('.txt'):
zipper.write(os.path.join(root, file), arcname=file) | python | def zip_unicode(output, version):
zipper = zipfile.ZipFile(os.path.join(output, 'unicodedata', '%s.zip' % version), 'w', zipfile.ZIP_DEFLATED)
target = os.path.join(output, 'unicodedata', version)
print('Zipping %s.zip...' % version)
for root, dirs, files in os.walk(target):
for file in files:
if file.endswith('.txt'):
zipper.write(os.path.join(root, file), arcname=file) | [
"def",
"zip_unicode",
"(",
"output",
",",
"version",
")",
":",
"zipper",
"=",
"zipfile",
".",
"ZipFile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"output",
",",
"'unicodedata'",
",",
"'%s.zip'",
"%",
"version",
")",
",",
"'w'",
",",
"zipfile",
".",
... | Zip the Unicode files. | [
"Zip",
"the",
"Unicode",
"files",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unidatadownload.py#L18-L29 |
13,007 | facelessuser/backrefs | tools/unidatadownload.py | unzip_unicode | def unzip_unicode(output, version):
"""Unzip the Unicode files."""
unzipper = zipfile.ZipFile(os.path.join(output, 'unicodedata', '%s.zip' % version))
target = os.path.join(output, 'unicodedata', version)
print('Unzipping %s.zip...' % version)
os.makedirs(target)
for f in unzipper.namelist():
# Do I need backslash on windows? Or is it forward as well?
unzipper.extract(f, target) | python | def unzip_unicode(output, version):
unzipper = zipfile.ZipFile(os.path.join(output, 'unicodedata', '%s.zip' % version))
target = os.path.join(output, 'unicodedata', version)
print('Unzipping %s.zip...' % version)
os.makedirs(target)
for f in unzipper.namelist():
# Do I need backslash on windows? Or is it forward as well?
unzipper.extract(f, target) | [
"def",
"unzip_unicode",
"(",
"output",
",",
"version",
")",
":",
"unzipper",
"=",
"zipfile",
".",
"ZipFile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"output",
",",
"'unicodedata'",
",",
"'%s.zip'",
"%",
"version",
")",
")",
"target",
"=",
"os",
".",
... | Unzip the Unicode files. | [
"Unzip",
"the",
"Unicode",
"files",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unidatadownload.py#L32-L44 |
13,008 | facelessuser/backrefs | tools/unidatadownload.py | download_unicodedata | def download_unicodedata(version, output=HOME, no_zip=False):
"""Download Unicode data scripts and blocks."""
files = [
'UnicodeData.txt',
'Scripts.txt',
'Blocks.txt',
'PropList.txt',
'DerivedCoreProperties.txt',
'DerivedNormalizationProps.txt',
'CompositionExclusions.txt',
'PropertyValueAliases.txt',
'PropertyAliases.txt',
'EastAsianWidth.txt',
'LineBreak.txt',
'HangulSyllableType.txt',
'DerivedAge.txt',
'auxiliary/WordBreakProperty.txt',
'auxiliary/SentenceBreakProperty.txt',
'auxiliary/GraphemeBreakProperty.txt',
'extracted/DerivedDecompositionType.txt',
'extracted/DerivedNumericType.txt',
'extracted/DerivedNumericValues.txt',
'extracted/DerivedJoiningType.txt',
'extracted/DerivedJoiningGroup.txt',
'extracted/DerivedCombiningClass.txt'
]
files.append('ScriptExtensions.txt')
if PY35:
files.append('IndicPositionalCategory.txt')
else:
files.append('IndicMatraCategory.txt')
files.append('IndicSyllabicCategory.txt')
if PY34:
files.append('BidiBrackets.txt')
if PY37:
files.append('VerticalOrientation.txt')
http_url = 'http://www.unicode.org/Public/%s/ucd/' % version
ftp_url = 'ftp://ftp.unicode.org/Public/%s/ucd/' % version
destination = os.path.join(output, 'unicodedata', version)
if not os.path.exists(destination):
os.makedirs(destination)
zip_data = not no_zip
for f in files:
file_location = os.path.join(destination, os.path.basename(f))
retrieved = False
if not os.path.exists(file_location):
for url in (ftp_url, http_url):
furl = url + f
try:
print('Downloading: %s --> %s' % (furl, file_location))
response = urlopen(furl, timeout=30)
data = response.read()
except Exception:
print('Failed: %s' % url)
continue
with open(file_location, 'w') as uf:
uf.write(data.decode('utf-8'))
retrieved = True
break
if not retrieved:
print('Failed to acquire all needed Unicode files!')
break
else:
retrieved = True
print('Skipping: found %s' % file_location)
if not retrieved:
zip_data = False
break
if zip_data and not os.path.exists(os.path.join(output, 'unicodedata', '%s.zip' % version)):
zip_unicode(output, version) | python | def download_unicodedata(version, output=HOME, no_zip=False):
files = [
'UnicodeData.txt',
'Scripts.txt',
'Blocks.txt',
'PropList.txt',
'DerivedCoreProperties.txt',
'DerivedNormalizationProps.txt',
'CompositionExclusions.txt',
'PropertyValueAliases.txt',
'PropertyAliases.txt',
'EastAsianWidth.txt',
'LineBreak.txt',
'HangulSyllableType.txt',
'DerivedAge.txt',
'auxiliary/WordBreakProperty.txt',
'auxiliary/SentenceBreakProperty.txt',
'auxiliary/GraphemeBreakProperty.txt',
'extracted/DerivedDecompositionType.txt',
'extracted/DerivedNumericType.txt',
'extracted/DerivedNumericValues.txt',
'extracted/DerivedJoiningType.txt',
'extracted/DerivedJoiningGroup.txt',
'extracted/DerivedCombiningClass.txt'
]
files.append('ScriptExtensions.txt')
if PY35:
files.append('IndicPositionalCategory.txt')
else:
files.append('IndicMatraCategory.txt')
files.append('IndicSyllabicCategory.txt')
if PY34:
files.append('BidiBrackets.txt')
if PY37:
files.append('VerticalOrientation.txt')
http_url = 'http://www.unicode.org/Public/%s/ucd/' % version
ftp_url = 'ftp://ftp.unicode.org/Public/%s/ucd/' % version
destination = os.path.join(output, 'unicodedata', version)
if not os.path.exists(destination):
os.makedirs(destination)
zip_data = not no_zip
for f in files:
file_location = os.path.join(destination, os.path.basename(f))
retrieved = False
if not os.path.exists(file_location):
for url in (ftp_url, http_url):
furl = url + f
try:
print('Downloading: %s --> %s' % (furl, file_location))
response = urlopen(furl, timeout=30)
data = response.read()
except Exception:
print('Failed: %s' % url)
continue
with open(file_location, 'w') as uf:
uf.write(data.decode('utf-8'))
retrieved = True
break
if not retrieved:
print('Failed to acquire all needed Unicode files!')
break
else:
retrieved = True
print('Skipping: found %s' % file_location)
if not retrieved:
zip_data = False
break
if zip_data and not os.path.exists(os.path.join(output, 'unicodedata', '%s.zip' % version)):
zip_unicode(output, version) | [
"def",
"download_unicodedata",
"(",
"version",
",",
"output",
"=",
"HOME",
",",
"no_zip",
"=",
"False",
")",
":",
"files",
"=",
"[",
"'UnicodeData.txt'",
",",
"'Scripts.txt'",
",",
"'Blocks.txt'",
",",
"'PropList.txt'",
",",
"'DerivedCoreProperties.txt'",
",",
"... | Download Unicode data scripts and blocks. | [
"Download",
"Unicode",
"data",
"scripts",
"and",
"blocks",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unidatadownload.py#L47-L125 |
13,009 | facelessuser/backrefs | tools/unidatadownload.py | get_unicodedata | def get_unicodedata(version, output=HOME, no_zip=False):
"""Ensure we have Unicode data to generate Unicode tables."""
target = os.path.join(output, 'unicodedata', version)
zip_target = os.path.join(output, 'unicodedata', '%s.zip' % version)
if not os.path.exists(target) and os.path.exists(zip_target):
unzip_unicode(output, version)
# Download missing files if any. Zip if required.
download_unicodedata(version, output, no_zip) | python | def get_unicodedata(version, output=HOME, no_zip=False):
target = os.path.join(output, 'unicodedata', version)
zip_target = os.path.join(output, 'unicodedata', '%s.zip' % version)
if not os.path.exists(target) and os.path.exists(zip_target):
unzip_unicode(output, version)
# Download missing files if any. Zip if required.
download_unicodedata(version, output, no_zip) | [
"def",
"get_unicodedata",
"(",
"version",
",",
"output",
"=",
"HOME",
",",
"no_zip",
"=",
"False",
")",
":",
"target",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output",
",",
"'unicodedata'",
",",
"version",
")",
"zip_target",
"=",
"os",
".",
"path",
... | Ensure we have Unicode data to generate Unicode tables. | [
"Ensure",
"we",
"have",
"Unicode",
"data",
"to",
"generate",
"Unicode",
"tables",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unidatadownload.py#L128-L138 |
13,010 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.process_quotes | def process_quotes(self, text):
"""Process quotes."""
escaped = False
in_quotes = False
current = []
quoted = []
i = _util.StringIter(text)
iter(i)
for t in i:
if not escaped and t == "\\":
escaped = True
elif escaped:
escaped = False
if t == "E":
if in_quotes:
current.append(_re.escape("".join(quoted)))
quoted = []
in_quotes = False
elif t == "Q" and not in_quotes:
in_quotes = True
elif in_quotes:
quoted.extend(["\\", t])
else:
current.extend(["\\", t])
elif in_quotes:
quoted.extend(t)
else:
current.append(t)
if in_quotes and escaped:
quoted.append("\\")
elif escaped:
current.append("\\")
if quoted:
current.append(_re.escape("".join(quoted)))
return "".join(current) | python | def process_quotes(self, text):
escaped = False
in_quotes = False
current = []
quoted = []
i = _util.StringIter(text)
iter(i)
for t in i:
if not escaped and t == "\\":
escaped = True
elif escaped:
escaped = False
if t == "E":
if in_quotes:
current.append(_re.escape("".join(quoted)))
quoted = []
in_quotes = False
elif t == "Q" and not in_quotes:
in_quotes = True
elif in_quotes:
quoted.extend(["\\", t])
else:
current.extend(["\\", t])
elif in_quotes:
quoted.extend(t)
else:
current.append(t)
if in_quotes and escaped:
quoted.append("\\")
elif escaped:
current.append("\\")
if quoted:
current.append(_re.escape("".join(quoted)))
return "".join(current) | [
"def",
"process_quotes",
"(",
"self",
",",
"text",
")",
":",
"escaped",
"=",
"False",
"in_quotes",
"=",
"False",
"current",
"=",
"[",
"]",
"quoted",
"=",
"[",
"]",
"i",
"=",
"_util",
".",
"StringIter",
"(",
"text",
")",
"iter",
"(",
"i",
")",
"for"... | Process quotes. | [
"Process",
"quotes",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L95-L133 |
13,011 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.verbose_comment | def verbose_comment(self, t, i):
"""Handle verbose comments."""
current = []
escaped = False
try:
while t != "\n":
if not escaped and t == "\\":
escaped = True
current.append(t)
elif escaped:
escaped = False
if t in self._new_refs:
current.append("\\")
current.append(t)
else:
current.append(t)
t = next(i)
except StopIteration:
pass
if t == "\n":
current.append(t)
return current | python | def verbose_comment(self, t, i):
current = []
escaped = False
try:
while t != "\n":
if not escaped and t == "\\":
escaped = True
current.append(t)
elif escaped:
escaped = False
if t in self._new_refs:
current.append("\\")
current.append(t)
else:
current.append(t)
t = next(i)
except StopIteration:
pass
if t == "\n":
current.append(t)
return current | [
"def",
"verbose_comment",
"(",
"self",
",",
"t",
",",
"i",
")",
":",
"current",
"=",
"[",
"]",
"escaped",
"=",
"False",
"try",
":",
"while",
"t",
"!=",
"\"\\n\"",
":",
"if",
"not",
"escaped",
"and",
"t",
"==",
"\"\\\\\"",
":",
"escaped",
"=",
"True... | Handle verbose comments. | [
"Handle",
"verbose",
"comments",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L135-L159 |
13,012 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.get_unicode_property | def get_unicode_property(self, i):
"""Get Unicode property."""
index = i.index
prop = []
value = []
try:
c = next(i)
if c.upper() in _ASCII_LETTERS:
prop.append(c)
elif c != '{':
raise SyntaxError("Unicode property missing '{' at %d!" % (i.index - 1))
else:
c = next(i)
if c == '^':
prop.append(c)
c = next(i)
while c not in (':', '=', '}'):
if c not in _PROPERTY:
raise SyntaxError('Invalid Unicode property character at %d!' % (i.index - 1))
if c not in _PROPERTY_STRIP:
prop.append(c)
c = next(i)
if c in (':', '='):
c = next(i)
while c != '}':
if c not in _PROPERTY:
raise SyntaxError('Invalid Unicode property character at %d!' % (i.index - 1))
if c not in _PROPERTY_STRIP:
value.append(c)
c = next(i)
if not value:
raise SyntaxError('Invalid Unicode property!')
except StopIteration:
raise SyntaxError("Missing or unmatched '{' at %d!" % index)
return ''.join(prop).lower(), ''.join(value).lower() | python | def get_unicode_property(self, i):
index = i.index
prop = []
value = []
try:
c = next(i)
if c.upper() in _ASCII_LETTERS:
prop.append(c)
elif c != '{':
raise SyntaxError("Unicode property missing '{' at %d!" % (i.index - 1))
else:
c = next(i)
if c == '^':
prop.append(c)
c = next(i)
while c not in (':', '=', '}'):
if c not in _PROPERTY:
raise SyntaxError('Invalid Unicode property character at %d!' % (i.index - 1))
if c not in _PROPERTY_STRIP:
prop.append(c)
c = next(i)
if c in (':', '='):
c = next(i)
while c != '}':
if c not in _PROPERTY:
raise SyntaxError('Invalid Unicode property character at %d!' % (i.index - 1))
if c not in _PROPERTY_STRIP:
value.append(c)
c = next(i)
if not value:
raise SyntaxError('Invalid Unicode property!')
except StopIteration:
raise SyntaxError("Missing or unmatched '{' at %d!" % index)
return ''.join(prop).lower(), ''.join(value).lower() | [
"def",
"get_unicode_property",
"(",
"self",
",",
"i",
")",
":",
"index",
"=",
"i",
".",
"index",
"prop",
"=",
"[",
"]",
"value",
"=",
"[",
"]",
"try",
":",
"c",
"=",
"next",
"(",
"i",
")",
"if",
"c",
".",
"upper",
"(",
")",
"in",
"_ASCII_LETTER... | Get Unicode property. | [
"Get",
"Unicode",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L185-L221 |
13,013 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.get_named_unicode | def get_named_unicode(self, i):
"""Get Unicode name."""
index = i.index
value = []
try:
if next(i) != '{':
raise ValueError("Named Unicode missing '{' %d!" % (i.index - 1))
c = next(i)
while c != '}':
value.append(c)
c = next(i)
except Exception:
raise SyntaxError("Unmatched '{' at %d!" % index)
return ''.join(value) | python | def get_named_unicode(self, i):
index = i.index
value = []
try:
if next(i) != '{':
raise ValueError("Named Unicode missing '{' %d!" % (i.index - 1))
c = next(i)
while c != '}':
value.append(c)
c = next(i)
except Exception:
raise SyntaxError("Unmatched '{' at %d!" % index)
return ''.join(value) | [
"def",
"get_named_unicode",
"(",
"self",
",",
"i",
")",
":",
"index",
"=",
"i",
".",
"index",
"value",
"=",
"[",
"]",
"try",
":",
"if",
"next",
"(",
"i",
")",
"!=",
"'{'",
":",
"raise",
"ValueError",
"(",
"\"Named Unicode missing '{' %d!\"",
"%",
"(",
... | Get Unicode name. | [
"Get",
"Unicode",
"name",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L223-L238 |
13,014 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.normal | def normal(self, t, i):
"""Handle normal chars."""
current = []
if t == "\\":
try:
t = next(i)
current.extend(self.reference(t, i))
except StopIteration:
current.append(t)
elif t == "(":
current.extend(self.subgroup(t, i))
elif self.verbose and t == "#":
current.extend(self.verbose_comment(t, i))
elif t == "[":
current.extend(self.char_groups(t, i))
else:
current.append(t)
return current | python | def normal(self, t, i):
current = []
if t == "\\":
try:
t = next(i)
current.extend(self.reference(t, i))
except StopIteration:
current.append(t)
elif t == "(":
current.extend(self.subgroup(t, i))
elif self.verbose and t == "#":
current.extend(self.verbose_comment(t, i))
elif t == "[":
current.extend(self.char_groups(t, i))
else:
current.append(t)
return current | [
"def",
"normal",
"(",
"self",
",",
"t",
",",
"i",
")",
":",
"current",
"=",
"[",
"]",
"if",
"t",
"==",
"\"\\\\\"",
":",
"try",
":",
"t",
"=",
"next",
"(",
"i",
")",
"current",
".",
"extend",
"(",
"self",
".",
"reference",
"(",
"t",
",",
"i",
... | Handle normal chars. | [
"Handle",
"normal",
"chars",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L512-L531 |
13,015 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.posix_props | def posix_props(self, prop, in_group=False):
"""
Insert POSIX properties.
Posix style properties are not as forgiving
as Unicode properties. Case does matter,
and whitespace and '-' and '_' will not be tolerated.
"""
try:
if self.is_bytes or not self.unicode:
pattern = _uniprops.get_posix_property(
prop, (_uniprops.POSIX_BYTES if self.is_bytes else _uniprops.POSIX)
)
else:
pattern = _uniprops.get_posix_property(prop, _uniprops.POSIX_UNICODE)
except Exception:
raise ValueError('Invalid POSIX property!')
if not in_group and not pattern: # pragma: no cover
pattern = '^%s' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE)
return [pattern] | python | def posix_props(self, prop, in_group=False):
try:
if self.is_bytes or not self.unicode:
pattern = _uniprops.get_posix_property(
prop, (_uniprops.POSIX_BYTES if self.is_bytes else _uniprops.POSIX)
)
else:
pattern = _uniprops.get_posix_property(prop, _uniprops.POSIX_UNICODE)
except Exception:
raise ValueError('Invalid POSIX property!')
if not in_group and not pattern: # pragma: no cover
pattern = '^%s' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE)
return [pattern] | [
"def",
"posix_props",
"(",
"self",
",",
"prop",
",",
"in_group",
"=",
"False",
")",
":",
"try",
":",
"if",
"self",
".",
"is_bytes",
"or",
"not",
"self",
".",
"unicode",
":",
"pattern",
"=",
"_uniprops",
".",
"get_posix_property",
"(",
"prop",
",",
"(",... | Insert POSIX properties.
Posix style properties are not as forgiving
as Unicode properties. Case does matter,
and whitespace and '-' and '_' will not be tolerated. | [
"Insert",
"POSIX",
"properties",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L533-L554 |
13,016 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.unicode_name | def unicode_name(self, name, in_group=False):
"""Insert Unicode value by its name."""
value = ord(_unicodedata.lookup(name))
if (self.is_bytes and value > 0xFF):
value = ""
if not in_group and value == "":
return '[^%s]' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE)
elif value == "":
return value
else:
return ['\\%03o' % value if value <= 0xFF else chr(value)] | python | def unicode_name(self, name, in_group=False):
value = ord(_unicodedata.lookup(name))
if (self.is_bytes and value > 0xFF):
value = ""
if not in_group and value == "":
return '[^%s]' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE)
elif value == "":
return value
else:
return ['\\%03o' % value if value <= 0xFF else chr(value)] | [
"def",
"unicode_name",
"(",
"self",
",",
"name",
",",
"in_group",
"=",
"False",
")",
":",
"value",
"=",
"ord",
"(",
"_unicodedata",
".",
"lookup",
"(",
"name",
")",
")",
"if",
"(",
"self",
".",
"is_bytes",
"and",
"value",
">",
"0xFF",
")",
":",
"va... | Insert Unicode value by its name. | [
"Insert",
"Unicode",
"value",
"by",
"its",
"name",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L556-L567 |
13,017 | facelessuser/backrefs | backrefs/_bre_parse.py | _SearchParser.unicode_props | def unicode_props(self, props, value, in_group=False, negate=False):
"""
Insert Unicode properties.
Unicode properties are very forgiving.
Case doesn't matter and `[ -_]` will be stripped out.
"""
# `'GC = Some_Unpredictable-Category Name' -> 'gc=someunpredictablecategoryname'`
category = None
# `\p{^negated}` Strip off the caret after evaluation.
if props.startswith("^"):
negate = not negate
if props.startswith("^"):
props = props[1:]
# Get the property and value.
# If a property is present and not block,
# we can assume `GC` as that is all we support.
# If we are wrong it will fail.
if value:
if _uniprops.is_enum(props):
category = props
props = value
elif value in ('y', 'yes', 't', 'true'):
category = 'binary'
elif value in ('n', 'no', 'f', 'false'):
category = 'binary'
negate = not negate
else:
raise ValueError('Invalid Unicode property!')
v = _uniprops.get_unicode_property(("^" if negate else "") + props, category, self.is_bytes)
if not in_group:
if not v:
v = '^%s' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE)
v = "[%s]" % v
properties = [v]
return properties | python | def unicode_props(self, props, value, in_group=False, negate=False):
# `'GC = Some_Unpredictable-Category Name' -> 'gc=someunpredictablecategoryname'`
category = None
# `\p{^negated}` Strip off the caret after evaluation.
if props.startswith("^"):
negate = not negate
if props.startswith("^"):
props = props[1:]
# Get the property and value.
# If a property is present and not block,
# we can assume `GC` as that is all we support.
# If we are wrong it will fail.
if value:
if _uniprops.is_enum(props):
category = props
props = value
elif value in ('y', 'yes', 't', 'true'):
category = 'binary'
elif value in ('n', 'no', 'f', 'false'):
category = 'binary'
negate = not negate
else:
raise ValueError('Invalid Unicode property!')
v = _uniprops.get_unicode_property(("^" if negate else "") + props, category, self.is_bytes)
if not in_group:
if not v:
v = '^%s' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE)
v = "[%s]" % v
properties = [v]
return properties | [
"def",
"unicode_props",
"(",
"self",
",",
"props",
",",
"value",
",",
"in_group",
"=",
"False",
",",
"negate",
"=",
"False",
")",
":",
"# `'GC = Some_Unpredictable-Category Name' -> 'gc=someunpredictablecategoryname'`",
"category",
"=",
"None",
"# `\\p{^negated}` Strip of... | Insert Unicode properties.
Unicode properties are very forgiving.
Case doesn't matter and `[ -_]` will be stripped out. | [
"Insert",
"Unicode",
"properties",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L569-L609 |
13,018 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.parse_format_index | def parse_format_index(self, text):
"""Parse format index."""
base = 10
prefix = text[1:3] if text[0] == "-" else text[:2]
if prefix[0:1] == "0":
char = prefix[-1]
if char == "b":
base = 2
elif char == "o":
base = 8
elif char == "x":
base = 16
try:
text = int(text, base)
except Exception:
pass
return text | python | def parse_format_index(self, text):
base = 10
prefix = text[1:3] if text[0] == "-" else text[:2]
if prefix[0:1] == "0":
char = prefix[-1]
if char == "b":
base = 2
elif char == "o":
base = 8
elif char == "x":
base = 16
try:
text = int(text, base)
except Exception:
pass
return text | [
"def",
"parse_format_index",
"(",
"self",
",",
"text",
")",
":",
"base",
"=",
"10",
"prefix",
"=",
"text",
"[",
"1",
":",
"3",
"]",
"if",
"text",
"[",
"0",
"]",
"==",
"\"-\"",
"else",
"text",
"[",
":",
"2",
"]",
"if",
"prefix",
"[",
"0",
":",
... | Parse format index. | [
"Parse",
"format",
"index",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L704-L721 |
13,019 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.handle_format | def handle_format(self, t, i):
"""Handle format."""
if t == '{':
t = self.format_next(i)
if t == '{':
self.get_single_stack()
self.result.append(t)
else:
field, text = self.get_format(t, i)
self.handle_format_group(field, text)
else:
t = self.format_next(i)
if t == '}':
self.get_single_stack()
self.result.append(t)
else:
raise SyntaxError("Unmatched '}' at %d!" % (i.index - 2)) | python | def handle_format(self, t, i):
if t == '{':
t = self.format_next(i)
if t == '{':
self.get_single_stack()
self.result.append(t)
else:
field, text = self.get_format(t, i)
self.handle_format_group(field, text)
else:
t = self.format_next(i)
if t == '}':
self.get_single_stack()
self.result.append(t)
else:
raise SyntaxError("Unmatched '}' at %d!" % (i.index - 2)) | [
"def",
"handle_format",
"(",
"self",
",",
"t",
",",
"i",
")",
":",
"if",
"t",
"==",
"'{'",
":",
"t",
"=",
"self",
".",
"format_next",
"(",
"i",
")",
"if",
"t",
"==",
"'{'",
":",
"self",
".",
"get_single_stack",
"(",
")",
"self",
".",
"result",
... | Handle format. | [
"Handle",
"format",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L857-L874 |
13,020 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.get_octal | def get_octal(self, c, i):
"""Get octal."""
index = i.index
value = []
zero_count = 0
try:
if c == '0':
for x in range(3):
if c != '0':
break
value.append(c)
c = next(i)
zero_count = len(value)
if zero_count < 3:
for x in range(3 - zero_count):
if c not in _OCTAL:
break
value.append(c)
c = next(i)
i.rewind(1)
except StopIteration:
pass
octal_count = len(value)
if not (self.use_format and octal_count) and not (zero_count and octal_count < 3) and octal_count != 3:
i.rewind(i.index - index)
value = []
return ''.join(value) if value else None | python | def get_octal(self, c, i):
index = i.index
value = []
zero_count = 0
try:
if c == '0':
for x in range(3):
if c != '0':
break
value.append(c)
c = next(i)
zero_count = len(value)
if zero_count < 3:
for x in range(3 - zero_count):
if c not in _OCTAL:
break
value.append(c)
c = next(i)
i.rewind(1)
except StopIteration:
pass
octal_count = len(value)
if not (self.use_format and octal_count) and not (zero_count and octal_count < 3) and octal_count != 3:
i.rewind(i.index - index)
value = []
return ''.join(value) if value else None | [
"def",
"get_octal",
"(",
"self",
",",
"c",
",",
"i",
")",
":",
"index",
"=",
"i",
".",
"index",
"value",
"=",
"[",
"]",
"zero_count",
"=",
"0",
"try",
":",
"if",
"c",
"==",
"'0'",
":",
"for",
"x",
"in",
"range",
"(",
"3",
")",
":",
"if",
"c... | Get octal. | [
"Get",
"octal",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L876-L905 |
13,021 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.parse_octal | def parse_octal(self, text, i):
"""Parse octal value."""
value = int(text, 8)
if value > 0xFF and self.is_bytes:
# Re fails on octal greater than `0o377` or `0xFF`
raise ValueError("octal escape value outside of range 0-0o377!")
else:
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
elif value <= 0xFF:
self.result.append('\\%03o' % value)
else:
self.result.append(chr(value)) | python | def parse_octal(self, text, i):
value = int(text, 8)
if value > 0xFF and self.is_bytes:
# Re fails on octal greater than `0o377` or `0xFF`
raise ValueError("octal escape value outside of range 0-0o377!")
else:
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
elif value <= 0xFF:
self.result.append('\\%03o' % value)
else:
self.result.append(chr(value)) | [
"def",
"parse_octal",
"(",
"self",
",",
"text",
",",
"i",
")",
":",
"value",
"=",
"int",
"(",
"text",
",",
"8",
")",
"if",
"value",
">",
"0xFF",
"and",
"self",
".",
"is_bytes",
":",
"# Re fails on octal greater than `0o377` or `0xFF`",
"raise",
"ValueError",... | Parse octal value. | [
"Parse",
"octal",
"value",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L907-L926 |
13,022 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.get_named_unicode | def get_named_unicode(self, i):
"""Get named Unicode."""
index = i.index
value = []
try:
if next(i) != '{':
raise SyntaxError("Named Unicode missing '{'' at %d!" % (i.index - 1))
c = next(i)
while c != '}':
value.append(c)
c = next(i)
except StopIteration:
raise SyntaxError("Unmatched '}' at %d!" % index)
return ''.join(value) | python | def get_named_unicode(self, i):
index = i.index
value = []
try:
if next(i) != '{':
raise SyntaxError("Named Unicode missing '{'' at %d!" % (i.index - 1))
c = next(i)
while c != '}':
value.append(c)
c = next(i)
except StopIteration:
raise SyntaxError("Unmatched '}' at %d!" % index)
return ''.join(value) | [
"def",
"get_named_unicode",
"(",
"self",
",",
"i",
")",
":",
"index",
"=",
"i",
".",
"index",
"value",
"=",
"[",
"]",
"try",
":",
"if",
"next",
"(",
"i",
")",
"!=",
"'{'",
":",
"raise",
"SyntaxError",
"(",
"\"Named Unicode missing '{'' at %d!\"",
"%",
... | Get named Unicode. | [
"Get",
"named",
"Unicode",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L928-L943 |
13,023 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.parse_named_unicode | def parse_named_unicode(self, i):
"""Parse named Unicode."""
value = ord(_unicodedata.lookup(self.get_named_unicode(i)))
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
elif value <= 0xFF:
self.result.append('\\%03o' % value)
else:
self.result.append(chr(value)) | python | def parse_named_unicode(self, i):
value = ord(_unicodedata.lookup(self.get_named_unicode(i)))
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
elif value <= 0xFF:
self.result.append('\\%03o' % value)
else:
self.result.append(chr(value)) | [
"def",
"parse_named_unicode",
"(",
"self",
",",
"i",
")",
":",
"value",
"=",
"ord",
"(",
"_unicodedata",
".",
"lookup",
"(",
"self",
".",
"get_named_unicode",
"(",
"i",
")",
")",
")",
"single",
"=",
"self",
".",
"get_single_stack",
"(",
")",
"if",
"sel... | Parse named Unicode. | [
"Parse",
"named",
"Unicode",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L945-L960 |
13,024 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.get_wide_unicode | def get_wide_unicode(self, i):
"""Get narrow Unicode."""
value = []
for x in range(3):
c = next(i)
if c == '0':
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1))
c = next(i)
if c in ('0', '1'):
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1))
for x in range(4):
c = next(i)
if c.lower() in _HEX:
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1))
return ''.join(value) | python | def get_wide_unicode(self, i):
value = []
for x in range(3):
c = next(i)
if c == '0':
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1))
c = next(i)
if c in ('0', '1'):
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1))
for x in range(4):
c = next(i)
if c.lower() in _HEX:
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid wide Unicode character at %d!' % (i.index - 1))
return ''.join(value) | [
"def",
"get_wide_unicode",
"(",
"self",
",",
"i",
")",
":",
"value",
"=",
"[",
"]",
"for",
"x",
"in",
"range",
"(",
"3",
")",
":",
"c",
"=",
"next",
"(",
"i",
")",
"if",
"c",
"==",
"'0'",
":",
"value",
".",
"append",
"(",
"c",
")",
"else",
... | Get narrow Unicode. | [
"Get",
"narrow",
"Unicode",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L962-L985 |
13,025 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.parse_unicode | def parse_unicode(self, i, wide=False):
"""Parse Unicode."""
text = self.get_wide_unicode(i) if wide else self.get_narrow_unicode(i)
value = int(text, 16)
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
elif value <= 0xFF:
self.result.append('\\%03o' % value)
else:
self.result.append(chr(value)) | python | def parse_unicode(self, i, wide=False):
text = self.get_wide_unicode(i) if wide else self.get_narrow_unicode(i)
value = int(text, 16)
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
elif value <= 0xFF:
self.result.append('\\%03o' % value)
else:
self.result.append(chr(value)) | [
"def",
"parse_unicode",
"(",
"self",
",",
"i",
",",
"wide",
"=",
"False",
")",
":",
"text",
"=",
"self",
".",
"get_wide_unicode",
"(",
"i",
")",
"if",
"wide",
"else",
"self",
".",
"get_narrow_unicode",
"(",
"i",
")",
"value",
"=",
"int",
"(",
"text",... | Parse Unicode. | [
"Parse",
"Unicode",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L999-L1015 |
13,026 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.get_byte | def get_byte(self, i):
"""Get byte."""
value = []
for x in range(2):
c = next(i)
if c.lower() in _HEX:
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid byte character at %d!' % (i.index - 1))
return ''.join(value) | python | def get_byte(self, i):
value = []
for x in range(2):
c = next(i)
if c.lower() in _HEX:
value.append(c)
else: # pragma: no cover
raise SyntaxError('Invalid byte character at %d!' % (i.index - 1))
return ''.join(value) | [
"def",
"get_byte",
"(",
"self",
",",
"i",
")",
":",
"value",
"=",
"[",
"]",
"for",
"x",
"in",
"range",
"(",
"2",
")",
":",
"c",
"=",
"next",
"(",
"i",
")",
"if",
"c",
".",
"lower",
"(",
")",
"in",
"_HEX",
":",
"value",
".",
"append",
"(",
... | Get byte. | [
"Get",
"byte",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1017-L1027 |
13,027 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.parse_bytes | def parse_bytes(self, i):
"""Parse byte."""
value = int(self.get_byte(i), 16)
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
else:
self.result.append('\\%03o' % value) | python | def parse_bytes(self, i):
value = int(self.get_byte(i), 16)
single = self.get_single_stack()
if self.span_stack:
text = self.convert_case(chr(value), self.span_stack[-1])
value = ord(self.convert_case(text, single)) if single is not None else ord(text)
elif single:
value = ord(self.convert_case(chr(value), single))
if self.use_format and value in _CURLY_BRACKETS_ORD:
self.handle_format(chr(value), i)
else:
self.result.append('\\%03o' % value) | [
"def",
"parse_bytes",
"(",
"self",
",",
"i",
")",
":",
"value",
"=",
"int",
"(",
"self",
".",
"get_byte",
"(",
"i",
")",
",",
"16",
")",
"single",
"=",
"self",
".",
"get_single_stack",
"(",
")",
"if",
"self",
".",
"span_stack",
":",
"text",
"=",
... | Parse byte. | [
"Parse",
"byte",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1029-L1042 |
13,028 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.format_next | def format_next(self, i):
"""Get next format char."""
c = next(i)
return self.format_references(next(i), i) if c == '\\' else c | python | def format_next(self, i):
c = next(i)
return self.format_references(next(i), i) if c == '\\' else c | [
"def",
"format_next",
"(",
"self",
",",
"i",
")",
":",
"c",
"=",
"next",
"(",
"i",
")",
"return",
"self",
".",
"format_references",
"(",
"next",
"(",
"i",
")",
",",
"i",
")",
"if",
"c",
"==",
"'\\\\'",
"else",
"c"
] | Get next format char. | [
"Get",
"next",
"format",
"char",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1094-L1098 |
13,029 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.format_references | def format_references(self, t, i):
"""Handle format references."""
octal = self.get_octal(t, i)
if octal:
value = int(octal, 8)
if value > 0xFF and self.is_bytes:
# Re fails on octal greater than `0o377` or `0xFF`
raise ValueError("octal escape value outside of range 0-0o377!")
value = chr(value)
elif t in _STANDARD_ESCAPES or t == '\\':
value = _BACK_SLASH_TRANSLATION['\\' + t]
elif not self.is_bytes and t == "U":
value = chr(int(self.get_wide_unicode(i), 16))
elif not self.is_bytes and t == "u":
value = chr(int(self.get_narrow_unicode(i), 16))
elif not self.is_bytes and t == "N":
value = _unicodedata.lookup(self.get_named_unicode(i))
elif t == "x":
value = chr(int(self.get_byte(i), 16))
else:
i.rewind(1)
value = '\\'
return value | python | def format_references(self, t, i):
octal = self.get_octal(t, i)
if octal:
value = int(octal, 8)
if value > 0xFF and self.is_bytes:
# Re fails on octal greater than `0o377` or `0xFF`
raise ValueError("octal escape value outside of range 0-0o377!")
value = chr(value)
elif t in _STANDARD_ESCAPES or t == '\\':
value = _BACK_SLASH_TRANSLATION['\\' + t]
elif not self.is_bytes and t == "U":
value = chr(int(self.get_wide_unicode(i), 16))
elif not self.is_bytes and t == "u":
value = chr(int(self.get_narrow_unicode(i), 16))
elif not self.is_bytes and t == "N":
value = _unicodedata.lookup(self.get_named_unicode(i))
elif t == "x":
value = chr(int(self.get_byte(i), 16))
else:
i.rewind(1)
value = '\\'
return value | [
"def",
"format_references",
"(",
"self",
",",
"t",
",",
"i",
")",
":",
"octal",
"=",
"self",
".",
"get_octal",
"(",
"t",
",",
"i",
")",
"if",
"octal",
":",
"value",
"=",
"int",
"(",
"octal",
",",
"8",
")",
"if",
"value",
">",
"0xFF",
"and",
"se... | Handle format references. | [
"Handle",
"format",
"references",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1100-L1123 |
13,030 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.span_case | def span_case(self, i, case):
"""Uppercase or lowercase the next range of characters until end marker is found."""
# A new \L, \C or \E should pop the last in the stack.
if self.span_stack:
self.span_stack.pop()
if self.single_stack:
self.single_stack.pop()
self.span_stack.append(case)
count = len(self.span_stack)
self.end_found = False
try:
while not self.end_found:
t = next(i)
if self.use_format and t in _CURLY_BRACKETS:
self.handle_format(t, i)
elif t == '\\':
try:
t = next(i)
self.reference(t, i)
except StopIteration:
self.result.append(t)
raise
else:
self.result.append(self.convert_case(t, case))
if self.end_found or count > len(self.span_stack):
self.end_found = False
break
except StopIteration:
pass
if count == len(self.span_stack):
self.span_stack.pop() | python | def span_case(self, i, case):
# A new \L, \C or \E should pop the last in the stack.
if self.span_stack:
self.span_stack.pop()
if self.single_stack:
self.single_stack.pop()
self.span_stack.append(case)
count = len(self.span_stack)
self.end_found = False
try:
while not self.end_found:
t = next(i)
if self.use_format and t in _CURLY_BRACKETS:
self.handle_format(t, i)
elif t == '\\':
try:
t = next(i)
self.reference(t, i)
except StopIteration:
self.result.append(t)
raise
else:
self.result.append(self.convert_case(t, case))
if self.end_found or count > len(self.span_stack):
self.end_found = False
break
except StopIteration:
pass
if count == len(self.span_stack):
self.span_stack.pop() | [
"def",
"span_case",
"(",
"self",
",",
"i",
",",
"case",
")",
":",
"# A new \\L, \\C or \\E should pop the last in the stack.",
"if",
"self",
".",
"span_stack",
":",
"self",
".",
"span_stack",
".",
"pop",
"(",
")",
"if",
"self",
".",
"single_stack",
":",
"self"... | Uppercase or lowercase the next range of characters until end marker is found. | [
"Uppercase",
"or",
"lowercase",
"the",
"next",
"range",
"of",
"characters",
"until",
"end",
"marker",
"is",
"found",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1206-L1237 |
13,031 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.convert_case | def convert_case(self, value, case):
"""Convert case."""
if self.is_bytes:
cased = []
for c in value:
if c in _ASCII_LETTERS:
cased.append(c.lower() if case == _LOWER else c.upper())
else:
cased.append(c)
return "".join(cased)
else:
return value.lower() if case == _LOWER else value.upper() | python | def convert_case(self, value, case):
if self.is_bytes:
cased = []
for c in value:
if c in _ASCII_LETTERS:
cased.append(c.lower() if case == _LOWER else c.upper())
else:
cased.append(c)
return "".join(cased)
else:
return value.lower() if case == _LOWER else value.upper() | [
"def",
"convert_case",
"(",
"self",
",",
"value",
",",
"case",
")",
":",
"if",
"self",
".",
"is_bytes",
":",
"cased",
"=",
"[",
"]",
"for",
"c",
"in",
"value",
":",
"if",
"c",
"in",
"_ASCII_LETTERS",
":",
"cased",
".",
"append",
"(",
"c",
".",
"l... | Convert case. | [
"Convert",
"case",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1239-L1251 |
13,032 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.single_case | def single_case(self, i, case):
"""Uppercase or lowercase the next character."""
# Pop a previous case if we have consecutive ones.
if self.single_stack:
self.single_stack.pop()
self.single_stack.append(case)
try:
t = next(i)
if self.use_format and t in _CURLY_BRACKETS:
self.handle_format(t, i)
elif t == '\\':
try:
t = next(i)
self.reference(t, i)
except StopIteration:
self.result.append(t)
raise
elif self.single_stack:
self.result.append(self.convert_case(t, self.get_single_stack()))
except StopIteration:
pass | python | def single_case(self, i, case):
# Pop a previous case if we have consecutive ones.
if self.single_stack:
self.single_stack.pop()
self.single_stack.append(case)
try:
t = next(i)
if self.use_format and t in _CURLY_BRACKETS:
self.handle_format(t, i)
elif t == '\\':
try:
t = next(i)
self.reference(t, i)
except StopIteration:
self.result.append(t)
raise
elif self.single_stack:
self.result.append(self.convert_case(t, self.get_single_stack()))
except StopIteration:
pass | [
"def",
"single_case",
"(",
"self",
",",
"i",
",",
"case",
")",
":",
"# Pop a previous case if we have consecutive ones.",
"if",
"self",
".",
"single_stack",
":",
"self",
".",
"single_stack",
".",
"pop",
"(",
")",
"self",
".",
"single_stack",
".",
"append",
"("... | Uppercase or lowercase the next character. | [
"Uppercase",
"or",
"lowercase",
"the",
"next",
"character",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1253-L1274 |
13,033 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.get_single_stack | def get_single_stack(self):
"""Get the correct single stack item to use."""
single = None
while self.single_stack:
single = self.single_stack.pop()
return single | python | def get_single_stack(self):
single = None
while self.single_stack:
single = self.single_stack.pop()
return single | [
"def",
"get_single_stack",
"(",
"self",
")",
":",
"single",
"=",
"None",
"while",
"self",
".",
"single_stack",
":",
"single",
"=",
"self",
".",
"single_stack",
".",
"pop",
"(",
")",
"return",
"single"
] | Get the correct single stack item to use. | [
"Get",
"the",
"correct",
"single",
"stack",
"item",
"to",
"use",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1276-L1282 |
13,034 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.handle_format_group | def handle_format_group(self, field, text):
"""Handle format group."""
# Handle auto incrementing group indexes
if field == '':
if self.auto:
field = str(self.auto_index)
text[0] = (_util.FMT_FIELD, field)
self.auto_index += 1
elif not self.manual and not self.auto:
self.auto = True
field = str(self.auto_index)
text[0] = (_util.FMT_FIELD, field)
self.auto_index += 1
else:
raise ValueError("Cannot switch to auto format during manual format!")
elif not self.manual and not self.auto:
self.manual = True
elif not self.manual:
raise ValueError("Cannot switch to manual format during auto format!")
self.handle_group(field, tuple(text), True) | python | def handle_format_group(self, field, text):
# Handle auto incrementing group indexes
if field == '':
if self.auto:
field = str(self.auto_index)
text[0] = (_util.FMT_FIELD, field)
self.auto_index += 1
elif not self.manual and not self.auto:
self.auto = True
field = str(self.auto_index)
text[0] = (_util.FMT_FIELD, field)
self.auto_index += 1
else:
raise ValueError("Cannot switch to auto format during manual format!")
elif not self.manual and not self.auto:
self.manual = True
elif not self.manual:
raise ValueError("Cannot switch to manual format during auto format!")
self.handle_group(field, tuple(text), True) | [
"def",
"handle_format_group",
"(",
"self",
",",
"field",
",",
"text",
")",
":",
"# Handle auto incrementing group indexes",
"if",
"field",
"==",
"''",
":",
"if",
"self",
".",
"auto",
":",
"field",
"=",
"str",
"(",
"self",
".",
"auto_index",
")",
"text",
"[... | Handle format group. | [
"Handle",
"format",
"group",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1284-L1305 |
13,035 | facelessuser/backrefs | backrefs/_bre_parse.py | _ReplaceParser.handle_group | def handle_group(self, text, capture=None, is_format=False):
"""Handle groups."""
if capture is None:
capture = tuple() if self.is_bytes else ''
if len(self.result) > 1:
self.literal_slots.append("".join(self.result))
if is_format:
self.literal_slots.extend(["\\g<", text, ">"])
else:
self.literal_slots.append(text)
del self.result[:]
self.result.append("")
self.slot += 1
elif is_format:
self.literal_slots.extend(["\\g<", text, ">"])
else:
self.literal_slots.append(text)
self.group_slots.append(
(
self.slot,
(
(self.span_stack[-1] if self.span_stack else None),
self.get_single_stack(),
capture
)
)
)
self.slot += 1 | python | def handle_group(self, text, capture=None, is_format=False):
if capture is None:
capture = tuple() if self.is_bytes else ''
if len(self.result) > 1:
self.literal_slots.append("".join(self.result))
if is_format:
self.literal_slots.extend(["\\g<", text, ">"])
else:
self.literal_slots.append(text)
del self.result[:]
self.result.append("")
self.slot += 1
elif is_format:
self.literal_slots.extend(["\\g<", text, ">"])
else:
self.literal_slots.append(text)
self.group_slots.append(
(
self.slot,
(
(self.span_stack[-1] if self.span_stack else None),
self.get_single_stack(),
capture
)
)
)
self.slot += 1 | [
"def",
"handle_group",
"(",
"self",
",",
"text",
",",
"capture",
"=",
"None",
",",
"is_format",
"=",
"False",
")",
":",
"if",
"capture",
"is",
"None",
":",
"capture",
"=",
"tuple",
"(",
")",
"if",
"self",
".",
"is_bytes",
"else",
"''",
"if",
"len",
... | Handle groups. | [
"Handle",
"groups",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1307-L1337 |
13,036 | facelessuser/backrefs | backrefs/_bre_parse.py | ReplaceTemplate._get_group_index | def _get_group_index(self, index):
"""Find and return the appropriate group index."""
g_index = None
for group in self.groups:
if group[0] == index:
g_index = group[1]
break
return g_index | python | def _get_group_index(self, index):
g_index = None
for group in self.groups:
if group[0] == index:
g_index = group[1]
break
return g_index | [
"def",
"_get_group_index",
"(",
"self",
",",
"index",
")",
":",
"g_index",
"=",
"None",
"for",
"group",
"in",
"self",
".",
"groups",
":",
"if",
"group",
"[",
"0",
"]",
"==",
"index",
":",
"g_index",
"=",
"group",
"[",
"1",
"]",
"break",
"return",
"... | Find and return the appropriate group index. | [
"Find",
"and",
"return",
"the",
"appropriate",
"group",
"index",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1436-L1444 |
13,037 | facelessuser/backrefs | backrefs/_bre_parse.py | ReplaceTemplate._get_group_attributes | def _get_group_attributes(self, index):
"""Find and return the appropriate group case."""
g_case = (None, None, -1)
for group in self.group_slots:
if group[0] == index:
g_case = group[1]
break
return g_case | python | def _get_group_attributes(self, index):
g_case = (None, None, -1)
for group in self.group_slots:
if group[0] == index:
g_case = group[1]
break
return g_case | [
"def",
"_get_group_attributes",
"(",
"self",
",",
"index",
")",
":",
"g_case",
"=",
"(",
"None",
",",
"None",
",",
"-",
"1",
")",
"for",
"group",
"in",
"self",
".",
"group_slots",
":",
"if",
"group",
"[",
"0",
"]",
"==",
"index",
":",
"g_case",
"="... | Find and return the appropriate group case. | [
"Find",
"and",
"return",
"the",
"appropriate",
"group",
"case",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1446-L1454 |
13,038 | facelessuser/backrefs | backrefs/util.py | _to_bstr | def _to_bstr(l):
"""Convert to byte string."""
if isinstance(l, str):
l = l.encode('ascii', 'backslashreplace')
elif not isinstance(l, bytes):
l = str(l).encode('ascii', 'backslashreplace')
return l | python | def _to_bstr(l):
if isinstance(l, str):
l = l.encode('ascii', 'backslashreplace')
elif not isinstance(l, bytes):
l = str(l).encode('ascii', 'backslashreplace')
return l | [
"def",
"_to_bstr",
"(",
"l",
")",
":",
"if",
"isinstance",
"(",
"l",
",",
"str",
")",
":",
"l",
"=",
"l",
".",
"encode",
"(",
"'ascii'",
",",
"'backslashreplace'",
")",
"elif",
"not",
"isinstance",
"(",
"l",
",",
"bytes",
")",
":",
"l",
"=",
"str... | Convert to byte string. | [
"Convert",
"to",
"byte",
"string",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/util.py#L65-L72 |
13,039 | facelessuser/backrefs | backrefs/util.py | format_string | def format_string(m, l, capture, is_bytes):
"""Perform a string format."""
for fmt_type, value in capture[1:]:
if fmt_type == FMT_ATTR:
# Attribute
l = getattr(l, value)
elif fmt_type == FMT_INDEX:
# Index
l = l[value]
elif fmt_type == FMT_CONV:
if is_bytes:
# Conversion
if value in ('r', 'a'):
l = repr(l).encode('ascii', 'backslashreplace')
elif value == 's':
# If the object is not string or byte string already
l = _to_bstr(l)
else:
# Conversion
if value == 'a':
l = ascii(l)
elif value == 'r':
l = repr(l)
elif value == 's':
# If the object is not string or byte string already
l = str(l)
elif fmt_type == FMT_SPEC:
# Integers and floats don't have an explicit 's' format type.
if value[3] and value[3] == 's':
if isinstance(l, int): # pragma: no cover
raise ValueError("Unknown format code 's' for object of type 'int'")
if isinstance(l, float): # pragma: no cover
raise ValueError("Unknown format code 's' for object of type 'float'")
# Ensure object is a byte string
l = _to_bstr(l) if is_bytes else str(l)
spec_type = value[1]
if spec_type == '^':
l = l.center(value[2], value[0])
elif spec_type == ">":
l = l.rjust(value[2], value[0])
else:
l = l.ljust(value[2], value[0])
# Make sure the final object is a byte string
return _to_bstr(l) if is_bytes else str(l) | python | def format_string(m, l, capture, is_bytes):
for fmt_type, value in capture[1:]:
if fmt_type == FMT_ATTR:
# Attribute
l = getattr(l, value)
elif fmt_type == FMT_INDEX:
# Index
l = l[value]
elif fmt_type == FMT_CONV:
if is_bytes:
# Conversion
if value in ('r', 'a'):
l = repr(l).encode('ascii', 'backslashreplace')
elif value == 's':
# If the object is not string or byte string already
l = _to_bstr(l)
else:
# Conversion
if value == 'a':
l = ascii(l)
elif value == 'r':
l = repr(l)
elif value == 's':
# If the object is not string or byte string already
l = str(l)
elif fmt_type == FMT_SPEC:
# Integers and floats don't have an explicit 's' format type.
if value[3] and value[3] == 's':
if isinstance(l, int): # pragma: no cover
raise ValueError("Unknown format code 's' for object of type 'int'")
if isinstance(l, float): # pragma: no cover
raise ValueError("Unknown format code 's' for object of type 'float'")
# Ensure object is a byte string
l = _to_bstr(l) if is_bytes else str(l)
spec_type = value[1]
if spec_type == '^':
l = l.center(value[2], value[0])
elif spec_type == ">":
l = l.rjust(value[2], value[0])
else:
l = l.ljust(value[2], value[0])
# Make sure the final object is a byte string
return _to_bstr(l) if is_bytes else str(l) | [
"def",
"format_string",
"(",
"m",
",",
"l",
",",
"capture",
",",
"is_bytes",
")",
":",
"for",
"fmt_type",
",",
"value",
"in",
"capture",
"[",
"1",
":",
"]",
":",
"if",
"fmt_type",
"==",
"FMT_ATTR",
":",
"# Attribute",
"l",
"=",
"getattr",
"(",
"l",
... | Perform a string format. | [
"Perform",
"a",
"string",
"format",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/util.py#L75-L122 |
13,040 | facelessuser/backrefs | backrefs/util.py | StringIter.rewind | def rewind(self, count):
"""Rewind index."""
if count > self._index: # pragma: no cover
raise ValueError("Can't rewind past beginning!")
self._index -= count | python | def rewind(self, count):
if count > self._index: # pragma: no cover
raise ValueError("Can't rewind past beginning!")
self._index -= count | [
"def",
"rewind",
"(",
"self",
",",
"count",
")",
":",
"if",
"count",
">",
"self",
".",
"_index",
":",
"# pragma: no cover",
"raise",
"ValueError",
"(",
"\"Can't rewind past beginning!\"",
")",
"self",
".",
"_index",
"-=",
"count"
] | Rewind index. | [
"Rewind",
"index",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/util.py#L45-L51 |
13,041 | facelessuser/backrefs | setup.py | get_requirements | def get_requirements():
"""Load list of dependencies."""
install_requires = []
with open("requirements/project.txt") as f:
for line in f:
if not line.startswith("#"):
install_requires.append(line.strip())
return install_requires | python | def get_requirements():
install_requires = []
with open("requirements/project.txt") as f:
for line in f:
if not line.startswith("#"):
install_requires.append(line.strip())
return install_requires | [
"def",
"get_requirements",
"(",
")",
":",
"install_requires",
"=",
"[",
"]",
"with",
"open",
"(",
"\"requirements/project.txt\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"not",
"line",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"install... | Load list of dependencies. | [
"Load",
"list",
"of",
"dependencies",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/setup.py#L27-L35 |
13,042 | facelessuser/backrefs | setup.py | get_unicodedata | def get_unicodedata():
"""Download the `unicodedata` version for the given Python version."""
import unicodedata
fail = False
uver = unicodedata.unidata_version
path = os.path.join(os.path.dirname(__file__), 'tools')
fp, pathname, desc = imp.find_module('unidatadownload', [path])
try:
unidatadownload = imp.load_module('unidatadownload', fp, pathname, desc)
unidatadownload.get_unicodedata(uver, no_zip=True)
except Exception:
print(traceback.format_exc())
fail = True
finally:
fp.close()
assert not fail, "Failed to obtain unicodedata!"
return uver | python | def get_unicodedata():
import unicodedata
fail = False
uver = unicodedata.unidata_version
path = os.path.join(os.path.dirname(__file__), 'tools')
fp, pathname, desc = imp.find_module('unidatadownload', [path])
try:
unidatadownload = imp.load_module('unidatadownload', fp, pathname, desc)
unidatadownload.get_unicodedata(uver, no_zip=True)
except Exception:
print(traceback.format_exc())
fail = True
finally:
fp.close()
assert not fail, "Failed to obtain unicodedata!"
return uver | [
"def",
"get_unicodedata",
"(",
")",
":",
"import",
"unicodedata",
"fail",
"=",
"False",
"uver",
"=",
"unicodedata",
".",
"unidata_version",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
... | Download the `unicodedata` version for the given Python version. | [
"Download",
"the",
"unicodedata",
"version",
"for",
"the",
"given",
"Python",
"version",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/setup.py#L38-L57 |
13,043 | facelessuser/backrefs | setup.py | generate_unicode_table | def generate_unicode_table():
"""Generate the Unicode table for the given Python version."""
uver = get_unicodedata()
fail = False
path = os.path.join(os.path.dirname(__file__), 'tools')
fp, pathname, desc = imp.find_module('unipropgen', [path])
try:
unipropgen = imp.load_module('unipropgen', fp, pathname, desc)
unipropgen.build_tables(
os.path.join(
os.path.dirname(__file__),
'backrefs', 'uniprops', 'unidata'
),
uver
)
except Exception:
print(traceback.format_exc())
fail = True
finally:
fp.close()
assert not fail, "Failed uniprops.py generation!" | python | def generate_unicode_table():
uver = get_unicodedata()
fail = False
path = os.path.join(os.path.dirname(__file__), 'tools')
fp, pathname, desc = imp.find_module('unipropgen', [path])
try:
unipropgen = imp.load_module('unipropgen', fp, pathname, desc)
unipropgen.build_tables(
os.path.join(
os.path.dirname(__file__),
'backrefs', 'uniprops', 'unidata'
),
uver
)
except Exception:
print(traceback.format_exc())
fail = True
finally:
fp.close()
assert not fail, "Failed uniprops.py generation!" | [
"def",
"generate_unicode_table",
"(",
")",
":",
"uver",
"=",
"get_unicodedata",
"(",
")",
"fail",
"=",
"False",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'tools'",
")",
"fp",
",",... | Generate the Unicode table for the given Python version. | [
"Generate",
"the",
"Unicode",
"table",
"for",
"the",
"given",
"Python",
"version",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/setup.py#L60-L82 |
13,044 | facelessuser/backrefs | backrefs/bregex.py | _cached_replace_compile | def _cached_replace_compile(pattern, repl, flags, pattern_type):
"""Cached replace compile."""
return _bregex_parse._ReplaceParser().parse(pattern, repl, bool(flags & FORMAT)) | python | def _cached_replace_compile(pattern, repl, flags, pattern_type):
return _bregex_parse._ReplaceParser().parse(pattern, repl, bool(flags & FORMAT)) | [
"def",
"_cached_replace_compile",
"(",
"pattern",
",",
"repl",
",",
"flags",
",",
"pattern_type",
")",
":",
"return",
"_bregex_parse",
".",
"_ReplaceParser",
"(",
")",
".",
"parse",
"(",
"pattern",
",",
"repl",
",",
"bool",
"(",
"flags",
"&",
"FORMAT",
")"... | Cached replace compile. | [
"Cached",
"replace",
"compile",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L92-L95 |
13,045 | facelessuser/backrefs | backrefs/bregex.py | _get_cache_size | def _get_cache_size(replace=False):
"""Get size of cache."""
if not replace:
size = _cached_search_compile.cache_info().currsize
else:
size = _cached_replace_compile.cache_info().currsize
return size | python | def _get_cache_size(replace=False):
if not replace:
size = _cached_search_compile.cache_info().currsize
else:
size = _cached_replace_compile.cache_info().currsize
return size | [
"def",
"_get_cache_size",
"(",
"replace",
"=",
"False",
")",
":",
"if",
"not",
"replace",
":",
"size",
"=",
"_cached_search_compile",
".",
"cache_info",
"(",
")",
".",
"currsize",
"else",
":",
"size",
"=",
"_cached_replace_compile",
".",
"cache_info",
"(",
"... | Get size of cache. | [
"Get",
"size",
"of",
"cache",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L98-L105 |
13,046 | facelessuser/backrefs | backrefs/bregex.py | _apply_replace_backrefs | def _apply_replace_backrefs(m, repl=None, flags=0):
"""Expand with either the `ReplaceTemplate` or compile on the fly, or return None."""
if m is None:
raise ValueError("Match is None!")
else:
if isinstance(repl, ReplaceTemplate):
return repl.expand(m)
elif isinstance(repl, (str, bytes)):
return _bregex_parse._ReplaceParser().parse(m.re, repl, bool(flags & FORMAT)).expand(m) | python | def _apply_replace_backrefs(m, repl=None, flags=0):
if m is None:
raise ValueError("Match is None!")
else:
if isinstance(repl, ReplaceTemplate):
return repl.expand(m)
elif isinstance(repl, (str, bytes)):
return _bregex_parse._ReplaceParser().parse(m.re, repl, bool(flags & FORMAT)).expand(m) | [
"def",
"_apply_replace_backrefs",
"(",
"m",
",",
"repl",
"=",
"None",
",",
"flags",
"=",
"0",
")",
":",
"if",
"m",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Match is None!\"",
")",
"else",
":",
"if",
"isinstance",
"(",
"repl",
",",
"ReplaceTempla... | Expand with either the `ReplaceTemplate` or compile on the fly, or return None. | [
"Expand",
"with",
"either",
"the",
"ReplaceTemplate",
"or",
"compile",
"on",
"the",
"fly",
"or",
"return",
"None",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L121-L130 |
13,047 | facelessuser/backrefs | backrefs/bregex.py | _assert_expandable | def _assert_expandable(repl, use_format=False):
"""Check if replace template is expandable."""
if isinstance(repl, ReplaceTemplate):
if repl.use_format != use_format:
if use_format:
raise ValueError("Replace not compiled as a format replace")
else:
raise ValueError("Replace should not be compiled as a format replace!")
elif not isinstance(repl, (str, bytes)):
raise TypeError("Expected string, buffer, or compiled replace!") | python | def _assert_expandable(repl, use_format=False):
if isinstance(repl, ReplaceTemplate):
if repl.use_format != use_format:
if use_format:
raise ValueError("Replace not compiled as a format replace")
else:
raise ValueError("Replace should not be compiled as a format replace!")
elif not isinstance(repl, (str, bytes)):
raise TypeError("Expected string, buffer, or compiled replace!") | [
"def",
"_assert_expandable",
"(",
"repl",
",",
"use_format",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"repl",
",",
"ReplaceTemplate",
")",
":",
"if",
"repl",
".",
"use_format",
"!=",
"use_format",
":",
"if",
"use_format",
":",
"raise",
"ValueError",
... | Check if replace template is expandable. | [
"Check",
"if",
"replace",
"template",
"is",
"expandable",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L160-L170 |
13,048 | facelessuser/backrefs | backrefs/bregex.py | compile_search | def compile_search(pattern, flags=0, **kwargs):
"""Compile with extended search references."""
return _regex.compile(_apply_search_backrefs(pattern, flags), flags, **kwargs) | python | def compile_search(pattern, flags=0, **kwargs):
return _regex.compile(_apply_search_backrefs(pattern, flags), flags, **kwargs) | [
"def",
"compile_search",
"(",
"pattern",
",",
"flags",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_regex",
".",
"compile",
"(",
"_apply_search_backrefs",
"(",
"pattern",
",",
"flags",
")",
",",
"flags",
",",
"*",
"*",
"kwargs",
")"
] | Compile with extended search references. | [
"Compile",
"with",
"extended",
"search",
"references",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L189-L192 |
13,049 | facelessuser/backrefs | backrefs/bregex.py | expandf | def expandf(m, format): # noqa A002
"""Expand the string using the format replace pattern or function."""
_assert_expandable(format, True)
return _apply_replace_backrefs(m, format, flags=FORMAT) | python | def expandf(m, format): # noqa A002
_assert_expandable(format, True)
return _apply_replace_backrefs(m, format, flags=FORMAT) | [
"def",
"expandf",
"(",
"m",
",",
"format",
")",
":",
"# noqa A002",
"_assert_expandable",
"(",
"format",
",",
"True",
")",
"return",
"_apply_replace_backrefs",
"(",
"m",
",",
"format",
",",
"flags",
"=",
"FORMAT",
")"
] | Expand the string using the format replace pattern or function. | [
"Expand",
"the",
"string",
"using",
"the",
"format",
"replace",
"pattern",
"or",
"function",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L387-L391 |
13,050 | facelessuser/backrefs | backrefs/bregex.py | subfn | def subfn(pattern, format, string, *args, **kwargs): # noqa A002
"""Wrapper for `subfn`."""
flags = args[4] if len(args) > 4 else kwargs.get('flags', 0)
is_replace = _is_replace(format)
is_string = isinstance(format, (str, bytes))
if is_replace and not format.use_format:
raise ValueError("Compiled replace is not a format object!")
pattern = compile_search(pattern, flags)
rflags = FORMAT if is_string else 0
return _regex.subn(
pattern, (compile_replace(pattern, format, flags=rflags) if is_replace or is_string else format), string,
*args, **kwargs
) | python | def subfn(pattern, format, string, *args, **kwargs): # noqa A002
flags = args[4] if len(args) > 4 else kwargs.get('flags', 0)
is_replace = _is_replace(format)
is_string = isinstance(format, (str, bytes))
if is_replace and not format.use_format:
raise ValueError("Compiled replace is not a format object!")
pattern = compile_search(pattern, flags)
rflags = FORMAT if is_string else 0
return _regex.subn(
pattern, (compile_replace(pattern, format, flags=rflags) if is_replace or is_string else format), string,
*args, **kwargs
) | [
"def",
"subfn",
"(",
"pattern",
",",
"format",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa A002",
"flags",
"=",
"args",
"[",
"4",
"]",
"if",
"len",
"(",
"args",
")",
">",
"4",
"else",
"kwargs",
".",
"get",
"(",
"... | Wrapper for `subfn`. | [
"Wrapper",
"for",
"subfn",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L464-L478 |
13,051 | facelessuser/backrefs | backrefs/bregex.py | Bregex._auto_compile | def _auto_compile(self, template, use_format=False):
"""Compile replacements."""
is_replace = _is_replace(template)
is_string = isinstance(template, (str, bytes))
if is_replace and use_format != template.use_format:
raise ValueError("Compiled replace cannot be a format object!")
if is_replace or (is_string and self.auto_compile):
return self.compile(template, (FORMAT if use_format and not is_replace else 0))
elif is_string and use_format:
# Reject an attempt to run format replace when auto-compiling
# of template strings has been disabled and we are using a
# template string.
raise AttributeError('Format replaces cannot be called without compiling replace template!')
else:
return template | python | def _auto_compile(self, template, use_format=False):
is_replace = _is_replace(template)
is_string = isinstance(template, (str, bytes))
if is_replace and use_format != template.use_format:
raise ValueError("Compiled replace cannot be a format object!")
if is_replace or (is_string and self.auto_compile):
return self.compile(template, (FORMAT if use_format and not is_replace else 0))
elif is_string and use_format:
# Reject an attempt to run format replace when auto-compiling
# of template strings has been disabled and we are using a
# template string.
raise AttributeError('Format replaces cannot be called without compiling replace template!')
else:
return template | [
"def",
"_auto_compile",
"(",
"self",
",",
"template",
",",
"use_format",
"=",
"False",
")",
":",
"is_replace",
"=",
"_is_replace",
"(",
"template",
")",
"is_string",
"=",
"isinstance",
"(",
"template",
",",
"(",
"str",
",",
"bytes",
")",
")",
"if",
"is_r... | Compile replacements. | [
"Compile",
"replacements",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L295-L310 |
13,052 | facelessuser/backrefs | backrefs/bregex.py | Bregex.search | def search(self, string, *args, **kwargs):
"""Apply `search`."""
return self._pattern.search(string, *args, **kwargs) | python | def search(self, string, *args, **kwargs):
return self._pattern.search(string, *args, **kwargs) | [
"def",
"search",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"search",
"(",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Apply `search`. | [
"Apply",
"search",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L317-L320 |
13,053 | facelessuser/backrefs | backrefs/bregex.py | Bregex.match | def match(self, string, *args, **kwargs):
"""Apply `match`."""
return self._pattern.match(string, *args, **kwargs) | python | def match(self, string, *args, **kwargs):
return self._pattern.match(string, *args, **kwargs) | [
"def",
"match",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"match",
"(",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Apply `match`. | [
"Apply",
"match",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L322-L325 |
13,054 | facelessuser/backrefs | backrefs/bregex.py | Bregex.fullmatch | def fullmatch(self, string, *args, **kwargs):
"""Apply `fullmatch`."""
return self._pattern.fullmatch(string, *args, **kwargs) | python | def fullmatch(self, string, *args, **kwargs):
return self._pattern.fullmatch(string, *args, **kwargs) | [
"def",
"fullmatch",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"fullmatch",
"(",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Apply `fullmatch`. | [
"Apply",
"fullmatch",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L327-L330 |
13,055 | facelessuser/backrefs | backrefs/bregex.py | Bregex.split | def split(self, string, *args, **kwargs):
"""Apply `split`."""
return self._pattern.split(string, *args, **kwargs) | python | def split(self, string, *args, **kwargs):
return self._pattern.split(string, *args, **kwargs) | [
"def",
"split",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"split",
"(",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Apply `split`. | [
"Apply",
"split",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L332-L335 |
13,056 | facelessuser/backrefs | backrefs/bregex.py | Bregex.splititer | def splititer(self, string, *args, **kwargs):
"""Apply `splititer`."""
return self._pattern.splititer(string, *args, **kwargs) | python | def splititer(self, string, *args, **kwargs):
return self._pattern.splititer(string, *args, **kwargs) | [
"def",
"splititer",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"splititer",
"(",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Apply `splititer`. | [
"Apply",
"splititer",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L337-L340 |
13,057 | facelessuser/backrefs | backrefs/bregex.py | Bregex.findall | def findall(self, string, *args, **kwargs):
"""Apply `findall`."""
return self._pattern.findall(string, *args, **kwargs) | python | def findall(self, string, *args, **kwargs):
return self._pattern.findall(string, *args, **kwargs) | [
"def",
"findall",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"findall",
"(",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Apply `findall`. | [
"Apply",
"findall",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L342-L345 |
13,058 | facelessuser/backrefs | backrefs/bregex.py | Bregex.finditer | def finditer(self, string, *args, **kwargs):
"""Apply `finditer`."""
return self._pattern.finditer(string, *args, **kwargs) | python | def finditer(self, string, *args, **kwargs):
return self._pattern.finditer(string, *args, **kwargs) | [
"def",
"finditer",
"(",
"self",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"finditer",
"(",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Apply `finditer`. | [
"Apply",
"finditer",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L347-L350 |
13,059 | facelessuser/backrefs | backrefs/bregex.py | Bregex.sub | def sub(self, repl, string, *args, **kwargs):
"""Apply `sub`."""
return self._pattern.sub(self._auto_compile(repl), string, *args, **kwargs) | python | def sub(self, repl, string, *args, **kwargs):
return self._pattern.sub(self._auto_compile(repl), string, *args, **kwargs) | [
"def",
"sub",
"(",
"self",
",",
"repl",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_pattern",
".",
"sub",
"(",
"self",
".",
"_auto_compile",
"(",
"repl",
")",
",",
"string",
",",
"*",
"args",
",",
... | Apply `sub`. | [
"Apply",
"sub",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L352-L355 |
13,060 | facelessuser/backrefs | backrefs/_bregex_parse.py | _SearchParser.get_posix | def get_posix(self, i):
"""Get POSIX."""
index = i.index
value = ['[']
try:
c = next(i)
if c != ':':
raise ValueError('Not a valid property!')
else:
value.append(c)
c = next(i)
if c == '^':
value.append(c)
c = next(i)
while c != ':':
if c not in _PROPERTY:
raise ValueError('Not a valid property!')
if c not in _PROPERTY_STRIP:
value.append(c)
c = next(i)
value.append(c)
c = next(i)
if c != ']' or not value:
raise ValueError('Unmatched ]')
value.append(c)
except Exception:
i.rewind(i.index - index)
value = []
return ''.join(value) if value else None | python | def get_posix(self, i):
index = i.index
value = ['[']
try:
c = next(i)
if c != ':':
raise ValueError('Not a valid property!')
else:
value.append(c)
c = next(i)
if c == '^':
value.append(c)
c = next(i)
while c != ':':
if c not in _PROPERTY:
raise ValueError('Not a valid property!')
if c not in _PROPERTY_STRIP:
value.append(c)
c = next(i)
value.append(c)
c = next(i)
if c != ']' or not value:
raise ValueError('Unmatched ]')
value.append(c)
except Exception:
i.rewind(i.index - index)
value = []
return ''.join(value) if value else None | [
"def",
"get_posix",
"(",
"self",
",",
"i",
")",
":",
"index",
"=",
"i",
".",
"index",
"value",
"=",
"[",
"'['",
"]",
"try",
":",
"c",
"=",
"next",
"(",
"i",
")",
"if",
"c",
"!=",
"':'",
":",
"raise",
"ValueError",
"(",
"'Not a valid property!'",
... | Get POSIX. | [
"Get",
"POSIX",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L202-L231 |
13,061 | facelessuser/backrefs | backrefs/_bregex_parse.py | _ReplaceParser.regex_parse_template | def regex_parse_template(self, template, pattern):
"""
Parse template for the regex module.
Do NOT edit the literal list returned by
_compile_replacement_helper as you will edit
the original cached value. Copy the values
instead.
"""
groups = []
literals = []
replacements = _compile_replacement_helper(pattern, template)
count = 0
for part in replacements:
if isinstance(part, int):
literals.append(None)
groups.append((count, part))
else:
literals.append(part)
count += 1
return groups, literals | python | def regex_parse_template(self, template, pattern):
groups = []
literals = []
replacements = _compile_replacement_helper(pattern, template)
count = 0
for part in replacements:
if isinstance(part, int):
literals.append(None)
groups.append((count, part))
else:
literals.append(part)
count += 1
return groups, literals | [
"def",
"regex_parse_template",
"(",
"self",
",",
"template",
",",
"pattern",
")",
":",
"groups",
"=",
"[",
"]",
"literals",
"=",
"[",
"]",
"replacements",
"=",
"_compile_replacement_helper",
"(",
"pattern",
",",
"template",
")",
"count",
"=",
"0",
"for",
"... | Parse template for the regex module.
Do NOT edit the literal list returned by
_compile_replacement_helper as you will edit
the original cached value. Copy the values
instead. | [
"Parse",
"template",
"for",
"the",
"regex",
"module",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L980-L1001 |
13,062 | facelessuser/backrefs | backrefs/_bregex_parse.py | ReplaceTemplate.expand | def expand(self, m):
"""Using the template, expand the string."""
if m is None:
raise ValueError("Match is None!")
sep = m.string[:0]
if isinstance(sep, bytes) != self._bytes:
raise TypeError('Match string type does not match expander string type!')
text = []
# Expand string
for x in range(0, len(self.literals)):
index = x
l = self.literals[x]
if l is None:
g_index = self._get_group_index(index)
span_case, single_case, capture = self._get_group_attributes(index)
if not self.use_format:
# Non format replace
try:
l = m.group(g_index)
except IndexError: # pragma: no cover
raise IndexError("'%d' is out of range!" % capture)
else:
# String format replace
try:
obj = m.captures(g_index)
except IndexError: # pragma: no cover
raise IndexError("'%d' is out of range!" % g_index)
l = _util.format_string(m, obj, capture, self._bytes)
if span_case is not None:
if span_case == _LOWER:
l = l.lower()
else:
l = l.upper()
if single_case is not None:
if single_case == _LOWER:
l = l[0:1].lower() + l[1:]
else:
l = l[0:1].upper() + l[1:]
text.append(l)
return sep.join(text) | python | def expand(self, m):
if m is None:
raise ValueError("Match is None!")
sep = m.string[:0]
if isinstance(sep, bytes) != self._bytes:
raise TypeError('Match string type does not match expander string type!')
text = []
# Expand string
for x in range(0, len(self.literals)):
index = x
l = self.literals[x]
if l is None:
g_index = self._get_group_index(index)
span_case, single_case, capture = self._get_group_attributes(index)
if not self.use_format:
# Non format replace
try:
l = m.group(g_index)
except IndexError: # pragma: no cover
raise IndexError("'%d' is out of range!" % capture)
else:
# String format replace
try:
obj = m.captures(g_index)
except IndexError: # pragma: no cover
raise IndexError("'%d' is out of range!" % g_index)
l = _util.format_string(m, obj, capture, self._bytes)
if span_case is not None:
if span_case == _LOWER:
l = l.lower()
else:
l = l.upper()
if single_case is not None:
if single_case == _LOWER:
l = l[0:1].lower() + l[1:]
else:
l = l[0:1].upper() + l[1:]
text.append(l)
return sep.join(text) | [
"def",
"expand",
"(",
"self",
",",
"m",
")",
":",
"if",
"m",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Match is None!\"",
")",
"sep",
"=",
"m",
".",
"string",
"[",
":",
"0",
"]",
"if",
"isinstance",
"(",
"sep",
",",
"bytes",
")",
"!=",
"s... | Using the template, expand the string. | [
"Using",
"the",
"template",
"expand",
"the",
"string",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bregex_parse.py#L1290-L1332 |
13,063 | facelessuser/backrefs | tools/unipropgen.py | uniformat | def uniformat(value):
"""Convert a Unicode char."""
if value in GROUP_ESCAPES:
# Escape characters that are (or will be in the future) problematic
c = "\\x%02x\\x%02x" % (0x5c, value)
elif value <= 0xFF:
c = "\\x%02x" % value
elif value <= 0xFFFF:
c = "\\u%04x" % value
else:
c = "\\U%08x" % value
return c | python | def uniformat(value):
if value in GROUP_ESCAPES:
# Escape characters that are (or will be in the future) problematic
c = "\\x%02x\\x%02x" % (0x5c, value)
elif value <= 0xFF:
c = "\\x%02x" % value
elif value <= 0xFFFF:
c = "\\u%04x" % value
else:
c = "\\U%08x" % value
return c | [
"def",
"uniformat",
"(",
"value",
")",
":",
"if",
"value",
"in",
"GROUP_ESCAPES",
":",
"# Escape characters that are (or will be in the future) problematic",
"c",
"=",
"\"\\\\x%02x\\\\x%02x\"",
"%",
"(",
"0x5c",
",",
"value",
")",
"elif",
"value",
"<=",
"0xFF",
":",... | Convert a Unicode char. | [
"Convert",
"a",
"Unicode",
"char",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L35-L47 |
13,064 | facelessuser/backrefs | tools/unipropgen.py | create_span | def create_span(unirange, is_bytes=False):
"""Clamp the Unicode range."""
if len(unirange) < 2:
unirange.append(unirange[0])
if is_bytes:
if unirange[0] > MAXASCII:
return None
if unirange[1] > MAXASCII:
unirange[1] = MAXASCII
return [x for x in range(unirange[0], unirange[1] + 1)] | python | def create_span(unirange, is_bytes=False):
if len(unirange) < 2:
unirange.append(unirange[0])
if is_bytes:
if unirange[0] > MAXASCII:
return None
if unirange[1] > MAXASCII:
unirange[1] = MAXASCII
return [x for x in range(unirange[0], unirange[1] + 1)] | [
"def",
"create_span",
"(",
"unirange",
",",
"is_bytes",
"=",
"False",
")",
":",
"if",
"len",
"(",
"unirange",
")",
"<",
"2",
":",
"unirange",
".",
"append",
"(",
"unirange",
"[",
"0",
"]",
")",
"if",
"is_bytes",
":",
"if",
"unirange",
"[",
"0",
"]"... | Clamp the Unicode range. | [
"Clamp",
"the",
"Unicode",
"range",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L66-L76 |
13,065 | facelessuser/backrefs | tools/unipropgen.py | not_explicitly_defined | def not_explicitly_defined(table, name, is_bytes=False):
"""Compose a table with the specified entry name of values not explicitly defined."""
all_chars = ALL_ASCII if is_bytes else ALL_CHARS
s = set()
for k, v in table.items():
s.update(v)
if name in table:
table[name] = list(set(table[name]) | (all_chars - s))
else:
table[name] = list(all_chars - s) | python | def not_explicitly_defined(table, name, is_bytes=False):
all_chars = ALL_ASCII if is_bytes else ALL_CHARS
s = set()
for k, v in table.items():
s.update(v)
if name in table:
table[name] = list(set(table[name]) | (all_chars - s))
else:
table[name] = list(all_chars - s) | [
"def",
"not_explicitly_defined",
"(",
"table",
",",
"name",
",",
"is_bytes",
"=",
"False",
")",
":",
"all_chars",
"=",
"ALL_ASCII",
"if",
"is_bytes",
"else",
"ALL_CHARS",
"s",
"=",
"set",
"(",
")",
"for",
"k",
",",
"v",
"in",
"table",
".",
"items",
"("... | Compose a table with the specified entry name of values not explicitly defined. | [
"Compose",
"a",
"table",
"with",
"the",
"specified",
"entry",
"name",
"of",
"values",
"not",
"explicitly",
"defined",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L79-L89 |
13,066 | facelessuser/backrefs | tools/unipropgen.py | char2range | def char2range(d, is_bytes=False, invert=True):
"""Convert the characters in the dict to a range in string form."""
fmt = bytesformat if is_bytes else uniformat
maxrange = MAXASCII if is_bytes else MAXUNICODE
for k1 in sorted(d.keys()):
v1 = d[k1]
if not isinstance(v1, list):
char2range(v1, is_bytes=is_bytes, invert=invert)
else:
inverted = k1.startswith('^')
v1.sort()
last = None
first = None
ilast = None
ifirst = None
v2 = []
iv2 = []
if v1 and v1[0] != 0:
ifirst = 0
for i in v1:
if first is None:
first = i
last = i
elif i == last + 1:
last = i
elif first is not None:
if first == last:
v2.append(fmt(first))
else:
v2.append("%s-%s" % (fmt(first), fmt(last)))
if invert and ifirst is not None:
ilast = first - 1
if ifirst == ilast:
iv2.append(fmt(ifirst))
else:
iv2.append("%s-%s" % (fmt(ifirst), fmt(ilast)))
ifirst = last + 1
first = i
last = i
if not v1:
iv2 = ["%s-%s" % (fmt(0), fmt(maxrange))]
elif first is not None:
if first == last:
v2.append(fmt(first))
else:
v2.append("%s-%s" % (fmt(first), fmt(last)))
if invert and ifirst is not None:
ilast = first - 1
if ifirst == ilast:
iv2.append(fmt(ifirst))
else:
iv2.append("%s-%s" % (fmt(ifirst), fmt(ilast)))
ifirst = last + 1
if invert and ifirst <= maxrange:
ilast = maxrange
if ifirst == ilast:
iv2.append(fmt(ifirst))
else:
iv2.append("%s-%s" % (fmt(ifirst), fmt(ilast)))
d[k1] = ''.join(v2)
if invert:
d[k1[1:] if inverted else '^' + k1] = ''.join(iv2) | python | def char2range(d, is_bytes=False, invert=True):
fmt = bytesformat if is_bytes else uniformat
maxrange = MAXASCII if is_bytes else MAXUNICODE
for k1 in sorted(d.keys()):
v1 = d[k1]
if not isinstance(v1, list):
char2range(v1, is_bytes=is_bytes, invert=invert)
else:
inverted = k1.startswith('^')
v1.sort()
last = None
first = None
ilast = None
ifirst = None
v2 = []
iv2 = []
if v1 and v1[0] != 0:
ifirst = 0
for i in v1:
if first is None:
first = i
last = i
elif i == last + 1:
last = i
elif first is not None:
if first == last:
v2.append(fmt(first))
else:
v2.append("%s-%s" % (fmt(first), fmt(last)))
if invert and ifirst is not None:
ilast = first - 1
if ifirst == ilast:
iv2.append(fmt(ifirst))
else:
iv2.append("%s-%s" % (fmt(ifirst), fmt(ilast)))
ifirst = last + 1
first = i
last = i
if not v1:
iv2 = ["%s-%s" % (fmt(0), fmt(maxrange))]
elif first is not None:
if first == last:
v2.append(fmt(first))
else:
v2.append("%s-%s" % (fmt(first), fmt(last)))
if invert and ifirst is not None:
ilast = first - 1
if ifirst == ilast:
iv2.append(fmt(ifirst))
else:
iv2.append("%s-%s" % (fmt(ifirst), fmt(ilast)))
ifirst = last + 1
if invert and ifirst <= maxrange:
ilast = maxrange
if ifirst == ilast:
iv2.append(fmt(ifirst))
else:
iv2.append("%s-%s" % (fmt(ifirst), fmt(ilast)))
d[k1] = ''.join(v2)
if invert:
d[k1[1:] if inverted else '^' + k1] = ''.join(iv2) | [
"def",
"char2range",
"(",
"d",
",",
"is_bytes",
"=",
"False",
",",
"invert",
"=",
"True",
")",
":",
"fmt",
"=",
"bytesformat",
"if",
"is_bytes",
"else",
"uniformat",
"maxrange",
"=",
"MAXASCII",
"if",
"is_bytes",
"else",
"MAXUNICODE",
"for",
"k1",
"in",
... | Convert the characters in the dict to a range in string form. | [
"Convert",
"the",
"characters",
"in",
"the",
"dict",
"to",
"a",
"range",
"in",
"string",
"form",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L92-L156 |
13,067 | facelessuser/backrefs | tools/unipropgen.py | gen_ccc | def gen_ccc(output, ascii_props=False, append=False, prefix=""):
"""Generate `canonical combining class` property."""
obj = {}
with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedCombiningClass.txt'), 'r', 'utf-8') as uf:
for line in uf:
if not line.startswith('#'):
data = line.split('#')[0].split(';')
if len(data) < 2:
continue
span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
if span is None:
continue
name = format_name(data[1])
if name not in obj:
obj[name] = []
obj[name].extend(span)
for x in range(0, 256):
key = str(x)
if key not in obj:
obj[key] = []
for name in list(obj.keys()):
s = set(obj[name])
obj[name] = sorted(s)
not_explicitly_defined(obj, '0', is_bytes=ascii_props)
# Convert characters values to ranges
char2range(obj, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
# Write out the Unicode properties
f.write('%s_canonical_combining_class = {\n' % prefix)
count = len(obj) - 1
i = 0
for k1, v1 in sorted(obj.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1 | python | def gen_ccc(output, ascii_props=False, append=False, prefix=""):
obj = {}
with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedCombiningClass.txt'), 'r', 'utf-8') as uf:
for line in uf:
if not line.startswith('#'):
data = line.split('#')[0].split(';')
if len(data) < 2:
continue
span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
if span is None:
continue
name = format_name(data[1])
if name not in obj:
obj[name] = []
obj[name].extend(span)
for x in range(0, 256):
key = str(x)
if key not in obj:
obj[key] = []
for name in list(obj.keys()):
s = set(obj[name])
obj[name] = sorted(s)
not_explicitly_defined(obj, '0', is_bytes=ascii_props)
# Convert characters values to ranges
char2range(obj, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
# Write out the Unicode properties
f.write('%s_canonical_combining_class = {\n' % prefix)
count = len(obj) - 1
i = 0
for k1, v1 in sorted(obj.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1 | [
"def",
"gen_ccc",
"(",
"output",
",",
"ascii_props",
"=",
"False",
",",
"append",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"obj",
"=",
"{",
"}",
"with",
"codecs",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"HOME",
",",
"'un... | Generate `canonical combining class` property. | [
"Generate",
"canonical",
"combining",
"class",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L220-L266 |
13,068 | facelessuser/backrefs | tools/unipropgen.py | gen_age | def gen_age(output, ascii_props=False, append=False, prefix=""):
"""Generate `age` property."""
obj = {}
all_chars = ALL_ASCII if ascii_props else ALL_CHARS
with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedAge.txt'), 'r', 'utf-8') as uf:
for line in uf:
if not line.startswith('#'):
data = line.split('#')[0].split(';')
if len(data) < 2:
continue
span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
name = format_name(data[1])
if name not in obj:
obj[name] = []
if span is None:
continue
obj[name].extend(span)
unassigned = set()
for x in obj.values():
unassigned |= set(x)
obj['na'] = list(all_chars - unassigned)
for name in list(obj.keys()):
s = set(obj[name])
obj[name] = sorted(s)
# Convert characters values to ranges
char2range(obj, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
# Write out the Unicode properties
f.write('%s_age = {\n' % prefix)
count = len(obj) - 1
i = 0
for k1, v1 in sorted(obj.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1 | python | def gen_age(output, ascii_props=False, append=False, prefix=""):
obj = {}
all_chars = ALL_ASCII if ascii_props else ALL_CHARS
with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedAge.txt'), 'r', 'utf-8') as uf:
for line in uf:
if not line.startswith('#'):
data = line.split('#')[0].split(';')
if len(data) < 2:
continue
span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
name = format_name(data[1])
if name not in obj:
obj[name] = []
if span is None:
continue
obj[name].extend(span)
unassigned = set()
for x in obj.values():
unassigned |= set(x)
obj['na'] = list(all_chars - unassigned)
for name in list(obj.keys()):
s = set(obj[name])
obj[name] = sorted(s)
# Convert characters values to ranges
char2range(obj, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
# Write out the Unicode properties
f.write('%s_age = {\n' % prefix)
count = len(obj) - 1
i = 0
for k1, v1 in sorted(obj.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1 | [
"def",
"gen_age",
"(",
"output",
",",
"ascii_props",
"=",
"False",
",",
"append",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"obj",
"=",
"{",
"}",
"all_chars",
"=",
"ALL_ASCII",
"if",
"ascii_props",
"else",
"ALL_CHARS",
"with",
"codecs",
".",
... | Generate `age` property. | [
"Generate",
"age",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L412-L459 |
13,069 | facelessuser/backrefs | tools/unipropgen.py | gen_nf_quick_check | def gen_nf_quick_check(output, ascii_props=False, append=False, prefix=""):
"""Generate quick check properties."""
categories = []
nf = {}
all_chars = ALL_ASCII if ascii_props else ALL_CHARS
file_name = os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedNormalizationProps.txt')
with codecs.open(file_name, 'r', 'utf-8') as uf:
for line in uf:
if not line.startswith('#'):
data = line.split('#')[0].split(';')
if len(data) < 2:
continue
if not data[1].strip().lower().endswith('_qc'):
continue
span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
if span is None:
continue
name = format_name(data[1][:-3] + 'quickcheck')
subvalue = format_name(data[2])
if name not in nf:
nf[name] = {}
categories.append(name)
if subvalue not in nf[name]:
nf[name][subvalue] = []
nf[name][subvalue].extend(span)
for k1, v1 in nf.items():
temp = set()
for k2 in list(v1.keys()):
temp |= set(v1[k2])
v1['y'] = list(all_chars - temp)
for k1, v1 in nf.items():
for name in list(v1.keys()):
s = set(nf[k1][name])
nf[k1][name] = sorted(s)
# Convert characters values to ranges
char2range(nf, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
for key, value in sorted(nf.items()):
# Write out the Unicode properties
f.write('%s_%s = {\n' % (prefix, key.replace('quickcheck', '_quick_check')))
count = len(value) - 1
i = 0
for k1, v1 in sorted(value.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1
return categories | python | def gen_nf_quick_check(output, ascii_props=False, append=False, prefix=""):
categories = []
nf = {}
all_chars = ALL_ASCII if ascii_props else ALL_CHARS
file_name = os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedNormalizationProps.txt')
with codecs.open(file_name, 'r', 'utf-8') as uf:
for line in uf:
if not line.startswith('#'):
data = line.split('#')[0].split(';')
if len(data) < 2:
continue
if not data[1].strip().lower().endswith('_qc'):
continue
span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
if span is None:
continue
name = format_name(data[1][:-3] + 'quickcheck')
subvalue = format_name(data[2])
if name not in nf:
nf[name] = {}
categories.append(name)
if subvalue not in nf[name]:
nf[name][subvalue] = []
nf[name][subvalue].extend(span)
for k1, v1 in nf.items():
temp = set()
for k2 in list(v1.keys()):
temp |= set(v1[k2])
v1['y'] = list(all_chars - temp)
for k1, v1 in nf.items():
for name in list(v1.keys()):
s = set(nf[k1][name])
nf[k1][name] = sorted(s)
# Convert characters values to ranges
char2range(nf, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
for key, value in sorted(nf.items()):
# Write out the Unicode properties
f.write('%s_%s = {\n' % (prefix, key.replace('quickcheck', '_quick_check')))
count = len(value) - 1
i = 0
for k1, v1 in sorted(value.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1
return categories | [
"def",
"gen_nf_quick_check",
"(",
"output",
",",
"ascii_props",
"=",
"False",
",",
"append",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"categories",
"=",
"[",
"]",
"nf",
"=",
"{",
"}",
"all_chars",
"=",
"ALL_ASCII",
"if",
"ascii_props",
"else",... | Generate quick check properties. | [
"Generate",
"quick",
"check",
"properties",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L462-L520 |
13,070 | facelessuser/backrefs | tools/unipropgen.py | gen_bidi | def gen_bidi(output, ascii_props=False, append=False, prefix=""):
"""Generate `bidi class` property."""
bidi_class = {}
max_range = MAXASCII if ascii_props else MAXUNICODE
with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'UnicodeData.txt'), 'r', 'utf-8') as uf:
for line in uf:
data = line.strip().split(';')
if data:
bidi = data[4].strip().lower()
if not bidi:
continue
value = int(data[0].strip(), 16)
if bidi not in bidi_class:
bidi_class[bidi] = []
if value > max_range:
continue
bidi_class[bidi].append(value)
for name in list(bidi_class.keys()):
s = set(bidi_class[name])
bidi_class[name] = sorted(s)
# Convert characters values to ranges
char2range(bidi_class, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
f.write('%s_bidi_classes = {\n' % prefix)
count = len(bidi_class) - 1
i = 0
for k1, v1 in sorted(bidi_class.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1 | python | def gen_bidi(output, ascii_props=False, append=False, prefix=""):
bidi_class = {}
max_range = MAXASCII if ascii_props else MAXUNICODE
with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'UnicodeData.txt'), 'r', 'utf-8') as uf:
for line in uf:
data = line.strip().split(';')
if data:
bidi = data[4].strip().lower()
if not bidi:
continue
value = int(data[0].strip(), 16)
if bidi not in bidi_class:
bidi_class[bidi] = []
if value > max_range:
continue
bidi_class[bidi].append(value)
for name in list(bidi_class.keys()):
s = set(bidi_class[name])
bidi_class[name] = sorted(s)
# Convert characters values to ranges
char2range(bidi_class, is_bytes=ascii_props)
with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
if not append:
f.write(HEADER)
f.write('%s_bidi_classes = {\n' % prefix)
count = len(bidi_class) - 1
i = 0
for k1, v1 in sorted(bidi_class.items()):
f.write(' "%s": "%s"' % (k1, v1))
if i == count:
f.write('\n}\n')
else:
f.write(',\n')
i += 1 | [
"def",
"gen_bidi",
"(",
"output",
",",
"ascii_props",
"=",
"False",
",",
"append",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"bidi_class",
"=",
"{",
"}",
"max_range",
"=",
"MAXASCII",
"if",
"ascii_props",
"else",
"MAXUNICODE",
"with",
"codecs",
... | Generate `bidi class` property. | [
"Generate",
"bidi",
"class",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L612-L653 |
13,071 | facelessuser/backrefs | tools/unipropgen.py | gen_uposix | def gen_uposix(table, posix_table):
"""Generate the posix table and write out to file."""
# `Alnum: [\p{L&}\p{Nd}]`
s = set(table['l']['c'] + table['n']['d'])
posix_table["posixalnum"] = list(s)
# `Alpha: [\p{L&}]`
s = set(table['l']['c'])
posix_table["posixalpha"] = list(s)
# `ASCII: [\x00-\x7F]`
s = set([x for x in range(0, 0x7F + 1)])
posix_table["posixascii"] = list(s)
# `Blank: [\p{Zs}\t]`
s = set(table['z']['s'] + [0x09])
posix_table["posixblank"] = list(s)
# `Cntrl: [\p{Cc}]`
s = set(table['c']['c'])
posix_table["posixcntrl"] = list(s)
# `Digit: [\p{Nd}]`
s = set(table['n']['d'])
posix_table["posixdigit"] = list(s)
# `Graph: [^\p{Z}\p{C}]`
s = set()
for table_name in ('z', 'c'):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
posix_table["^posixgraph"] = list(s)
# `Lower: [\p{Ll}]`
s = set(table['l']['l'])
posix_table["posixlower"] = list(s)
# `Print: [\P{C}]`
s = set()
for table_name in ('c',):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
posix_table["^posixprint"] = list(s)
# `Punct: [\p{P}\p{S}]`
s = set()
for table_name in ('p', 's'):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
posix_table["posixpunct"] = list(s)
# `Space: [\p{Z}\t\r\n\v\f]`
s = set()
for table_name in ('z',):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
s |= set([x for x in range(0x09, 0x0e)])
posix_table["posixspace"] = list(s)
# `Upper: [\p{Lu}]`
s = set(table['l']['u'])
posix_table["posixupper"] = list(s)
# `XDigit: [A-Fa-f0-9]`
s = set([x for x in range(0x30, 0x39 + 1)])
s |= set([x for x in range(0x41, 0x46 + 1)])
s |= set([x for x in range(0x61, 0x66 + 1)])
posix_table["posixxdigit"] = list(s) | python | def gen_uposix(table, posix_table):
# `Alnum: [\p{L&}\p{Nd}]`
s = set(table['l']['c'] + table['n']['d'])
posix_table["posixalnum"] = list(s)
# `Alpha: [\p{L&}]`
s = set(table['l']['c'])
posix_table["posixalpha"] = list(s)
# `ASCII: [\x00-\x7F]`
s = set([x for x in range(0, 0x7F + 1)])
posix_table["posixascii"] = list(s)
# `Blank: [\p{Zs}\t]`
s = set(table['z']['s'] + [0x09])
posix_table["posixblank"] = list(s)
# `Cntrl: [\p{Cc}]`
s = set(table['c']['c'])
posix_table["posixcntrl"] = list(s)
# `Digit: [\p{Nd}]`
s = set(table['n']['d'])
posix_table["posixdigit"] = list(s)
# `Graph: [^\p{Z}\p{C}]`
s = set()
for table_name in ('z', 'c'):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
posix_table["^posixgraph"] = list(s)
# `Lower: [\p{Ll}]`
s = set(table['l']['l'])
posix_table["posixlower"] = list(s)
# `Print: [\P{C}]`
s = set()
for table_name in ('c',):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
posix_table["^posixprint"] = list(s)
# `Punct: [\p{P}\p{S}]`
s = set()
for table_name in ('p', 's'):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
posix_table["posixpunct"] = list(s)
# `Space: [\p{Z}\t\r\n\v\f]`
s = set()
for table_name in ('z',):
for sub_table_name in table[table_name]:
if not sub_table_name.startswith('^'):
s |= set(table[table_name][sub_table_name])
s |= set([x for x in range(0x09, 0x0e)])
posix_table["posixspace"] = list(s)
# `Upper: [\p{Lu}]`
s = set(table['l']['u'])
posix_table["posixupper"] = list(s)
# `XDigit: [A-Fa-f0-9]`
s = set([x for x in range(0x30, 0x39 + 1)])
s |= set([x for x in range(0x41, 0x46 + 1)])
s |= set([x for x in range(0x61, 0x66 + 1)])
posix_table["posixxdigit"] = list(s) | [
"def",
"gen_uposix",
"(",
"table",
",",
"posix_table",
")",
":",
"# `Alnum: [\\p{L&}\\p{Nd}]`",
"s",
"=",
"set",
"(",
"table",
"[",
"'l'",
"]",
"[",
"'c'",
"]",
"+",
"table",
"[",
"'n'",
"]",
"[",
"'d'",
"]",
")",
"posix_table",
"[",
"\"posixalnum\"",
... | Generate the posix table and write out to file. | [
"Generate",
"the",
"posix",
"table",
"and",
"write",
"out",
"to",
"file",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L740-L812 |
13,072 | facelessuser/backrefs | tools/unipropgen.py | set_version | def set_version(version):
"""Set version."""
global UNIVERSION
global UNIVERSION_INFO
if version is None:
version = unicodedata.unidata_version
UNIVERSION = version
UNIVERSION_INFO = tuple([int(x) for x in UNIVERSION.split('.')]) | python | def set_version(version):
global UNIVERSION
global UNIVERSION_INFO
if version is None:
version = unicodedata.unidata_version
UNIVERSION = version
UNIVERSION_INFO = tuple([int(x) for x in UNIVERSION.split('.')]) | [
"def",
"set_version",
"(",
"version",
")",
":",
"global",
"UNIVERSION",
"global",
"UNIVERSION_INFO",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"unicodedata",
".",
"unidata_version",
"UNIVERSION",
"=",
"version",
"UNIVERSION_INFO",
"=",
"tuple",
"(",
"[... | Set version. | [
"Set",
"version",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/tools/unipropgen.py#L1239-L1249 |
13,073 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_posix_property | def get_posix_property(value, mode=POSIX):
"""Retrieve the posix category."""
if mode == POSIX_BYTES:
return unidata.ascii_posix_properties[value]
elif mode == POSIX_UNICODE:
return unidata.unicode_binary[
('^posix' + value[1:]) if value.startswith('^') else ('posix' + value)
]
else:
return unidata.unicode_posix_properties[value] | python | def get_posix_property(value, mode=POSIX):
if mode == POSIX_BYTES:
return unidata.ascii_posix_properties[value]
elif mode == POSIX_UNICODE:
return unidata.unicode_binary[
('^posix' + value[1:]) if value.startswith('^') else ('posix' + value)
]
else:
return unidata.unicode_posix_properties[value] | [
"def",
"get_posix_property",
"(",
"value",
",",
"mode",
"=",
"POSIX",
")",
":",
"if",
"mode",
"==",
"POSIX_BYTES",
":",
"return",
"unidata",
".",
"ascii_posix_properties",
"[",
"value",
"]",
"elif",
"mode",
"==",
"POSIX_UNICODE",
":",
"return",
"unidata",
".... | Retrieve the posix category. | [
"Retrieve",
"the",
"posix",
"category",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L16-L26 |
13,074 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_gc_property | def get_gc_property(value, is_bytes=False):
"""Get `GC` property."""
obj = unidata.ascii_properties if is_bytes else unidata.unicode_properties
if value.startswith('^'):
negate = True
value = value[1:]
else:
negate = False
value = unidata.unicode_alias['generalcategory'].get(value, value)
assert 1 <= len(value) <= 2, 'Invalid property!'
if not negate:
p1, p2 = (value[0], value[1]) if len(value) > 1 else (value[0], None)
value = ''.join(
[v for k, v in obj.get(p1, {}).items() if not k.startswith('^')]
) if p2 is None else obj.get(p1, {}).get(p2, '')
else:
p1, p2 = (value[0], value[1]) if len(value) > 1 else (value[0], '')
value = obj.get(p1, {}).get('^' + p2, '')
assert value, 'Invalid property!'
return value | python | def get_gc_property(value, is_bytes=False):
obj = unidata.ascii_properties if is_bytes else unidata.unicode_properties
if value.startswith('^'):
negate = True
value = value[1:]
else:
negate = False
value = unidata.unicode_alias['generalcategory'].get(value, value)
assert 1 <= len(value) <= 2, 'Invalid property!'
if not negate:
p1, p2 = (value[0], value[1]) if len(value) > 1 else (value[0], None)
value = ''.join(
[v for k, v in obj.get(p1, {}).items() if not k.startswith('^')]
) if p2 is None else obj.get(p1, {}).get(p2, '')
else:
p1, p2 = (value[0], value[1]) if len(value) > 1 else (value[0], '')
value = obj.get(p1, {}).get('^' + p2, '')
assert value, 'Invalid property!'
return value | [
"def",
"get_gc_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_properties",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_properties",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"negate",... | Get `GC` property. | [
"Get",
"GC",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L29-L53 |
13,075 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_binary_property | def get_binary_property(value, is_bytes=False):
"""Get `BINARY` property."""
obj = unidata.ascii_binary if is_bytes else unidata.unicode_binary
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['binary'].get(negated, negated)
else:
value = unidata.unicode_alias['binary'].get(value, value)
return obj[value] | python | def get_binary_property(value, is_bytes=False):
obj = unidata.ascii_binary if is_bytes else unidata.unicode_binary
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['binary'].get(negated, negated)
else:
value = unidata.unicode_alias['binary'].get(value, value)
return obj[value] | [
"def",
"get_binary_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_binary",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_binary",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"negated",
... | Get `BINARY` property. | [
"Get",
"BINARY",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L56-L67 |
13,076 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_canonical_combining_class_property | def get_canonical_combining_class_property(value, is_bytes=False):
"""Get `CANONICAL COMBINING CLASS` property."""
obj = unidata.ascii_canonical_combining_class if is_bytes else unidata.unicode_canonical_combining_class
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['canonicalcombiningclass'].get(negated, negated)
else:
value = unidata.unicode_alias['canonicalcombiningclass'].get(value, value)
return obj[value] | python | def get_canonical_combining_class_property(value, is_bytes=False):
obj = unidata.ascii_canonical_combining_class if is_bytes else unidata.unicode_canonical_combining_class
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['canonicalcombiningclass'].get(negated, negated)
else:
value = unidata.unicode_alias['canonicalcombiningclass'].get(value, value)
return obj[value] | [
"def",
"get_canonical_combining_class_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_canonical_combining_class",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_canonical_combining_class",
"if",
"value",
".",
"s... | Get `CANONICAL COMBINING CLASS` property. | [
"Get",
"CANONICAL",
"COMBINING",
"CLASS",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L70-L81 |
13,077 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_east_asian_width_property | def get_east_asian_width_property(value, is_bytes=False):
"""Get `EAST ASIAN WIDTH` property."""
obj = unidata.ascii_east_asian_width if is_bytes else unidata.unicode_east_asian_width
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['eastasianwidth'].get(negated, negated)
else:
value = unidata.unicode_alias['eastasianwidth'].get(value, value)
return obj[value] | python | def get_east_asian_width_property(value, is_bytes=False):
obj = unidata.ascii_east_asian_width if is_bytes else unidata.unicode_east_asian_width
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['eastasianwidth'].get(negated, negated)
else:
value = unidata.unicode_alias['eastasianwidth'].get(value, value)
return obj[value] | [
"def",
"get_east_asian_width_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_east_asian_width",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_east_asian_width",
"if",
"value",
".",
"startswith",
"(",
"'^'",... | Get `EAST ASIAN WIDTH` property. | [
"Get",
"EAST",
"ASIAN",
"WIDTH",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L84-L95 |
13,078 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_grapheme_cluster_break_property | def get_grapheme_cluster_break_property(value, is_bytes=False):
"""Get `GRAPHEME CLUSTER BREAK` property."""
obj = unidata.ascii_grapheme_cluster_break if is_bytes else unidata.unicode_grapheme_cluster_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['graphemeclusterbreak'].get(negated, negated)
else:
value = unidata.unicode_alias['graphemeclusterbreak'].get(value, value)
return obj[value] | python | def get_grapheme_cluster_break_property(value, is_bytes=False):
obj = unidata.ascii_grapheme_cluster_break if is_bytes else unidata.unicode_grapheme_cluster_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['graphemeclusterbreak'].get(negated, negated)
else:
value = unidata.unicode_alias['graphemeclusterbreak'].get(value, value)
return obj[value] | [
"def",
"get_grapheme_cluster_break_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_grapheme_cluster_break",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_grapheme_cluster_break",
"if",
"value",
".",
"startswith... | Get `GRAPHEME CLUSTER BREAK` property. | [
"Get",
"GRAPHEME",
"CLUSTER",
"BREAK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L98-L109 |
13,079 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_line_break_property | def get_line_break_property(value, is_bytes=False):
"""Get `LINE BREAK` property."""
obj = unidata.ascii_line_break if is_bytes else unidata.unicode_line_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['linebreak'].get(negated, negated)
else:
value = unidata.unicode_alias['linebreak'].get(value, value)
return obj[value] | python | def get_line_break_property(value, is_bytes=False):
obj = unidata.ascii_line_break if is_bytes else unidata.unicode_line_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['linebreak'].get(negated, negated)
else:
value = unidata.unicode_alias['linebreak'].get(value, value)
return obj[value] | [
"def",
"get_line_break_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_line_break",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_line_break",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"... | Get `LINE BREAK` property. | [
"Get",
"LINE",
"BREAK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L112-L123 |
13,080 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_sentence_break_property | def get_sentence_break_property(value, is_bytes=False):
"""Get `SENTENCE BREAK` property."""
obj = unidata.ascii_sentence_break if is_bytes else unidata.unicode_sentence_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['sentencebreak'].get(negated, negated)
else:
value = unidata.unicode_alias['sentencebreak'].get(value, value)
return obj[value] | python | def get_sentence_break_property(value, is_bytes=False):
obj = unidata.ascii_sentence_break if is_bytes else unidata.unicode_sentence_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['sentencebreak'].get(negated, negated)
else:
value = unidata.unicode_alias['sentencebreak'].get(value, value)
return obj[value] | [
"def",
"get_sentence_break_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_sentence_break",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_sentence_break",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")"... | Get `SENTENCE BREAK` property. | [
"Get",
"SENTENCE",
"BREAK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L126-L137 |
13,081 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_word_break_property | def get_word_break_property(value, is_bytes=False):
"""Get `WORD BREAK` property."""
obj = unidata.ascii_word_break if is_bytes else unidata.unicode_word_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['wordbreak'].get(negated, negated)
else:
value = unidata.unicode_alias['wordbreak'].get(value, value)
return obj[value] | python | def get_word_break_property(value, is_bytes=False):
obj = unidata.ascii_word_break if is_bytes else unidata.unicode_word_break
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['wordbreak'].get(negated, negated)
else:
value = unidata.unicode_alias['wordbreak'].get(value, value)
return obj[value] | [
"def",
"get_word_break_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_word_break",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_word_break",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"... | Get `WORD BREAK` property. | [
"Get",
"WORD",
"BREAK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L140-L151 |
13,082 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_hangul_syllable_type_property | def get_hangul_syllable_type_property(value, is_bytes=False):
"""Get `HANGUL SYLLABLE TYPE` property."""
obj = unidata.ascii_hangul_syllable_type if is_bytes else unidata.unicode_hangul_syllable_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['hangulsyllabletype'].get(negated, negated)
else:
value = unidata.unicode_alias['hangulsyllabletype'].get(value, value)
return obj[value] | python | def get_hangul_syllable_type_property(value, is_bytes=False):
obj = unidata.ascii_hangul_syllable_type if is_bytes else unidata.unicode_hangul_syllable_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['hangulsyllabletype'].get(negated, negated)
else:
value = unidata.unicode_alias['hangulsyllabletype'].get(value, value)
return obj[value] | [
"def",
"get_hangul_syllable_type_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_hangul_syllable_type",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_hangul_syllable_type",
"if",
"value",
".",
"startswith",
"... | Get `HANGUL SYLLABLE TYPE` property. | [
"Get",
"HANGUL",
"SYLLABLE",
"TYPE",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L154-L165 |
13,083 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_indic_syllabic_category_property | def get_indic_syllabic_category_property(value, is_bytes=False):
"""Get `INDIC SYLLABIC CATEGORY` property."""
obj = unidata.ascii_indic_syllabic_category if is_bytes else unidata.unicode_indic_syllabic_category
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['indicsyllabiccategory'].get(negated, negated)
else:
value = unidata.unicode_alias['indicsyllabiccategory'].get(value, value)
return obj[value] | python | def get_indic_syllabic_category_property(value, is_bytes=False):
obj = unidata.ascii_indic_syllabic_category if is_bytes else unidata.unicode_indic_syllabic_category
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['indicsyllabiccategory'].get(negated, negated)
else:
value = unidata.unicode_alias['indicsyllabiccategory'].get(value, value)
return obj[value] | [
"def",
"get_indic_syllabic_category_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_indic_syllabic_category",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_indic_syllabic_category",
"if",
"value",
".",
"startsw... | Get `INDIC SYLLABIC CATEGORY` property. | [
"Get",
"INDIC",
"SYLLABIC",
"CATEGORY",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L187-L198 |
13,084 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_decomposition_type_property | def get_decomposition_type_property(value, is_bytes=False):
"""Get `DECOMPOSITION TYPE` property."""
obj = unidata.ascii_decomposition_type if is_bytes else unidata.unicode_decomposition_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['decompositiontype'].get(negated, negated)
else:
value = unidata.unicode_alias['decompositiontype'].get(value, value)
return obj[value] | python | def get_decomposition_type_property(value, is_bytes=False):
obj = unidata.ascii_decomposition_type if is_bytes else unidata.unicode_decomposition_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['decompositiontype'].get(negated, negated)
else:
value = unidata.unicode_alias['decompositiontype'].get(value, value)
return obj[value] | [
"def",
"get_decomposition_type_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_decomposition_type",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_decomposition_type",
"if",
"value",
".",
"startswith",
"(",
... | Get `DECOMPOSITION TYPE` property. | [
"Get",
"DECOMPOSITION",
"TYPE",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L201-L212 |
13,085 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_nfc_quick_check_property | def get_nfc_quick_check_property(value, is_bytes=False):
"""Get `NFC QUICK CHECK` property."""
obj = unidata.ascii_nfc_quick_check if is_bytes else unidata.unicode_nfc_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfcquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfcquickcheck'].get(value, value)
return obj[value] | python | def get_nfc_quick_check_property(value, is_bytes=False):
obj = unidata.ascii_nfc_quick_check if is_bytes else unidata.unicode_nfc_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfcquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfcquickcheck'].get(value, value)
return obj[value] | [
"def",
"get_nfc_quick_check_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_nfc_quick_check",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_nfc_quick_check",
"if",
"value",
".",
"startswith",
"(",
"'^'",
... | Get `NFC QUICK CHECK` property. | [
"Get",
"NFC",
"QUICK",
"CHECK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L215-L226 |
13,086 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_nfd_quick_check_property | def get_nfd_quick_check_property(value, is_bytes=False):
"""Get `NFD QUICK CHECK` property."""
obj = unidata.ascii_nfd_quick_check if is_bytes else unidata.unicode_nfd_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfdquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfdquickcheck'].get(value, value)
return obj[value] | python | def get_nfd_quick_check_property(value, is_bytes=False):
obj = unidata.ascii_nfd_quick_check if is_bytes else unidata.unicode_nfd_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfdquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfdquickcheck'].get(value, value)
return obj[value] | [
"def",
"get_nfd_quick_check_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_nfd_quick_check",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_nfd_quick_check",
"if",
"value",
".",
"startswith",
"(",
"'^'",
... | Get `NFD QUICK CHECK` property. | [
"Get",
"NFD",
"QUICK",
"CHECK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L229-L240 |
13,087 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_nfkc_quick_check_property | def get_nfkc_quick_check_property(value, is_bytes=False):
"""Get `NFKC QUICK CHECK` property."""
obj = unidata.ascii_nfkc_quick_check if is_bytes else unidata.unicode_nfkc_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfkcquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfkcquickcheck'].get(value, value)
return obj[value] | python | def get_nfkc_quick_check_property(value, is_bytes=False):
obj = unidata.ascii_nfkc_quick_check if is_bytes else unidata.unicode_nfkc_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfkcquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfkcquickcheck'].get(value, value)
return obj[value] | [
"def",
"get_nfkc_quick_check_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_nfkc_quick_check",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_nfkc_quick_check",
"if",
"value",
".",
"startswith",
"(",
"'^'",... | Get `NFKC QUICK CHECK` property. | [
"Get",
"NFKC",
"QUICK",
"CHECK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L243-L254 |
13,088 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_nfkd_quick_check_property | def get_nfkd_quick_check_property(value, is_bytes=False):
"""Get `NFKD QUICK CHECK` property."""
obj = unidata.ascii_nfkd_quick_check if is_bytes else unidata.unicode_nfkd_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfkdquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfkdquickcheck'].get(value, value)
return obj[value] | python | def get_nfkd_quick_check_property(value, is_bytes=False):
obj = unidata.ascii_nfkd_quick_check if is_bytes else unidata.unicode_nfkd_quick_check
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['nfkdquickcheck'].get(negated, negated)
else:
value = unidata.unicode_alias['nfkdquickcheck'].get(value, value)
return obj[value] | [
"def",
"get_nfkd_quick_check_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_nfkd_quick_check",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_nfkd_quick_check",
"if",
"value",
".",
"startswith",
"(",
"'^'",... | Get `NFKD QUICK CHECK` property. | [
"Get",
"NFKD",
"QUICK",
"CHECK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L257-L268 |
13,089 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_numeric_type_property | def get_numeric_type_property(value, is_bytes=False):
"""Get `NUMERIC TYPE` property."""
obj = unidata.ascii_numeric_type if is_bytes else unidata.unicode_numeric_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['numerictype'].get(negated, negated)
else:
value = unidata.unicode_alias['numerictype'].get(value, value)
return obj[value] | python | def get_numeric_type_property(value, is_bytes=False):
obj = unidata.ascii_numeric_type if is_bytes else unidata.unicode_numeric_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['numerictype'].get(negated, negated)
else:
value = unidata.unicode_alias['numerictype'].get(value, value)
return obj[value] | [
"def",
"get_numeric_type_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_numeric_type",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_numeric_type",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":... | Get `NUMERIC TYPE` property. | [
"Get",
"NUMERIC",
"TYPE",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L271-L282 |
13,090 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_numeric_value_property | def get_numeric_value_property(value, is_bytes=False):
"""Get `NUMERIC VALUE` property."""
obj = unidata.ascii_numeric_values if is_bytes else unidata.unicode_numeric_values
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['numericvalue'].get(negated, negated)
else:
value = unidata.unicode_alias['numericvalue'].get(value, value)
return obj[value] | python | def get_numeric_value_property(value, is_bytes=False):
obj = unidata.ascii_numeric_values if is_bytes else unidata.unicode_numeric_values
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['numericvalue'].get(negated, negated)
else:
value = unidata.unicode_alias['numericvalue'].get(value, value)
return obj[value] | [
"def",
"get_numeric_value_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_numeric_values",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_numeric_values",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",... | Get `NUMERIC VALUE` property. | [
"Get",
"NUMERIC",
"VALUE",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L285-L296 |
13,091 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_age_property | def get_age_property(value, is_bytes=False):
"""Get `AGE` property."""
obj = unidata.ascii_age if is_bytes else unidata.unicode_age
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['age'].get(negated, negated)
else:
value = unidata.unicode_alias['age'].get(value, value)
return obj[value] | python | def get_age_property(value, is_bytes=False):
obj = unidata.ascii_age if is_bytes else unidata.unicode_age
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['age'].get(negated, negated)
else:
value = unidata.unicode_alias['age'].get(value, value)
return obj[value] | [
"def",
"get_age_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_age",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_age",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"negated",
"=",
"v... | Get `AGE` property. | [
"Get",
"AGE",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L299-L310 |
13,092 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_joining_type_property | def get_joining_type_property(value, is_bytes=False):
"""Get `JOINING TYPE` property."""
obj = unidata.ascii_joining_type if is_bytes else unidata.unicode_joining_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['joiningtype'].get(negated, negated)
else:
value = unidata.unicode_alias['joiningtype'].get(value, value)
return obj[value] | python | def get_joining_type_property(value, is_bytes=False):
obj = unidata.ascii_joining_type if is_bytes else unidata.unicode_joining_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['joiningtype'].get(negated, negated)
else:
value = unidata.unicode_alias['joiningtype'].get(value, value)
return obj[value] | [
"def",
"get_joining_type_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_joining_type",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_joining_type",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":... | Get `JOINING TYPE` property. | [
"Get",
"JOINING",
"TYPE",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L313-L324 |
13,093 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_joining_group_property | def get_joining_group_property(value, is_bytes=False):
"""Get `JOINING GROUP` property."""
obj = unidata.ascii_joining_group if is_bytes else unidata.unicode_joining_group
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['joininggroup'].get(negated, negated)
else:
value = unidata.unicode_alias['joininggroup'].get(value, value)
return obj[value] | python | def get_joining_group_property(value, is_bytes=False):
obj = unidata.ascii_joining_group if is_bytes else unidata.unicode_joining_group
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['joininggroup'].get(negated, negated)
else:
value = unidata.unicode_alias['joininggroup'].get(value, value)
return obj[value] | [
"def",
"get_joining_group_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_joining_group",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_joining_group",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
... | Get `JOINING GROUP` property. | [
"Get",
"JOINING",
"GROUP",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L327-L338 |
13,094 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_script_property | def get_script_property(value, is_bytes=False):
"""Get `SC` property."""
obj = unidata.ascii_scripts if is_bytes else unidata.unicode_scripts
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['script'].get(negated, negated)
else:
value = unidata.unicode_alias['script'].get(value, value)
return obj[value] | python | def get_script_property(value, is_bytes=False):
obj = unidata.ascii_scripts if is_bytes else unidata.unicode_scripts
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['script'].get(negated, negated)
else:
value = unidata.unicode_alias['script'].get(value, value)
return obj[value] | [
"def",
"get_script_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_scripts",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_scripts",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"negated",
... | Get `SC` property. | [
"Get",
"SC",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L341-L352 |
13,095 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_script_extension_property | def get_script_extension_property(value, is_bytes=False):
"""Get `SCX` property."""
obj = unidata.ascii_script_extensions if is_bytes else unidata.unicode_script_extensions
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['script'].get(negated, negated)
else:
value = unidata.unicode_alias['script'].get(value, value)
return obj[value] | python | def get_script_extension_property(value, is_bytes=False):
obj = unidata.ascii_script_extensions if is_bytes else unidata.unicode_script_extensions
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['script'].get(negated, negated)
else:
value = unidata.unicode_alias['script'].get(value, value)
return obj[value] | [
"def",
"get_script_extension_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_script_extensions",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_script_extensions",
"if",
"value",
".",
"startswith",
"(",
"'^'... | Get `SCX` property. | [
"Get",
"SCX",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L355-L366 |
13,096 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_block_property | def get_block_property(value, is_bytes=False):
"""Get `BLK` property."""
obj = unidata.ascii_blocks if is_bytes else unidata.unicode_blocks
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['block'].get(negated, negated)
else:
value = unidata.unicode_alias['block'].get(value, value)
return obj[value] | python | def get_block_property(value, is_bytes=False):
obj = unidata.ascii_blocks if is_bytes else unidata.unicode_blocks
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['block'].get(negated, negated)
else:
value = unidata.unicode_alias['block'].get(value, value)
return obj[value] | [
"def",
"get_block_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_blocks",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_blocks",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"negated",
"... | Get `BLK` property. | [
"Get",
"BLK",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L369-L380 |
13,097 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_bidi_property | def get_bidi_property(value, is_bytes=False):
"""Get `BC` property."""
obj = unidata.ascii_bidi_classes if is_bytes else unidata.unicode_bidi_classes
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['bidiclass'].get(negated, negated)
else:
value = unidata.unicode_alias['bidiclass'].get(value, value)
return obj[value] | python | def get_bidi_property(value, is_bytes=False):
obj = unidata.ascii_bidi_classes if is_bytes else unidata.unicode_bidi_classes
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['bidiclass'].get(negated, negated)
else:
value = unidata.unicode_alias['bidiclass'].get(value, value)
return obj[value] | [
"def",
"get_bidi_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_bidi_classes",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_bidi_classes",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"ne... | Get `BC` property. | [
"Get",
"BC",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L383-L394 |
13,098 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_bidi_paired_bracket_type_property | def get_bidi_paired_bracket_type_property(value, is_bytes=False):
"""Get `BPT` property."""
obj = unidata.ascii_bidi_paired_bracket_type if is_bytes else unidata.unicode_bidi_paired_bracket_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['bidipairedbrackettype'].get(negated, negated)
else:
value = unidata.unicode_alias['bidipairedbrackettype'].get(value, value)
return obj[value] | python | def get_bidi_paired_bracket_type_property(value, is_bytes=False):
obj = unidata.ascii_bidi_paired_bracket_type if is_bytes else unidata.unicode_bidi_paired_bracket_type
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['bidipairedbrackettype'].get(negated, negated)
else:
value = unidata.unicode_alias['bidipairedbrackettype'].get(value, value)
return obj[value] | [
"def",
"get_bidi_paired_bracket_type_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_bidi_paired_bracket_type",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_bidi_paired_bracket_type",
"if",
"value",
".",
"star... | Get `BPT` property. | [
"Get",
"BPT",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L397-L408 |
13,099 | facelessuser/backrefs | backrefs/uniprops/__init__.py | get_vertical_orientation_property | def get_vertical_orientation_property(value, is_bytes=False):
"""Get `VO` property."""
obj = unidata.ascii_vertical_orientation if is_bytes else unidata.unicode_vertical_orientation
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['verticalorientation'].get(negated, negated)
else:
value = unidata.unicode_alias['verticalorientation'].get(value, value)
return obj[value] | python | def get_vertical_orientation_property(value, is_bytes=False):
obj = unidata.ascii_vertical_orientation if is_bytes else unidata.unicode_vertical_orientation
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['verticalorientation'].get(negated, negated)
else:
value = unidata.unicode_alias['verticalorientation'].get(value, value)
return obj[value] | [
"def",
"get_vertical_orientation_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_vertical_orientation",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_vertical_orientation",
"if",
"value",
".",
"startswith",
"... | Get `VO` property. | [
"Get",
"VO",
"property",
"."
] | 3b3d60f5d57b02044f880aa29c9c5add0e31a34f | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L411-L422 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.