id
int64 0
190k
| prompt
stringlengths 21
13.4M
| docstring
stringlengths 1
12k
⌀ |
---|---|---|
1,432 | import asyncio
import json
import platform
import sys
import threading
import warnings
from contextlib import asynccontextmanager
from json import JSONDecodeError
from typing import (
AsyncGenerator,
AsyncIterator,
Dict,
Iterator,
Optional,
Tuple,
Union,
overload,
)
from urllib.parse import urlencode, urlsplit, urlunsplit
import aiohttp
import requests
import openai
from openai import error, util, version
from openai.openai_response import OpenAIResponse
from openai.util import ApiType
MAX_CONNECTION_RETRIES = 2
def _requests_proxies_arg(proxy) -> Optional[Dict[str, str]]:
"""Returns a value suitable for the 'proxies' argument to 'requests.request."""
if proxy is None:
return None
elif isinstance(proxy, str):
return {"http": proxy, "https": proxy}
elif isinstance(proxy, dict):
return proxy.copy()
else:
raise ValueError(
"'openai.proxy' must be specified as either a string URL or a dict with string URL under the https and/or http keys."
)
def _make_session() -> requests.Session:
if not openai.verify_ssl_certs:
warnings.warn("verify_ssl_certs is ignored; openai always verifies.")
s = requests.Session()
proxies = _requests_proxies_arg(openai.proxy)
if proxies:
s.proxies = proxies
s.mount(
"https://",
requests.adapters.HTTPAdapter(max_retries=MAX_CONNECTION_RETRIES),
)
return s | null |
1,433 | import asyncio
import json
import platform
import sys
import threading
import warnings
from contextlib import asynccontextmanager
from json import JSONDecodeError
from typing import (
AsyncGenerator,
AsyncIterator,
Dict,
Iterator,
Optional,
Tuple,
Union,
overload,
)
from urllib.parse import urlencode, urlsplit, urlunsplit
import aiohttp
import requests
import openai
from openai import error, util, version
from openai.openai_response import OpenAIResponse
from openai.util import ApiType
def parse_stream_helper(line: bytes) -> Optional[str]:
if line:
if line.strip() == b"data: [DONE]":
# return here will cause GeneratorExit exception in urllib3
# and it will close http connection with TCP Reset
return None
if line.startswith(b"data: "):
line = line[len(b"data: "):]
return line.decode("utf-8")
else:
return None
return None
def parse_stream(rbody: Iterator[bytes]) -> Iterator[str]:
for line in rbody:
_line = parse_stream_helper(line)
if _line is not None:
yield _line | null |
1,434 | import asyncio
import json
import platform
import sys
import threading
import warnings
from contextlib import asynccontextmanager
from json import JSONDecodeError
from typing import (
AsyncGenerator,
AsyncIterator,
Dict,
Iterator,
Optional,
Tuple,
Union,
overload,
)
from urllib.parse import urlencode, urlsplit, urlunsplit
import aiohttp
import requests
import openai
from openai import error, util, version
from openai.openai_response import OpenAIResponse
from openai.util import ApiType
def parse_stream_helper(line: bytes) -> Optional[str]:
if line:
if line.strip() == b"data: [DONE]":
# return here will cause GeneratorExit exception in urllib3
# and it will close http connection with TCP Reset
return None
if line.startswith(b"data: "):
line = line[len(b"data: "):]
return line.decode("utf-8")
else:
return None
return None
async def parse_stream_async(rbody: aiohttp.StreamReader):
async for line in rbody:
_line = parse_stream_helper(line)
if _line is not None:
yield _line | null |
1,435 | import asyncio
import json
import platform
import sys
import threading
import warnings
from contextlib import asynccontextmanager
from json import JSONDecodeError
from typing import (
AsyncGenerator,
AsyncIterator,
Dict,
Iterator,
Optional,
Tuple,
Union,
overload,
)
from urllib.parse import urlencode, urlsplit, urlunsplit
import aiohttp
import requests
import openai
from openai import error, util, version
from openai.openai_response import OpenAIResponse
from openai.util import ApiType
async def aiohttp_session() -> AsyncIterator[aiohttp.ClientSession]:
user_set_session = openai.aiosession.get()
if user_set_session:
yield user_set_session
else:
async with aiohttp.ClientSession() as session:
yield session | null |
1,436 | from urllib.parse import quote_plus
from openai import api_requestor, util
def _nested_resource_class_methods(
resource,
path=None,
operations=None,
resource_plural=None,
async_=False,
):
if resource_plural is None:
resource_plural = "%ss" % resource
if path is None:
path = resource_plural
if operations is None:
raise ValueError("operations list required")
def wrapper(cls):
def nested_resource_url(cls, id, nested_id=None):
url = "%s/%s/%s" % (cls.class_url(), quote_plus(id), quote_plus(path))
if nested_id is not None:
url += "/%s" % quote_plus(nested_id)
return url
resource_url_method = "%ss_url" % resource
setattr(cls, resource_url_method, classmethod(nested_resource_url))
def nested_resource_request(
cls,
method,
url,
api_key=None,
request_id=None,
api_version=None,
organization=None,
**params,
):
requestor = api_requestor.APIRequestor(
api_key, api_version=api_version, organization=organization
)
response, _, api_key = requestor.request(
method, url, params, request_id=request_id
)
return util.convert_to_openai_object(
response, api_key, api_version, organization
)
async def anested_resource_request(
cls,
method,
url,
api_key=None,
request_id=None,
api_version=None,
organization=None,
**params,
):
requestor = api_requestor.APIRequestor(
api_key, api_version=api_version, organization=organization
)
response, _, api_key = await requestor.arequest(
method, url, params, request_id=request_id
)
return util.convert_to_openai_object(
response, api_key, api_version, organization
)
resource_request_method = "%ss_request" % resource
setattr(
cls,
resource_request_method,
classmethod(
anested_resource_request if async_ else nested_resource_request
),
)
for operation in operations:
if operation == "create":
def create_nested_resource(cls, id, **params):
url = getattr(cls, resource_url_method)(id)
return getattr(cls, resource_request_method)("post", url, **params)
create_method = "create_%s" % resource
setattr(cls, create_method, classmethod(create_nested_resource))
elif operation == "retrieve":
def retrieve_nested_resource(cls, id, nested_id, **params):
url = getattr(cls, resource_url_method)(id, nested_id)
return getattr(cls, resource_request_method)("get", url, **params)
retrieve_method = "retrieve_%s" % resource
setattr(cls, retrieve_method, classmethod(retrieve_nested_resource))
elif operation == "update":
def modify_nested_resource(cls, id, nested_id, **params):
url = getattr(cls, resource_url_method)(id, nested_id)
return getattr(cls, resource_request_method)("post", url, **params)
modify_method = "modify_%s" % resource
setattr(cls, modify_method, classmethod(modify_nested_resource))
elif operation == "delete":
def delete_nested_resource(cls, id, nested_id, **params):
url = getattr(cls, resource_url_method)(id, nested_id)
return getattr(cls, resource_request_method)(
"delete", url, **params
)
delete_method = "delete_%s" % resource
setattr(cls, delete_method, classmethod(delete_nested_resource))
elif operation == "list":
def list_nested_resources(cls, id, **params):
url = getattr(cls, resource_url_method)(id)
return getattr(cls, resource_request_method)("get", url, **params)
list_method = "list_%s" % resource_plural
setattr(cls, list_method, classmethod(list_nested_resources))
else:
raise ValueError("Unknown operation: %s" % operation)
return cls
return wrapper
def nested_resource_class_methods(
resource,
path=None,
operations=None,
resource_plural=None,
):
return _nested_resource_class_methods(
resource, path, operations, resource_plural, async_=False
) | null |
1,437 | from urllib.parse import quote_plus
from openai import api_requestor, util
def _nested_resource_class_methods(
resource,
path=None,
operations=None,
resource_plural=None,
async_=False,
):
if resource_plural is None:
resource_plural = "%ss" % resource
if path is None:
path = resource_plural
if operations is None:
raise ValueError("operations list required")
def wrapper(cls):
def nested_resource_url(cls, id, nested_id=None):
url = "%s/%s/%s" % (cls.class_url(), quote_plus(id), quote_plus(path))
if nested_id is not None:
url += "/%s" % quote_plus(nested_id)
return url
resource_url_method = "%ss_url" % resource
setattr(cls, resource_url_method, classmethod(nested_resource_url))
def nested_resource_request(
cls,
method,
url,
api_key=None,
request_id=None,
api_version=None,
organization=None,
**params,
):
requestor = api_requestor.APIRequestor(
api_key, api_version=api_version, organization=organization
)
response, _, api_key = requestor.request(
method, url, params, request_id=request_id
)
return util.convert_to_openai_object(
response, api_key, api_version, organization
)
async def anested_resource_request(
cls,
method,
url,
api_key=None,
request_id=None,
api_version=None,
organization=None,
**params,
):
requestor = api_requestor.APIRequestor(
api_key, api_version=api_version, organization=organization
)
response, _, api_key = await requestor.arequest(
method, url, params, request_id=request_id
)
return util.convert_to_openai_object(
response, api_key, api_version, organization
)
resource_request_method = "%ss_request" % resource
setattr(
cls,
resource_request_method,
classmethod(
anested_resource_request if async_ else nested_resource_request
),
)
for operation in operations:
if operation == "create":
def create_nested_resource(cls, id, **params):
url = getattr(cls, resource_url_method)(id)
return getattr(cls, resource_request_method)("post", url, **params)
create_method = "create_%s" % resource
setattr(cls, create_method, classmethod(create_nested_resource))
elif operation == "retrieve":
def retrieve_nested_resource(cls, id, nested_id, **params):
url = getattr(cls, resource_url_method)(id, nested_id)
return getattr(cls, resource_request_method)("get", url, **params)
retrieve_method = "retrieve_%s" % resource
setattr(cls, retrieve_method, classmethod(retrieve_nested_resource))
elif operation == "update":
def modify_nested_resource(cls, id, nested_id, **params):
url = getattr(cls, resource_url_method)(id, nested_id)
return getattr(cls, resource_request_method)("post", url, **params)
modify_method = "modify_%s" % resource
setattr(cls, modify_method, classmethod(modify_nested_resource))
elif operation == "delete":
def delete_nested_resource(cls, id, nested_id, **params):
url = getattr(cls, resource_url_method)(id, nested_id)
return getattr(cls, resource_request_method)(
"delete", url, **params
)
delete_method = "delete_%s" % resource
setattr(cls, delete_method, classmethod(delete_nested_resource))
elif operation == "list":
def list_nested_resources(cls, id, **params):
url = getattr(cls, resource_url_method)(id)
return getattr(cls, resource_request_method)("get", url, **params)
list_method = "list_%s" % resource_plural
setattr(cls, list_method, classmethod(list_nested_resources))
else:
raise ValueError("Unknown operation: %s" % operation)
return cls
return wrapper
def anested_resource_class_methods(
resource,
path=None,
operations=None,
resource_plural=None,
):
return _nested_resource_class_methods(
resource, path, operations, resource_plural, async_=True
) | null |
1,438 | import os
import sys
from typing import Any, Callable, NamedTuple, Optional
from openai.datalib import pandas as pd, assert_has_pandas
class Remediation(NamedTuple):
name: str
immediate_msg: Optional[str] = None
necessary_msg: Optional[str] = None
necessary_fn: Optional[Callable[[Any], Any]] = None
optional_msg: Optional[str] = None
optional_fn: Optional[Callable[[Any], Any]] = None
error_msg: Optional[str] = None
The provided code snippet includes necessary dependencies for implementing the `read_any_format` function. Write a Python function `def read_any_format(fname, fields=["prompt", "completion"])` to solve the following problem:
This function will read a file saved in .csv, .json, .txt, .xlsx or .tsv format using pandas. - for .xlsx it will read the first sheet - for .txt it will assume completions and split on newline
Here is the function:
def read_any_format(fname, fields=["prompt", "completion"]):
"""
This function will read a file saved in .csv, .json, .txt, .xlsx or .tsv format using pandas.
- for .xlsx it will read the first sheet
- for .txt it will assume completions and split on newline
"""
assert_has_pandas()
remediation = None
necessary_msg = None
immediate_msg = None
error_msg = None
df = None
if os.path.isfile(fname):
try:
if fname.lower().endswith(".csv") or fname.lower().endswith(".tsv"):
file_extension_str, separator = (
("CSV", ",") if fname.lower().endswith(".csv") else ("TSV", "\t")
)
immediate_msg = f"\n- Based on your file extension, your file is formatted as a {file_extension_str} file"
necessary_msg = (
f"Your format `{file_extension_str}` will be converted to `JSONL`"
)
df = pd.read_csv(fname, sep=separator, dtype=str).fillna("")
elif fname.lower().endswith(".xlsx"):
immediate_msg = "\n- Based on your file extension, your file is formatted as an Excel file"
necessary_msg = "Your format `XLSX` will be converted to `JSONL`"
xls = pd.ExcelFile(fname)
sheets = xls.sheet_names
if len(sheets) > 1:
immediate_msg += "\n- Your Excel file contains more than one sheet. Please either save as csv or ensure all data is present in the first sheet. WARNING: Reading only the first sheet..."
df = pd.read_excel(fname, dtype=str).fillna("")
elif fname.lower().endswith(".txt"):
immediate_msg = (
"\n- Based on your file extension, you provided a text file"
)
necessary_msg = "Your format `TXT` will be converted to `JSONL`"
with open(fname, "r") as f:
content = f.read()
df = pd.DataFrame(
[["", line] for line in content.split("\n")],
columns=fields,
dtype=str,
).fillna("")
elif fname.lower().endswith(".jsonl"):
df = pd.read_json(fname, lines=True, dtype=str).fillna("")
if len(df) == 1:
# this is NOT what we expect for a .jsonl file
immediate_msg = "\n- Your JSONL file appears to be in a JSON format. Your file will be converted to JSONL format"
necessary_msg = "Your format `JSON` will be converted to `JSONL`"
df = pd.read_json(fname, dtype=str).fillna("")
else:
pass # this is what we expect for a .jsonl file
elif fname.lower().endswith(".json"):
df = pd.read_json(fname, lines=True, dtype=str).fillna("")
if len(df) == 1:
# this is what we expect for a .json file
df = pd.read_json(fname, dtype=str).fillna("")
else:
# this is NOT what we expect for a .json file
immediate_msg = "\n- Your JSON file appears to be in a JSONL format. Your file will be converted to JSONL format"
necessary_msg = "Your format `JSON` will be converted to `JSONL`"
else:
error_msg = "Your file must have one of the following extensions: .CSV, .TSV, .XLSX, .TXT, .JSON or .JSONL"
if "." in fname:
error_msg += f" Your file `{fname}` ends with the extension `.{fname.split('.')[-1]}` which is not supported."
else:
error_msg += f" Your file `{fname}` is missing a file extension."
except (ValueError, TypeError):
file_extension_str = fname.split(".")[-1].upper()
error_msg = f"Your file `{fname}` does not appear to be in valid {file_extension_str} format. Please ensure your file is formatted as a valid {file_extension_str} file."
else:
error_msg = f"File {fname} does not exist."
remediation = Remediation(
name="read_any_format",
necessary_msg=necessary_msg,
immediate_msg=immediate_msg,
error_msg=error_msg,
)
return df, remediation | This function will read a file saved in .csv, .json, .txt, .xlsx or .tsv format using pandas. - for .xlsx it will read the first sheet - for .txt it will assume completions and split on newline |
1,439 | import os
import sys
from typing import Any, Callable, NamedTuple, Optional
from openai.datalib import pandas as pd, assert_has_pandas
def accept_suggestion(input_text, auto_accept):
sys.stdout.write(input_text)
if auto_accept:
sys.stdout.write("Y\n")
return True
return input().lower() != "n"
def estimate_fine_tuning_time(df):
"""
Estimate the time it'll take to fine-tune the dataset
"""
ft_format = infer_task_type(df)
expected_time = 1.0
if ft_format == "classification":
num_examples = len(df)
expected_time = num_examples * 1.44
else:
size = df.memory_usage(index=True).sum()
expected_time = size * 0.0515
def format_time(time):
if time < 60:
return f"{round(time, 2)} seconds"
elif time < 3600:
return f"{round(time / 60, 2)} minutes"
elif time < 86400:
return f"{round(time / 3600, 2)} hours"
else:
return f"{round(time / 86400, 2)} days"
time_string = format_time(expected_time + 140)
sys.stdout.write(
f"Once your model starts training, it'll approximately take {time_string} to train a `curie` model, and less for `ada` and `babbage`. Queue will approximately take half an hour per job ahead of you.\n"
)
def get_outfnames(fname, split):
suffixes = ["_train", "_valid"] if split else [""]
i = 0
while True:
index_suffix = f" ({i})" if i > 0 else ""
candidate_fnames = [
os.path.splitext(fname)[0] + "_prepared" + suffix + index_suffix + ".jsonl"
for suffix in suffixes
]
if not any(os.path.isfile(f) for f in candidate_fnames):
return candidate_fnames
i += 1
def get_classification_hyperparams(df):
n_classes = df.completion.nunique()
pos_class = None
if n_classes == 2:
pos_class = df.completion.value_counts().index[0]
return n_classes, pos_class
def infer_task_type(df):
"""
Infer the likely fine-tuning task type from the data
"""
CLASSIFICATION_THRESHOLD = 3 # min_average instances of each class
if sum(df.prompt.str.len()) == 0:
return "open-ended generation"
if len(df.completion.unique()) < len(df) / CLASSIFICATION_THRESHOLD:
return "classification"
return "conditional generation"
def get_common_xfix(series, xfix="suffix"):
"""
Finds the longest common suffix or prefix of all the values in a series
"""
common_xfix = ""
while True:
common_xfixes = (
series.str[-(len(common_xfix) + 1) :]
if xfix == "suffix"
else series.str[: len(common_xfix) + 1]
) # first few or last few characters
if (
common_xfixes.nunique() != 1
): # we found the character at which we don't have a unique xfix anymore
break
elif (
common_xfix == common_xfixes.values[0]
): # the entire first row is a prefix of every other row
break
else: # the first or last few characters are still common across all rows - let's try to add one more
common_xfix = common_xfixes.values[0]
return common_xfix
The provided code snippet includes necessary dependencies for implementing the `write_out_file` function. Write a Python function `def write_out_file(df, fname, any_remediations, auto_accept)` to solve the following problem:
This function will write out a dataframe to a file, if the user would like to proceed, and also offer a fine-tuning command with the newly created file. For classification it will optionally ask the user if they would like to split the data into train/valid files, and modify the suggested command to include the valid set.
Here is the function:
def write_out_file(df, fname, any_remediations, auto_accept):
"""
This function will write out a dataframe to a file, if the user would like to proceed, and also offer a fine-tuning command with the newly created file.
For classification it will optionally ask the user if they would like to split the data into train/valid files, and modify the suggested command to include the valid set.
"""
ft_format = infer_task_type(df)
common_prompt_suffix = get_common_xfix(df.prompt, xfix="suffix")
common_completion_suffix = get_common_xfix(df.completion, xfix="suffix")
split = False
input_text = "- [Recommended] Would you like to split into training and validation set? [Y/n]: "
if ft_format == "classification":
if accept_suggestion(input_text, auto_accept):
split = True
additional_params = ""
common_prompt_suffix_new_line_handled = common_prompt_suffix.replace("\n", "\\n")
common_completion_suffix_new_line_handled = common_completion_suffix.replace(
"\n", "\\n"
)
optional_ending_string = (
f' Make sure to include `stop=["{common_completion_suffix_new_line_handled}"]` so that the generated texts ends at the expected place.'
if len(common_completion_suffix_new_line_handled) > 0
else ""
)
input_text = "\n\nYour data will be written to a new JSONL file. Proceed [Y/n]: "
if not any_remediations and not split:
sys.stdout.write(
f'\nYou can use your file for fine-tuning:\n> openai api fine_tunes.create -t "{fname}"{additional_params}\n\nAfter you’ve fine-tuned a model, remember that your prompt has to end with the indicator string `{common_prompt_suffix_new_line_handled}` for the model to start generating completions, rather than continuing with the prompt.{optional_ending_string}\n'
)
estimate_fine_tuning_time(df)
elif accept_suggestion(input_text, auto_accept):
fnames = get_outfnames(fname, split)
if split:
assert len(fnames) == 2 and "train" in fnames[0] and "valid" in fnames[1]
MAX_VALID_EXAMPLES = 1000
n_train = max(len(df) - MAX_VALID_EXAMPLES, int(len(df) * 0.8))
df_train = df.sample(n=n_train, random_state=42)
df_valid = df.drop(df_train.index)
df_train[["prompt", "completion"]].to_json(
fnames[0], lines=True, orient="records", force_ascii=False
)
df_valid[["prompt", "completion"]].to_json(
fnames[1], lines=True, orient="records", force_ascii=False
)
n_classes, pos_class = get_classification_hyperparams(df)
additional_params += " --compute_classification_metrics"
if n_classes == 2:
additional_params += f' --classification_positive_class "{pos_class}"'
else:
additional_params += f" --classification_n_classes {n_classes}"
else:
assert len(fnames) == 1
df[["prompt", "completion"]].to_json(
fnames[0], lines=True, orient="records", force_ascii=False
)
# Add -v VALID_FILE if we split the file into train / valid
files_string = ("s" if split else "") + " to `" + ("` and `".join(fnames))
valid_string = f' -v "{fnames[1]}"' if split else ""
separator_reminder = (
""
if len(common_prompt_suffix_new_line_handled) == 0
else f"After you’ve fine-tuned a model, remember that your prompt has to end with the indicator string `{common_prompt_suffix_new_line_handled}` for the model to start generating completions, rather than continuing with the prompt."
)
sys.stdout.write(
f'\nWrote modified file{files_string}`\nFeel free to take a look!\n\nNow use that file when fine-tuning:\n> openai api fine_tunes.create -t "{fnames[0]}"{valid_string}{additional_params}\n\n{separator_reminder}{optional_ending_string}\n'
)
estimate_fine_tuning_time(df)
else:
sys.stdout.write("Aborting... did not write the file\n") | This function will write out a dataframe to a file, if the user would like to proceed, and also offer a fine-tuning command with the newly created file. For classification it will optionally ask the user if they would like to split the data into train/valid files, and modify the suggested command to include the valid set. |
1,440 | import os
import sys
from typing import Any, Callable, NamedTuple, Optional
from openai.datalib import pandas as pd, assert_has_pandas
def num_examples_validator(df):
"""
This validator will only print out the number of examples and recommend to the user to increase the number of examples if less than 100.
"""
MIN_EXAMPLES = 100
optional_suggestion = (
""
if len(df) >= MIN_EXAMPLES
else ". In general, we recommend having at least a few hundred examples. We've found that performance tends to linearly increase for every doubling of the number of examples"
)
immediate_msg = (
f"\n- Your file contains {len(df)} prompt-completion pairs{optional_suggestion}"
)
return Remediation(name="num_examples", immediate_msg=immediate_msg)
def necessary_column_validator(df, necessary_column):
"""
This validator will ensure that the necessary column is present in the dataframe.
"""
def lower_case_column(df, column):
cols = [c for c in df.columns if str(c).lower() == column]
df.rename(columns={cols[0]: column.lower()}, inplace=True)
return df
immediate_msg = None
necessary_fn = None
necessary_msg = None
error_msg = None
if necessary_column not in df.columns:
if necessary_column in [str(c).lower() for c in df.columns]:
def lower_case_column_creator(df):
return lower_case_column(df, necessary_column)
necessary_fn = lower_case_column_creator
immediate_msg = (
f"\n- The `{necessary_column}` column/key should be lowercase"
)
necessary_msg = f"Lower case column name to `{necessary_column}`"
else:
error_msg = f"`{necessary_column}` column/key is missing. Please make sure you name your columns/keys appropriately, then retry"
return Remediation(
name="necessary_column",
immediate_msg=immediate_msg,
necessary_msg=necessary_msg,
necessary_fn=necessary_fn,
error_msg=error_msg,
)
def additional_column_validator(df, fields=["prompt", "completion"]):
"""
This validator will remove additional columns from the dataframe.
"""
additional_columns = []
necessary_msg = None
immediate_msg = None
necessary_fn = None
if len(df.columns) > 2:
additional_columns = [c for c in df.columns if c not in fields]
warn_message = ""
for ac in additional_columns:
dups = [c for c in additional_columns if ac in c]
if len(dups) > 0:
warn_message += f"\n WARNING: Some of the additional columns/keys contain `{ac}` in their name. These will be ignored, and the column/key `{ac}` will be used instead. This could also result from a duplicate column/key in the provided file."
immediate_msg = f"\n- The input file should contain exactly two columns/keys per row. Additional columns/keys present are: {additional_columns}{warn_message}"
necessary_msg = f"Remove additional columns/keys: {additional_columns}"
def necessary_fn(x):
return x[fields]
return Remediation(
name="additional_column",
immediate_msg=immediate_msg,
necessary_msg=necessary_msg,
necessary_fn=necessary_fn,
)
def non_empty_field_validator(df, field="completion"):
"""
This validator will ensure that no completion is empty.
"""
necessary_msg = None
necessary_fn = None
immediate_msg = None
if df[field].apply(lambda x: x == "").any() or df[field].isnull().any():
empty_rows = (df[field] == "") | (df[field].isnull())
empty_indexes = df.reset_index().index[empty_rows].tolist()
immediate_msg = f"\n- `{field}` column/key should not contain empty strings. These are rows: {empty_indexes}"
def necessary_fn(x):
return x[x[field] != ""].dropna(subset=[field])
necessary_msg = f"Remove {len(empty_indexes)} rows with empty {field}s"
return Remediation(
name=f"empty_{field}",
immediate_msg=immediate_msg,
necessary_msg=necessary_msg,
necessary_fn=necessary_fn,
)
def duplicated_rows_validator(df, fields=["prompt", "completion"]):
"""
This validator will suggest to the user to remove duplicate rows if they exist.
"""
duplicated_rows = df.duplicated(subset=fields)
duplicated_indexes = df.reset_index().index[duplicated_rows].tolist()
immediate_msg = None
optional_msg = None
optional_fn = None
if len(duplicated_indexes) > 0:
immediate_msg = f"\n- There are {len(duplicated_indexes)} duplicated {'-'.join(fields)} sets. These are rows: {duplicated_indexes}"
optional_msg = f"Remove {len(duplicated_indexes)} duplicate rows"
def optional_fn(x):
return x.drop_duplicates(subset=fields)
return Remediation(
name="duplicated_rows",
immediate_msg=immediate_msg,
optional_msg=optional_msg,
optional_fn=optional_fn,
)
def long_examples_validator(df):
"""
This validator will suggest to the user to remove examples that are too long.
"""
immediate_msg = None
optional_msg = None
optional_fn = None
ft_type = infer_task_type(df)
if ft_type != "open-ended generation":
def get_long_indexes(d):
long_examples = d.apply(
lambda x: len(x.prompt) + len(x.completion) > 10000, axis=1
)
return d.reset_index().index[long_examples].tolist()
long_indexes = get_long_indexes(df)
if len(long_indexes) > 0:
immediate_msg = f"\n- There are {len(long_indexes)} examples that are very long. These are rows: {long_indexes}\nFor conditional generation, and for classification the examples shouldn't be longer than 2048 tokens."
optional_msg = f"Remove {len(long_indexes)} long examples"
def optional_fn(x):
long_indexes_to_drop = get_long_indexes(x)
if long_indexes != long_indexes_to_drop:
sys.stdout.write(f"The indices of the long examples has changed as a result of a previously applied recommendation.\nThe {len(long_indexes_to_drop)} long examples to be dropped are now at the following indices: {long_indexes_to_drop}\n")
return x.drop(long_indexes_to_drop)
return Remediation(
name="long_examples",
immediate_msg=immediate_msg,
optional_msg=optional_msg,
optional_fn=optional_fn,
)
def common_prompt_suffix_validator(df):
"""
This validator will suggest to add a common suffix to the prompt if one doesn't already exist in case of classification or conditional generation.
"""
error_msg = None
immediate_msg = None
optional_msg = None
optional_fn = None
# Find a suffix which is not contained within the prompt otherwise
suggested_suffix = "\n\n### =>\n\n"
suffix_options = [
" ->",
"\n\n###\n\n",
"\n\n===\n\n",
"\n\n---\n\n",
"\n\n===>\n\n",
"\n\n--->\n\n",
]
for suffix_option in suffix_options:
if suffix_option == " ->":
if df.prompt.str.contains("\n").any():
continue
if df.prompt.str.contains(suffix_option, regex=False).any():
continue
suggested_suffix = suffix_option
break
display_suggested_suffix = suggested_suffix.replace("\n", "\\n")
ft_type = infer_task_type(df)
if ft_type == "open-ended generation":
return Remediation(name="common_suffix")
def add_suffix(x, suffix):
x["prompt"] += suffix
return x
common_suffix = get_common_xfix(df.prompt, xfix="suffix")
if (df.prompt == common_suffix).all():
error_msg = f"All prompts are identical: `{common_suffix}`\nConsider leaving the prompts blank if you want to do open-ended generation, otherwise ensure prompts are different"
return Remediation(name="common_suffix", error_msg=error_msg)
if common_suffix != "":
common_suffix_new_line_handled = common_suffix.replace("\n", "\\n")
immediate_msg = (
f"\n- All prompts end with suffix `{common_suffix_new_line_handled}`"
)
if len(common_suffix) > 10:
immediate_msg += f". This suffix seems very long. Consider replacing with a shorter suffix, such as `{display_suggested_suffix}`"
if (
df.prompt.str[: -len(common_suffix)]
.str.contains(common_suffix, regex=False)
.any()
):
immediate_msg += f"\n WARNING: Some of your prompts contain the suffix `{common_suffix}` more than once. We strongly suggest that you review your prompts and add a unique suffix"
else:
immediate_msg = "\n- Your data does not contain a common separator at the end of your prompts. Having a separator string appended to the end of the prompt makes it clearer to the fine-tuned model where the completion should begin. See https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset for more detail and examples. If you intend to do open-ended generation, then you should leave the prompts empty"
if common_suffix == "":
optional_msg = (
f"Add a suffix separator `{display_suggested_suffix}` to all prompts"
)
def optional_fn(x):
return add_suffix(x, suggested_suffix)
return Remediation(
name="common_completion_suffix",
immediate_msg=immediate_msg,
optional_msg=optional_msg,
optional_fn=optional_fn,
error_msg=error_msg,
)
def common_prompt_prefix_validator(df):
"""
This validator will suggest to remove a common prefix from the prompt if a long one exist.
"""
MAX_PREFIX_LEN = 12
immediate_msg = None
optional_msg = None
optional_fn = None
common_prefix = get_common_xfix(df.prompt, xfix="prefix")
if common_prefix == "":
return Remediation(name="common_prefix")
def remove_common_prefix(x, prefix):
x["prompt"] = x["prompt"].str[len(prefix) :]
return x
if (df.prompt == common_prefix).all():
# already handled by common_suffix_validator
return Remediation(name="common_prefix")
if common_prefix != "":
immediate_msg = f"\n- All prompts start with prefix `{common_prefix}`"
if MAX_PREFIX_LEN < len(common_prefix):
immediate_msg += ". Fine-tuning doesn't require the instruction specifying the task, or a few-shot example scenario. Most of the time you should only add the input data into the prompt, and the desired output into the completion"
optional_msg = f"Remove prefix `{common_prefix}` from all prompts"
def optional_fn(x):
return remove_common_prefix(x, common_prefix)
return Remediation(
name="common_prompt_prefix",
immediate_msg=immediate_msg,
optional_msg=optional_msg,
optional_fn=optional_fn,
)
def common_completion_prefix_validator(df):
"""
This validator will suggest to remove a common prefix from the completion if a long one exist.
"""
MAX_PREFIX_LEN = 5
common_prefix = get_common_xfix(df.completion, xfix="prefix")
ws_prefix = len(common_prefix) > 0 and common_prefix[0] == " "
if len(common_prefix) < MAX_PREFIX_LEN:
return Remediation(name="common_prefix")
def remove_common_prefix(x, prefix, ws_prefix):
x["completion"] = x["completion"].str[len(prefix) :]
if ws_prefix:
# keep the single whitespace as prefix
x["completion"] = " " + x["completion"]
return x
if (df.completion == common_prefix).all():
# already handled by common_suffix_validator
return Remediation(name="common_prefix")
immediate_msg = f"\n- All completions start with prefix `{common_prefix}`. Most of the time you should only add the output data into the completion, without any prefix"
optional_msg = f"Remove prefix `{common_prefix}` from all completions"
def optional_fn(x):
return remove_common_prefix(x, common_prefix, ws_prefix)
return Remediation(
name="common_completion_prefix",
immediate_msg=immediate_msg,
optional_msg=optional_msg,
optional_fn=optional_fn,
)
def common_completion_suffix_validator(df):
"""
This validator will suggest to add a common suffix to the completion if one doesn't already exist in case of classification or conditional generation.
"""
error_msg = None
immediate_msg = None
optional_msg = None
optional_fn = None
ft_type = infer_task_type(df)
if ft_type == "open-ended generation" or ft_type == "classification":
return Remediation(name="common_suffix")
common_suffix = get_common_xfix(df.completion, xfix="suffix")
if (df.completion == common_suffix).all():
error_msg = f"All completions are identical: `{common_suffix}`\nEnsure completions are different, otherwise the model will just repeat `{common_suffix}`"
return Remediation(name="common_suffix", error_msg=error_msg)
# Find a suffix which is not contained within the completion otherwise
suggested_suffix = " [END]"
suffix_options = [
"\n",
".",
" END",
"***",
"+++",
"&&&",
"$$$",
"@@@",
"%%%",
]
for suffix_option in suffix_options:
if df.completion.str.contains(suffix_option, regex=False).any():
continue
suggested_suffix = suffix_option
break
display_suggested_suffix = suggested_suffix.replace("\n", "\\n")
def add_suffix(x, suffix):
x["completion"] += suffix
return x
if common_suffix != "":
common_suffix_new_line_handled = common_suffix.replace("\n", "\\n")
immediate_msg = (
f"\n- All completions end with suffix `{common_suffix_new_line_handled}`"
)
if len(common_suffix) > 10:
immediate_msg += f". This suffix seems very long. Consider replacing with a shorter suffix, such as `{display_suggested_suffix}`"
if (
df.completion.str[: -len(common_suffix)]
.str.contains(common_suffix, regex=False)
.any()
):
immediate_msg += f"\n WARNING: Some of your completions contain the suffix `{common_suffix}` more than once. We suggest that you review your completions and add a unique ending"
else:
immediate_msg = "\n- Your data does not contain a common ending at the end of your completions. Having a common ending string appended to the end of the completion makes it clearer to the fine-tuned model where the completion should end. See https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset for more detail and examples."
if common_suffix == "":
optional_msg = (
f"Add a suffix ending `{display_suggested_suffix}` to all completions"
)
def optional_fn(x):
return add_suffix(x, suggested_suffix)
return Remediation(
name="common_completion_suffix",
immediate_msg=immediate_msg,
optional_msg=optional_msg,
optional_fn=optional_fn,
error_msg=error_msg,
)
def completions_space_start_validator(df):
"""
This validator will suggest to add a space at the start of the completion if it doesn't already exist. This helps with tokenization.
"""
def add_space_start(x):
x["completion"] = x["completion"].apply(
lambda x: ("" if x[0] == " " else " ") + x
)
return x
optional_msg = None
optional_fn = None
immediate_msg = None
if df.completion.str[:1].nunique() != 1 or df.completion.values[0][0] != " ":
immediate_msg = "\n- The completion should start with a whitespace character (` `). This tends to produce better results due to the tokenization we use. See https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset for more details"
optional_msg = "Add a whitespace character to the beginning of the completion"
optional_fn = add_space_start
return Remediation(
name="completion_space_start",
immediate_msg=immediate_msg,
optional_msg=optional_msg,
optional_fn=optional_fn,
)
def lower_case_validator(df, column):
"""
This validator will suggest to lowercase the column values, if more than a third of letters are uppercase.
"""
def lower_case(x):
x[column] = x[column].str.lower()
return x
count_upper = (
df[column]
.apply(lambda x: sum(1 for c in x if c.isalpha() and c.isupper()))
.sum()
)
count_lower = (
df[column]
.apply(lambda x: sum(1 for c in x if c.isalpha() and c.islower()))
.sum()
)
if count_upper * 2 > count_lower:
return Remediation(
name="lower_case",
immediate_msg=f"\n- More than a third of your `{column}` column/key is uppercase. Uppercase {column}s tends to perform worse than a mixture of case encountered in normal language. We recommend to lower case the data if that makes sense in your domain. See https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset for more details",
optional_msg=f"Lowercase all your data in column/key `{column}`",
optional_fn=lower_case,
)
def format_inferrer_validator(df):
"""
This validator will infer the likely fine-tuning format of the data, and display it to the user if it is classification.
It will also suggest to use ada and explain train/validation split benefits.
"""
ft_type = infer_task_type(df)
immediate_msg = None
if ft_type == "classification":
immediate_msg = f"\n- Based on your data it seems like you're trying to fine-tune a model for {ft_type}\n- For classification, we recommend you try one of the faster and cheaper models, such as `ada`\n- For classification, you can estimate the expected model performance by keeping a held out dataset, which is not used for training"
return Remediation(name="num_examples", immediate_msg=immediate_msg)
def get_validators():
return [
num_examples_validator,
lambda x: necessary_column_validator(x, "prompt"),
lambda x: necessary_column_validator(x, "completion"),
additional_column_validator,
non_empty_field_validator,
format_inferrer_validator,
duplicated_rows_validator,
long_examples_validator,
lambda x: lower_case_validator(x, "prompt"),
lambda x: lower_case_validator(x, "completion"),
common_prompt_suffix_validator,
common_prompt_prefix_validator,
common_completion_prefix_validator,
common_completion_suffix_validator,
completions_space_start_validator,
] | null |
1,441 | import os
import sys
from typing import Any, Callable, NamedTuple, Optional
from openai.datalib import pandas as pd, assert_has_pandas
def apply_necessary_remediation(df, remediation):
def apply_optional_remediation(df, remediation, auto_accept):
def apply_validators(
df,
fname,
remediation,
validators,
auto_accept,
write_out_file_func,
):
optional_remediations = []
if remediation is not None:
optional_remediations.append(remediation)
for validator in validators:
remediation = validator(df)
if remediation is not None:
optional_remediations.append(remediation)
df = apply_necessary_remediation(df, remediation)
any_optional_or_necessary_remediations = any(
[
remediation
for remediation in optional_remediations
if remediation.optional_msg is not None
or remediation.necessary_msg is not None
]
)
any_necessary_applied = any(
[
remediation
for remediation in optional_remediations
if remediation.necessary_msg is not None
]
)
any_optional_applied = False
if any_optional_or_necessary_remediations:
sys.stdout.write(
"\n\nBased on the analysis we will perform the following actions:\n"
)
for remediation in optional_remediations:
df, optional_applied = apply_optional_remediation(
df, remediation, auto_accept
)
any_optional_applied = any_optional_applied or optional_applied
else:
sys.stdout.write("\n\nNo remediations found.\n")
any_optional_or_necessary_applied = any_optional_applied or any_necessary_applied
write_out_file_func(df, fname, any_optional_or_necessary_applied, auto_accept) | null |
1,442 | HAS_NUMPY = bool(numpy)
NUMPY_INSTRUCTIONS = INSTRUCTIONS.format(library="numpy")
class MissingDependencyError(Exception):
pass
def assert_has_numpy():
if not HAS_NUMPY:
raise MissingDependencyError(NUMPY_INSTRUCTIONS) | null |
1,443 | import os
import sys
import time
from collections import OrderedDict
from datetime import timedelta
from ._internal_utils import to_native_string
from .adapters import HTTPAdapter
from .auth import _basic_auth_str
from .compat import Mapping, cookielib, urljoin, urlparse
from .cookies import (
RequestsCookieJar,
cookiejar_from_dict,
extract_cookies_to_jar,
merge_cookies,
)
from .exceptions import (
ChunkedEncodingError,
ContentDecodingError,
InvalidSchema,
TooManyRedirects,
)
from .hooks import default_hooks, dispatch_hook
from .models import ( # noqa: F401
DEFAULT_REDIRECT_LIMIT,
REDIRECT_STATI,
PreparedRequest,
Request,
)
from .status_codes import codes
from .structures import CaseInsensitiveDict
from .utils import ( # noqa: F401
DEFAULT_PORTS,
default_headers,
get_auth_from_url,
get_environ_proxies,
get_netrc_auth,
requote_uri,
resolve_proxies,
rewind_body,
should_bypass_proxies,
to_key_val_list,
)
def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
"""Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
"""
if session_setting is None:
return request_setting
if request_setting is None:
return session_setting
# Bypass if not a dictionary (e.g. verify)
if not (
isinstance(session_setting, Mapping) and isinstance(request_setting, Mapping)
):
return request_setting
merged_setting = dict_class(to_key_val_list(session_setting))
merged_setting.update(to_key_val_list(request_setting))
# Remove keys that are set to None. Extract keys first to avoid altering
# the dictionary during iteration.
none_keys = [k for (k, v) in merged_setting.items() if v is None]
for key in none_keys:
del merged_setting[key]
return merged_setting
The provided code snippet includes necessary dependencies for implementing the `merge_hooks` function. Write a Python function `def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict)` to solve the following problem:
Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely.
Here is the function:
def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
"""
if session_hooks is None or session_hooks.get("response") == []:
return request_hooks
if request_hooks is None or request_hooks.get("response") == []:
return session_hooks
return merge_setting(request_hooks, session_hooks, dict_class) | Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. |
1,444 | from . import sessions
def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How many seconds to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""
# By using the 'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)
The provided code snippet includes necessary dependencies for implementing the `get` function. Write a Python function `def get(url, params=None, **kwargs)` to solve the following problem:
r"""Sends a GET request. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the query string for the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response
Here is the function:
def get(url, params=None, **kwargs):
r"""Sends a GET request.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request("get", url, params=params, **kwargs) | r"""Sends a GET request. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the query string for the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response |
1,445 | from . import sessions
def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How many seconds to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""
# By using the 'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)
The provided code snippet includes necessary dependencies for implementing the `options` function. Write a Python function `def options(url, **kwargs)` to solve the following problem:
r"""Sends an OPTIONS request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response
Here is the function:
def options(url, **kwargs):
r"""Sends an OPTIONS request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request("options", url, **kwargs) | r"""Sends an OPTIONS request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response |
1,446 | from . import sessions
def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How many seconds to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""
# By using the 'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)
The provided code snippet includes necessary dependencies for implementing the `head` function. Write a Python function `def head(url, **kwargs)` to solve the following problem:
r"""Sends a HEAD request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. If `allow_redirects` is not provided, it will be set to `False` (as opposed to the default :meth:`request` behavior). :return: :class:`Response <Response>` object :rtype: requests.Response
Here is the function:
def head(url, **kwargs):
r"""Sends a HEAD request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes. If
`allow_redirects` is not provided, it will be set to `False` (as
opposed to the default :meth:`request` behavior).
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
kwargs.setdefault("allow_redirects", False)
return request("head", url, **kwargs) | r"""Sends a HEAD request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. If `allow_redirects` is not provided, it will be set to `False` (as opposed to the default :meth:`request` behavior). :return: :class:`Response <Response>` object :rtype: requests.Response |
1,447 | from . import sessions
def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How many seconds to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""
# By using the 'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)
The provided code snippet includes necessary dependencies for implementing the `post` function. Write a Python function `def post(url, data=None, json=None, **kwargs)` to solve the following problem:
r"""Sends a POST request. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json data to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response
Here is the function:
def post(url, data=None, json=None, **kwargs):
r"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request("post", url, data=data, json=json, **kwargs) | r"""Sends a POST request. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json data to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response |
1,448 | from . import sessions
def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How many seconds to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""
# By using the 'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)
The provided code snippet includes necessary dependencies for implementing the `put` function. Write a Python function `def put(url, data=None, **kwargs)` to solve the following problem:
r"""Sends a PUT request. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json data to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response
Here is the function:
def put(url, data=None, **kwargs):
r"""Sends a PUT request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request("put", url, data=data, **kwargs) | r"""Sends a PUT request. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json data to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response |
1,449 | from . import sessions
def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How many seconds to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""
# By using the 'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)
The provided code snippet includes necessary dependencies for implementing the `patch` function. Write a Python function `def patch(url, data=None, **kwargs)` to solve the following problem:
r"""Sends a PATCH request. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json data to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response
Here is the function:
def patch(url, data=None, **kwargs):
r"""Sends a PATCH request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request("patch", url, data=data, **kwargs) | r"""Sends a PATCH request. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json data to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response |
1,450 | from . import sessions
def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.
``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``
or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string
defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers
to add for the file.
:param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) How many seconds to wait for the server to send data
before giving up, as a float, or a :ref:`(connect timeout, read
timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to ``True``.
:type allow_redirects: bool
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use. Defaults to ``True``.
:param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
:return: :class:`Response <Response>` object
:rtype: requests.Response
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""
# By using the 'with' statement we are sure the session is closed, thus we
# avoid leaving sockets open which can trigger a ResourceWarning in some
# cases, and look like a memory leak in others.
with sessions.Session() as session:
return session.request(method=method, url=url, **kwargs)
The provided code snippet includes necessary dependencies for implementing the `delete` function. Write a Python function `def delete(url, **kwargs)` to solve the following problem:
r"""Sends a DELETE request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response
Here is the function:
def delete(url, **kwargs):
r"""Sends a DELETE request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request("delete", url, **kwargs) | r"""Sends a DELETE request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response |
1,451 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `dict_to_sequence` function. Write a Python function `def dict_to_sequence(d)` to solve the following problem:
Returns an internal sequence dictionary update.
Here is the function:
def dict_to_sequence(d):
"""Returns an internal sequence dictionary update."""
if hasattr(d, "items"):
d = d.items()
return d | Returns an internal sequence dictionary update. |
1,452 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
import warnings
warnings.simplefilter("ignore", DependencyWarning)
warnings.simplefilter("default", FileModeWarning, append=True)
class FileModeWarning(RequestsWarning, DeprecationWarning):
"""A file was opened in text mode, but Requests determined its binary length."""
def super_len(o):
total_length = None
current_position = 0
if hasattr(o, "__len__"):
total_length = len(o)
elif hasattr(o, "len"):
total_length = o.len
elif hasattr(o, "fileno"):
try:
fileno = o.fileno()
except (io.UnsupportedOperation, AttributeError):
# AttributeError is a surprising exception, seeing as how we've just checked
# that `hasattr(o, 'fileno')`. It happens for objects obtained via
# `Tarfile.extractfile()`, per issue 5229.
pass
else:
total_length = os.fstat(fileno).st_size
# Having used fstat to determine the file length, we need to
# confirm that this file was opened up in binary mode.
if "b" not in o.mode:
warnings.warn(
(
"Requests has determined the content-length for this "
"request using the binary size of the file: however, the "
"file has been opened in text mode (i.e. without the 'b' "
"flag in the mode). This may lead to an incorrect "
"content-length. In Requests 3.0, support will be removed "
"for files in text mode."
),
FileModeWarning,
)
if hasattr(o, "tell"):
try:
current_position = o.tell()
except OSError:
# This can happen in some weird situations, such as when the file
# is actually a special file descriptor like stdin. In this
# instance, we don't know what the length is, so set it to zero and
# let requests chunk it instead.
if total_length is not None:
current_position = total_length
else:
if hasattr(o, "seek") and total_length is None:
# StringIO and BytesIO have seek but no usable fileno
try:
# seek to end of file
o.seek(0, 2)
total_length = o.tell()
# seek back to current position to support
# partially read file-like objects
o.seek(current_position or 0)
except OSError:
total_length = 0
if total_length is None:
total_length = 0
return max(0, total_length - current_position) | null |
1,453 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
NETRC_FILES = (".netrc", "_netrc")
str = str
The provided code snippet includes necessary dependencies for implementing the `get_netrc_auth` function. Write a Python function `def get_netrc_auth(url, raise_errors=False)` to solve the following problem:
Returns the Requests tuple auth for a given url from netrc.
Here is the function:
def get_netrc_auth(url, raise_errors=False):
"""Returns the Requests tuple auth for a given url from netrc."""
netrc_file = os.environ.get("NETRC")
if netrc_file is not None:
netrc_locations = (netrc_file,)
else:
netrc_locations = (f"~/{f}" for f in NETRC_FILES)
try:
from netrc import NetrcParseError, netrc
netrc_path = None
for f in netrc_locations:
try:
loc = os.path.expanduser(f)
except KeyError:
# os.path.expanduser can fail when $HOME is undefined and
# getpwuid fails. See https://bugs.python.org/issue20164 &
# https://github.com/psf/requests/issues/1846
return
if os.path.exists(loc):
netrc_path = loc
break
# Abort early if there isn't one.
if netrc_path is None:
return
ri = urlparse(url)
# Strip port numbers from netloc. This weird `if...encode`` dance is
# used for Python 3.2, which doesn't support unicode literals.
splitstr = b":"
if isinstance(url, str):
splitstr = splitstr.decode("ascii")
host = ri.netloc.split(splitstr)[0]
try:
_netrc = netrc(netrc_path).authenticators(host)
if _netrc:
# Return with login / password
login_i = 0 if _netrc[0] else 1
return (_netrc[login_i], _netrc[2])
except (NetrcParseError, OSError):
# If there was a parsing error or a permissions issue reading the file,
# we'll just skip netrc auth unless explicitly asked to raise errors.
if raise_errors:
raise
# App Engine hackiness.
except (ImportError, AttributeError):
pass | Returns the Requests tuple auth for a given url from netrc. |
1,454 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
basestring = (str, bytes)
The provided code snippet includes necessary dependencies for implementing the `guess_filename` function. Write a Python function `def guess_filename(obj)` to solve the following problem:
Tries to guess the filename of the given object.
Here is the function:
def guess_filename(obj):
"""Tries to guess the filename of the given object."""
name = getattr(obj, "name", None)
if name and isinstance(name, basestring) and name[0] != "<" and name[-1] != ">":
return os.path.basename(name) | Tries to guess the filename of the given object. |
1,455 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def atomic_open(filename):
"""Write a file to the disk in an atomic fashion"""
tmp_descriptor, tmp_name = tempfile.mkstemp(dir=os.path.dirname(filename))
try:
with os.fdopen(tmp_descriptor, "wb") as tmp_handler:
yield tmp_handler
os.replace(tmp_name, filename)
except BaseException:
os.remove(tmp_name)
raise
The provided code snippet includes necessary dependencies for implementing the `extract_zipped_paths` function. Write a Python function `def extract_zipped_paths(path)` to solve the following problem:
Replace nonexistent paths that look like they refer to a member of a zip archive with the location of an extracted copy of the target, or else just return the provided path unchanged.
Here is the function:
def extract_zipped_paths(path):
"""Replace nonexistent paths that look like they refer to a member of a zip
archive with the location of an extracted copy of the target, or else
just return the provided path unchanged.
"""
if os.path.exists(path):
# this is already a valid path, no need to do anything further
return path
# find the first valid part of the provided path and treat that as a zip archive
# assume the rest of the path is the name of a member in the archive
archive, member = os.path.split(path)
while archive and not os.path.exists(archive):
archive, prefix = os.path.split(archive)
if not prefix:
# If we don't check for an empty prefix after the split (in other words, archive remains unchanged after the split),
# we _can_ end up in an infinite loop on a rare corner case affecting a small number of users
break
member = "/".join([prefix, member])
if not zipfile.is_zipfile(archive):
return path
zip_file = zipfile.ZipFile(archive)
if member not in zip_file.namelist():
return path
# we have a valid zip archive and a valid member of that archive
tmp = tempfile.gettempdir()
extracted_path = os.path.join(tmp, member.split("/")[-1])
if not os.path.exists(extracted_path):
# use read + write to avoid the creating nested folders, we only want the file, avoids mkdir racing condition
with atomic_open(extracted_path) as file_handler:
file_handler.write(zip_file.read(member))
return extracted_path | Replace nonexistent paths that look like they refer to a member of a zip archive with the location of an extracted copy of the target, or else just return the provided path unchanged. |
1,456 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
str = str
bytes = bytes
The provided code snippet includes necessary dependencies for implementing the `from_key_val_list` function. Write a Python function `def from_key_val_list(value)` to solve the following problem:
Take an object and test to see if it can be represented as a dictionary. Unless it can not be represented as such, return an OrderedDict, e.g., :: >>> from_key_val_list([('key', 'val')]) OrderedDict([('key', 'val')]) >>> from_key_val_list('string') Traceback (most recent call last): ... ValueError: cannot encode objects that are not 2-tuples >>> from_key_val_list({'key': 'val'}) OrderedDict([('key', 'val')]) :rtype: OrderedDict
Here is the function:
def from_key_val_list(value):
"""Take an object and test to see if it can be represented as a
dictionary. Unless it can not be represented as such, return an
OrderedDict, e.g.,
::
>>> from_key_val_list([('key', 'val')])
OrderedDict([('key', 'val')])
>>> from_key_val_list('string')
Traceback (most recent call last):
...
ValueError: cannot encode objects that are not 2-tuples
>>> from_key_val_list({'key': 'val'})
OrderedDict([('key', 'val')])
:rtype: OrderedDict
"""
if value is None:
return None
if isinstance(value, (str, bytes, bool, int)):
raise ValueError("cannot encode objects that are not 2-tuples")
return OrderedDict(value) | Take an object and test to see if it can be represented as a dictionary. Unless it can not be represented as such, return an OrderedDict, e.g., :: >>> from_key_val_list([('key', 'val')]) OrderedDict([('key', 'val')]) >>> from_key_val_list('string') Traceback (most recent call last): ... ValueError: cannot encode objects that are not 2-tuples >>> from_key_val_list({'key': 'val'}) OrderedDict([('key', 'val')]) :rtype: OrderedDict |
1,457 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def unquote_header_value(value, is_filename=False):
r"""Unquotes a header value. (Reversal of :func:`quote_header_value`).
This does not use the real unquoting but what browsers are actually
using for quoting.
:param value: the header value to unquote.
:rtype: str
"""
if value and value[0] == value[-1] == '"':
# this is not the real unquoting, but fixing this so that the
# RFC is met will result in bugs with internet explorer and
# probably some other browsers as well. IE for example is
# uploading files with "C:\foo\bar.txt" as filename
value = value[1:-1]
# if this is a filename and the starting characters look like
# a UNC path, then just return the value without quotes. Using the
# replace sequence below on a UNC path has the effect of turning
# the leading double slash into a single slash and then
# _fix_ie_filename() doesn't work correctly. See #458.
if not is_filename or value[:2] != "\\\\":
return value.replace("\\\\", "\\").replace('\\"', '"')
return value
The provided code snippet includes necessary dependencies for implementing the `parse_list_header` function. Write a Python function `def parse_list_header(value)` to solve the following problem:
Parse lists as described by RFC 2068 Section 2. In particular, parse comma-separated lists where the elements of the list may include quoted-strings. A quoted-string could contain a comma. A non-quoted string could have quotes in the middle. Quotes are removed automatically after parsing. It basically works like :func:`parse_set_header` just that items may appear multiple times and case sensitivity is preserved. The return value is a standard :class:`list`: >>> parse_list_header('token, "quoted value"') ['token', 'quoted value'] To create a header from the :class:`list` again, use the :func:`dump_header` function. :param value: a string with a list header. :return: :class:`list` :rtype: list
Here is the function:
def parse_list_header(value):
"""Parse lists as described by RFC 2068 Section 2.
In particular, parse comma-separated lists where the elements of
the list may include quoted-strings. A quoted-string could
contain a comma. A non-quoted string could have quotes in the
middle. Quotes are removed automatically after parsing.
It basically works like :func:`parse_set_header` just that items
may appear multiple times and case sensitivity is preserved.
The return value is a standard :class:`list`:
>>> parse_list_header('token, "quoted value"')
['token', 'quoted value']
To create a header from the :class:`list` again, use the
:func:`dump_header` function.
:param value: a string with a list header.
:return: :class:`list`
:rtype: list
"""
result = []
for item in _parse_list_header(value):
if item[:1] == item[-1:] == '"':
item = unquote_header_value(item[1:-1])
result.append(item)
return result | Parse lists as described by RFC 2068 Section 2. In particular, parse comma-separated lists where the elements of the list may include quoted-strings. A quoted-string could contain a comma. A non-quoted string could have quotes in the middle. Quotes are removed automatically after parsing. It basically works like :func:`parse_set_header` just that items may appear multiple times and case sensitivity is preserved. The return value is a standard :class:`list`: >>> parse_list_header('token, "quoted value"') ['token', 'quoted value'] To create a header from the :class:`list` again, use the :func:`dump_header` function. :param value: a string with a list header. :return: :class:`list` :rtype: list |
1,458 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def unquote_header_value(value, is_filename=False):
r"""Unquotes a header value. (Reversal of :func:`quote_header_value`).
This does not use the real unquoting but what browsers are actually
using for quoting.
:param value: the header value to unquote.
:rtype: str
"""
if value and value[0] == value[-1] == '"':
# this is not the real unquoting, but fixing this so that the
# RFC is met will result in bugs with internet explorer and
# probably some other browsers as well. IE for example is
# uploading files with "C:\foo\bar.txt" as filename
value = value[1:-1]
# if this is a filename and the starting characters look like
# a UNC path, then just return the value without quotes. Using the
# replace sequence below on a UNC path has the effect of turning
# the leading double slash into a single slash and then
# _fix_ie_filename() doesn't work correctly. See #458.
if not is_filename or value[:2] != "\\\\":
return value.replace("\\\\", "\\").replace('\\"', '"')
return value
The provided code snippet includes necessary dependencies for implementing the `parse_dict_header` function. Write a Python function `def parse_dict_header(value)` to solve the following problem:
Parse lists of key, value pairs as described by RFC 2068 Section 2 and convert them into a python dict: >>> d = parse_dict_header('foo="is a fish", bar="as well"') >>> type(d) is dict True >>> sorted(d.items()) [('bar', 'as well'), ('foo', 'is a fish')] If there is no value for a key it will be `None`: >>> parse_dict_header('key_without_value') {'key_without_value': None} To create a header from the :class:`dict` again, use the :func:`dump_header` function. :param value: a string with a dict header. :return: :class:`dict` :rtype: dict
Here is the function:
def parse_dict_header(value):
"""Parse lists of key, value pairs as described by RFC 2068 Section 2 and
convert them into a python dict:
>>> d = parse_dict_header('foo="is a fish", bar="as well"')
>>> type(d) is dict
True
>>> sorted(d.items())
[('bar', 'as well'), ('foo', 'is a fish')]
If there is no value for a key it will be `None`:
>>> parse_dict_header('key_without_value')
{'key_without_value': None}
To create a header from the :class:`dict` again, use the
:func:`dump_header` function.
:param value: a string with a dict header.
:return: :class:`dict`
:rtype: dict
"""
result = {}
for item in _parse_list_header(value):
if "=" not in item:
result[item] = None
continue
name, value = item.split("=", 1)
if value[:1] == value[-1:] == '"':
value = unquote_header_value(value[1:-1])
result[name] = value
return result | Parse lists of key, value pairs as described by RFC 2068 Section 2 and convert them into a python dict: >>> d = parse_dict_header('foo="is a fish", bar="as well"') >>> type(d) is dict True >>> sorted(d.items()) [('bar', 'as well'), ('foo', 'is a fish')] If there is no value for a key it will be `None`: >>> parse_dict_header('key_without_value') {'key_without_value': None} To create a header from the :class:`dict` again, use the :func:`dump_header` function. :param value: a string with a dict header. :return: :class:`dict` :rtype: dict |
1,459 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `dict_from_cookiejar` function. Write a Python function `def dict_from_cookiejar(cj)` to solve the following problem:
Returns a key/value dictionary from a CookieJar. :param cj: CookieJar object to extract cookies from. :rtype: dict
Here is the function:
def dict_from_cookiejar(cj):
"""Returns a key/value dictionary from a CookieJar.
:param cj: CookieJar object to extract cookies from.
:rtype: dict
"""
cookie_dict = {}
for cookie in cj:
cookie_dict[cookie.name] = cookie.value
return cookie_dict | Returns a key/value dictionary from a CookieJar. :param cj: CookieJar object to extract cookies from. :rtype: dict |
1,460 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
"""Returns a CookieJar from a key/value dictionary.
:param cookie_dict: Dict of key/values to insert into CookieJar.
:param cookiejar: (optional) A cookiejar to add the cookies to.
:param overwrite: (optional) If False, will not replace cookies
already in the jar with new ones.
:rtype: CookieJar
"""
if cookiejar is None:
cookiejar = RequestsCookieJar()
if cookie_dict is not None:
names_from_jar = [cookie.name for cookie in cookiejar]
for name in cookie_dict:
if overwrite or (name not in names_from_jar):
cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
return cookiejar
The provided code snippet includes necessary dependencies for implementing the `add_dict_to_cookiejar` function. Write a Python function `def add_dict_to_cookiejar(cj, cookie_dict)` to solve the following problem:
Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. :rtype: CookieJar
Here is the function:
def add_dict_to_cookiejar(cj, cookie_dict):
"""Returns a CookieJar from a key/value dictionary.
:param cj: CookieJar to insert cookies into.
:param cookie_dict: Dict of key/values to insert into CookieJar.
:rtype: CookieJar
"""
return cookiejar_from_dict(cookie_dict, cj) | Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. :rtype: CookieJar |
1,461 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
import warnings
warnings.simplefilter("ignore", DependencyWarning)
warnings.simplefilter("default", FileModeWarning, append=True)
The provided code snippet includes necessary dependencies for implementing the `get_encodings_from_content` function. Write a Python function `def get_encodings_from_content(content)` to solve the following problem:
Returns encodings from given content string. :param content: bytestring to extract encodings from.
Here is the function:
def get_encodings_from_content(content):
"""Returns encodings from given content string.
:param content: bytestring to extract encodings from.
"""
warnings.warn(
(
"In requests 3.0, get_encodings_from_content will be removed. For "
"more information, please see the discussion on issue #2266. (This"
" warning should only appear once.)"
),
DeprecationWarning,
)
charset_re = re.compile(r'<meta.*?charset=["\']*(.+?)["\'>]', flags=re.I)
pragma_re = re.compile(r'<meta.*?content=["\']*;?charset=(.+?)["\'>]', flags=re.I)
xml_re = re.compile(r'^<\?xml.*?encoding=["\']*(.+?)["\'>]')
return (
charset_re.findall(content)
+ pragma_re.findall(content)
+ xml_re.findall(content)
) | Returns encodings from given content string. :param content: bytestring to extract encodings from. |
1,462 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `stream_decode_response_unicode` function. Write a Python function `def stream_decode_response_unicode(iterator, r)` to solve the following problem:
Stream decodes an iterator.
Here is the function:
def stream_decode_response_unicode(iterator, r):
"""Stream decodes an iterator."""
if r.encoding is None:
yield from iterator
return
decoder = codecs.getincrementaldecoder(r.encoding)(errors="replace")
for chunk in iterator:
rv = decoder.decode(chunk)
if rv:
yield rv
rv = decoder.decode(b"", final=True)
if rv:
yield rv | Stream decodes an iterator. |
1,463 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `iter_slices` function. Write a Python function `def iter_slices(string, slice_length)` to solve the following problem:
Iterate over slices of a string.
Here is the function:
def iter_slices(string, slice_length):
"""Iterate over slices of a string."""
pos = 0
if slice_length is None or slice_length <= 0:
slice_length = len(string)
while pos < len(string):
yield string[pos : pos + slice_length]
pos += slice_length | Iterate over slices of a string. |
1,464 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def get_encoding_from_headers(headers):
"""Returns encodings from given HTTP Header Dict.
:param headers: dictionary to extract encoding from.
:rtype: str
"""
content_type = headers.get("content-type")
if not content_type:
return None
content_type, params = _parse_content_type_header(content_type)
if "charset" in params:
return params["charset"].strip("'\"")
if "text" in content_type:
return "ISO-8859-1"
if "application/json" in content_type:
# Assume UTF-8 based on RFC 4627: https://www.ietf.org/rfc/rfc4627.txt since the charset was unset
return "utf-8"
import warnings
warnings.simplefilter("ignore", DependencyWarning)
warnings.simplefilter("default", FileModeWarning, append=True)
str = str
The provided code snippet includes necessary dependencies for implementing the `get_unicode_from_response` function. Write a Python function `def get_unicode_from_response(r)` to solve the following problem:
Returns the requested content back in unicode. :param r: Response object to get unicode content from. Tried: 1. charset from content-type 2. fall back and replace all unicode characters :rtype: str
Here is the function:
def get_unicode_from_response(r):
"""Returns the requested content back in unicode.
:param r: Response object to get unicode content from.
Tried:
1. charset from content-type
2. fall back and replace all unicode characters
:rtype: str
"""
warnings.warn(
(
"In requests 3.0, get_unicode_from_response will be removed. For "
"more information, please see the discussion on issue #2266. (This"
" warning should only appear once.)"
),
DeprecationWarning,
)
tried_encodings = []
# Try charset from content-type
encoding = get_encoding_from_headers(r.headers)
if encoding:
try:
return str(r.content, encoding)
except UnicodeError:
tried_encodings.append(encoding)
# Fall back:
try:
return str(r.content, encoding, errors="replace")
except TypeError:
return r.content | Returns the requested content back in unicode. :param r: Response object to get unicode content from. Tried: 1. charset from content-type 2. fall back and replace all unicode characters :rtype: str |
1,465 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def unquote_unreserved(uri):
"""Un-escape any percent-escape sequences in a URI that are unreserved
characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
:rtype: str
"""
parts = uri.split("%")
for i in range(1, len(parts)):
h = parts[i][0:2]
if len(h) == 2 and h.isalnum():
try:
c = chr(int(h, 16))
except ValueError:
raise InvalidURL(f"Invalid percent-escape sequence: '{h}'")
if c in UNRESERVED_SET:
parts[i] = c + parts[i][2:]
else:
parts[i] = f"%{parts[i]}"
else:
parts[i] = f"%{parts[i]}"
return "".join(parts)
class InvalidURL(RequestException, ValueError):
"""The URL provided was somehow invalid."""
The provided code snippet includes necessary dependencies for implementing the `requote_uri` function. Write a Python function `def requote_uri(uri)` to solve the following problem:
Re-quote the given URI. This function passes the given URI through an unquote/quote cycle to ensure that it is fully and consistently quoted. :rtype: str
Here is the function:
def requote_uri(uri):
"""Re-quote the given URI.
This function passes the given URI through an unquote/quote cycle to
ensure that it is fully and consistently quoted.
:rtype: str
"""
safe_with_percent = "!#$%&'()*+,/:;=?@[]~"
safe_without_percent = "!#$&'()*+,/:;=?@[]~"
try:
# Unquote only the unreserved characters
# Then quote only illegal characters (do not quote reserved,
# unreserved, or '%')
return quote(unquote_unreserved(uri), safe=safe_with_percent)
except InvalidURL:
# We couldn't unquote the given URI, so let's try quoting it, but
# there may be unquoted '%'s in the URI. We need to make sure they're
# properly quoted so they do not cause issues elsewhere.
return quote(uri, safe=safe_without_percent) | Re-quote the given URI. This function passes the given URI through an unquote/quote cycle to ensure that it is fully and consistently quoted. :rtype: str |
1,466 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `select_proxy` function. Write a Python function `def select_proxy(url, proxies)` to solve the following problem:
Select a proxy for the url, if applicable. :param url: The url being for the request :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
Here is the function:
def select_proxy(url, proxies):
"""Select a proxy for the url, if applicable.
:param url: The url being for the request
:param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
"""
proxies = proxies or {}
urlparts = urlparse(url)
if urlparts.hostname is None:
return proxies.get(urlparts.scheme, proxies.get("all"))
proxy_keys = [
urlparts.scheme + "://" + urlparts.hostname,
urlparts.scheme,
"all://" + urlparts.hostname,
"all",
]
proxy = None
for proxy_key in proxy_keys:
if proxy_key in proxies:
proxy = proxies[proxy_key]
break
return proxy | Select a proxy for the url, if applicable. :param url: The url being for the request :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs |
1,467 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def should_bypass_proxies(url, no_proxy):
"""
Returns whether we should bypass proxies or not.
:rtype: bool
"""
# Prioritize lowercase environment variables over uppercase
# to keep a consistent behaviour with other http projects (curl, wget).
def get_proxy(key):
return os.environ.get(key) or os.environ.get(key.upper())
# First check whether no_proxy is defined. If it is, check that the URL
# we're getting isn't in the no_proxy list.
no_proxy_arg = no_proxy
if no_proxy is None:
no_proxy = get_proxy("no_proxy")
parsed = urlparse(url)
if parsed.hostname is None:
# URLs don't always have hostnames, e.g. file:/// urls.
return True
if no_proxy:
# We need to check whether we match here. We need to see if we match
# the end of the hostname, both with and without the port.
no_proxy = (host for host in no_proxy.replace(" ", "").split(",") if host)
if is_ipv4_address(parsed.hostname):
for proxy_ip in no_proxy:
if is_valid_cidr(proxy_ip):
if address_in_network(parsed.hostname, proxy_ip):
return True
elif parsed.hostname == proxy_ip:
# If no_proxy ip was defined in plain IP notation instead of cidr notation &
# matches the IP of the index
return True
else:
host_with_port = parsed.hostname
if parsed.port:
host_with_port += f":{parsed.port}"
for host in no_proxy:
if parsed.hostname.endswith(host) or host_with_port.endswith(host):
# The URL does match something in no_proxy, so we don't want
# to apply the proxies on this URL.
return True
with set_environ("no_proxy", no_proxy_arg):
# parsed.hostname can be `None` in cases such as a file URI.
try:
bypass = proxy_bypass(parsed.hostname)
except (TypeError, socket.gaierror):
bypass = False
if bypass:
return True
return False
def get_environ_proxies(url, no_proxy=None):
"""
Return a dict of environment proxies.
:rtype: dict
"""
if should_bypass_proxies(url, no_proxy=no_proxy):
return {}
else:
return getproxies()
The provided code snippet includes necessary dependencies for implementing the `resolve_proxies` function. Write a Python function `def resolve_proxies(request, proxies, trust_env=True)` to solve the following problem:
This method takes proxy information from a request and configuration input to resolve a mapping of target proxies. This will consider settings such a NO_PROXY to strip proxy configurations. :param request: Request or PreparedRequest :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs :param trust_env: Boolean declaring whether to trust environment configs :rtype: dict
Here is the function:
def resolve_proxies(request, proxies, trust_env=True):
"""This method takes proxy information from a request and configuration
input to resolve a mapping of target proxies. This will consider settings
such a NO_PROXY to strip proxy configurations.
:param request: Request or PreparedRequest
:param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
:param trust_env: Boolean declaring whether to trust environment configs
:rtype: dict
"""
proxies = proxies if proxies is not None else {}
url = request.url
scheme = urlparse(url).scheme
no_proxy = proxies.get("no_proxy")
new_proxies = proxies.copy()
if trust_env and not should_bypass_proxies(url, no_proxy=no_proxy):
environ_proxies = get_environ_proxies(url, no_proxy=no_proxy)
proxy = environ_proxies.get(scheme, environ_proxies.get("all"))
if proxy:
new_proxies.setdefault(scheme, proxy)
return new_proxies | This method takes proxy information from a request and configuration input to resolve a mapping of target proxies. This will consider settings such a NO_PROXY to strip proxy configurations. :param request: Request or PreparedRequest :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs :param trust_env: Boolean declaring whether to trust environment configs :rtype: dict |
1,468 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
DEFAULT_ACCEPT_ENCODING = ", ".join(
re.split(r",\s*", make_headers(accept_encoding=True)["accept-encoding"])
)
def default_user_agent(name="python-requests"):
"""
Return a string representing the default user agent.
:rtype: str
"""
return f"{name}/{__version__}"
class CaseInsensitiveDict(MutableMapping):
"""A case-insensitive ``dict``-like object.
Implements all methods and operations of
``MutableMapping`` as well as dict's ``copy``. Also
provides ``lower_items``.
All keys are expected to be strings. The structure remembers the
case of the last key to be set, and ``iter(instance)``,
``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()``
will contain case-sensitive keys. However, querying and contains
testing is case insensitive::
cid = CaseInsensitiveDict()
cid['Accept'] = 'application/json'
cid['aCCEPT'] == 'application/json' # True
list(cid) == ['Accept'] # True
For example, ``headers['content-encoding']`` will return the
value of a ``'Content-Encoding'`` response header, regardless
of how the header name was originally stored.
If the constructor, ``.update``, or equality comparison
operations are given keys that have equal ``.lower()``s, the
behavior is undefined.
"""
def __init__(self, data=None, **kwargs):
self._store = OrderedDict()
if data is None:
data = {}
self.update(data, **kwargs)
def __setitem__(self, key, value):
# Use the lowercased key for lookups, but store the actual
# key alongside the value.
self._store[key.lower()] = (key, value)
def __getitem__(self, key):
return self._store[key.lower()][1]
def __delitem__(self, key):
del self._store[key.lower()]
def __iter__(self):
return (casedkey for casedkey, mappedvalue in self._store.values())
def __len__(self):
return len(self._store)
def lower_items(self):
"""Like iteritems(), but with all lowercase keys."""
return ((lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items())
def __eq__(self, other):
if isinstance(other, Mapping):
other = CaseInsensitiveDict(other)
else:
return NotImplemented
# Compare insensitively
return dict(self.lower_items()) == dict(other.lower_items())
# Copy is required
def copy(self):
return CaseInsensitiveDict(self._store.values())
def __repr__(self):
return str(dict(self.items()))
The provided code snippet includes necessary dependencies for implementing the `default_headers` function. Write a Python function `def default_headers()` to solve the following problem:
:rtype: requests.structures.CaseInsensitiveDict
Here is the function:
def default_headers():
"""
:rtype: requests.structures.CaseInsensitiveDict
"""
return CaseInsensitiveDict(
{
"User-Agent": default_user_agent(),
"Accept-Encoding": DEFAULT_ACCEPT_ENCODING,
"Accept": "*/*",
"Connection": "keep-alive",
}
) | :rtype: requests.structures.CaseInsensitiveDict |
1,469 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `parse_header_links` function. Write a Python function `def parse_header_links(value)` to solve the following problem:
Return a list of parsed link headers proxies. i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg" :rtype: list
Here is the function:
def parse_header_links(value):
"""Return a list of parsed link headers proxies.
i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
:rtype: list
"""
links = []
replace_chars = " '\""
value = value.strip(replace_chars)
if not value:
return links
for val in re.split(", *<", value):
try:
url, params = val.split(";", 1)
except ValueError:
url, params = val, ""
link = {"url": url.strip("<> '\"")}
for param in params.split(";"):
try:
key, value = param.split("=")
except ValueError:
break
link[key.strip(replace_chars)] = value.strip(replace_chars)
links.append(link)
return links | Return a list of parsed link headers proxies. i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg" :rtype: list |
1,470 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
_null = "\x00".encode("ascii")
_null2 = _null * 2
_null3 = _null * 3
The provided code snippet includes necessary dependencies for implementing the `guess_json_utf` function. Write a Python function `def guess_json_utf(data)` to solve the following problem:
:rtype: str
Here is the function:
def guess_json_utf(data):
"""
:rtype: str
"""
# JSON always starts with two ASCII characters, so detection is as
# easy as counting the nulls and from their location and count
# determine the encoding. Also detect a BOM, if present.
sample = data[:4]
if sample in (codecs.BOM_UTF32_LE, codecs.BOM_UTF32_BE):
return "utf-32" # BOM included
if sample[:3] == codecs.BOM_UTF8:
return "utf-8-sig" # BOM included, MS style (discouraged)
if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE):
return "utf-16" # BOM included
nullcount = sample.count(_null)
if nullcount == 0:
return "utf-8"
if nullcount == 2:
if sample[::2] == _null2: # 1st and 3rd are null
return "utf-16-be"
if sample[1::2] == _null2: # 2nd and 4th are null
return "utf-16-le"
# Did not detect 2 valid UTF-16 ascii-range characters
if nullcount == 3:
if sample[:3] == _null3:
return "utf-32-be"
if sample[1:] == _null3:
return "utf-32-le"
# Did not detect a valid UTF-32 ascii-range character
return None | :rtype: str |
1,471 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `prepend_scheme_if_needed` function. Write a Python function `def prepend_scheme_if_needed(url, new_scheme)` to solve the following problem:
Given a URL that may or may not have a scheme, prepend the given scheme. Does not replace a present scheme with the one provided as an argument. :rtype: str
Here is the function:
def prepend_scheme_if_needed(url, new_scheme):
"""Given a URL that may or may not have a scheme, prepend the given scheme.
Does not replace a present scheme with the one provided as an argument.
:rtype: str
"""
parsed = parse_url(url)
scheme, auth, host, port, path, query, fragment = parsed
# A defect in urlparse determines that there isn't a netloc present in some
# urls. We previously assumed parsing was overly cautious, and swapped the
# netloc and path. Due to a lack of tests on the original defect, this is
# maintained with parse_url for backwards compatibility.
netloc = parsed.netloc
if not netloc:
netloc, path = path, netloc
if auth:
# parse_url doesn't provide the netloc with auth
# so we'll add it ourselves.
netloc = "@".join([auth, netloc])
if scheme is None:
scheme = new_scheme
if path is None:
path = ""
return urlunparse((scheme, netloc, path, "", query, fragment)) | Given a URL that may or may not have a scheme, prepend the given scheme. Does not replace a present scheme with the one provided as an argument. :rtype: str |
1,472 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `get_auth_from_url` function. Write a Python function `def get_auth_from_url(url)` to solve the following problem:
Given a url with authentication components, extract them into a tuple of username,password. :rtype: (str,str)
Here is the function:
def get_auth_from_url(url):
"""Given a url with authentication components, extract them into a tuple of
username,password.
:rtype: (str,str)
"""
parsed = urlparse(url)
try:
auth = (unquote(parsed.username), unquote(parsed.password))
except (AttributeError, TypeError):
auth = ("", "")
return auth | Given a url with authentication components, extract them into a tuple of username,password. :rtype: (str,str) |
1,473 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
def _validate_header_part(header_part, header_kind, validator):
if not validator.match(header_part):
raise InvalidHeader(
f"Invalid leading whitespace, reserved character(s), or return"
f"character(s) in header {header_kind}: {header_part!r}"
)
HEADER_VALIDATORS = {
bytes: (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE),
str: (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR),
}
class InvalidHeader(RequestException, ValueError):
"""The header value provided was somehow invalid."""
The provided code snippet includes necessary dependencies for implementing the `check_header_validity` function. Write a Python function `def check_header_validity(header)` to solve the following problem:
Verifies that header parts don't contain leading whitespace reserved characters, or return characters. :param header: tuple, in the format (name, value).
Here is the function:
def check_header_validity(header):
"""Verifies that header parts don't contain leading whitespace
reserved characters, or return characters.
:param header: tuple, in the format (name, value).
"""
name, value = header
for part in header:
if type(part) not in HEADER_VALIDATORS:
raise InvalidHeader(
f"Header part ({part!r}) from {{{name!r}: {value!r}}} must be "
f"of type str or bytes, not {type(part)}"
)
_validate_header_part(name, "name", HEADER_VALIDATORS[type(name)][0])
_validate_header_part(value, "value", HEADER_VALIDATORS[type(value)][1]) | Verifies that header parts don't contain leading whitespace reserved characters, or return characters. :param header: tuple, in the format (name, value). |
1,474 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
The provided code snippet includes necessary dependencies for implementing the `urldefragauth` function. Write a Python function `def urldefragauth(url)` to solve the following problem:
Given a url remove the fragment and the authentication part. :rtype: str
Here is the function:
def urldefragauth(url):
"""
Given a url remove the fragment and the authentication part.
:rtype: str
"""
scheme, netloc, path, params, query, fragment = urlparse(url)
# see func:`prepend_scheme_if_needed`
if not netloc:
netloc, path = path, netloc
netloc = netloc.rsplit("@", 1)[-1]
return urlunparse((scheme, netloc, path, params, query, "")) | Given a url remove the fragment and the authentication part. :rtype: str |
1,475 | import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict
from urllib3.util import make_headers, parse_url
from . import certs
from .__version__ import __version__
from ._internal_utils import HEADER_VALIDATORS, to_native_string
from .compat import (
Mapping,
basestring,
bytes,
getproxies,
getproxies_environment,
integer_types,
)
from .compat import parse_http_list as _parse_list_header
from .compat import (
proxy_bypass,
proxy_bypass_environment,
quote,
str,
unquote,
urlparse,
urlunparse,
)
from .cookies import cookiejar_from_dict
from .exceptions import (
FileModeWarning,
InvalidHeader,
InvalidURL,
UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict
integer_types = (int,)
class UnrewindableBodyError(RequestException):
"""Requests encountered an error when trying to rewind a body."""
The provided code snippet includes necessary dependencies for implementing the `rewind_body` function. Write a Python function `def rewind_body(prepared_request)` to solve the following problem:
Move file pointer back to its recorded starting position so it can be read again on redirect.
Here is the function:
def rewind_body(prepared_request):
"""Move file pointer back to its recorded starting position
so it can be read again on redirect.
"""
body_seek = getattr(prepared_request.body, "seek", None)
if body_seek is not None and isinstance(
prepared_request._body_position, integer_types
):
try:
body_seek(prepared_request._body_position)
except OSError:
raise UnrewindableBodyError(
"An error occurred when rewinding request body for redirect."
)
else:
raise UnrewindableBodyError("Unable to rewind request body for redirect.") | Move file pointer back to its recorded starting position so it can be read again on redirect. |
1,476 | import os.path
import socket
from urllib3.exceptions import ClosedPoolError, ConnectTimeoutError
from urllib3.exceptions import HTTPError as _HTTPError
from urllib3.exceptions import InvalidHeader as _InvalidHeader
from urllib3.exceptions import (
LocationValueError,
MaxRetryError,
NewConnectionError,
ProtocolError,
)
from urllib3.exceptions import ProxyError as _ProxyError
from urllib3.exceptions import ReadTimeoutError, ResponseError
from urllib3.exceptions import SSLError as _SSLError
from urllib3.poolmanager import PoolManager, proxy_from_url
from urllib3.response import HTTPResponse
from urllib3.util import Timeout as TimeoutSauce
from urllib3.util import parse_url
from urllib3.util.retry import Retry
from .auth import _basic_auth_str
from .compat import basestring, urlparse
from .cookies import extract_cookies_to_jar
from .exceptions import (
ConnectionError,
ConnectTimeout,
InvalidHeader,
InvalidProxyURL,
InvalidSchema,
InvalidURL,
ProxyError,
ReadTimeout,
RetryError,
SSLError,
)
from .models import Response
from .structures import CaseInsensitiveDict
from .utils import (
DEFAULT_CA_BUNDLE_PATH,
extract_zipped_paths,
get_auth_from_url,
get_encoding_from_headers,
prepend_scheme_if_needed,
select_proxy,
urldefragauth,
)
class InvalidSchema(RequestException, ValueError):
"""The URL scheme provided is either invalid or unsupported."""
def SOCKSProxyManager(*args, **kwargs):
raise InvalidSchema("Missing dependencies for SOCKS support.") | null |
1,477 | import calendar
import copy
import time
from ._internal_utils import to_native_string
from .compat import Morsel, MutableMapping, cookielib, urlparse, urlunparse
class MockRequest:
"""Wraps a `requests.Request` to mimic a `urllib2.Request`.
The code in `cookielib.CookieJar` expects this interface in order to correctly
manage cookie policies, i.e., determine whether a cookie can be set, given the
domains of the request and the cookie.
The original request object is read-only. The client is responsible for collecting
the new headers via `get_new_headers()` and interpreting them appropriately. You
probably want `get_cookie_header`, defined below.
"""
def __init__(self, request):
self._r = request
self._new_headers = {}
self.type = urlparse(self._r.url).scheme
def get_type(self):
return self.type
def get_host(self):
return urlparse(self._r.url).netloc
def get_origin_req_host(self):
return self.get_host()
def get_full_url(self):
# Only return the response's URL if the user hadn't set the Host
# header
if not self._r.headers.get("Host"):
return self._r.url
# If they did set it, retrieve it and reconstruct the expected domain
host = to_native_string(self._r.headers["Host"], encoding="utf-8")
parsed = urlparse(self._r.url)
# Reconstruct the URL as we expect it
return urlunparse(
[
parsed.scheme,
host,
parsed.path,
parsed.params,
parsed.query,
parsed.fragment,
]
)
def is_unverifiable(self):
return True
def has_header(self, name):
return name in self._r.headers or name in self._new_headers
def get_header(self, name, default=None):
return self._r.headers.get(name, self._new_headers.get(name, default))
def add_header(self, key, val):
"""cookielib has no legitimate use for this method; add it back if you find one."""
raise NotImplementedError(
"Cookie headers should be added with add_unredirected_header()"
)
def add_unredirected_header(self, name, value):
self._new_headers[name] = value
def get_new_headers(self):
return self._new_headers
def unverifiable(self):
return self.is_unverifiable()
def origin_req_host(self):
return self.get_origin_req_host()
def host(self):
return self.get_host()
class MockResponse:
"""Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.
...what? Basically, expose the parsed HTTP headers from the server response
the way `cookielib` expects to see them.
"""
def __init__(self, headers):
"""Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers
"""
self._headers = headers
def info(self):
return self._headers
def getheaders(self, name):
self._headers.getheaders(name)
The provided code snippet includes necessary dependencies for implementing the `extract_cookies_to_jar` function. Write a Python function `def extract_cookies_to_jar(jar, request, response)` to solve the following problem:
Extract the cookies from the response into a CookieJar. :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar) :param request: our own requests.Request object :param response: urllib3.HTTPResponse object
Here is the function:
def extract_cookies_to_jar(jar, request, response):
"""Extract the cookies from the response into a CookieJar.
:param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
:param request: our own requests.Request object
:param response: urllib3.HTTPResponse object
"""
if not (hasattr(response, "_original_response") and response._original_response):
return
# the _original_response field is the wrapped httplib.HTTPResponse object,
req = MockRequest(request)
# pull out the HTTPMessage with the headers and put it in the mock:
res = MockResponse(response._original_response.msg)
jar.extract_cookies(res, req) | Extract the cookies from the response into a CookieJar. :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar) :param request: our own requests.Request object :param response: urllib3.HTTPResponse object |
1,478 | import calendar
import copy
import time
from ._internal_utils import to_native_string
from .compat import Morsel, MutableMapping, cookielib, urlparse, urlunparse
class MockRequest:
"""Wraps a `requests.Request` to mimic a `urllib2.Request`.
The code in `cookielib.CookieJar` expects this interface in order to correctly
manage cookie policies, i.e., determine whether a cookie can be set, given the
domains of the request and the cookie.
The original request object is read-only. The client is responsible for collecting
the new headers via `get_new_headers()` and interpreting them appropriately. You
probably want `get_cookie_header`, defined below.
"""
def __init__(self, request):
self._r = request
self._new_headers = {}
self.type = urlparse(self._r.url).scheme
def get_type(self):
return self.type
def get_host(self):
return urlparse(self._r.url).netloc
def get_origin_req_host(self):
return self.get_host()
def get_full_url(self):
# Only return the response's URL if the user hadn't set the Host
# header
if not self._r.headers.get("Host"):
return self._r.url
# If they did set it, retrieve it and reconstruct the expected domain
host = to_native_string(self._r.headers["Host"], encoding="utf-8")
parsed = urlparse(self._r.url)
# Reconstruct the URL as we expect it
return urlunparse(
[
parsed.scheme,
host,
parsed.path,
parsed.params,
parsed.query,
parsed.fragment,
]
)
def is_unverifiable(self):
return True
def has_header(self, name):
return name in self._r.headers or name in self._new_headers
def get_header(self, name, default=None):
return self._r.headers.get(name, self._new_headers.get(name, default))
def add_header(self, key, val):
"""cookielib has no legitimate use for this method; add it back if you find one."""
raise NotImplementedError(
"Cookie headers should be added with add_unredirected_header()"
)
def add_unredirected_header(self, name, value):
self._new_headers[name] = value
def get_new_headers(self):
return self._new_headers
def unverifiable(self):
return self.is_unverifiable()
def origin_req_host(self):
return self.get_origin_req_host()
def host(self):
return self.get_host()
The provided code snippet includes necessary dependencies for implementing the `get_cookie_header` function. Write a Python function `def get_cookie_header(jar, request)` to solve the following problem:
Produce an appropriate Cookie header string to be sent with `request`, or None. :rtype: str
Here is the function:
def get_cookie_header(jar, request):
"""
Produce an appropriate Cookie header string to be sent with `request`, or None.
:rtype: str
"""
r = MockRequest(request)
jar.add_cookie_header(r)
return r.get_new_headers().get("Cookie") | Produce an appropriate Cookie header string to be sent with `request`, or None. :rtype: str |
1,479 | import calendar
import copy
import time
from ._internal_utils import to_native_string
from .compat import Morsel, MutableMapping, cookielib, urlparse, urlunparse
The provided code snippet includes necessary dependencies for implementing the `remove_cookie_by_name` function. Write a Python function `def remove_cookie_by_name(cookiejar, name, domain=None, path=None)` to solve the following problem:
Unsets a cookie by name, by default over all domains and paths. Wraps CookieJar.clear(), is O(n).
Here is the function:
def remove_cookie_by_name(cookiejar, name, domain=None, path=None):
"""Unsets a cookie by name, by default over all domains and paths.
Wraps CookieJar.clear(), is O(n).
"""
clearables = []
for cookie in cookiejar:
if cookie.name != name:
continue
if domain is not None and domain != cookie.domain:
continue
if path is not None and path != cookie.path:
continue
clearables.append((cookie.domain, cookie.path, cookie.name))
for domain, path, name in clearables:
cookiejar.clear(domain, path, name) | Unsets a cookie by name, by default over all domains and paths. Wraps CookieJar.clear(), is O(n). |
1,480 | import calendar
import copy
import time
from ._internal_utils import to_native_string
from .compat import Morsel, MutableMapping, cookielib, urlparse, urlunparse
def _copy_cookie_jar(jar):
if jar is None:
return None
if hasattr(jar, "copy"):
# We're dealing with an instance of RequestsCookieJar
return jar.copy()
# We're dealing with a generic CookieJar instance
new_jar = copy.copy(jar)
new_jar.clear()
for cookie in jar:
new_jar.set_cookie(copy.copy(cookie))
return new_jar | null |
1,481 | import calendar
import copy
import time
from ._internal_utils import to_native_string
from .compat import Morsel, MutableMapping, cookielib, urlparse, urlunparse
def create_cookie(name, value, **kwargs):
"""Make a cookie from underspecified parameters.
By default, the pair of `name` and `value` will be set for the domain ''
and sent on every request (this is sometimes called a "supercookie").
"""
result = {
"version": 0,
"name": name,
"value": value,
"port": None,
"domain": "",
"path": "/",
"secure": False,
"expires": None,
"discard": True,
"comment": None,
"comment_url": None,
"rest": {"HttpOnly": None},
"rfc2109": False,
}
badargs = set(kwargs) - set(result)
if badargs:
raise TypeError(
f"create_cookie() got unexpected keyword arguments: {list(badargs)}"
)
result.update(kwargs)
result["port_specified"] = bool(result["port"])
result["domain_specified"] = bool(result["domain"])
result["domain_initial_dot"] = result["domain"].startswith(".")
result["path_specified"] = bool(result["path"])
return cookielib.Cookie(**result)
The provided code snippet includes necessary dependencies for implementing the `morsel_to_cookie` function. Write a Python function `def morsel_to_cookie(morsel)` to solve the following problem:
Convert a Morsel object into a Cookie containing the one k/v pair.
Here is the function:
def morsel_to_cookie(morsel):
"""Convert a Morsel object into a Cookie containing the one k/v pair."""
expires = None
if morsel["max-age"]:
try:
expires = int(time.time() + int(morsel["max-age"]))
except ValueError:
raise TypeError(f"max-age: {morsel['max-age']} must be integer")
elif morsel["expires"]:
time_template = "%a, %d-%b-%Y %H:%M:%S GMT"
expires = calendar.timegm(time.strptime(morsel["expires"], time_template))
return create_cookie(
comment=morsel["comment"],
comment_url=bool(morsel["comment"]),
discard=False,
domain=morsel["domain"],
expires=expires,
name=morsel.key,
path=morsel["path"],
port=None,
rest={"HttpOnly": morsel["httponly"]},
rfc2109=False,
secure=bool(morsel["secure"]),
value=morsel.value,
version=morsel["version"] or 0,
) | Convert a Morsel object into a Cookie containing the one k/v pair. |
1,482 | import calendar
import copy
import time
from ._internal_utils import to_native_string
from .compat import Morsel, MutableMapping, cookielib, urlparse, urlunparse
def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
"""Returns a CookieJar from a key/value dictionary.
:param cookie_dict: Dict of key/values to insert into CookieJar.
:param cookiejar: (optional) A cookiejar to add the cookies to.
:param overwrite: (optional) If False, will not replace cookies
already in the jar with new ones.
:rtype: CookieJar
"""
if cookiejar is None:
cookiejar = RequestsCookieJar()
if cookie_dict is not None:
names_from_jar = [cookie.name for cookie in cookiejar]
for name in cookie_dict:
if overwrite or (name not in names_from_jar):
cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
return cookiejar
The provided code snippet includes necessary dependencies for implementing the `merge_cookies` function. Write a Python function `def merge_cookies(cookiejar, cookies)` to solve the following problem:
Add cookies to cookiejar and returns a merged CookieJar. :param cookiejar: CookieJar object to add the cookies to. :param cookies: Dictionary or CookieJar object to be added. :rtype: CookieJar
Here is the function:
def merge_cookies(cookiejar, cookies):
"""Add cookies to cookiejar and returns a merged CookieJar.
:param cookiejar: CookieJar object to add the cookies to.
:param cookies: Dictionary or CookieJar object to be added.
:rtype: CookieJar
"""
if not isinstance(cookiejar, cookielib.CookieJar):
raise ValueError("You can only merge into CookieJar")
if isinstance(cookies, dict):
cookiejar = cookiejar_from_dict(cookies, cookiejar=cookiejar, overwrite=False)
elif isinstance(cookies, cookielib.CookieJar):
try:
cookiejar.update(cookies)
except AttributeError:
for cookie_in_jar in cookies:
cookiejar.set_cookie(cookie_in_jar)
return cookiejar | Add cookies to cookiejar and returns a merged CookieJar. :param cookiejar: CookieJar object to add the cookies to. :param cookies: Dictionary or CookieJar object to be added. :rtype: CookieJar |
1,483 | HOOKS = ["response"]
def default_hooks():
return {event: [] for event in HOOKS} | null |
1,484 |
The provided code snippet includes necessary dependencies for implementing the `dispatch_hook` function. Write a Python function `def dispatch_hook(key, hooks, hook_data, **kwargs)` to solve the following problem:
Dispatches a hook dictionary on a given piece of data.
Here is the function:
def dispatch_hook(key, hooks, hook_data, **kwargs):
"""Dispatches a hook dictionary on a given piece of data."""
hooks = hooks or {}
hooks = hooks.get(key)
if hooks:
if hasattr(hooks, "__call__"):
hooks = [hooks]
for hook in hooks:
_hook_data = hook(hook_data, **kwargs)
if _hook_data is not None:
hook_data = _hook_data
return hook_data | Dispatches a hook dictionary on a given piece of data. |
1,485 | import json
import platform
import ssl
import sys
import idna
import urllib3
from . import __version__ as requests_version
try:
import charset_normalizer
except ImportError:
charset_normalizer = None
try:
import chardet
except ImportError:
chardet = None
try:
from urllib3.contrib import pyopenssl
except ImportError:
pyopenssl = None
OpenSSL = None
cryptography = None
else:
import cryptography
import OpenSSL
def _implementation():
"""Return a dict with the Python implementation and version.
Provide both the name and the version of the Python implementation
currently running. For example, on CPython 3.10.3 it will return
{'name': 'CPython', 'version': '3.10.3'}.
This function works best on CPython and PyPy: in particular, it probably
doesn't work for Jython or IronPython. Future investigation should be done
to work out the correct shape of the code for those platforms.
"""
implementation = platform.python_implementation()
if implementation == "CPython":
implementation_version = platform.python_version()
elif implementation == "PyPy":
implementation_version = "{}.{}.{}".format(
sys.pypy_version_info.major,
sys.pypy_version_info.minor,
sys.pypy_version_info.micro,
)
if sys.pypy_version_info.releaselevel != "final":
implementation_version = "".join(
[implementation_version, sys.pypy_version_info.releaselevel]
)
elif implementation == "Jython":
implementation_version = platform.python_version() # Complete Guess
elif implementation == "IronPython":
implementation_version = platform.python_version() # Complete Guess
else:
implementation_version = "Unknown"
return {"name": implementation, "version": implementation_version}
try:
from charset_normalizer import __version__ as charset_normalizer_version
except ImportError:
charset_normalizer_version = None
try:
from chardet import __version__ as chardet_version
except ImportError:
chardet_version = None
try:
try:
import ssl
except ImportError:
ssl = None
if not getattr(ssl, "HAS_SNI", False):
from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3()
# Check cryptography version
from cryptography import __version__ as cryptography_version
_check_cryptography(cryptography_version)
except ImportError:
pass
__version__ = "2.28.2"
The provided code snippet includes necessary dependencies for implementing the `info` function. Write a Python function `def info()` to solve the following problem:
Generate information for a bug report.
Here is the function:
def info():
"""Generate information for a bug report."""
try:
platform_info = {
"system": platform.system(),
"release": platform.release(),
}
except OSError:
platform_info = {
"system": "Unknown",
"release": "Unknown",
}
implementation_info = _implementation()
urllib3_info = {"version": urllib3.__version__}
charset_normalizer_info = {"version": None}
chardet_info = {"version": None}
if charset_normalizer:
charset_normalizer_info = {"version": charset_normalizer.__version__}
if chardet:
chardet_info = {"version": chardet.__version__}
pyopenssl_info = {
"version": None,
"openssl_version": "",
}
if OpenSSL:
pyopenssl_info = {
"version": OpenSSL.__version__,
"openssl_version": f"{OpenSSL.SSL.OPENSSL_VERSION_NUMBER:x}",
}
cryptography_info = {
"version": getattr(cryptography, "__version__", ""),
}
idna_info = {
"version": getattr(idna, "__version__", ""),
}
system_ssl = ssl.OPENSSL_VERSION_NUMBER
system_ssl_info = {"version": f"{system_ssl:x}" if system_ssl is not None else ""}
return {
"platform": platform_info,
"implementation": implementation_info,
"system_ssl": system_ssl_info,
"using_pyopenssl": pyopenssl is not None,
"using_charset_normalizer": chardet is None,
"pyOpenSSL": pyopenssl_info,
"urllib3": urllib3_info,
"chardet": chardet_info,
"charset_normalizer": charset_normalizer_info,
"cryptography": cryptography_info,
"idna": idna_info,
"requests": {
"version": requests_version,
},
} | Generate information for a bug report. |
1,486 | from .structures import LookupDict
_codes = {
# Informational.
100: ("continue",),
101: ("switching_protocols",),
102: ("processing",),
103: ("checkpoint",),
122: ("uri_too_long", "request_uri_too_long"),
200: ("ok", "okay", "all_ok", "all_okay", "all_good", "\\o/", "✓"),
201: ("created",),
202: ("accepted",),
203: ("non_authoritative_info", "non_authoritative_information"),
204: ("no_content",),
205: ("reset_content", "reset"),
206: ("partial_content", "partial"),
207: ("multi_status", "multiple_status", "multi_stati", "multiple_stati"),
208: ("already_reported",),
226: ("im_used",),
# Redirection.
300: ("multiple_choices",),
301: ("moved_permanently", "moved", "\\o-"),
302: ("found",),
303: ("see_other", "other"),
304: ("not_modified",),
305: ("use_proxy",),
306: ("switch_proxy",),
307: ("temporary_redirect", "temporary_moved", "temporary"),
308: (
"permanent_redirect",
"resume_incomplete",
"resume",
), # "resume" and "resume_incomplete" to be removed in 3.0
# Client Error.
400: ("bad_request", "bad"),
401: ("unauthorized",),
402: ("payment_required", "payment"),
403: ("forbidden",),
404: ("not_found", "-o-"),
405: ("method_not_allowed", "not_allowed"),
406: ("not_acceptable",),
407: ("proxy_authentication_required", "proxy_auth", "proxy_authentication"),
408: ("request_timeout", "timeout"),
409: ("conflict",),
410: ("gone",),
411: ("length_required",),
412: ("precondition_failed", "precondition"),
413: ("request_entity_too_large",),
414: ("request_uri_too_large",),
415: ("unsupported_media_type", "unsupported_media", "media_type"),
416: (
"requested_range_not_satisfiable",
"requested_range",
"range_not_satisfiable",
),
417: ("expectation_failed",),
418: ("im_a_teapot", "teapot", "i_am_a_teapot"),
421: ("misdirected_request",),
422: ("unprocessable_entity", "unprocessable"),
423: ("locked",),
424: ("failed_dependency", "dependency"),
425: ("unordered_collection", "unordered"),
426: ("upgrade_required", "upgrade"),
428: ("precondition_required", "precondition"),
429: ("too_many_requests", "too_many"),
431: ("header_fields_too_large", "fields_too_large"),
444: ("no_response", "none"),
449: ("retry_with", "retry"),
450: ("blocked_by_windows_parental_controls", "parental_controls"),
451: ("unavailable_for_legal_reasons", "legal_reasons"),
499: ("client_closed_request",),
# Server Error.
500: ("internal_server_error", "server_error", "/o\\", "✗"),
501: ("not_implemented",),
502: ("bad_gateway",),
503: ("service_unavailable", "unavailable"),
504: ("gateway_timeout",),
505: ("http_version_not_supported", "http_version"),
506: ("variant_also_negotiates",),
507: ("insufficient_storage",),
509: ("bandwidth_limit_exceeded", "bandwidth"),
510: ("not_extended",),
511: ("network_authentication_required", "network_auth", "network_authentication"),
}
codes = LookupDict(name="status_codes")
def _init():
for code, titles in _codes.items():
for title in titles:
setattr(codes, title, code)
if not title.startswith(("\\", "/")):
setattr(codes, title.upper(), code)
def doc(code):
names = ", ".join(f"``{n}``" for n in _codes[code])
return "* %d: %s" % (code, names)
global __doc__
__doc__ = (
__doc__ + "\n" + "\n".join(doc(code) for code in sorted(_codes))
if __doc__ is not None
else None
) | null |
1,487 | import re
from .compat import builtin_str
The provided code snippet includes necessary dependencies for implementing the `unicode_is_ascii` function. Write a Python function `def unicode_is_ascii(u_string)` to solve the following problem:
Determine if unicode string only contains ASCII characters. :param str u_string: unicode string to check. Must be unicode and not Python 2 `str`. :rtype: bool
Here is the function:
def unicode_is_ascii(u_string):
"""Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool
"""
assert isinstance(u_string, str)
try:
u_string.encode("ascii")
return True
except UnicodeEncodeError:
return False | Determine if unicode string only contains ASCII characters. :param str u_string: unicode string to check. Must be unicode and not Python 2 `str`. :rtype: bool |
1,488 | import hashlib
import os
import re
import threading
import time
import warnings
from base64 import b64encode
from ._internal_utils import to_native_string
from .compat import basestring, str, urlparse
from .cookies import extract_cookies_to_jar
from .utils import parse_dict_header
import warnings
warnings.simplefilter("ignore", DependencyWarning)
warnings.simplefilter("default", FileModeWarning, append=True)
def to_native_string(string, encoding="ascii"):
"""Given a string object, regardless of type, returns a representation of
that string in the native string type, encoding and decoding where
necessary. This assumes ASCII unless told otherwise.
"""
if isinstance(string, builtin_str):
out = string
else:
out = string.decode(encoding)
return out
str = str
basestring = (str, bytes)
The provided code snippet includes necessary dependencies for implementing the `_basic_auth_str` function. Write a Python function `def _basic_auth_str(username, password)` to solve the following problem:
Returns a Basic Auth string.
Here is the function:
def _basic_auth_str(username, password):
"""Returns a Basic Auth string."""
# "I want us to put a big-ol' comment on top of it that
# says that this behaviour is dumb but we need to preserve
# it because people are relying on it."
# - Lukasa
#
# These are here solely to maintain backwards compatibility
# for things like ints. This will be removed in 3.0.0.
if not isinstance(username, basestring):
warnings.warn(
"Non-string usernames will no longer be supported in Requests "
"3.0.0. Please convert the object you've passed in ({!r}) to "
"a string or bytes object in the near future to avoid "
"problems.".format(username),
category=DeprecationWarning,
)
username = str(username)
if not isinstance(password, basestring):
warnings.warn(
"Non-string passwords will no longer be supported in Requests "
"3.0.0. Please convert the object you've passed in ({!r}) to "
"a string or bytes object in the near future to avoid "
"problems.".format(type(password)),
category=DeprecationWarning,
)
password = str(password)
# -- End Removal --
if isinstance(username, str):
username = username.encode("latin1")
if isinstance(password, str):
password = password.encode("latin1")
authstr = "Basic " + to_native_string(
b64encode(b":".join((username, password))).strip()
)
return authstr | Returns a Basic Auth string. |
1,489 | import sys
import types
from array import array
from collections import abc
from ._abc import MultiMapping, MutableMultiMapping
def GenericAlias(cls):
return cls | null |
1,490 | import sys
import types
from array import array
from collections import abc
from ._abc import MultiMapping, MutableMultiMapping
_version = array("Q", [0])
class _Base:
def _title(self, key):
def getall(self, key, default=_marker):
def getone(self, key, default=_marker):
def __getitem__(self, key):
def get(self, key, default=None):
def __iter__(self):
def __len__(self):
def keys(self):
def items(self):
def values(self):
def __eq__(self, other):
def __contains__(self, key):
def __repr__(self):
def getversion(md):
if not isinstance(md, _Base):
raise TypeError("Parameter should be multidict or proxy")
return md._impl._version | null |
1,491 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _abc_itemsview_register(view_cls):
ItemsView.register(view_cls) | null |
1,492 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _abc_keysview_register(view_cls):
KeysView.register(view_cls) | null |
1,493 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _abc_valuesview_register(view_cls):
ValuesView.register(view_cls) | null |
1,494 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _viewbaseset_richcmp(view, other, op):
if op == 0: # <
if not isinstance(other, Set):
return NotImplemented
return len(view) < len(other) and view <= other
elif op == 1: # <=
if not isinstance(other, Set):
return NotImplemented
if len(view) > len(other):
return False
for elem in view:
if elem not in other:
return False
return True
elif op == 2: # ==
if not isinstance(other, Set):
return NotImplemented
return len(view) == len(other) and view <= other
elif op == 3: # !=
return not view == other
elif op == 4: # >
if not isinstance(other, Set):
return NotImplemented
return len(view) > len(other) and view >= other
elif op == 5: # >=
if not isinstance(other, Set):
return NotImplemented
if len(view) < len(other):
return False
for elem in other:
if elem not in view:
return False
return True | null |
1,495 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _viewbaseset_and(view, other):
if not isinstance(other, Iterable):
return NotImplemented
if isinstance(view, Set):
view = set(iter(view))
if isinstance(other, Set):
other = set(iter(other))
if not isinstance(other, Set):
other = set(iter(other))
return view & other | null |
1,496 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _viewbaseset_or(view, other):
if not isinstance(other, Iterable):
return NotImplemented
if isinstance(view, Set):
view = set(iter(view))
if isinstance(other, Set):
other = set(iter(other))
if not isinstance(other, Set):
other = set(iter(other))
return view | other | null |
1,497 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _viewbaseset_sub(view, other):
if not isinstance(other, Iterable):
return NotImplemented
if isinstance(view, Set):
view = set(iter(view))
if isinstance(other, Set):
other = set(iter(other))
if not isinstance(other, Set):
other = set(iter(other))
return view - other | null |
1,498 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _viewbaseset_xor(view, other):
if not isinstance(other, Iterable):
return NotImplemented
if isinstance(view, Set):
view = set(iter(view))
if isinstance(other, Set):
other = set(iter(other))
if not isinstance(other, Set):
other = set(iter(other))
return view ^ other | null |
1,499 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
The provided code snippet includes necessary dependencies for implementing the `_itemsview_isdisjoint` function. Write a Python function `def _itemsview_isdisjoint(view, other)` to solve the following problem:
Return True if two sets have a null intersection.
Here is the function:
def _itemsview_isdisjoint(view, other):
"Return True if two sets have a null intersection."
for v in other:
if v in view:
return False
return True | Return True if two sets have a null intersection. |
1,500 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _itemsview_repr(view):
lst = []
for k, v in view:
lst.append("{!r}: {!r}".format(k, v))
body = ", ".join(lst)
return "{}({})".format(view.__class__.__name__, body) | null |
1,501 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
The provided code snippet includes necessary dependencies for implementing the `_keysview_isdisjoint` function. Write a Python function `def _keysview_isdisjoint(view, other)` to solve the following problem:
Return True if two sets have a null intersection.
Here is the function:
def _keysview_isdisjoint(view, other):
"Return True if two sets have a null intersection."
for k in other:
if k in view:
return False
return True | Return True if two sets have a null intersection. |
1,502 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _keysview_repr(view):
lst = []
for k in view:
lst.append("{!r}".format(k))
body = ", ".join(lst)
return "{}({})".format(view.__class__.__name__, body) | null |
1,503 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _valuesview_repr(view):
lst = []
for v in view:
lst.append("{!r}".format(v))
body = ", ".join(lst)
return "{}({})".format(view.__class__.__name__, body) | null |
1,504 | from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
def _mdrepr(md):
lst = []
for k, v in md.items():
lst.append("'{}': {!r}".format(k, v))
body = ", ".join(lst)
return "<{}({})>".format(md.__class__.__name__, body) | null |
1,505 | from typing import List, Tuple, Union
def _seg_0() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x0, '3'),
(0x1, '3'),
(0x2, '3'),
(0x3, '3'),
(0x4, '3'),
(0x5, '3'),
(0x6, '3'),
(0x7, '3'),
(0x8, '3'),
(0x9, '3'),
(0xA, '3'),
(0xB, '3'),
(0xC, '3'),
(0xD, '3'),
(0xE, '3'),
(0xF, '3'),
(0x10, '3'),
(0x11, '3'),
(0x12, '3'),
(0x13, '3'),
(0x14, '3'),
(0x15, '3'),
(0x16, '3'),
(0x17, '3'),
(0x18, '3'),
(0x19, '3'),
(0x1A, '3'),
(0x1B, '3'),
(0x1C, '3'),
(0x1D, '3'),
(0x1E, '3'),
(0x1F, '3'),
(0x20, '3'),
(0x21, '3'),
(0x22, '3'),
(0x23, '3'),
(0x24, '3'),
(0x25, '3'),
(0x26, '3'),
(0x27, '3'),
(0x28, '3'),
(0x29, '3'),
(0x2A, '3'),
(0x2B, '3'),
(0x2C, '3'),
(0x2D, 'V'),
(0x2E, 'V'),
(0x2F, '3'),
(0x30, 'V'),
(0x31, 'V'),
(0x32, 'V'),
(0x33, 'V'),
(0x34, 'V'),
(0x35, 'V'),
(0x36, 'V'),
(0x37, 'V'),
(0x38, 'V'),
(0x39, 'V'),
(0x3A, '3'),
(0x3B, '3'),
(0x3C, '3'),
(0x3D, '3'),
(0x3E, '3'),
(0x3F, '3'),
(0x40, '3'),
(0x41, 'M', 'a'),
(0x42, 'M', 'b'),
(0x43, 'M', 'c'),
(0x44, 'M', 'd'),
(0x45, 'M', 'e'),
(0x46, 'M', 'f'),
(0x47, 'M', 'g'),
(0x48, 'M', 'h'),
(0x49, 'M', 'i'),
(0x4A, 'M', 'j'),
(0x4B, 'M', 'k'),
(0x4C, 'M', 'l'),
(0x4D, 'M', 'm'),
(0x4E, 'M', 'n'),
(0x4F, 'M', 'o'),
(0x50, 'M', 'p'),
(0x51, 'M', 'q'),
(0x52, 'M', 'r'),
(0x53, 'M', 's'),
(0x54, 'M', 't'),
(0x55, 'M', 'u'),
(0x56, 'M', 'v'),
(0x57, 'M', 'w'),
(0x58, 'M', 'x'),
(0x59, 'M', 'y'),
(0x5A, 'M', 'z'),
(0x5B, '3'),
(0x5C, '3'),
(0x5D, '3'),
(0x5E, '3'),
(0x5F, '3'),
(0x60, '3'),
(0x61, 'V'),
(0x62, 'V'),
(0x63, 'V'),
] | null |
1,506 | from typing import List, Tuple, Union
def _seg_1() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x64, 'V'),
(0x65, 'V'),
(0x66, 'V'),
(0x67, 'V'),
(0x68, 'V'),
(0x69, 'V'),
(0x6A, 'V'),
(0x6B, 'V'),
(0x6C, 'V'),
(0x6D, 'V'),
(0x6E, 'V'),
(0x6F, 'V'),
(0x70, 'V'),
(0x71, 'V'),
(0x72, 'V'),
(0x73, 'V'),
(0x74, 'V'),
(0x75, 'V'),
(0x76, 'V'),
(0x77, 'V'),
(0x78, 'V'),
(0x79, 'V'),
(0x7A, 'V'),
(0x7B, '3'),
(0x7C, '3'),
(0x7D, '3'),
(0x7E, '3'),
(0x7F, '3'),
(0x80, 'X'),
(0x81, 'X'),
(0x82, 'X'),
(0x83, 'X'),
(0x84, 'X'),
(0x85, 'X'),
(0x86, 'X'),
(0x87, 'X'),
(0x88, 'X'),
(0x89, 'X'),
(0x8A, 'X'),
(0x8B, 'X'),
(0x8C, 'X'),
(0x8D, 'X'),
(0x8E, 'X'),
(0x8F, 'X'),
(0x90, 'X'),
(0x91, 'X'),
(0x92, 'X'),
(0x93, 'X'),
(0x94, 'X'),
(0x95, 'X'),
(0x96, 'X'),
(0x97, 'X'),
(0x98, 'X'),
(0x99, 'X'),
(0x9A, 'X'),
(0x9B, 'X'),
(0x9C, 'X'),
(0x9D, 'X'),
(0x9E, 'X'),
(0x9F, 'X'),
(0xA0, '3', ' '),
(0xA1, 'V'),
(0xA2, 'V'),
(0xA3, 'V'),
(0xA4, 'V'),
(0xA5, 'V'),
(0xA6, 'V'),
(0xA7, 'V'),
(0xA8, '3', ' ̈'),
(0xA9, 'V'),
(0xAA, 'M', 'a'),
(0xAB, 'V'),
(0xAC, 'V'),
(0xAD, 'I'),
(0xAE, 'V'),
(0xAF, '3', ' ̄'),
(0xB0, 'V'),
(0xB1, 'V'),
(0xB2, 'M', '2'),
(0xB3, 'M', '3'),
(0xB4, '3', ' ́'),
(0xB5, 'M', 'μ'),
(0xB6, 'V'),
(0xB7, 'V'),
(0xB8, '3', ' ̧'),
(0xB9, 'M', '1'),
(0xBA, 'M', 'o'),
(0xBB, 'V'),
(0xBC, 'M', '1⁄4'),
(0xBD, 'M', '1⁄2'),
(0xBE, 'M', '3⁄4'),
(0xBF, 'V'),
(0xC0, 'M', 'à'),
(0xC1, 'M', 'á'),
(0xC2, 'M', 'â'),
(0xC3, 'M', 'ã'),
(0xC4, 'M', 'ä'),
(0xC5, 'M', 'å'),
(0xC6, 'M', 'æ'),
(0xC7, 'M', 'ç'),
] | null |
1,507 | from typing import List, Tuple, Union
def _seg_2() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0xC8, 'M', 'è'),
(0xC9, 'M', 'é'),
(0xCA, 'M', 'ê'),
(0xCB, 'M', 'ë'),
(0xCC, 'M', 'ì'),
(0xCD, 'M', 'í'),
(0xCE, 'M', 'î'),
(0xCF, 'M', 'ï'),
(0xD0, 'M', 'ð'),
(0xD1, 'M', 'ñ'),
(0xD2, 'M', 'ò'),
(0xD3, 'M', 'ó'),
(0xD4, 'M', 'ô'),
(0xD5, 'M', 'õ'),
(0xD6, 'M', 'ö'),
(0xD7, 'V'),
(0xD8, 'M', 'ø'),
(0xD9, 'M', 'ù'),
(0xDA, 'M', 'ú'),
(0xDB, 'M', 'û'),
(0xDC, 'M', 'ü'),
(0xDD, 'M', 'ý'),
(0xDE, 'M', 'þ'),
(0xDF, 'D', 'ss'),
(0xE0, 'V'),
(0xE1, 'V'),
(0xE2, 'V'),
(0xE3, 'V'),
(0xE4, 'V'),
(0xE5, 'V'),
(0xE6, 'V'),
(0xE7, 'V'),
(0xE8, 'V'),
(0xE9, 'V'),
(0xEA, 'V'),
(0xEB, 'V'),
(0xEC, 'V'),
(0xED, 'V'),
(0xEE, 'V'),
(0xEF, 'V'),
(0xF0, 'V'),
(0xF1, 'V'),
(0xF2, 'V'),
(0xF3, 'V'),
(0xF4, 'V'),
(0xF5, 'V'),
(0xF6, 'V'),
(0xF7, 'V'),
(0xF8, 'V'),
(0xF9, 'V'),
(0xFA, 'V'),
(0xFB, 'V'),
(0xFC, 'V'),
(0xFD, 'V'),
(0xFE, 'V'),
(0xFF, 'V'),
(0x100, 'M', 'ā'),
(0x101, 'V'),
(0x102, 'M', 'ă'),
(0x103, 'V'),
(0x104, 'M', 'ą'),
(0x105, 'V'),
(0x106, 'M', 'ć'),
(0x107, 'V'),
(0x108, 'M', 'ĉ'),
(0x109, 'V'),
(0x10A, 'M', 'ċ'),
(0x10B, 'V'),
(0x10C, 'M', 'č'),
(0x10D, 'V'),
(0x10E, 'M', 'ď'),
(0x10F, 'V'),
(0x110, 'M', 'đ'),
(0x111, 'V'),
(0x112, 'M', 'ē'),
(0x113, 'V'),
(0x114, 'M', 'ĕ'),
(0x115, 'V'),
(0x116, 'M', 'ė'),
(0x117, 'V'),
(0x118, 'M', 'ę'),
(0x119, 'V'),
(0x11A, 'M', 'ě'),
(0x11B, 'V'),
(0x11C, 'M', 'ĝ'),
(0x11D, 'V'),
(0x11E, 'M', 'ğ'),
(0x11F, 'V'),
(0x120, 'M', 'ġ'),
(0x121, 'V'),
(0x122, 'M', 'ģ'),
(0x123, 'V'),
(0x124, 'M', 'ĥ'),
(0x125, 'V'),
(0x126, 'M', 'ħ'),
(0x127, 'V'),
(0x128, 'M', 'ĩ'),
(0x129, 'V'),
(0x12A, 'M', 'ī'),
(0x12B, 'V'),
] | null |
1,508 | from typing import List, Tuple, Union
def _seg_3() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x12C, 'M', 'ĭ'),
(0x12D, 'V'),
(0x12E, 'M', 'į'),
(0x12F, 'V'),
(0x130, 'M', 'i̇'),
(0x131, 'V'),
(0x132, 'M', 'ij'),
(0x134, 'M', 'ĵ'),
(0x135, 'V'),
(0x136, 'M', 'ķ'),
(0x137, 'V'),
(0x139, 'M', 'ĺ'),
(0x13A, 'V'),
(0x13B, 'M', 'ļ'),
(0x13C, 'V'),
(0x13D, 'M', 'ľ'),
(0x13E, 'V'),
(0x13F, 'M', 'l·'),
(0x141, 'M', 'ł'),
(0x142, 'V'),
(0x143, 'M', 'ń'),
(0x144, 'V'),
(0x145, 'M', 'ņ'),
(0x146, 'V'),
(0x147, 'M', 'ň'),
(0x148, 'V'),
(0x149, 'M', 'ʼn'),
(0x14A, 'M', 'ŋ'),
(0x14B, 'V'),
(0x14C, 'M', 'ō'),
(0x14D, 'V'),
(0x14E, 'M', 'ŏ'),
(0x14F, 'V'),
(0x150, 'M', 'ő'),
(0x151, 'V'),
(0x152, 'M', 'œ'),
(0x153, 'V'),
(0x154, 'M', 'ŕ'),
(0x155, 'V'),
(0x156, 'M', 'ŗ'),
(0x157, 'V'),
(0x158, 'M', 'ř'),
(0x159, 'V'),
(0x15A, 'M', 'ś'),
(0x15B, 'V'),
(0x15C, 'M', 'ŝ'),
(0x15D, 'V'),
(0x15E, 'M', 'ş'),
(0x15F, 'V'),
(0x160, 'M', 'š'),
(0x161, 'V'),
(0x162, 'M', 'ţ'),
(0x163, 'V'),
(0x164, 'M', 'ť'),
(0x165, 'V'),
(0x166, 'M', 'ŧ'),
(0x167, 'V'),
(0x168, 'M', 'ũ'),
(0x169, 'V'),
(0x16A, 'M', 'ū'),
(0x16B, 'V'),
(0x16C, 'M', 'ŭ'),
(0x16D, 'V'),
(0x16E, 'M', 'ů'),
(0x16F, 'V'),
(0x170, 'M', 'ű'),
(0x171, 'V'),
(0x172, 'M', 'ų'),
(0x173, 'V'),
(0x174, 'M', 'ŵ'),
(0x175, 'V'),
(0x176, 'M', 'ŷ'),
(0x177, 'V'),
(0x178, 'M', 'ÿ'),
(0x179, 'M', 'ź'),
(0x17A, 'V'),
(0x17B, 'M', 'ż'),
(0x17C, 'V'),
(0x17D, 'M', 'ž'),
(0x17E, 'V'),
(0x17F, 'M', 's'),
(0x180, 'V'),
(0x181, 'M', 'ɓ'),
(0x182, 'M', 'ƃ'),
(0x183, 'V'),
(0x184, 'M', 'ƅ'),
(0x185, 'V'),
(0x186, 'M', 'ɔ'),
(0x187, 'M', 'ƈ'),
(0x188, 'V'),
(0x189, 'M', 'ɖ'),
(0x18A, 'M', 'ɗ'),
(0x18B, 'M', 'ƌ'),
(0x18C, 'V'),
(0x18E, 'M', 'ǝ'),
(0x18F, 'M', 'ə'),
(0x190, 'M', 'ɛ'),
(0x191, 'M', 'ƒ'),
(0x192, 'V'),
(0x193, 'M', 'ɠ'),
] | null |
1,509 | from typing import List, Tuple, Union
def _seg_4() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x194, 'M', 'ɣ'),
(0x195, 'V'),
(0x196, 'M', 'ɩ'),
(0x197, 'M', 'ɨ'),
(0x198, 'M', 'ƙ'),
(0x199, 'V'),
(0x19C, 'M', 'ɯ'),
(0x19D, 'M', 'ɲ'),
(0x19E, 'V'),
(0x19F, 'M', 'ɵ'),
(0x1A0, 'M', 'ơ'),
(0x1A1, 'V'),
(0x1A2, 'M', 'ƣ'),
(0x1A3, 'V'),
(0x1A4, 'M', 'ƥ'),
(0x1A5, 'V'),
(0x1A6, 'M', 'ʀ'),
(0x1A7, 'M', 'ƨ'),
(0x1A8, 'V'),
(0x1A9, 'M', 'ʃ'),
(0x1AA, 'V'),
(0x1AC, 'M', 'ƭ'),
(0x1AD, 'V'),
(0x1AE, 'M', 'ʈ'),
(0x1AF, 'M', 'ư'),
(0x1B0, 'V'),
(0x1B1, 'M', 'ʊ'),
(0x1B2, 'M', 'ʋ'),
(0x1B3, 'M', 'ƴ'),
(0x1B4, 'V'),
(0x1B5, 'M', 'ƶ'),
(0x1B6, 'V'),
(0x1B7, 'M', 'ʒ'),
(0x1B8, 'M', 'ƹ'),
(0x1B9, 'V'),
(0x1BC, 'M', 'ƽ'),
(0x1BD, 'V'),
(0x1C4, 'M', 'dž'),
(0x1C7, 'M', 'lj'),
(0x1CA, 'M', 'nj'),
(0x1CD, 'M', 'ǎ'),
(0x1CE, 'V'),
(0x1CF, 'M', 'ǐ'),
(0x1D0, 'V'),
(0x1D1, 'M', 'ǒ'),
(0x1D2, 'V'),
(0x1D3, 'M', 'ǔ'),
(0x1D4, 'V'),
(0x1D5, 'M', 'ǖ'),
(0x1D6, 'V'),
(0x1D7, 'M', 'ǘ'),
(0x1D8, 'V'),
(0x1D9, 'M', 'ǚ'),
(0x1DA, 'V'),
(0x1DB, 'M', 'ǜ'),
(0x1DC, 'V'),
(0x1DE, 'M', 'ǟ'),
(0x1DF, 'V'),
(0x1E0, 'M', 'ǡ'),
(0x1E1, 'V'),
(0x1E2, 'M', 'ǣ'),
(0x1E3, 'V'),
(0x1E4, 'M', 'ǥ'),
(0x1E5, 'V'),
(0x1E6, 'M', 'ǧ'),
(0x1E7, 'V'),
(0x1E8, 'M', 'ǩ'),
(0x1E9, 'V'),
(0x1EA, 'M', 'ǫ'),
(0x1EB, 'V'),
(0x1EC, 'M', 'ǭ'),
(0x1ED, 'V'),
(0x1EE, 'M', 'ǯ'),
(0x1EF, 'V'),
(0x1F1, 'M', 'dz'),
(0x1F4, 'M', 'ǵ'),
(0x1F5, 'V'),
(0x1F6, 'M', 'ƕ'),
(0x1F7, 'M', 'ƿ'),
(0x1F8, 'M', 'ǹ'),
(0x1F9, 'V'),
(0x1FA, 'M', 'ǻ'),
(0x1FB, 'V'),
(0x1FC, 'M', 'ǽ'),
(0x1FD, 'V'),
(0x1FE, 'M', 'ǿ'),
(0x1FF, 'V'),
(0x200, 'M', 'ȁ'),
(0x201, 'V'),
(0x202, 'M', 'ȃ'),
(0x203, 'V'),
(0x204, 'M', 'ȅ'),
(0x205, 'V'),
(0x206, 'M', 'ȇ'),
(0x207, 'V'),
(0x208, 'M', 'ȉ'),
(0x209, 'V'),
(0x20A, 'M', 'ȋ'),
(0x20B, 'V'),
(0x20C, 'M', 'ȍ'),
] | null |
1,510 | from typing import List, Tuple, Union
def _seg_5() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x20D, 'V'),
(0x20E, 'M', 'ȏ'),
(0x20F, 'V'),
(0x210, 'M', 'ȑ'),
(0x211, 'V'),
(0x212, 'M', 'ȓ'),
(0x213, 'V'),
(0x214, 'M', 'ȕ'),
(0x215, 'V'),
(0x216, 'M', 'ȗ'),
(0x217, 'V'),
(0x218, 'M', 'ș'),
(0x219, 'V'),
(0x21A, 'M', 'ț'),
(0x21B, 'V'),
(0x21C, 'M', 'ȝ'),
(0x21D, 'V'),
(0x21E, 'M', 'ȟ'),
(0x21F, 'V'),
(0x220, 'M', 'ƞ'),
(0x221, 'V'),
(0x222, 'M', 'ȣ'),
(0x223, 'V'),
(0x224, 'M', 'ȥ'),
(0x225, 'V'),
(0x226, 'M', 'ȧ'),
(0x227, 'V'),
(0x228, 'M', 'ȩ'),
(0x229, 'V'),
(0x22A, 'M', 'ȫ'),
(0x22B, 'V'),
(0x22C, 'M', 'ȭ'),
(0x22D, 'V'),
(0x22E, 'M', 'ȯ'),
(0x22F, 'V'),
(0x230, 'M', 'ȱ'),
(0x231, 'V'),
(0x232, 'M', 'ȳ'),
(0x233, 'V'),
(0x23A, 'M', 'ⱥ'),
(0x23B, 'M', 'ȼ'),
(0x23C, 'V'),
(0x23D, 'M', 'ƚ'),
(0x23E, 'M', 'ⱦ'),
(0x23F, 'V'),
(0x241, 'M', 'ɂ'),
(0x242, 'V'),
(0x243, 'M', 'ƀ'),
(0x244, 'M', 'ʉ'),
(0x245, 'M', 'ʌ'),
(0x246, 'M', 'ɇ'),
(0x247, 'V'),
(0x248, 'M', 'ɉ'),
(0x249, 'V'),
(0x24A, 'M', 'ɋ'),
(0x24B, 'V'),
(0x24C, 'M', 'ɍ'),
(0x24D, 'V'),
(0x24E, 'M', 'ɏ'),
(0x24F, 'V'),
(0x2B0, 'M', 'h'),
(0x2B1, 'M', 'ɦ'),
(0x2B2, 'M', 'j'),
(0x2B3, 'M', 'r'),
(0x2B4, 'M', 'ɹ'),
(0x2B5, 'M', 'ɻ'),
(0x2B6, 'M', 'ʁ'),
(0x2B7, 'M', 'w'),
(0x2B8, 'M', 'y'),
(0x2B9, 'V'),
(0x2D8, '3', ' ̆'),
(0x2D9, '3', ' ̇'),
(0x2DA, '3', ' ̊'),
(0x2DB, '3', ' ̨'),
(0x2DC, '3', ' ̃'),
(0x2DD, '3', ' ̋'),
(0x2DE, 'V'),
(0x2E0, 'M', 'ɣ'),
(0x2E1, 'M', 'l'),
(0x2E2, 'M', 's'),
(0x2E3, 'M', 'x'),
(0x2E4, 'M', 'ʕ'),
(0x2E5, 'V'),
(0x340, 'M', '̀'),
(0x341, 'M', '́'),
(0x342, 'V'),
(0x343, 'M', '̓'),
(0x344, 'M', '̈́'),
(0x345, 'M', 'ι'),
(0x346, 'V'),
(0x34F, 'I'),
(0x350, 'V'),
(0x370, 'M', 'ͱ'),
(0x371, 'V'),
(0x372, 'M', 'ͳ'),
(0x373, 'V'),
(0x374, 'M', 'ʹ'),
(0x375, 'V'),
(0x376, 'M', 'ͷ'),
(0x377, 'V'),
] | null |
1,511 | from typing import List, Tuple, Union
def _seg_6() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x378, 'X'),
(0x37A, '3', ' ι'),
(0x37B, 'V'),
(0x37E, '3', ';'),
(0x37F, 'M', 'ϳ'),
(0x380, 'X'),
(0x384, '3', ' ́'),
(0x385, '3', ' ̈́'),
(0x386, 'M', 'ά'),
(0x387, 'M', '·'),
(0x388, 'M', 'έ'),
(0x389, 'M', 'ή'),
(0x38A, 'M', 'ί'),
(0x38B, 'X'),
(0x38C, 'M', 'ό'),
(0x38D, 'X'),
(0x38E, 'M', 'ύ'),
(0x38F, 'M', 'ώ'),
(0x390, 'V'),
(0x391, 'M', 'α'),
(0x392, 'M', 'β'),
(0x393, 'M', 'γ'),
(0x394, 'M', 'δ'),
(0x395, 'M', 'ε'),
(0x396, 'M', 'ζ'),
(0x397, 'M', 'η'),
(0x398, 'M', 'θ'),
(0x399, 'M', 'ι'),
(0x39A, 'M', 'κ'),
(0x39B, 'M', 'λ'),
(0x39C, 'M', 'μ'),
(0x39D, 'M', 'ν'),
(0x39E, 'M', 'ξ'),
(0x39F, 'M', 'ο'),
(0x3A0, 'M', 'π'),
(0x3A1, 'M', 'ρ'),
(0x3A2, 'X'),
(0x3A3, 'M', 'σ'),
(0x3A4, 'M', 'τ'),
(0x3A5, 'M', 'υ'),
(0x3A6, 'M', 'φ'),
(0x3A7, 'M', 'χ'),
(0x3A8, 'M', 'ψ'),
(0x3A9, 'M', 'ω'),
(0x3AA, 'M', 'ϊ'),
(0x3AB, 'M', 'ϋ'),
(0x3AC, 'V'),
(0x3C2, 'D', 'σ'),
(0x3C3, 'V'),
(0x3CF, 'M', 'ϗ'),
(0x3D0, 'M', 'β'),
(0x3D1, 'M', 'θ'),
(0x3D2, 'M', 'υ'),
(0x3D3, 'M', 'ύ'),
(0x3D4, 'M', 'ϋ'),
(0x3D5, 'M', 'φ'),
(0x3D6, 'M', 'π'),
(0x3D7, 'V'),
(0x3D8, 'M', 'ϙ'),
(0x3D9, 'V'),
(0x3DA, 'M', 'ϛ'),
(0x3DB, 'V'),
(0x3DC, 'M', 'ϝ'),
(0x3DD, 'V'),
(0x3DE, 'M', 'ϟ'),
(0x3DF, 'V'),
(0x3E0, 'M', 'ϡ'),
(0x3E1, 'V'),
(0x3E2, 'M', 'ϣ'),
(0x3E3, 'V'),
(0x3E4, 'M', 'ϥ'),
(0x3E5, 'V'),
(0x3E6, 'M', 'ϧ'),
(0x3E7, 'V'),
(0x3E8, 'M', 'ϩ'),
(0x3E9, 'V'),
(0x3EA, 'M', 'ϫ'),
(0x3EB, 'V'),
(0x3EC, 'M', 'ϭ'),
(0x3ED, 'V'),
(0x3EE, 'M', 'ϯ'),
(0x3EF, 'V'),
(0x3F0, 'M', 'κ'),
(0x3F1, 'M', 'ρ'),
(0x3F2, 'M', 'σ'),
(0x3F3, 'V'),
(0x3F4, 'M', 'θ'),
(0x3F5, 'M', 'ε'),
(0x3F6, 'V'),
(0x3F7, 'M', 'ϸ'),
(0x3F8, 'V'),
(0x3F9, 'M', 'σ'),
(0x3FA, 'M', 'ϻ'),
(0x3FB, 'V'),
(0x3FD, 'M', 'ͻ'),
(0x3FE, 'M', 'ͼ'),
(0x3FF, 'M', 'ͽ'),
(0x400, 'M', 'ѐ'),
(0x401, 'M', 'ё'),
(0x402, 'M', 'ђ'),
] | null |
1,512 | from typing import List, Tuple, Union
def _seg_7() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x403, 'M', 'ѓ'),
(0x404, 'M', 'є'),
(0x405, 'M', 'ѕ'),
(0x406, 'M', 'і'),
(0x407, 'M', 'ї'),
(0x408, 'M', 'ј'),
(0x409, 'M', 'љ'),
(0x40A, 'M', 'њ'),
(0x40B, 'M', 'ћ'),
(0x40C, 'M', 'ќ'),
(0x40D, 'M', 'ѝ'),
(0x40E, 'M', 'ў'),
(0x40F, 'M', 'џ'),
(0x410, 'M', 'а'),
(0x411, 'M', 'б'),
(0x412, 'M', 'в'),
(0x413, 'M', 'г'),
(0x414, 'M', 'д'),
(0x415, 'M', 'е'),
(0x416, 'M', 'ж'),
(0x417, 'M', 'з'),
(0x418, 'M', 'и'),
(0x419, 'M', 'й'),
(0x41A, 'M', 'к'),
(0x41B, 'M', 'л'),
(0x41C, 'M', 'м'),
(0x41D, 'M', 'н'),
(0x41E, 'M', 'о'),
(0x41F, 'M', 'п'),
(0x420, 'M', 'р'),
(0x421, 'M', 'с'),
(0x422, 'M', 'т'),
(0x423, 'M', 'у'),
(0x424, 'M', 'ф'),
(0x425, 'M', 'х'),
(0x426, 'M', 'ц'),
(0x427, 'M', 'ч'),
(0x428, 'M', 'ш'),
(0x429, 'M', 'щ'),
(0x42A, 'M', 'ъ'),
(0x42B, 'M', 'ы'),
(0x42C, 'M', 'ь'),
(0x42D, 'M', 'э'),
(0x42E, 'M', 'ю'),
(0x42F, 'M', 'я'),
(0x430, 'V'),
(0x460, 'M', 'ѡ'),
(0x461, 'V'),
(0x462, 'M', 'ѣ'),
(0x463, 'V'),
(0x464, 'M', 'ѥ'),
(0x465, 'V'),
(0x466, 'M', 'ѧ'),
(0x467, 'V'),
(0x468, 'M', 'ѩ'),
(0x469, 'V'),
(0x46A, 'M', 'ѫ'),
(0x46B, 'V'),
(0x46C, 'M', 'ѭ'),
(0x46D, 'V'),
(0x46E, 'M', 'ѯ'),
(0x46F, 'V'),
(0x470, 'M', 'ѱ'),
(0x471, 'V'),
(0x472, 'M', 'ѳ'),
(0x473, 'V'),
(0x474, 'M', 'ѵ'),
(0x475, 'V'),
(0x476, 'M', 'ѷ'),
(0x477, 'V'),
(0x478, 'M', 'ѹ'),
(0x479, 'V'),
(0x47A, 'M', 'ѻ'),
(0x47B, 'V'),
(0x47C, 'M', 'ѽ'),
(0x47D, 'V'),
(0x47E, 'M', 'ѿ'),
(0x47F, 'V'),
(0x480, 'M', 'ҁ'),
(0x481, 'V'),
(0x48A, 'M', 'ҋ'),
(0x48B, 'V'),
(0x48C, 'M', 'ҍ'),
(0x48D, 'V'),
(0x48E, 'M', 'ҏ'),
(0x48F, 'V'),
(0x490, 'M', 'ґ'),
(0x491, 'V'),
(0x492, 'M', 'ғ'),
(0x493, 'V'),
(0x494, 'M', 'ҕ'),
(0x495, 'V'),
(0x496, 'M', 'җ'),
(0x497, 'V'),
(0x498, 'M', 'ҙ'),
(0x499, 'V'),
(0x49A, 'M', 'қ'),
(0x49B, 'V'),
(0x49C, 'M', 'ҝ'),
(0x49D, 'V'),
] | null |
1,513 | from typing import List, Tuple, Union
def _seg_8() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x49E, 'M', 'ҟ'),
(0x49F, 'V'),
(0x4A0, 'M', 'ҡ'),
(0x4A1, 'V'),
(0x4A2, 'M', 'ң'),
(0x4A3, 'V'),
(0x4A4, 'M', 'ҥ'),
(0x4A5, 'V'),
(0x4A6, 'M', 'ҧ'),
(0x4A7, 'V'),
(0x4A8, 'M', 'ҩ'),
(0x4A9, 'V'),
(0x4AA, 'M', 'ҫ'),
(0x4AB, 'V'),
(0x4AC, 'M', 'ҭ'),
(0x4AD, 'V'),
(0x4AE, 'M', 'ү'),
(0x4AF, 'V'),
(0x4B0, 'M', 'ұ'),
(0x4B1, 'V'),
(0x4B2, 'M', 'ҳ'),
(0x4B3, 'V'),
(0x4B4, 'M', 'ҵ'),
(0x4B5, 'V'),
(0x4B6, 'M', 'ҷ'),
(0x4B7, 'V'),
(0x4B8, 'M', 'ҹ'),
(0x4B9, 'V'),
(0x4BA, 'M', 'һ'),
(0x4BB, 'V'),
(0x4BC, 'M', 'ҽ'),
(0x4BD, 'V'),
(0x4BE, 'M', 'ҿ'),
(0x4BF, 'V'),
(0x4C0, 'X'),
(0x4C1, 'M', 'ӂ'),
(0x4C2, 'V'),
(0x4C3, 'M', 'ӄ'),
(0x4C4, 'V'),
(0x4C5, 'M', 'ӆ'),
(0x4C6, 'V'),
(0x4C7, 'M', 'ӈ'),
(0x4C8, 'V'),
(0x4C9, 'M', 'ӊ'),
(0x4CA, 'V'),
(0x4CB, 'M', 'ӌ'),
(0x4CC, 'V'),
(0x4CD, 'M', 'ӎ'),
(0x4CE, 'V'),
(0x4D0, 'M', 'ӑ'),
(0x4D1, 'V'),
(0x4D2, 'M', 'ӓ'),
(0x4D3, 'V'),
(0x4D4, 'M', 'ӕ'),
(0x4D5, 'V'),
(0x4D6, 'M', 'ӗ'),
(0x4D7, 'V'),
(0x4D8, 'M', 'ә'),
(0x4D9, 'V'),
(0x4DA, 'M', 'ӛ'),
(0x4DB, 'V'),
(0x4DC, 'M', 'ӝ'),
(0x4DD, 'V'),
(0x4DE, 'M', 'ӟ'),
(0x4DF, 'V'),
(0x4E0, 'M', 'ӡ'),
(0x4E1, 'V'),
(0x4E2, 'M', 'ӣ'),
(0x4E3, 'V'),
(0x4E4, 'M', 'ӥ'),
(0x4E5, 'V'),
(0x4E6, 'M', 'ӧ'),
(0x4E7, 'V'),
(0x4E8, 'M', 'ө'),
(0x4E9, 'V'),
(0x4EA, 'M', 'ӫ'),
(0x4EB, 'V'),
(0x4EC, 'M', 'ӭ'),
(0x4ED, 'V'),
(0x4EE, 'M', 'ӯ'),
(0x4EF, 'V'),
(0x4F0, 'M', 'ӱ'),
(0x4F1, 'V'),
(0x4F2, 'M', 'ӳ'),
(0x4F3, 'V'),
(0x4F4, 'M', 'ӵ'),
(0x4F5, 'V'),
(0x4F6, 'M', 'ӷ'),
(0x4F7, 'V'),
(0x4F8, 'M', 'ӹ'),
(0x4F9, 'V'),
(0x4FA, 'M', 'ӻ'),
(0x4FB, 'V'),
(0x4FC, 'M', 'ӽ'),
(0x4FD, 'V'),
(0x4FE, 'M', 'ӿ'),
(0x4FF, 'V'),
(0x500, 'M', 'ԁ'),
(0x501, 'V'),
(0x502, 'M', 'ԃ'),
] | null |
1,514 | from typing import List, Tuple, Union
def _seg_9() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x503, 'V'),
(0x504, 'M', 'ԅ'),
(0x505, 'V'),
(0x506, 'M', 'ԇ'),
(0x507, 'V'),
(0x508, 'M', 'ԉ'),
(0x509, 'V'),
(0x50A, 'M', 'ԋ'),
(0x50B, 'V'),
(0x50C, 'M', 'ԍ'),
(0x50D, 'V'),
(0x50E, 'M', 'ԏ'),
(0x50F, 'V'),
(0x510, 'M', 'ԑ'),
(0x511, 'V'),
(0x512, 'M', 'ԓ'),
(0x513, 'V'),
(0x514, 'M', 'ԕ'),
(0x515, 'V'),
(0x516, 'M', 'ԗ'),
(0x517, 'V'),
(0x518, 'M', 'ԙ'),
(0x519, 'V'),
(0x51A, 'M', 'ԛ'),
(0x51B, 'V'),
(0x51C, 'M', 'ԝ'),
(0x51D, 'V'),
(0x51E, 'M', 'ԟ'),
(0x51F, 'V'),
(0x520, 'M', 'ԡ'),
(0x521, 'V'),
(0x522, 'M', 'ԣ'),
(0x523, 'V'),
(0x524, 'M', 'ԥ'),
(0x525, 'V'),
(0x526, 'M', 'ԧ'),
(0x527, 'V'),
(0x528, 'M', 'ԩ'),
(0x529, 'V'),
(0x52A, 'M', 'ԫ'),
(0x52B, 'V'),
(0x52C, 'M', 'ԭ'),
(0x52D, 'V'),
(0x52E, 'M', 'ԯ'),
(0x52F, 'V'),
(0x530, 'X'),
(0x531, 'M', 'ա'),
(0x532, 'M', 'բ'),
(0x533, 'M', 'գ'),
(0x534, 'M', 'դ'),
(0x535, 'M', 'ե'),
(0x536, 'M', 'զ'),
(0x537, 'M', 'է'),
(0x538, 'M', 'ը'),
(0x539, 'M', 'թ'),
(0x53A, 'M', 'ժ'),
(0x53B, 'M', 'ի'),
(0x53C, 'M', 'լ'),
(0x53D, 'M', 'խ'),
(0x53E, 'M', 'ծ'),
(0x53F, 'M', 'կ'),
(0x540, 'M', 'հ'),
(0x541, 'M', 'ձ'),
(0x542, 'M', 'ղ'),
(0x543, 'M', 'ճ'),
(0x544, 'M', 'մ'),
(0x545, 'M', 'յ'),
(0x546, 'M', 'ն'),
(0x547, 'M', 'շ'),
(0x548, 'M', 'ո'),
(0x549, 'M', 'չ'),
(0x54A, 'M', 'պ'),
(0x54B, 'M', 'ջ'),
(0x54C, 'M', 'ռ'),
(0x54D, 'M', 'ս'),
(0x54E, 'M', 'վ'),
(0x54F, 'M', 'տ'),
(0x550, 'M', 'ր'),
(0x551, 'M', 'ց'),
(0x552, 'M', 'ւ'),
(0x553, 'M', 'փ'),
(0x554, 'M', 'ք'),
(0x555, 'M', 'օ'),
(0x556, 'M', 'ֆ'),
(0x557, 'X'),
(0x559, 'V'),
(0x587, 'M', 'եւ'),
(0x588, 'V'),
(0x58B, 'X'),
(0x58D, 'V'),
(0x590, 'X'),
(0x591, 'V'),
(0x5C8, 'X'),
(0x5D0, 'V'),
(0x5EB, 'X'),
(0x5EF, 'V'),
(0x5F5, 'X'),
(0x606, 'V'),
(0x61C, 'X'),
(0x61D, 'V'),
] | null |
1,515 | from typing import List, Tuple, Union
def _seg_10() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x675, 'M', 'اٴ'),
(0x676, 'M', 'وٴ'),
(0x677, 'M', 'ۇٴ'),
(0x678, 'M', 'يٴ'),
(0x679, 'V'),
(0x6DD, 'X'),
(0x6DE, 'V'),
(0x70E, 'X'),
(0x710, 'V'),
(0x74B, 'X'),
(0x74D, 'V'),
(0x7B2, 'X'),
(0x7C0, 'V'),
(0x7FB, 'X'),
(0x7FD, 'V'),
(0x82E, 'X'),
(0x830, 'V'),
(0x83F, 'X'),
(0x840, 'V'),
(0x85C, 'X'),
(0x85E, 'V'),
(0x85F, 'X'),
(0x860, 'V'),
(0x86B, 'X'),
(0x870, 'V'),
(0x88F, 'X'),
(0x898, 'V'),
(0x8E2, 'X'),
(0x8E3, 'V'),
(0x958, 'M', 'क़'),
(0x959, 'M', 'ख़'),
(0x95A, 'M', 'ग़'),
(0x95B, 'M', 'ज़'),
(0x95C, 'M', 'ड़'),
(0x95D, 'M', 'ढ़'),
(0x95E, 'M', 'फ़'),
(0x95F, 'M', 'य़'),
(0x960, 'V'),
(0x984, 'X'),
(0x985, 'V'),
(0x98D, 'X'),
(0x98F, 'V'),
(0x991, 'X'),
(0x993, 'V'),
(0x9A9, 'X'),
(0x9AA, 'V'),
(0x9B1, 'X'),
(0x9B2, 'V'),
(0x9B3, 'X'),
(0x9B6, 'V'),
(0x9BA, 'X'),
(0x9BC, 'V'),
(0x9C5, 'X'),
(0x9C7, 'V'),
(0x9C9, 'X'),
(0x9CB, 'V'),
(0x9CF, 'X'),
(0x9D7, 'V'),
(0x9D8, 'X'),
(0x9DC, 'M', 'ড়'),
(0x9DD, 'M', 'ঢ়'),
(0x9DE, 'X'),
(0x9DF, 'M', 'য়'),
(0x9E0, 'V'),
(0x9E4, 'X'),
(0x9E6, 'V'),
(0x9FF, 'X'),
(0xA01, 'V'),
(0xA04, 'X'),
(0xA05, 'V'),
(0xA0B, 'X'),
(0xA0F, 'V'),
(0xA11, 'X'),
(0xA13, 'V'),
(0xA29, 'X'),
(0xA2A, 'V'),
(0xA31, 'X'),
(0xA32, 'V'),
(0xA33, 'M', 'ਲ਼'),
(0xA34, 'X'),
(0xA35, 'V'),
(0xA36, 'M', 'ਸ਼'),
(0xA37, 'X'),
(0xA38, 'V'),
(0xA3A, 'X'),
(0xA3C, 'V'),
(0xA3D, 'X'),
(0xA3E, 'V'),
(0xA43, 'X'),
(0xA47, 'V'),
(0xA49, 'X'),
(0xA4B, 'V'),
(0xA4E, 'X'),
(0xA51, 'V'),
(0xA52, 'X'),
(0xA59, 'M', 'ਖ਼'),
(0xA5A, 'M', 'ਗ਼'),
(0xA5B, 'M', 'ਜ਼'),
(0xA5C, 'V'),
(0xA5D, 'X'),
] | null |
1,516 | from typing import List, Tuple, Union
def _seg_11() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0xA5E, 'M', 'ਫ਼'),
(0xA5F, 'X'),
(0xA66, 'V'),
(0xA77, 'X'),
(0xA81, 'V'),
(0xA84, 'X'),
(0xA85, 'V'),
(0xA8E, 'X'),
(0xA8F, 'V'),
(0xA92, 'X'),
(0xA93, 'V'),
(0xAA9, 'X'),
(0xAAA, 'V'),
(0xAB1, 'X'),
(0xAB2, 'V'),
(0xAB4, 'X'),
(0xAB5, 'V'),
(0xABA, 'X'),
(0xABC, 'V'),
(0xAC6, 'X'),
(0xAC7, 'V'),
(0xACA, 'X'),
(0xACB, 'V'),
(0xACE, 'X'),
(0xAD0, 'V'),
(0xAD1, 'X'),
(0xAE0, 'V'),
(0xAE4, 'X'),
(0xAE6, 'V'),
(0xAF2, 'X'),
(0xAF9, 'V'),
(0xB00, 'X'),
(0xB01, 'V'),
(0xB04, 'X'),
(0xB05, 'V'),
(0xB0D, 'X'),
(0xB0F, 'V'),
(0xB11, 'X'),
(0xB13, 'V'),
(0xB29, 'X'),
(0xB2A, 'V'),
(0xB31, 'X'),
(0xB32, 'V'),
(0xB34, 'X'),
(0xB35, 'V'),
(0xB3A, 'X'),
(0xB3C, 'V'),
(0xB45, 'X'),
(0xB47, 'V'),
(0xB49, 'X'),
(0xB4B, 'V'),
(0xB4E, 'X'),
(0xB55, 'V'),
(0xB58, 'X'),
(0xB5C, 'M', 'ଡ଼'),
(0xB5D, 'M', 'ଢ଼'),
(0xB5E, 'X'),
(0xB5F, 'V'),
(0xB64, 'X'),
(0xB66, 'V'),
(0xB78, 'X'),
(0xB82, 'V'),
(0xB84, 'X'),
(0xB85, 'V'),
(0xB8B, 'X'),
(0xB8E, 'V'),
(0xB91, 'X'),
(0xB92, 'V'),
(0xB96, 'X'),
(0xB99, 'V'),
(0xB9B, 'X'),
(0xB9C, 'V'),
(0xB9D, 'X'),
(0xB9E, 'V'),
(0xBA0, 'X'),
(0xBA3, 'V'),
(0xBA5, 'X'),
(0xBA8, 'V'),
(0xBAB, 'X'),
(0xBAE, 'V'),
(0xBBA, 'X'),
(0xBBE, 'V'),
(0xBC3, 'X'),
(0xBC6, 'V'),
(0xBC9, 'X'),
(0xBCA, 'V'),
(0xBCE, 'X'),
(0xBD0, 'V'),
(0xBD1, 'X'),
(0xBD7, 'V'),
(0xBD8, 'X'),
(0xBE6, 'V'),
(0xBFB, 'X'),
(0xC00, 'V'),
(0xC0D, 'X'),
(0xC0E, 'V'),
(0xC11, 'X'),
(0xC12, 'V'),
(0xC29, 'X'),
(0xC2A, 'V'),
] | null |
1,517 | from typing import List, Tuple, Union
def _seg_12() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0xC3A, 'X'),
(0xC3C, 'V'),
(0xC45, 'X'),
(0xC46, 'V'),
(0xC49, 'X'),
(0xC4A, 'V'),
(0xC4E, 'X'),
(0xC55, 'V'),
(0xC57, 'X'),
(0xC58, 'V'),
(0xC5B, 'X'),
(0xC5D, 'V'),
(0xC5E, 'X'),
(0xC60, 'V'),
(0xC64, 'X'),
(0xC66, 'V'),
(0xC70, 'X'),
(0xC77, 'V'),
(0xC8D, 'X'),
(0xC8E, 'V'),
(0xC91, 'X'),
(0xC92, 'V'),
(0xCA9, 'X'),
(0xCAA, 'V'),
(0xCB4, 'X'),
(0xCB5, 'V'),
(0xCBA, 'X'),
(0xCBC, 'V'),
(0xCC5, 'X'),
(0xCC6, 'V'),
(0xCC9, 'X'),
(0xCCA, 'V'),
(0xCCE, 'X'),
(0xCD5, 'V'),
(0xCD7, 'X'),
(0xCDD, 'V'),
(0xCDF, 'X'),
(0xCE0, 'V'),
(0xCE4, 'X'),
(0xCE6, 'V'),
(0xCF0, 'X'),
(0xCF1, 'V'),
(0xCF4, 'X'),
(0xD00, 'V'),
(0xD0D, 'X'),
(0xD0E, 'V'),
(0xD11, 'X'),
(0xD12, 'V'),
(0xD45, 'X'),
(0xD46, 'V'),
(0xD49, 'X'),
(0xD4A, 'V'),
(0xD50, 'X'),
(0xD54, 'V'),
(0xD64, 'X'),
(0xD66, 'V'),
(0xD80, 'X'),
(0xD81, 'V'),
(0xD84, 'X'),
(0xD85, 'V'),
(0xD97, 'X'),
(0xD9A, 'V'),
(0xDB2, 'X'),
(0xDB3, 'V'),
(0xDBC, 'X'),
(0xDBD, 'V'),
(0xDBE, 'X'),
(0xDC0, 'V'),
(0xDC7, 'X'),
(0xDCA, 'V'),
(0xDCB, 'X'),
(0xDCF, 'V'),
(0xDD5, 'X'),
(0xDD6, 'V'),
(0xDD7, 'X'),
(0xDD8, 'V'),
(0xDE0, 'X'),
(0xDE6, 'V'),
(0xDF0, 'X'),
(0xDF2, 'V'),
(0xDF5, 'X'),
(0xE01, 'V'),
(0xE33, 'M', 'ํา'),
(0xE34, 'V'),
(0xE3B, 'X'),
(0xE3F, 'V'),
(0xE5C, 'X'),
(0xE81, 'V'),
(0xE83, 'X'),
(0xE84, 'V'),
(0xE85, 'X'),
(0xE86, 'V'),
(0xE8B, 'X'),
(0xE8C, 'V'),
(0xEA4, 'X'),
(0xEA5, 'V'),
(0xEA6, 'X'),
(0xEA7, 'V'),
(0xEB3, 'M', 'ໍາ'),
(0xEB4, 'V'),
] | null |
1,518 | from typing import List, Tuple, Union
def _seg_13() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0xEBE, 'X'),
(0xEC0, 'V'),
(0xEC5, 'X'),
(0xEC6, 'V'),
(0xEC7, 'X'),
(0xEC8, 'V'),
(0xECF, 'X'),
(0xED0, 'V'),
(0xEDA, 'X'),
(0xEDC, 'M', 'ຫນ'),
(0xEDD, 'M', 'ຫມ'),
(0xEDE, 'V'),
(0xEE0, 'X'),
(0xF00, 'V'),
(0xF0C, 'M', '་'),
(0xF0D, 'V'),
(0xF43, 'M', 'གྷ'),
(0xF44, 'V'),
(0xF48, 'X'),
(0xF49, 'V'),
(0xF4D, 'M', 'ཌྷ'),
(0xF4E, 'V'),
(0xF52, 'M', 'དྷ'),
(0xF53, 'V'),
(0xF57, 'M', 'བྷ'),
(0xF58, 'V'),
(0xF5C, 'M', 'ཛྷ'),
(0xF5D, 'V'),
(0xF69, 'M', 'ཀྵ'),
(0xF6A, 'V'),
(0xF6D, 'X'),
(0xF71, 'V'),
(0xF73, 'M', 'ཱི'),
(0xF74, 'V'),
(0xF75, 'M', 'ཱུ'),
(0xF76, 'M', 'ྲྀ'),
(0xF77, 'M', 'ྲཱྀ'),
(0xF78, 'M', 'ླྀ'),
(0xF79, 'M', 'ླཱྀ'),
(0xF7A, 'V'),
(0xF81, 'M', 'ཱྀ'),
(0xF82, 'V'),
(0xF93, 'M', 'ྒྷ'),
(0xF94, 'V'),
(0xF98, 'X'),
(0xF99, 'V'),
(0xF9D, 'M', 'ྜྷ'),
(0xF9E, 'V'),
(0xFA2, 'M', 'ྡྷ'),
(0xFA3, 'V'),
(0xFA7, 'M', 'ྦྷ'),
(0xFA8, 'V'),
(0xFAC, 'M', 'ྫྷ'),
(0xFAD, 'V'),
(0xFB9, 'M', 'ྐྵ'),
(0xFBA, 'V'),
(0xFBD, 'X'),
(0xFBE, 'V'),
(0xFCD, 'X'),
(0xFCE, 'V'),
(0xFDB, 'X'),
(0x1000, 'V'),
(0x10A0, 'X'),
(0x10C7, 'M', 'ⴧ'),
(0x10C8, 'X'),
(0x10CD, 'M', 'ⴭ'),
(0x10CE, 'X'),
(0x10D0, 'V'),
(0x10FC, 'M', 'ნ'),
(0x10FD, 'V'),
(0x115F, 'X'),
(0x1161, 'V'),
(0x1249, 'X'),
(0x124A, 'V'),
(0x124E, 'X'),
(0x1250, 'V'),
(0x1257, 'X'),
(0x1258, 'V'),
(0x1259, 'X'),
(0x125A, 'V'),
(0x125E, 'X'),
(0x1260, 'V'),
(0x1289, 'X'),
(0x128A, 'V'),
(0x128E, 'X'),
(0x1290, 'V'),
(0x12B1, 'X'),
(0x12B2, 'V'),
(0x12B6, 'X'),
(0x12B8, 'V'),
(0x12BF, 'X'),
(0x12C0, 'V'),
(0x12C1, 'X'),
(0x12C2, 'V'),
(0x12C6, 'X'),
(0x12C8, 'V'),
(0x12D7, 'X'),
(0x12D8, 'V'),
(0x1311, 'X'),
(0x1312, 'V'),
] | null |
1,519 | from typing import List, Tuple, Union
def _seg_14() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1316, 'X'),
(0x1318, 'V'),
(0x135B, 'X'),
(0x135D, 'V'),
(0x137D, 'X'),
(0x1380, 'V'),
(0x139A, 'X'),
(0x13A0, 'V'),
(0x13F6, 'X'),
(0x13F8, 'M', 'Ᏸ'),
(0x13F9, 'M', 'Ᏹ'),
(0x13FA, 'M', 'Ᏺ'),
(0x13FB, 'M', 'Ᏻ'),
(0x13FC, 'M', 'Ᏼ'),
(0x13FD, 'M', 'Ᏽ'),
(0x13FE, 'X'),
(0x1400, 'V'),
(0x1680, 'X'),
(0x1681, 'V'),
(0x169D, 'X'),
(0x16A0, 'V'),
(0x16F9, 'X'),
(0x1700, 'V'),
(0x1716, 'X'),
(0x171F, 'V'),
(0x1737, 'X'),
(0x1740, 'V'),
(0x1754, 'X'),
(0x1760, 'V'),
(0x176D, 'X'),
(0x176E, 'V'),
(0x1771, 'X'),
(0x1772, 'V'),
(0x1774, 'X'),
(0x1780, 'V'),
(0x17B4, 'X'),
(0x17B6, 'V'),
(0x17DE, 'X'),
(0x17E0, 'V'),
(0x17EA, 'X'),
(0x17F0, 'V'),
(0x17FA, 'X'),
(0x1800, 'V'),
(0x1806, 'X'),
(0x1807, 'V'),
(0x180B, 'I'),
(0x180E, 'X'),
(0x180F, 'I'),
(0x1810, 'V'),
(0x181A, 'X'),
(0x1820, 'V'),
(0x1879, 'X'),
(0x1880, 'V'),
(0x18AB, 'X'),
(0x18B0, 'V'),
(0x18F6, 'X'),
(0x1900, 'V'),
(0x191F, 'X'),
(0x1920, 'V'),
(0x192C, 'X'),
(0x1930, 'V'),
(0x193C, 'X'),
(0x1940, 'V'),
(0x1941, 'X'),
(0x1944, 'V'),
(0x196E, 'X'),
(0x1970, 'V'),
(0x1975, 'X'),
(0x1980, 'V'),
(0x19AC, 'X'),
(0x19B0, 'V'),
(0x19CA, 'X'),
(0x19D0, 'V'),
(0x19DB, 'X'),
(0x19DE, 'V'),
(0x1A1C, 'X'),
(0x1A1E, 'V'),
(0x1A5F, 'X'),
(0x1A60, 'V'),
(0x1A7D, 'X'),
(0x1A7F, 'V'),
(0x1A8A, 'X'),
(0x1A90, 'V'),
(0x1A9A, 'X'),
(0x1AA0, 'V'),
(0x1AAE, 'X'),
(0x1AB0, 'V'),
(0x1ACF, 'X'),
(0x1B00, 'V'),
(0x1B4D, 'X'),
(0x1B50, 'V'),
(0x1B7F, 'X'),
(0x1B80, 'V'),
(0x1BF4, 'X'),
(0x1BFC, 'V'),
(0x1C38, 'X'),
(0x1C3B, 'V'),
(0x1C4A, 'X'),
(0x1C4D, 'V'),
(0x1C80, 'M', 'в'),
] | null |
1,520 | from typing import List, Tuple, Union
def _seg_15() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1C81, 'M', 'д'),
(0x1C82, 'M', 'о'),
(0x1C83, 'M', 'с'),
(0x1C84, 'M', 'т'),
(0x1C86, 'M', 'ъ'),
(0x1C87, 'M', 'ѣ'),
(0x1C88, 'M', 'ꙋ'),
(0x1C89, 'X'),
(0x1C90, 'M', 'ა'),
(0x1C91, 'M', 'ბ'),
(0x1C92, 'M', 'გ'),
(0x1C93, 'M', 'დ'),
(0x1C94, 'M', 'ე'),
(0x1C95, 'M', 'ვ'),
(0x1C96, 'M', 'ზ'),
(0x1C97, 'M', 'თ'),
(0x1C98, 'M', 'ი'),
(0x1C99, 'M', 'კ'),
(0x1C9A, 'M', 'ლ'),
(0x1C9B, 'M', 'მ'),
(0x1C9C, 'M', 'ნ'),
(0x1C9D, 'M', 'ო'),
(0x1C9E, 'M', 'პ'),
(0x1C9F, 'M', 'ჟ'),
(0x1CA0, 'M', 'რ'),
(0x1CA1, 'M', 'ს'),
(0x1CA2, 'M', 'ტ'),
(0x1CA3, 'M', 'უ'),
(0x1CA4, 'M', 'ფ'),
(0x1CA5, 'M', 'ქ'),
(0x1CA6, 'M', 'ღ'),
(0x1CA7, 'M', 'ყ'),
(0x1CA8, 'M', 'შ'),
(0x1CA9, 'M', 'ჩ'),
(0x1CAA, 'M', 'ც'),
(0x1CAB, 'M', 'ძ'),
(0x1CAC, 'M', 'წ'),
(0x1CAD, 'M', 'ჭ'),
(0x1CAE, 'M', 'ხ'),
(0x1CAF, 'M', 'ჯ'),
(0x1CB0, 'M', 'ჰ'),
(0x1CB1, 'M', 'ჱ'),
(0x1CB2, 'M', 'ჲ'),
(0x1CB3, 'M', 'ჳ'),
(0x1CB4, 'M', 'ჴ'),
(0x1CB5, 'M', 'ჵ'),
(0x1CB6, 'M', 'ჶ'),
(0x1CB7, 'M', 'ჷ'),
(0x1CB8, 'M', 'ჸ'),
(0x1CB9, 'M', 'ჹ'),
(0x1CBA, 'M', 'ჺ'),
(0x1CBB, 'X'),
(0x1CBD, 'M', 'ჽ'),
(0x1CBE, 'M', 'ჾ'),
(0x1CBF, 'M', 'ჿ'),
(0x1CC0, 'V'),
(0x1CC8, 'X'),
(0x1CD0, 'V'),
(0x1CFB, 'X'),
(0x1D00, 'V'),
(0x1D2C, 'M', 'a'),
(0x1D2D, 'M', 'æ'),
(0x1D2E, 'M', 'b'),
(0x1D2F, 'V'),
(0x1D30, 'M', 'd'),
(0x1D31, 'M', 'e'),
(0x1D32, 'M', 'ǝ'),
(0x1D33, 'M', 'g'),
(0x1D34, 'M', 'h'),
(0x1D35, 'M', 'i'),
(0x1D36, 'M', 'j'),
(0x1D37, 'M', 'k'),
(0x1D38, 'M', 'l'),
(0x1D39, 'M', 'm'),
(0x1D3A, 'M', 'n'),
(0x1D3B, 'V'),
(0x1D3C, 'M', 'o'),
(0x1D3D, 'M', 'ȣ'),
(0x1D3E, 'M', 'p'),
(0x1D3F, 'M', 'r'),
(0x1D40, 'M', 't'),
(0x1D41, 'M', 'u'),
(0x1D42, 'M', 'w'),
(0x1D43, 'M', 'a'),
(0x1D44, 'M', 'ɐ'),
(0x1D45, 'M', 'ɑ'),
(0x1D46, 'M', 'ᴂ'),
(0x1D47, 'M', 'b'),
(0x1D48, 'M', 'd'),
(0x1D49, 'M', 'e'),
(0x1D4A, 'M', 'ə'),
(0x1D4B, 'M', 'ɛ'),
(0x1D4C, 'M', 'ɜ'),
(0x1D4D, 'M', 'g'),
(0x1D4E, 'V'),
(0x1D4F, 'M', 'k'),
(0x1D50, 'M', 'm'),
(0x1D51, 'M', 'ŋ'),
(0x1D52, 'M', 'o'),
(0x1D53, 'M', 'ɔ'),
] | null |
1,521 | from typing import List, Tuple, Union
def _seg_16() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1D54, 'M', 'ᴖ'),
(0x1D55, 'M', 'ᴗ'),
(0x1D56, 'M', 'p'),
(0x1D57, 'M', 't'),
(0x1D58, 'M', 'u'),
(0x1D59, 'M', 'ᴝ'),
(0x1D5A, 'M', 'ɯ'),
(0x1D5B, 'M', 'v'),
(0x1D5C, 'M', 'ᴥ'),
(0x1D5D, 'M', 'β'),
(0x1D5E, 'M', 'γ'),
(0x1D5F, 'M', 'δ'),
(0x1D60, 'M', 'φ'),
(0x1D61, 'M', 'χ'),
(0x1D62, 'M', 'i'),
(0x1D63, 'M', 'r'),
(0x1D64, 'M', 'u'),
(0x1D65, 'M', 'v'),
(0x1D66, 'M', 'β'),
(0x1D67, 'M', 'γ'),
(0x1D68, 'M', 'ρ'),
(0x1D69, 'M', 'φ'),
(0x1D6A, 'M', 'χ'),
(0x1D6B, 'V'),
(0x1D78, 'M', 'н'),
(0x1D79, 'V'),
(0x1D9B, 'M', 'ɒ'),
(0x1D9C, 'M', 'c'),
(0x1D9D, 'M', 'ɕ'),
(0x1D9E, 'M', 'ð'),
(0x1D9F, 'M', 'ɜ'),
(0x1DA0, 'M', 'f'),
(0x1DA1, 'M', 'ɟ'),
(0x1DA2, 'M', 'ɡ'),
(0x1DA3, 'M', 'ɥ'),
(0x1DA4, 'M', 'ɨ'),
(0x1DA5, 'M', 'ɩ'),
(0x1DA6, 'M', 'ɪ'),
(0x1DA7, 'M', 'ᵻ'),
(0x1DA8, 'M', 'ʝ'),
(0x1DA9, 'M', 'ɭ'),
(0x1DAA, 'M', 'ᶅ'),
(0x1DAB, 'M', 'ʟ'),
(0x1DAC, 'M', 'ɱ'),
(0x1DAD, 'M', 'ɰ'),
(0x1DAE, 'M', 'ɲ'),
(0x1DAF, 'M', 'ɳ'),
(0x1DB0, 'M', 'ɴ'),
(0x1DB1, 'M', 'ɵ'),
(0x1DB2, 'M', 'ɸ'),
(0x1DB3, 'M', 'ʂ'),
(0x1DB4, 'M', 'ʃ'),
(0x1DB5, 'M', 'ƫ'),
(0x1DB6, 'M', 'ʉ'),
(0x1DB7, 'M', 'ʊ'),
(0x1DB8, 'M', 'ᴜ'),
(0x1DB9, 'M', 'ʋ'),
(0x1DBA, 'M', 'ʌ'),
(0x1DBB, 'M', 'z'),
(0x1DBC, 'M', 'ʐ'),
(0x1DBD, 'M', 'ʑ'),
(0x1DBE, 'M', 'ʒ'),
(0x1DBF, 'M', 'θ'),
(0x1DC0, 'V'),
(0x1E00, 'M', 'ḁ'),
(0x1E01, 'V'),
(0x1E02, 'M', 'ḃ'),
(0x1E03, 'V'),
(0x1E04, 'M', 'ḅ'),
(0x1E05, 'V'),
(0x1E06, 'M', 'ḇ'),
(0x1E07, 'V'),
(0x1E08, 'M', 'ḉ'),
(0x1E09, 'V'),
(0x1E0A, 'M', 'ḋ'),
(0x1E0B, 'V'),
(0x1E0C, 'M', 'ḍ'),
(0x1E0D, 'V'),
(0x1E0E, 'M', 'ḏ'),
(0x1E0F, 'V'),
(0x1E10, 'M', 'ḑ'),
(0x1E11, 'V'),
(0x1E12, 'M', 'ḓ'),
(0x1E13, 'V'),
(0x1E14, 'M', 'ḕ'),
(0x1E15, 'V'),
(0x1E16, 'M', 'ḗ'),
(0x1E17, 'V'),
(0x1E18, 'M', 'ḙ'),
(0x1E19, 'V'),
(0x1E1A, 'M', 'ḛ'),
(0x1E1B, 'V'),
(0x1E1C, 'M', 'ḝ'),
(0x1E1D, 'V'),
(0x1E1E, 'M', 'ḟ'),
(0x1E1F, 'V'),
(0x1E20, 'M', 'ḡ'),
(0x1E21, 'V'),
(0x1E22, 'M', 'ḣ'),
(0x1E23, 'V'),
] | null |
1,522 | from typing import List, Tuple, Union
def _seg_17() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1E24, 'M', 'ḥ'),
(0x1E25, 'V'),
(0x1E26, 'M', 'ḧ'),
(0x1E27, 'V'),
(0x1E28, 'M', 'ḩ'),
(0x1E29, 'V'),
(0x1E2A, 'M', 'ḫ'),
(0x1E2B, 'V'),
(0x1E2C, 'M', 'ḭ'),
(0x1E2D, 'V'),
(0x1E2E, 'M', 'ḯ'),
(0x1E2F, 'V'),
(0x1E30, 'M', 'ḱ'),
(0x1E31, 'V'),
(0x1E32, 'M', 'ḳ'),
(0x1E33, 'V'),
(0x1E34, 'M', 'ḵ'),
(0x1E35, 'V'),
(0x1E36, 'M', 'ḷ'),
(0x1E37, 'V'),
(0x1E38, 'M', 'ḹ'),
(0x1E39, 'V'),
(0x1E3A, 'M', 'ḻ'),
(0x1E3B, 'V'),
(0x1E3C, 'M', 'ḽ'),
(0x1E3D, 'V'),
(0x1E3E, 'M', 'ḿ'),
(0x1E3F, 'V'),
(0x1E40, 'M', 'ṁ'),
(0x1E41, 'V'),
(0x1E42, 'M', 'ṃ'),
(0x1E43, 'V'),
(0x1E44, 'M', 'ṅ'),
(0x1E45, 'V'),
(0x1E46, 'M', 'ṇ'),
(0x1E47, 'V'),
(0x1E48, 'M', 'ṉ'),
(0x1E49, 'V'),
(0x1E4A, 'M', 'ṋ'),
(0x1E4B, 'V'),
(0x1E4C, 'M', 'ṍ'),
(0x1E4D, 'V'),
(0x1E4E, 'M', 'ṏ'),
(0x1E4F, 'V'),
(0x1E50, 'M', 'ṑ'),
(0x1E51, 'V'),
(0x1E52, 'M', 'ṓ'),
(0x1E53, 'V'),
(0x1E54, 'M', 'ṕ'),
(0x1E55, 'V'),
(0x1E56, 'M', 'ṗ'),
(0x1E57, 'V'),
(0x1E58, 'M', 'ṙ'),
(0x1E59, 'V'),
(0x1E5A, 'M', 'ṛ'),
(0x1E5B, 'V'),
(0x1E5C, 'M', 'ṝ'),
(0x1E5D, 'V'),
(0x1E5E, 'M', 'ṟ'),
(0x1E5F, 'V'),
(0x1E60, 'M', 'ṡ'),
(0x1E61, 'V'),
(0x1E62, 'M', 'ṣ'),
(0x1E63, 'V'),
(0x1E64, 'M', 'ṥ'),
(0x1E65, 'V'),
(0x1E66, 'M', 'ṧ'),
(0x1E67, 'V'),
(0x1E68, 'M', 'ṩ'),
(0x1E69, 'V'),
(0x1E6A, 'M', 'ṫ'),
(0x1E6B, 'V'),
(0x1E6C, 'M', 'ṭ'),
(0x1E6D, 'V'),
(0x1E6E, 'M', 'ṯ'),
(0x1E6F, 'V'),
(0x1E70, 'M', 'ṱ'),
(0x1E71, 'V'),
(0x1E72, 'M', 'ṳ'),
(0x1E73, 'V'),
(0x1E74, 'M', 'ṵ'),
(0x1E75, 'V'),
(0x1E76, 'M', 'ṷ'),
(0x1E77, 'V'),
(0x1E78, 'M', 'ṹ'),
(0x1E79, 'V'),
(0x1E7A, 'M', 'ṻ'),
(0x1E7B, 'V'),
(0x1E7C, 'M', 'ṽ'),
(0x1E7D, 'V'),
(0x1E7E, 'M', 'ṿ'),
(0x1E7F, 'V'),
(0x1E80, 'M', 'ẁ'),
(0x1E81, 'V'),
(0x1E82, 'M', 'ẃ'),
(0x1E83, 'V'),
(0x1E84, 'M', 'ẅ'),
(0x1E85, 'V'),
(0x1E86, 'M', 'ẇ'),
(0x1E87, 'V'),
] | null |
1,523 | from typing import List, Tuple, Union
def _seg_18() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1E88, 'M', 'ẉ'),
(0x1E89, 'V'),
(0x1E8A, 'M', 'ẋ'),
(0x1E8B, 'V'),
(0x1E8C, 'M', 'ẍ'),
(0x1E8D, 'V'),
(0x1E8E, 'M', 'ẏ'),
(0x1E8F, 'V'),
(0x1E90, 'M', 'ẑ'),
(0x1E91, 'V'),
(0x1E92, 'M', 'ẓ'),
(0x1E93, 'V'),
(0x1E94, 'M', 'ẕ'),
(0x1E95, 'V'),
(0x1E9A, 'M', 'aʾ'),
(0x1E9B, 'M', 'ṡ'),
(0x1E9C, 'V'),
(0x1E9E, 'M', 'ss'),
(0x1E9F, 'V'),
(0x1EA0, 'M', 'ạ'),
(0x1EA1, 'V'),
(0x1EA2, 'M', 'ả'),
(0x1EA3, 'V'),
(0x1EA4, 'M', 'ấ'),
(0x1EA5, 'V'),
(0x1EA6, 'M', 'ầ'),
(0x1EA7, 'V'),
(0x1EA8, 'M', 'ẩ'),
(0x1EA9, 'V'),
(0x1EAA, 'M', 'ẫ'),
(0x1EAB, 'V'),
(0x1EAC, 'M', 'ậ'),
(0x1EAD, 'V'),
(0x1EAE, 'M', 'ắ'),
(0x1EAF, 'V'),
(0x1EB0, 'M', 'ằ'),
(0x1EB1, 'V'),
(0x1EB2, 'M', 'ẳ'),
(0x1EB3, 'V'),
(0x1EB4, 'M', 'ẵ'),
(0x1EB5, 'V'),
(0x1EB6, 'M', 'ặ'),
(0x1EB7, 'V'),
(0x1EB8, 'M', 'ẹ'),
(0x1EB9, 'V'),
(0x1EBA, 'M', 'ẻ'),
(0x1EBB, 'V'),
(0x1EBC, 'M', 'ẽ'),
(0x1EBD, 'V'),
(0x1EBE, 'M', 'ế'),
(0x1EBF, 'V'),
(0x1EC0, 'M', 'ề'),
(0x1EC1, 'V'),
(0x1EC2, 'M', 'ể'),
(0x1EC3, 'V'),
(0x1EC4, 'M', 'ễ'),
(0x1EC5, 'V'),
(0x1EC6, 'M', 'ệ'),
(0x1EC7, 'V'),
(0x1EC8, 'M', 'ỉ'),
(0x1EC9, 'V'),
(0x1ECA, 'M', 'ị'),
(0x1ECB, 'V'),
(0x1ECC, 'M', 'ọ'),
(0x1ECD, 'V'),
(0x1ECE, 'M', 'ỏ'),
(0x1ECF, 'V'),
(0x1ED0, 'M', 'ố'),
(0x1ED1, 'V'),
(0x1ED2, 'M', 'ồ'),
(0x1ED3, 'V'),
(0x1ED4, 'M', 'ổ'),
(0x1ED5, 'V'),
(0x1ED6, 'M', 'ỗ'),
(0x1ED7, 'V'),
(0x1ED8, 'M', 'ộ'),
(0x1ED9, 'V'),
(0x1EDA, 'M', 'ớ'),
(0x1EDB, 'V'),
(0x1EDC, 'M', 'ờ'),
(0x1EDD, 'V'),
(0x1EDE, 'M', 'ở'),
(0x1EDF, 'V'),
(0x1EE0, 'M', 'ỡ'),
(0x1EE1, 'V'),
(0x1EE2, 'M', 'ợ'),
(0x1EE3, 'V'),
(0x1EE4, 'M', 'ụ'),
(0x1EE5, 'V'),
(0x1EE6, 'M', 'ủ'),
(0x1EE7, 'V'),
(0x1EE8, 'M', 'ứ'),
(0x1EE9, 'V'),
(0x1EEA, 'M', 'ừ'),
(0x1EEB, 'V'),
(0x1EEC, 'M', 'ử'),
(0x1EED, 'V'),
(0x1EEE, 'M', 'ữ'),
(0x1EEF, 'V'),
(0x1EF0, 'M', 'ự'),
] | null |
1,524 | from typing import List, Tuple, Union
def _seg_19() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1EF1, 'V'),
(0x1EF2, 'M', 'ỳ'),
(0x1EF3, 'V'),
(0x1EF4, 'M', 'ỵ'),
(0x1EF5, 'V'),
(0x1EF6, 'M', 'ỷ'),
(0x1EF7, 'V'),
(0x1EF8, 'M', 'ỹ'),
(0x1EF9, 'V'),
(0x1EFA, 'M', 'ỻ'),
(0x1EFB, 'V'),
(0x1EFC, 'M', 'ỽ'),
(0x1EFD, 'V'),
(0x1EFE, 'M', 'ỿ'),
(0x1EFF, 'V'),
(0x1F08, 'M', 'ἀ'),
(0x1F09, 'M', 'ἁ'),
(0x1F0A, 'M', 'ἂ'),
(0x1F0B, 'M', 'ἃ'),
(0x1F0C, 'M', 'ἄ'),
(0x1F0D, 'M', 'ἅ'),
(0x1F0E, 'M', 'ἆ'),
(0x1F0F, 'M', 'ἇ'),
(0x1F10, 'V'),
(0x1F16, 'X'),
(0x1F18, 'M', 'ἐ'),
(0x1F19, 'M', 'ἑ'),
(0x1F1A, 'M', 'ἒ'),
(0x1F1B, 'M', 'ἓ'),
(0x1F1C, 'M', 'ἔ'),
(0x1F1D, 'M', 'ἕ'),
(0x1F1E, 'X'),
(0x1F20, 'V'),
(0x1F28, 'M', 'ἠ'),
(0x1F29, 'M', 'ἡ'),
(0x1F2A, 'M', 'ἢ'),
(0x1F2B, 'M', 'ἣ'),
(0x1F2C, 'M', 'ἤ'),
(0x1F2D, 'M', 'ἥ'),
(0x1F2E, 'M', 'ἦ'),
(0x1F2F, 'M', 'ἧ'),
(0x1F30, 'V'),
(0x1F38, 'M', 'ἰ'),
(0x1F39, 'M', 'ἱ'),
(0x1F3A, 'M', 'ἲ'),
(0x1F3B, 'M', 'ἳ'),
(0x1F3C, 'M', 'ἴ'),
(0x1F3D, 'M', 'ἵ'),
(0x1F3E, 'M', 'ἶ'),
(0x1F3F, 'M', 'ἷ'),
(0x1F40, 'V'),
(0x1F46, 'X'),
(0x1F48, 'M', 'ὀ'),
(0x1F49, 'M', 'ὁ'),
(0x1F4A, 'M', 'ὂ'),
(0x1F4B, 'M', 'ὃ'),
(0x1F4C, 'M', 'ὄ'),
(0x1F4D, 'M', 'ὅ'),
(0x1F4E, 'X'),
(0x1F50, 'V'),
(0x1F58, 'X'),
(0x1F59, 'M', 'ὑ'),
(0x1F5A, 'X'),
(0x1F5B, 'M', 'ὓ'),
(0x1F5C, 'X'),
(0x1F5D, 'M', 'ὕ'),
(0x1F5E, 'X'),
(0x1F5F, 'M', 'ὗ'),
(0x1F60, 'V'),
(0x1F68, 'M', 'ὠ'),
(0x1F69, 'M', 'ὡ'),
(0x1F6A, 'M', 'ὢ'),
(0x1F6B, 'M', 'ὣ'),
(0x1F6C, 'M', 'ὤ'),
(0x1F6D, 'M', 'ὥ'),
(0x1F6E, 'M', 'ὦ'),
(0x1F6F, 'M', 'ὧ'),
(0x1F70, 'V'),
(0x1F71, 'M', 'ά'),
(0x1F72, 'V'),
(0x1F73, 'M', 'έ'),
(0x1F74, 'V'),
(0x1F75, 'M', 'ή'),
(0x1F76, 'V'),
(0x1F77, 'M', 'ί'),
(0x1F78, 'V'),
(0x1F79, 'M', 'ό'),
(0x1F7A, 'V'),
(0x1F7B, 'M', 'ύ'),
(0x1F7C, 'V'),
(0x1F7D, 'M', 'ώ'),
(0x1F7E, 'X'),
(0x1F80, 'M', 'ἀι'),
(0x1F81, 'M', 'ἁι'),
(0x1F82, 'M', 'ἂι'),
(0x1F83, 'M', 'ἃι'),
(0x1F84, 'M', 'ἄι'),
(0x1F85, 'M', 'ἅι'),
(0x1F86, 'M', 'ἆι'),
(0x1F87, 'M', 'ἇι'),
] | null |
1,525 | from typing import List, Tuple, Union
def _seg_20() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1F88, 'M', 'ἀι'),
(0x1F89, 'M', 'ἁι'),
(0x1F8A, 'M', 'ἂι'),
(0x1F8B, 'M', 'ἃι'),
(0x1F8C, 'M', 'ἄι'),
(0x1F8D, 'M', 'ἅι'),
(0x1F8E, 'M', 'ἆι'),
(0x1F8F, 'M', 'ἇι'),
(0x1F90, 'M', 'ἠι'),
(0x1F91, 'M', 'ἡι'),
(0x1F92, 'M', 'ἢι'),
(0x1F93, 'M', 'ἣι'),
(0x1F94, 'M', 'ἤι'),
(0x1F95, 'M', 'ἥι'),
(0x1F96, 'M', 'ἦι'),
(0x1F97, 'M', 'ἧι'),
(0x1F98, 'M', 'ἠι'),
(0x1F99, 'M', 'ἡι'),
(0x1F9A, 'M', 'ἢι'),
(0x1F9B, 'M', 'ἣι'),
(0x1F9C, 'M', 'ἤι'),
(0x1F9D, 'M', 'ἥι'),
(0x1F9E, 'M', 'ἦι'),
(0x1F9F, 'M', 'ἧι'),
(0x1FA0, 'M', 'ὠι'),
(0x1FA1, 'M', 'ὡι'),
(0x1FA2, 'M', 'ὢι'),
(0x1FA3, 'M', 'ὣι'),
(0x1FA4, 'M', 'ὤι'),
(0x1FA5, 'M', 'ὥι'),
(0x1FA6, 'M', 'ὦι'),
(0x1FA7, 'M', 'ὧι'),
(0x1FA8, 'M', 'ὠι'),
(0x1FA9, 'M', 'ὡι'),
(0x1FAA, 'M', 'ὢι'),
(0x1FAB, 'M', 'ὣι'),
(0x1FAC, 'M', 'ὤι'),
(0x1FAD, 'M', 'ὥι'),
(0x1FAE, 'M', 'ὦι'),
(0x1FAF, 'M', 'ὧι'),
(0x1FB0, 'V'),
(0x1FB2, 'M', 'ὰι'),
(0x1FB3, 'M', 'αι'),
(0x1FB4, 'M', 'άι'),
(0x1FB5, 'X'),
(0x1FB6, 'V'),
(0x1FB7, 'M', 'ᾶι'),
(0x1FB8, 'M', 'ᾰ'),
(0x1FB9, 'M', 'ᾱ'),
(0x1FBA, 'M', 'ὰ'),
(0x1FBB, 'M', 'ά'),
(0x1FBC, 'M', 'αι'),
(0x1FBD, '3', ' ̓'),
(0x1FBE, 'M', 'ι'),
(0x1FBF, '3', ' ̓'),
(0x1FC0, '3', ' ͂'),
(0x1FC1, '3', ' ̈͂'),
(0x1FC2, 'M', 'ὴι'),
(0x1FC3, 'M', 'ηι'),
(0x1FC4, 'M', 'ήι'),
(0x1FC5, 'X'),
(0x1FC6, 'V'),
(0x1FC7, 'M', 'ῆι'),
(0x1FC8, 'M', 'ὲ'),
(0x1FC9, 'M', 'έ'),
(0x1FCA, 'M', 'ὴ'),
(0x1FCB, 'M', 'ή'),
(0x1FCC, 'M', 'ηι'),
(0x1FCD, '3', ' ̓̀'),
(0x1FCE, '3', ' ̓́'),
(0x1FCF, '3', ' ̓͂'),
(0x1FD0, 'V'),
(0x1FD3, 'M', 'ΐ'),
(0x1FD4, 'X'),
(0x1FD6, 'V'),
(0x1FD8, 'M', 'ῐ'),
(0x1FD9, 'M', 'ῑ'),
(0x1FDA, 'M', 'ὶ'),
(0x1FDB, 'M', 'ί'),
(0x1FDC, 'X'),
(0x1FDD, '3', ' ̔̀'),
(0x1FDE, '3', ' ̔́'),
(0x1FDF, '3', ' ̔͂'),
(0x1FE0, 'V'),
(0x1FE3, 'M', 'ΰ'),
(0x1FE4, 'V'),
(0x1FE8, 'M', 'ῠ'),
(0x1FE9, 'M', 'ῡ'),
(0x1FEA, 'M', 'ὺ'),
(0x1FEB, 'M', 'ύ'),
(0x1FEC, 'M', 'ῥ'),
(0x1FED, '3', ' ̈̀'),
(0x1FEE, '3', ' ̈́'),
(0x1FEF, '3', '`'),
(0x1FF0, 'X'),
(0x1FF2, 'M', 'ὼι'),
(0x1FF3, 'M', 'ωι'),
(0x1FF4, 'M', 'ώι'),
(0x1FF5, 'X'),
(0x1FF6, 'V'),
] | null |
1,526 | from typing import List, Tuple, Union
def _seg_21() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x1FF7, 'M', 'ῶι'),
(0x1FF8, 'M', 'ὸ'),
(0x1FF9, 'M', 'ό'),
(0x1FFA, 'M', 'ὼ'),
(0x1FFB, 'M', 'ώ'),
(0x1FFC, 'M', 'ωι'),
(0x1FFD, '3', ' ́'),
(0x1FFE, '3', ' ̔'),
(0x1FFF, 'X'),
(0x2000, '3', ' '),
(0x200B, 'I'),
(0x200C, 'D', ''),
(0x200E, 'X'),
(0x2010, 'V'),
(0x2011, 'M', '‐'),
(0x2012, 'V'),
(0x2017, '3', ' ̳'),
(0x2018, 'V'),
(0x2024, 'X'),
(0x2027, 'V'),
(0x2028, 'X'),
(0x202F, '3', ' '),
(0x2030, 'V'),
(0x2033, 'M', '′′'),
(0x2034, 'M', '′′′'),
(0x2035, 'V'),
(0x2036, 'M', '‵‵'),
(0x2037, 'M', '‵‵‵'),
(0x2038, 'V'),
(0x203C, '3', '!!'),
(0x203D, 'V'),
(0x203E, '3', ' ̅'),
(0x203F, 'V'),
(0x2047, '3', '??'),
(0x2048, '3', '?!'),
(0x2049, '3', '!?'),
(0x204A, 'V'),
(0x2057, 'M', '′′′′'),
(0x2058, 'V'),
(0x205F, '3', ' '),
(0x2060, 'I'),
(0x2061, 'X'),
(0x2064, 'I'),
(0x2065, 'X'),
(0x2070, 'M', '0'),
(0x2071, 'M', 'i'),
(0x2072, 'X'),
(0x2074, 'M', '4'),
(0x2075, 'M', '5'),
(0x2076, 'M', '6'),
(0x2077, 'M', '7'),
(0x2078, 'M', '8'),
(0x2079, 'M', '9'),
(0x207A, '3', '+'),
(0x207B, 'M', '−'),
(0x207C, '3', '='),
(0x207D, '3', '('),
(0x207E, '3', ')'),
(0x207F, 'M', 'n'),
(0x2080, 'M', '0'),
(0x2081, 'M', '1'),
(0x2082, 'M', '2'),
(0x2083, 'M', '3'),
(0x2084, 'M', '4'),
(0x2085, 'M', '5'),
(0x2086, 'M', '6'),
(0x2087, 'M', '7'),
(0x2088, 'M', '8'),
(0x2089, 'M', '9'),
(0x208A, '3', '+'),
(0x208B, 'M', '−'),
(0x208C, '3', '='),
(0x208D, '3', '('),
(0x208E, '3', ')'),
(0x208F, 'X'),
(0x2090, 'M', 'a'),
(0x2091, 'M', 'e'),
(0x2092, 'M', 'o'),
(0x2093, 'M', 'x'),
(0x2094, 'M', 'ə'),
(0x2095, 'M', 'h'),
(0x2096, 'M', 'k'),
(0x2097, 'M', 'l'),
(0x2098, 'M', 'm'),
(0x2099, 'M', 'n'),
(0x209A, 'M', 'p'),
(0x209B, 'M', 's'),
(0x209C, 'M', 't'),
(0x209D, 'X'),
(0x20A0, 'V'),
(0x20A8, 'M', 'rs'),
(0x20A9, 'V'),
(0x20C1, 'X'),
(0x20D0, 'V'),
(0x20F1, 'X'),
(0x2100, '3', 'a/c'),
(0x2101, '3', 'a/s'),
(0x2102, 'M', 'c'),
(0x2103, 'M', '°c'),
(0x2104, 'V'),
] | null |
1,527 | from typing import List, Tuple, Union
def _seg_22() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x2105, '3', 'c/o'),
(0x2106, '3', 'c/u'),
(0x2107, 'M', 'ɛ'),
(0x2108, 'V'),
(0x2109, 'M', '°f'),
(0x210A, 'M', 'g'),
(0x210B, 'M', 'h'),
(0x210F, 'M', 'ħ'),
(0x2110, 'M', 'i'),
(0x2112, 'M', 'l'),
(0x2114, 'V'),
(0x2115, 'M', 'n'),
(0x2116, 'M', 'no'),
(0x2117, 'V'),
(0x2119, 'M', 'p'),
(0x211A, 'M', 'q'),
(0x211B, 'M', 'r'),
(0x211E, 'V'),
(0x2120, 'M', 'sm'),
(0x2121, 'M', 'tel'),
(0x2122, 'M', 'tm'),
(0x2123, 'V'),
(0x2124, 'M', 'z'),
(0x2125, 'V'),
(0x2126, 'M', 'ω'),
(0x2127, 'V'),
(0x2128, 'M', 'z'),
(0x2129, 'V'),
(0x212A, 'M', 'k'),
(0x212B, 'M', 'å'),
(0x212C, 'M', 'b'),
(0x212D, 'M', 'c'),
(0x212E, 'V'),
(0x212F, 'M', 'e'),
(0x2131, 'M', 'f'),
(0x2132, 'X'),
(0x2133, 'M', 'm'),
(0x2134, 'M', 'o'),
(0x2135, 'M', 'א'),
(0x2136, 'M', 'ב'),
(0x2137, 'M', 'ג'),
(0x2138, 'M', 'ד'),
(0x2139, 'M', 'i'),
(0x213A, 'V'),
(0x213B, 'M', 'fax'),
(0x213C, 'M', 'π'),
(0x213D, 'M', 'γ'),
(0x213F, 'M', 'π'),
(0x2140, 'M', '∑'),
(0x2141, 'V'),
(0x2145, 'M', 'd'),
(0x2147, 'M', 'e'),
(0x2148, 'M', 'i'),
(0x2149, 'M', 'j'),
(0x214A, 'V'),
(0x2150, 'M', '1⁄7'),
(0x2151, 'M', '1⁄9'),
(0x2152, 'M', '1⁄10'),
(0x2153, 'M', '1⁄3'),
(0x2154, 'M', '2⁄3'),
(0x2155, 'M', '1⁄5'),
(0x2156, 'M', '2⁄5'),
(0x2157, 'M', '3⁄5'),
(0x2158, 'M', '4⁄5'),
(0x2159, 'M', '1⁄6'),
(0x215A, 'M', '5⁄6'),
(0x215B, 'M', '1⁄8'),
(0x215C, 'M', '3⁄8'),
(0x215D, 'M', '5⁄8'),
(0x215E, 'M', '7⁄8'),
(0x215F, 'M', '1⁄'),
(0x2160, 'M', 'i'),
(0x2161, 'M', 'ii'),
(0x2162, 'M', 'iii'),
(0x2163, 'M', 'iv'),
(0x2164, 'M', 'v'),
(0x2165, 'M', 'vi'),
(0x2166, 'M', 'vii'),
(0x2167, 'M', 'viii'),
(0x2168, 'M', 'ix'),
(0x2169, 'M', 'x'),
(0x216A, 'M', 'xi'),
(0x216B, 'M', 'xii'),
(0x216C, 'M', 'l'),
(0x216D, 'M', 'c'),
(0x216E, 'M', 'd'),
(0x216F, 'M', 'm'),
(0x2170, 'M', 'i'),
(0x2171, 'M', 'ii'),
(0x2172, 'M', 'iii'),
(0x2173, 'M', 'iv'),
(0x2174, 'M', 'v'),
(0x2175, 'M', 'vi'),
(0x2176, 'M', 'vii'),
(0x2177, 'M', 'viii'),
(0x2178, 'M', 'ix'),
(0x2179, 'M', 'x'),
(0x217A, 'M', 'xi'),
(0x217B, 'M', 'xii'),
(0x217C, 'M', 'l'),
] | null |
1,528 | from typing import List, Tuple, Union
def _seg_23() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x217D, 'M', 'c'),
(0x217E, 'M', 'd'),
(0x217F, 'M', 'm'),
(0x2180, 'V'),
(0x2183, 'X'),
(0x2184, 'V'),
(0x2189, 'M', '0⁄3'),
(0x218A, 'V'),
(0x218C, 'X'),
(0x2190, 'V'),
(0x222C, 'M', '∫∫'),
(0x222D, 'M', '∫∫∫'),
(0x222E, 'V'),
(0x222F, 'M', '∮∮'),
(0x2230, 'M', '∮∮∮'),
(0x2231, 'V'),
(0x2260, '3'),
(0x2261, 'V'),
(0x226E, '3'),
(0x2270, 'V'),
(0x2329, 'M', '〈'),
(0x232A, 'M', '〉'),
(0x232B, 'V'),
(0x2427, 'X'),
(0x2440, 'V'),
(0x244B, 'X'),
(0x2460, 'M', '1'),
(0x2461, 'M', '2'),
(0x2462, 'M', '3'),
(0x2463, 'M', '4'),
(0x2464, 'M', '5'),
(0x2465, 'M', '6'),
(0x2466, 'M', '7'),
(0x2467, 'M', '8'),
(0x2468, 'M', '9'),
(0x2469, 'M', '10'),
(0x246A, 'M', '11'),
(0x246B, 'M', '12'),
(0x246C, 'M', '13'),
(0x246D, 'M', '14'),
(0x246E, 'M', '15'),
(0x246F, 'M', '16'),
(0x2470, 'M', '17'),
(0x2471, 'M', '18'),
(0x2472, 'M', '19'),
(0x2473, 'M', '20'),
(0x2474, '3', '(1)'),
(0x2475, '3', '(2)'),
(0x2476, '3', '(3)'),
(0x2477, '3', '(4)'),
(0x2478, '3', '(5)'),
(0x2479, '3', '(6)'),
(0x247A, '3', '(7)'),
(0x247B, '3', '(8)'),
(0x247C, '3', '(9)'),
(0x247D, '3', '(10)'),
(0x247E, '3', '(11)'),
(0x247F, '3', '(12)'),
(0x2480, '3', '(13)'),
(0x2481, '3', '(14)'),
(0x2482, '3', '(15)'),
(0x2483, '3', '(16)'),
(0x2484, '3', '(17)'),
(0x2485, '3', '(18)'),
(0x2486, '3', '(19)'),
(0x2487, '3', '(20)'),
(0x2488, 'X'),
(0x249C, '3', '(a)'),
(0x249D, '3', '(b)'),
(0x249E, '3', '(c)'),
(0x249F, '3', '(d)'),
(0x24A0, '3', '(e)'),
(0x24A1, '3', '(f)'),
(0x24A2, '3', '(g)'),
(0x24A3, '3', '(h)'),
(0x24A4, '3', '(i)'),
(0x24A5, '3', '(j)'),
(0x24A6, '3', '(k)'),
(0x24A7, '3', '(l)'),
(0x24A8, '3', '(m)'),
(0x24A9, '3', '(n)'),
(0x24AA, '3', '(o)'),
(0x24AB, '3', '(p)'),
(0x24AC, '3', '(q)'),
(0x24AD, '3', '(r)'),
(0x24AE, '3', '(s)'),
(0x24AF, '3', '(t)'),
(0x24B0, '3', '(u)'),
(0x24B1, '3', '(v)'),
(0x24B2, '3', '(w)'),
(0x24B3, '3', '(x)'),
(0x24B4, '3', '(y)'),
(0x24B5, '3', '(z)'),
(0x24B6, 'M', 'a'),
(0x24B7, 'M', 'b'),
(0x24B8, 'M', 'c'),
(0x24B9, 'M', 'd'),
(0x24BA, 'M', 'e'),
(0x24BB, 'M', 'f'),
(0x24BC, 'M', 'g'),
] | null |
1,529 | from typing import List, Tuple, Union
def _seg_24() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x24BD, 'M', 'h'),
(0x24BE, 'M', 'i'),
(0x24BF, 'M', 'j'),
(0x24C0, 'M', 'k'),
(0x24C1, 'M', 'l'),
(0x24C2, 'M', 'm'),
(0x24C3, 'M', 'n'),
(0x24C4, 'M', 'o'),
(0x24C5, 'M', 'p'),
(0x24C6, 'M', 'q'),
(0x24C7, 'M', 'r'),
(0x24C8, 'M', 's'),
(0x24C9, 'M', 't'),
(0x24CA, 'M', 'u'),
(0x24CB, 'M', 'v'),
(0x24CC, 'M', 'w'),
(0x24CD, 'M', 'x'),
(0x24CE, 'M', 'y'),
(0x24CF, 'M', 'z'),
(0x24D0, 'M', 'a'),
(0x24D1, 'M', 'b'),
(0x24D2, 'M', 'c'),
(0x24D3, 'M', 'd'),
(0x24D4, 'M', 'e'),
(0x24D5, 'M', 'f'),
(0x24D6, 'M', 'g'),
(0x24D7, 'M', 'h'),
(0x24D8, 'M', 'i'),
(0x24D9, 'M', 'j'),
(0x24DA, 'M', 'k'),
(0x24DB, 'M', 'l'),
(0x24DC, 'M', 'm'),
(0x24DD, 'M', 'n'),
(0x24DE, 'M', 'o'),
(0x24DF, 'M', 'p'),
(0x24E0, 'M', 'q'),
(0x24E1, 'M', 'r'),
(0x24E2, 'M', 's'),
(0x24E3, 'M', 't'),
(0x24E4, 'M', 'u'),
(0x24E5, 'M', 'v'),
(0x24E6, 'M', 'w'),
(0x24E7, 'M', 'x'),
(0x24E8, 'M', 'y'),
(0x24E9, 'M', 'z'),
(0x24EA, 'M', '0'),
(0x24EB, 'V'),
(0x2A0C, 'M', '∫∫∫∫'),
(0x2A0D, 'V'),
(0x2A74, '3', '::='),
(0x2A75, '3', '=='),
(0x2A76, '3', '==='),
(0x2A77, 'V'),
(0x2ADC, 'M', '⫝̸'),
(0x2ADD, 'V'),
(0x2B74, 'X'),
(0x2B76, 'V'),
(0x2B96, 'X'),
(0x2B97, 'V'),
(0x2C00, 'M', 'ⰰ'),
(0x2C01, 'M', 'ⰱ'),
(0x2C02, 'M', 'ⰲ'),
(0x2C03, 'M', 'ⰳ'),
(0x2C04, 'M', 'ⰴ'),
(0x2C05, 'M', 'ⰵ'),
(0x2C06, 'M', 'ⰶ'),
(0x2C07, 'M', 'ⰷ'),
(0x2C08, 'M', 'ⰸ'),
(0x2C09, 'M', 'ⰹ'),
(0x2C0A, 'M', 'ⰺ'),
(0x2C0B, 'M', 'ⰻ'),
(0x2C0C, 'M', 'ⰼ'),
(0x2C0D, 'M', 'ⰽ'),
(0x2C0E, 'M', 'ⰾ'),
(0x2C0F, 'M', 'ⰿ'),
(0x2C10, 'M', 'ⱀ'),
(0x2C11, 'M', 'ⱁ'),
(0x2C12, 'M', 'ⱂ'),
(0x2C13, 'M', 'ⱃ'),
(0x2C14, 'M', 'ⱄ'),
(0x2C15, 'M', 'ⱅ'),
(0x2C16, 'M', 'ⱆ'),
(0x2C17, 'M', 'ⱇ'),
(0x2C18, 'M', 'ⱈ'),
(0x2C19, 'M', 'ⱉ'),
(0x2C1A, 'M', 'ⱊ'),
(0x2C1B, 'M', 'ⱋ'),
(0x2C1C, 'M', 'ⱌ'),
(0x2C1D, 'M', 'ⱍ'),
(0x2C1E, 'M', 'ⱎ'),
(0x2C1F, 'M', 'ⱏ'),
(0x2C20, 'M', 'ⱐ'),
(0x2C21, 'M', 'ⱑ'),
(0x2C22, 'M', 'ⱒ'),
(0x2C23, 'M', 'ⱓ'),
(0x2C24, 'M', 'ⱔ'),
(0x2C25, 'M', 'ⱕ'),
(0x2C26, 'M', 'ⱖ'),
(0x2C27, 'M', 'ⱗ'),
(0x2C28, 'M', 'ⱘ'),
] | null |
1,530 | from typing import List, Tuple, Union
def _seg_25() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x2C29, 'M', 'ⱙ'),
(0x2C2A, 'M', 'ⱚ'),
(0x2C2B, 'M', 'ⱛ'),
(0x2C2C, 'M', 'ⱜ'),
(0x2C2D, 'M', 'ⱝ'),
(0x2C2E, 'M', 'ⱞ'),
(0x2C2F, 'M', 'ⱟ'),
(0x2C30, 'V'),
(0x2C60, 'M', 'ⱡ'),
(0x2C61, 'V'),
(0x2C62, 'M', 'ɫ'),
(0x2C63, 'M', 'ᵽ'),
(0x2C64, 'M', 'ɽ'),
(0x2C65, 'V'),
(0x2C67, 'M', 'ⱨ'),
(0x2C68, 'V'),
(0x2C69, 'M', 'ⱪ'),
(0x2C6A, 'V'),
(0x2C6B, 'M', 'ⱬ'),
(0x2C6C, 'V'),
(0x2C6D, 'M', 'ɑ'),
(0x2C6E, 'M', 'ɱ'),
(0x2C6F, 'M', 'ɐ'),
(0x2C70, 'M', 'ɒ'),
(0x2C71, 'V'),
(0x2C72, 'M', 'ⱳ'),
(0x2C73, 'V'),
(0x2C75, 'M', 'ⱶ'),
(0x2C76, 'V'),
(0x2C7C, 'M', 'j'),
(0x2C7D, 'M', 'v'),
(0x2C7E, 'M', 'ȿ'),
(0x2C7F, 'M', 'ɀ'),
(0x2C80, 'M', 'ⲁ'),
(0x2C81, 'V'),
(0x2C82, 'M', 'ⲃ'),
(0x2C83, 'V'),
(0x2C84, 'M', 'ⲅ'),
(0x2C85, 'V'),
(0x2C86, 'M', 'ⲇ'),
(0x2C87, 'V'),
(0x2C88, 'M', 'ⲉ'),
(0x2C89, 'V'),
(0x2C8A, 'M', 'ⲋ'),
(0x2C8B, 'V'),
(0x2C8C, 'M', 'ⲍ'),
(0x2C8D, 'V'),
(0x2C8E, 'M', 'ⲏ'),
(0x2C8F, 'V'),
(0x2C90, 'M', 'ⲑ'),
(0x2C91, 'V'),
(0x2C92, 'M', 'ⲓ'),
(0x2C93, 'V'),
(0x2C94, 'M', 'ⲕ'),
(0x2C95, 'V'),
(0x2C96, 'M', 'ⲗ'),
(0x2C97, 'V'),
(0x2C98, 'M', 'ⲙ'),
(0x2C99, 'V'),
(0x2C9A, 'M', 'ⲛ'),
(0x2C9B, 'V'),
(0x2C9C, 'M', 'ⲝ'),
(0x2C9D, 'V'),
(0x2C9E, 'M', 'ⲟ'),
(0x2C9F, 'V'),
(0x2CA0, 'M', 'ⲡ'),
(0x2CA1, 'V'),
(0x2CA2, 'M', 'ⲣ'),
(0x2CA3, 'V'),
(0x2CA4, 'M', 'ⲥ'),
(0x2CA5, 'V'),
(0x2CA6, 'M', 'ⲧ'),
(0x2CA7, 'V'),
(0x2CA8, 'M', 'ⲩ'),
(0x2CA9, 'V'),
(0x2CAA, 'M', 'ⲫ'),
(0x2CAB, 'V'),
(0x2CAC, 'M', 'ⲭ'),
(0x2CAD, 'V'),
(0x2CAE, 'M', 'ⲯ'),
(0x2CAF, 'V'),
(0x2CB0, 'M', 'ⲱ'),
(0x2CB1, 'V'),
(0x2CB2, 'M', 'ⲳ'),
(0x2CB3, 'V'),
(0x2CB4, 'M', 'ⲵ'),
(0x2CB5, 'V'),
(0x2CB6, 'M', 'ⲷ'),
(0x2CB7, 'V'),
(0x2CB8, 'M', 'ⲹ'),
(0x2CB9, 'V'),
(0x2CBA, 'M', 'ⲻ'),
(0x2CBB, 'V'),
(0x2CBC, 'M', 'ⲽ'),
(0x2CBD, 'V'),
(0x2CBE, 'M', 'ⲿ'),
(0x2CBF, 'V'),
(0x2CC0, 'M', 'ⳁ'),
(0x2CC1, 'V'),
(0x2CC2, 'M', 'ⳃ'),
] | null |
1,531 | from typing import List, Tuple, Union
def _seg_26() -> List[Union[Tuple[int, str], Tuple[int, str, str]]]:
return [
(0x2CC3, 'V'),
(0x2CC4, 'M', 'ⳅ'),
(0x2CC5, 'V'),
(0x2CC6, 'M', 'ⳇ'),
(0x2CC7, 'V'),
(0x2CC8, 'M', 'ⳉ'),
(0x2CC9, 'V'),
(0x2CCA, 'M', 'ⳋ'),
(0x2CCB, 'V'),
(0x2CCC, 'M', 'ⳍ'),
(0x2CCD, 'V'),
(0x2CCE, 'M', 'ⳏ'),
(0x2CCF, 'V'),
(0x2CD0, 'M', 'ⳑ'),
(0x2CD1, 'V'),
(0x2CD2, 'M', 'ⳓ'),
(0x2CD3, 'V'),
(0x2CD4, 'M', 'ⳕ'),
(0x2CD5, 'V'),
(0x2CD6, 'M', 'ⳗ'),
(0x2CD7, 'V'),
(0x2CD8, 'M', 'ⳙ'),
(0x2CD9, 'V'),
(0x2CDA, 'M', 'ⳛ'),
(0x2CDB, 'V'),
(0x2CDC, 'M', 'ⳝ'),
(0x2CDD, 'V'),
(0x2CDE, 'M', 'ⳟ'),
(0x2CDF, 'V'),
(0x2CE0, 'M', 'ⳡ'),
(0x2CE1, 'V'),
(0x2CE2, 'M', 'ⳣ'),
(0x2CE3, 'V'),
(0x2CEB, 'M', 'ⳬ'),
(0x2CEC, 'V'),
(0x2CED, 'M', 'ⳮ'),
(0x2CEE, 'V'),
(0x2CF2, 'M', 'ⳳ'),
(0x2CF3, 'V'),
(0x2CF4, 'X'),
(0x2CF9, 'V'),
(0x2D26, 'X'),
(0x2D27, 'V'),
(0x2D28, 'X'),
(0x2D2D, 'V'),
(0x2D2E, 'X'),
(0x2D30, 'V'),
(0x2D68, 'X'),
(0x2D6F, 'M', 'ⵡ'),
(0x2D70, 'V'),
(0x2D71, 'X'),
(0x2D7F, 'V'),
(0x2D97, 'X'),
(0x2DA0, 'V'),
(0x2DA7, 'X'),
(0x2DA8, 'V'),
(0x2DAF, 'X'),
(0x2DB0, 'V'),
(0x2DB7, 'X'),
(0x2DB8, 'V'),
(0x2DBF, 'X'),
(0x2DC0, 'V'),
(0x2DC7, 'X'),
(0x2DC8, 'V'),
(0x2DCF, 'X'),
(0x2DD0, 'V'),
(0x2DD7, 'X'),
(0x2DD8, 'V'),
(0x2DDF, 'X'),
(0x2DE0, 'V'),
(0x2E5E, 'X'),
(0x2E80, 'V'),
(0x2E9A, 'X'),
(0x2E9B, 'V'),
(0x2E9F, 'M', '母'),
(0x2EA0, 'V'),
(0x2EF3, 'M', '龟'),
(0x2EF4, 'X'),
(0x2F00, 'M', '一'),
(0x2F01, 'M', '丨'),
(0x2F02, 'M', '丶'),
(0x2F03, 'M', '丿'),
(0x2F04, 'M', '乙'),
(0x2F05, 'M', '亅'),
(0x2F06, 'M', '二'),
(0x2F07, 'M', '亠'),
(0x2F08, 'M', '人'),
(0x2F09, 'M', '儿'),
(0x2F0A, 'M', '入'),
(0x2F0B, 'M', '八'),
(0x2F0C, 'M', '冂'),
(0x2F0D, 'M', '冖'),
(0x2F0E, 'M', '冫'),
(0x2F0F, 'M', '几'),
(0x2F10, 'M', '凵'),
(0x2F11, 'M', '刀'),
(0x2F12, 'M', '力'),
(0x2F13, 'M', '勹'),
(0x2F14, 'M', '匕'),
(0x2F15, 'M', '匚'),
] | null |
Subsets and Splits