function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def context(self) -> metadata_context.MetadataContext:
"""Returns metadata context for the experiment."""
return metadata_context.MetadataContext(
creator=getpass.getuser(),
annotations=metadata_context.ContextAnnotations()) | deepmind/xmanager | [
669,
33,
669,
13,
1619456631
] |
def create_experiment(experiment_title: Optional[str] = None) -> Experiment:
"""Returns a concrete Experiment instance."""
raise NotImplementedError | deepmind/xmanager | [
669,
33,
669,
13,
1619456631
] |
def sort_by_system_instance_health(instances):
return sorted(
instances,
key=lambda i: (
i.instance_status["SystemStatus"]["Status"] != "ok"
or i.instance_status["InstanceStatus"]["Status"] != "ok"
),
) | Yelp/paasta | [
1644,
229,
1644,
129,
1445895353
] |
def sort_by_total_tasks(instances):
return sorted(instances, key=lambda i: i.task_counts.count, reverse=True) | Yelp/paasta | [
1644,
229,
1644,
129,
1445895353
] |
def _normalize_path(filename):
"""Normalizes a relative path to a command to spawn.
Args:
filename: String; relative or absolute path.
Returns:
The normalized path. This is necessary because in our use case,
vexflow_generator_pipeline will live in a different directory from
vexflow_generator, an... | tensorflow/moonlight | [
311,
68,
311,
25,
1523981102
] |
def __init__(self, num_pages_per_batch, vexflow_generator_command,
svg_to_png_command):
self.num_pages_per_batch = num_pages_per_batch
self.vexflow_generator_command = vexflow_generator_command
self.svg_to_png_command = svg_to_png_command | tensorflow/moonlight | [
311,
68,
311,
25,
1523981102
] |
def get_pages_for_batch(self, batch_num, num_pages_per_batch):
"""Generates the music score pages in a single batch.
The generator takes in a seed for the RNG for each page, and outputs all
pages at once. The seeds for all batches are consecutive for determinism,
starting from 0, but each seed to the M... | tensorflow/moonlight | [
311,
68,
311,
25,
1523981102
] |
def _svg_to_png(self, svg):
svg_to_png_command = list(self.svg_to_png_command)
svg_to_png_command[0] = _normalize_path(svg_to_png_command[0])
popen = subprocess.Popen(
svg_to_png_command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stder... | tensorflow/moonlight | [
311,
68,
311,
25,
1523981102
] |
def __init__(self,
negative_example_distance,
patch_width,
negative_to_positive_example_ratio,
noise_fn=lambda x: x):
self.negative_example_distance = negative_example_distance
self.patch_width = patch_width
self.negative_to_positive_example_ratio ... | tensorflow/moonlight | [
311,
68,
311,
25,
1523981102
] |
def process(self, item):
png_contents, staff_message = item
staff_message = musicscore_pb2.Staff.FromString(staff_message)
with tf.Session(graph=self.omr.graph) as sess:
# Load the image, then feed it in to apply noise.
# Randomly rotate the image and apply noise, then dump it back out as a
... | tensorflow/moonlight | [
311,
68,
311,
25,
1523981102
] |
def __init__(
self,
code: LiquidityPoolWithdrawResultCode, | StellarCN/py-stellar-base | [
328,
158,
328,
6,
1443187561
] |
def pack(self, packer: Packer) -> None:
self.code.pack(packer)
if self.code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_SUCCESS:
return | StellarCN/py-stellar-base | [
328,
158,
328,
6,
1443187561
] |
def unpack(cls, unpacker: Unpacker) -> "LiquidityPoolWithdrawResult":
code = LiquidityPoolWithdrawResultCode.unpack(unpacker)
if code == LiquidityPoolWithdrawResultCode.LIQUIDITY_POOL_WITHDRAW_SUCCESS:
return cls(code=code)
return cls(code=code) | StellarCN/py-stellar-base | [
328,
158,
328,
6,
1443187561
] |
def from_xdr_bytes(cls, xdr: bytes) -> "LiquidityPoolWithdrawResult":
unpacker = Unpacker(xdr)
return cls.unpack(unpacker) | StellarCN/py-stellar-base | [
328,
158,
328,
6,
1443187561
] |
def from_xdr(cls, xdr: str) -> "LiquidityPoolWithdrawResult":
xdr_bytes = base64.b64decode(xdr.encode())
return cls.from_xdr_bytes(xdr_bytes) | StellarCN/py-stellar-base | [
328,
158,
328,
6,
1443187561
] |
def get_model_evaluation_text_classification_sample(
project: str,
model_id: str,
evaluation_id: str,
location: str = "us-central1",
api_endpoint: str = "us-central1-aiplatform.googleapis.com", | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def forwards(self, orm):
# Adding model 'Cloud'
db.create_table(u'cloudslave_cloud', (
('name', self.gf('django.db.models.fields.CharField')(max_length=200, primary_key=True)),
('endpoint', self.gf('django.db.models.fields.URLField')(max_length=200)),
('user_name', se... | sorenh/python-django-cloudslave | [
2,
3,
2,
1,
1371802788
] |
def index_json(request):
queryParams = request.GET.copy()
queryParams.update(request.POST)
try:
jsonp = queryParams.get('jsonp', False)
requestContext = {
'localOnly': int( queryParams.get('local', 0) ),
'forwardHeaders': extractForwardHeaders(request),
}
matches = STORE.get_index(r... | criteo-forks/graphite-web | [
1,
4,
1,
2,
1372665938
] |
def find_view(request):
"View for finding metrics matching a given pattern"
queryParams = request.GET.copy()
queryParams.update(request.POST)
format = queryParams.get('format', 'treejson')
leaves_only = queryParamAsInt(queryParams, 'leavesOnly', 0)
local_only = queryParamAsInt(queryParams, 'local', 0)
w... | criteo-forks/graphite-web | [
1,
4,
1,
2,
1372665938
] |
def get_metadata_view(request):
queryParams = request.GET.copy()
queryParams.update(request.POST)
key = queryParams.get('key')
metrics = queryParams.getlist('metric')
jsonp = queryParams.get('jsonp', False)
results = {}
for metric in metrics:
try:
results[metric] = CarbonLink.get_metadata(metri... | criteo-forks/graphite-web | [
1,
4,
1,
2,
1372665938
] |
def tree_json(nodes, base_path, wildcards=False):
results = []
branchNode = {
'allowChildren': 1,
'expandable': 1,
'leaf': 0,
}
leafNode = {
'allowChildren': 0,
'expandable': 0,
'leaf': 1,
}
#Add a wildcard node if appropriate
if len(nodes) > 1 and wildcards:
wildcardNode = {... | criteo-forks/graphite-web | [
1,
4,
1,
2,
1372665938
] |
def pickle_nodes(nodes):
nodes_info = []
for node in nodes:
info = dict(path=node.path, is_leaf=node.is_leaf)
if node.is_leaf:
info['intervals'] = node.intervals
nodes_info.append(info)
return pickle.dumps(nodes_info, protocol=-1) | criteo-forks/graphite-web | [
1,
4,
1,
2,
1372665938
] |
def json_nodes(nodes):
nodes_info = []
for node in nodes:
info = dict(path=node.path, is_leaf=node.is_leaf)
if node.is_leaf:
info['intervals'] = [{'start': i.start, 'end': i.end} for i in node.intervals]
nodes_info.append(info)
return sorted(nodes_info, key=lambda item: item['path']) | criteo-forks/graphite-web | [
1,
4,
1,
2,
1372665938
] |
def _update_user_info(self):
self.user_info[self.construct_key(FLOATING_IPS_KEY)] = \
util.str2bool(self.user_info.get_cloud(FLOATING_IPS_KEY, 'false')) | slipstream/SlipStreamConnectors | [
3,
2,
3,
6,
1409573258
] |
def tearDown(self):
os.environ.pop('SLIPSTREAM_CONNECTOR_INSTANCE')
os.environ.pop('SLIPSTREAM_BOOTSTRAP_BIN')
self.client = None
self.ch = None | slipstream/SlipStreamConnectors | [
3,
2,
3,
6,
1409573258
] |
def xtest_2_buildImage(self):
self.client.run_category = RUN_CATEGORY_IMAGE
self.client.start_nodes_and_clients(self.user_info, {NodeDecorator.MACHINE_NAME: self.node_instance})
instances_details = self.client.get_vms_details()
assert instances_details
assert instances_details[... | slipstream/SlipStreamConnectors | [
3,
2,
3,
6,
1409573258
] |
def xtest_4_start_image_with_extra_disk(self):
self.client.run_category = RUN_CATEGORY_IMAGE
self.client.start_nodes_and_clients(self.user_info,
{NodeDecorator.MACHINE_NAME: self.node_instance_with_additional_disk})
vm_id = self.client.get_vms()[Node... | slipstream/SlipStreamConnectors | [
3,
2,
3,
6,
1409573258
] |
def compress(directory: str, destination: str) -> subprocess.CompletedProcess:
"""Compress the given directory into the tarfile at destination."""
# Note: we don't use the stdlib's "tarfile" module for performance reasons.
# While it can handle creating tarfiles, its not as efficient on large
# numbers ... | googleapis/docuploader | [
8,
8,
8,
11,
1551827709
] |
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def add_role_definition_with_http_info(self, body=None, created_by=None, **kwargs): # noqa: E501
"""Add a new role definition) # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> ... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def add_user_roles_with_http_info(self, body=None, created_by=None, **kwargs): # noqa: E501
"""Add a new user with roles (to make api requests) # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def get_current_user_permissions_with_http_info(self, **kwargs): # noqa: E501
"""List user permissions # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_current... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def get_current_user_subject_with_http_info(self, **kwargs): # noqa: E501
"""Get user information # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_current_user... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def get_role_definition_with_http_info(self, role=None, **kwargs): # noqa: E501
"""Get role definition # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_role_de... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def get_user_roles_with_http_info(self, username=None, **kwargs): # noqa: E501
"""Get roles associated to a user # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.g... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def invalidate_user_with_http_info(self, username=None, created_by=None, **kwargs): # noqa: E501
"""Invalidate an existing user # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>>... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def update_role_definition_with_http_info(self, body=None, created_by=None, **kwargs): # noqa: E501
"""Update a new role definition) # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def update_user_password_with_http_info(self, username=None, body=None, created_by=None, **kwargs): # noqa: E501
"""Update a user password # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
... | killbill/killbill-client-python | [
10,
16,
10,
2,
1339972407
] |
def parse_record(parent_field, record):
field_names = []
field_values = []
for name in record:
if isinstance(record[name], dict):
new_parent_field = parent_field.copy()
new_parent_field.append(name)
names = " ".join(new_parent_field)
if "converted" in ... | aerospike/aerospike-admin | [
37,
20,
37,
9,
1409778886
] |
def get_separate_output(in_str=""):
_regex = re.compile(r"((?<=^{).*?(?=^}))", re.MULTILINE | re.DOTALL)
out = re.findall(_regex, in_str)
ls = []
for item in out:
item = remove_escape_sequence(item)
item = "{" + item + "}"
ls.append(json.loads(item))
return ls | aerospike/aerospike-admin | [
37,
20,
37,
9,
1409778886
] |
def get_merged_header(*lines):
h = [[_f for _f in _h.split(" ") if _f] for _h in lines]
header = []
if len(h) == 0 or any(len(h[i]) != len(h[i + 1]) for i in range(len(h) - 1)):
return header
for idx in range(len(h[0])):
header_i = h[0][idx]
for jdx in range(len(h) - 1):
... | aerospike/aerospike-admin | [
37,
20,
37,
9,
1409778886
] |
def check_for_subset_in_list_of_lists(actual_list, list_of_expected_sub_lists):
for expected_list in list_of_expected_sub_lists:
if check_for_subset(actual_list, expected_list):
return True
return False | aerospike/aerospike-admin | [
37,
20,
37,
9,
1409778886
] |
def setUp(self):
super(CorruptTest, self).setUp()
self.signal_lt = lt.select(self.input_lt, {'mask': util.slice_1(False)})
rc = lt.ReshapeCoder(['z', 'channel', 'mask'], ['channel'])
self.corrupt_coded_lt = augment.corrupt(0.1, 0.05, 0.1,
rc.encode(self.signa... | google/in-silico-labeling | [
248,
83,
248,
4,
1513032868
] |
def test(self):
self.assertEqual(self.corrupt_lt.axes, self.signal_lt.axes)
self.save_images('corrupt', [self.get_images('', self.corrupt_lt)])
self.assert_images_near('corrupt', True) | google/in-silico-labeling | [
248,
83,
248,
4,
1513032868
] |
def setUp(self):
super(AugmentTest, self).setUp()
ap = augment.AugmentParameters(0.1, 0.05, 0.1)
self.input_augment_lt, self.target_augment_lt = augment.augment(
ap, self.input_lt, self.target_lt) | google/in-silico-labeling | [
248,
83,
248,
4,
1513032868
] |
def test(self):
self.assertEqual(self.input_augment_lt.axes, self.input_lt.axes)
self.assertEqual(self.target_augment_lt.axes, self.target_lt.axes)
self.save_images('augment', [
self.get_images('input_', self.input_augment_lt),
self.get_images('target_', self.target_augment_lt)
])
s... | google/in-silico-labeling | [
248,
83,
248,
4,
1513032868
] |
def load_data():
"""Loads the data files needed for the module.
Could be used by processes that care about controlling when the data is
loaded. Otherwise, data will be loaded the first time it's needed.
"""
global _data_is_loaded
if not _data_is_loaded:
_load_property_value_aliases_txt... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _char_to_int(char):
"""Converts a potential character to its scalar value."""
if type(char) in [str, type(u"")]:
return ord(char)
else:
return char | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def chars_with_property(propname):
load_data()
return frozenset(_core_properties_data[propname]) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def combining(char):
"""Returns the canonical combining class of a character."""
load_data()
char = _char_to_int(char)
try:
return _combining_class_data[char]
except KeyError:
return 0 | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def canonical_decomposition(char):
"""Returns the canonical decomposition of a character as a Unicode string."""
load_data()
char = _char_to_int(char)
try:
return _decomposition_data[char]
except KeyError:
return u"" | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def script_extensions(char):
"""Returns the script extensions property of a character.
The return value is a frozenset of four-letter script codes.
"""
load_data()
char = _char_to_int(char)
try:
return _script_extensions_data[char]
except KeyError:
return frozenset([script(c... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def block_range(block):
"""Returns a range (first, last) of the named block."""
load_data()
return _block_range[block] | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def block_names():
"""Returns the names of the blocks in block order."""
load_data()
return _block_names[:] | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_default_ignorable(char):
"""Returns true if the character has the Default_Ignorable property."""
load_data()
if isinstance(char, (str, unicode)):
char = ord(char)
return char in _core_properties_data["Default_Ignorable_Code_Point"] | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_defined(char):
"""Returns true if the character is defined in the Unicode Standard."""
load_data()
if isinstance(char, (str, unicode)):
char = ord(char)
return char in _defined_characters | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def mirrored(char):
"""Returns 1 if the characters is bidi mirroring, 0 otherwise."""
load_data()
if isinstance(char, (str, unicode)):
char = ord(char)
return int(char in _bidi_mirroring_characters) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def mirrored_chars():
return frozenset(_bidi_mirroring_glyph_data.keys()) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def indic_syllabic_category(char):
"""Returns the Indic syllabic category of a character."""
load_data()
if isinstance(char, (str, unicode)):
char = ord(char)
try:
return _bidi_syllabic_data[char]
except KeyError:
return "Other" | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def defined_characters(version=None, scr=None):
"""Returns the set of all defined characters in the Unicode Standard."""
load_data()
# handle common error where version is passed as string, the age test
# will always pass
if version is not None:
version = float(version)
try:
retu... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _folded_script_name(script_name):
"""Folds a script name to its bare bones for comparison."""
# string.translate is changed by codecs, the method no longer takes two
# parameters and so script_name.translate(None, "'-_ ") fails to compile
return _strip_re.sub("", script_name).lower() | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def human_readable_script_name(code):
"""Returns a human-readable name for the script code."""
try:
return _HARD_CODED_HUMAN_READABLE_SCRIPT_NAMES[code]
except KeyError:
load_data()
return _script_code_to_long_name[code] | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def open_unicode_data_file(data_file_name):
"""Opens a Unicode data file.
Args:
data_file_name: A string containing the filename of the data file.
Returns:
A file handle to the data file.
"""
filename = path.join(_DATA_DIR_PATH, data_file_name)
return codecs.open(filename, "r", "ut... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _parse_semicolon_separated_data(input_data):
"""Reads semicolon-separated Unicode data from an input string.
Reads a Unicode data file already imported into a string. The format is
the Unicode data file format with a list of values separated by
semicolons. The number of the values on different line... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_scripts_txt():
"""Load script property from Scripts.txt."""
with open_unicode_data_file("Scripts.txt") as scripts_txt:
script_ranges = _parse_code_ranges(scripts_txt.read())
for first, last, script_name in script_ranges:
folded_script_name = _folded_script_name(script_name)
... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_blocks_txt():
"""Load block name from Blocks.txt."""
with open_unicode_data_file("Blocks.txt") as blocks_txt:
block_ranges = _parse_code_ranges(blocks_txt.read())
for first, last, block_name in block_ranges:
_block_names.append(block_name)
_block_range[block_name] = (first... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_derived_core_properties_txt():
"""Load derived core properties from Blocks.txt."""
with open_unicode_data_file("DerivedCoreProperties.txt") as dcp_txt:
dcp_ranges = _parse_code_ranges(dcp_txt.read())
for first, last, property_name in dcp_ranges:
for character_code in range(first, ... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_bidi_mirroring_txt():
"""Load bidi mirroring glyphs from BidiMirroring.txt."""
with open_unicode_data_file("BidiMirroring.txt") as bidi_mirroring_txt:
bmg_pairs = _parse_semicolon_separated_data(bidi_mirroring_txt.read())
for char, bmg in bmg_pairs:
char = int(char, 16)
b... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_emoji_data():
"""Parse the new draft format of emoji-data.txt"""
global _presentation_default_emoji, _presentation_default_text
global _emoji, _emoji_modifier_base
if _presentation_default_emoji:
return
emoji_sets = {
"Emoji": set(),
"Emoji_Presentation": set(),
... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _read_emoji_data(lines):
"""Parse lines of emoji data and return a map from sequence to tuples of
name, age, type."""
line_re = re.compile(
r"(?:([0-9A-F ]+)|([0-9A-F]+\.\.[0-9A-F]+)\s*);\s*(%s)\s*;\s*([^#]*)\s*#\s*E?(\d+\.\d+).*"
% "|".join(EMOJI_SEQUENCE_TYPES)
)
result = {}
... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _read_emoji_test_data(data_string):
"""Parse the emoji-test.txt data. This has names of proposed emoji that are
not yet in the full Unicode data file. Returns a list of tuples of
sequence, group, subgroup, name.
The data is a string."""
line_re = re.compile(
r"([0-9a-fA-F ]+)\s*;\s*(%... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _get_order_patch(order_text, seq_to_name):
"""Create a mapping from a key sequence to a list of sequence, name tuples.
This will be used to insert additional sequences after the key sequence
in the order data. seq_to_name is a mapping from new sequence to name,
so the names don't have to be duplica... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _apply_order_patch(patch, group_list):
"""patch is a map from a key sequence to list of sequence, name pairs, and
group_list is an ordered list of sequence, group, subgroup, name tuples.
Iterate through the group list appending each item to a new list, and
after appending an item matching a key sequ... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_emoji_group_data(seq):
"""Return group data for the canonical sequence seq, or None.
Group data is a tuple of index, group, subgroup, and name. The
index is a unique global sort index for the sequence among all
sequences in the group data."""
_load_emoji_group_data()
return _emoji_group... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_emoji_subgroups(group):
"""Return the subgroups of this group, in order, or None
if the group is not recognized."""
_load_emoji_group_data()
subgroups = []
subgroup = None
for _, g, sg, _ in sorted(_emoji_group_data.values()):
if g == group:
if sg != subgroup:
... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_sorted_emoji_sequences(seqs):
"""Seqs is a collection of canonical emoji sequences. Returns a list of
these sequences in the canonical emoji group order. Sequences that are not
canonical are placed at the end, in unicode code point order.
"""
_load_emoji_group_data()
return sorted(seqs... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def add_data(data):
for k, t in data.items():
if k in _emoji_sequence_data:
print("already have data for sequence:", seq_to_string(k), t)
_emoji_sequence_data[k] = t
if EMOJI_VS in k:
_emoji_non_vs_to_canonical[strip_emoji_vs(k)] = k | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_emoji_sequences(age=None, types=None):
"""Return the set of canonical emoji sequences, filtering to those <= age
if age is not None, and those with type in types (if not a string) or
type == types (if type is a string) if types is not None. By default
all sequences are returned, including those... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_emoji_sequence_name(seq):
"""Return the name of the (possibly non-canonical) sequence, or None if
not recognized as a sequence."""
data = get_emoji_sequence_data(seq)
return None if not data else data[0] | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_emoji_sequence_type(seq):
"""Return the type of the (possibly non-canonical) sequence, or None if
not recognized as a sequence. Types are in EMOJI_SEQUENCE_TYPES."""
data = get_emoji_sequence_data(seq)
return None if not data else data[2] | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_canonical_emoji_sequence(seq):
"""Return the canonical version of this emoji sequence if the sequence is
known, or None."""
if is_canonical_emoji_sequence(seq):
return seq
seq = strip_emoji_vs(seq)
return _emoji_non_vs_to_canonical.get(seq, None) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def seq_to_string(seq):
"""Return a string representation of the codepoint sequence."""
return "_".join("%04x" % cp for cp in seq) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_cp_seq(seq):
return all(0 <= n <= 0x10FFFF for n in seq) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_regional_indicator(cp):
return _REGIONAL_INDICATOR_START <= cp <= _REGIONAL_INDICATOR_END | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def regional_indicator_to_ascii(cp):
assert is_regional_indicator(cp)
return chr(cp - _REGIONAL_INDICATOR_START + ord("A")) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def string_to_regional_indicator_seq(s):
assert len(s) == 2
return ascii_to_regional_indicator(s[0]), ascii_to_regional_indicator(s[1]) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_tag(cp):
return 0xE0020 < cp < 0xE0080 or cp == 0xE0001 | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_regional_tag_seq(seq):
return (
seq[0] == 0x1F3F4
and seq[-1] == 0xE007F
and all(0xE0020 < cp < 0xE007E for cp in seq[1:-1])
) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_skintone_modifier(cp):
return _FITZ_START <= cp <= _FITZ_END | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_presentation_default_text():
_load_emoji_data()
return _presentation_default_text | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def is_emoji(cp):
_load_emoji_data()
return cp in _emoji | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_unicode_emoji_variants():
"""Parse StandardizedVariants.txt and initialize a set of characters
that have a defined emoji variant presentation. All such characters
also have a text variant presentation so a single set works for both."""
global _emoji_variants, _emoji_variants_proposed
if ... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_variant_data():
"""Parse StandardizedVariants.txt and initialize all non-emoji variant
data. The data is a mapping from codepoint to a list of tuples of:
- variant selector
- compatibility character (-1 if there is none)
- shaping context (bitmask, 1 2 4 8 for isolate initial medial final... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def get_variant_data(cp):
_load_variant_data()
return _variant_data[cp][:] if cp in _variant_data else None | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _load_proposed_emoji_data():
"""Parse proposed-emoji.txt if it exists to get cps/names of proposed emoji
(but not approved) for this version of Unicode."""
global _proposed_emoji_data, _proposed_emoji_data_cps
if _proposed_emoji_data:
return
_proposed_emoji_data = {}
line_re = re.c... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def proposed_emoji_cps():
_load_proposed_emoji_data()
return _proposed_emoji_data_cps | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def read_codeset(text):
line_re = re.compile(r"^0x([0-9a-fA-F]{2,6})\s+0x([0-9a-fA-F]{4,6})\s+.*")
codeset = set()
for line in text.splitlines():
m = line_re.match(line)
if m:
cp = int(m.group(2), 16)
codeset.add(cp)
return codeset | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def _dump_emoji_presentation():
"""Dump presentation info, for testing."""
text_p = 0
emoji_p = 0
for cp in sorted(get_emoji()):
cp_name = name(cp, "<error>")
if cp in get_presentation_default_emoji():
presentation = "emoji"
emoji_p += 1
elif cp in get_pr... | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def see_also(cp):
_load_nameslist_data()
return frozenset(_nameslist_see_also.get(cp)) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
def alt_names(cp):
"""Return list of name, nametype tuples for cp, or None."""
_load_namealiases_data()
return tuple(_namealiases_alt_names.get(cp)) | googlefonts/nototools | [
247,
96,
247,
108,
1433465447
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.