id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
246,900 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _prune_traverse_using_omitted_locations | def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations,
complex_optional_roots, location_to_optional_roots):
"""Return a prefix of the given traverse, excluding any blocks after an omitted optional.
Given a subset (omitted_locations) of comple... | python | def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations,
complex_optional_roots, location_to_optional_roots):
new_match_traversal = []
for step in match_traversal:
new_step = step
if isinstance(step.root_block, Traverse) and step... | [
"def",
"_prune_traverse_using_omitted_locations",
"(",
"match_traversal",
",",
"omitted_locations",
",",
"complex_optional_roots",
",",
"location_to_optional_roots",
")",
":",
"new_match_traversal",
"=",
"[",
"]",
"for",
"step",
"in",
"match_traversal",
":",
"new_step",
"... | Return a prefix of the given traverse, excluding any blocks after an omitted optional.
Given a subset (omitted_locations) of complex_optional_roots, return a new match traversal
removing all MatchStep objects that are within any omitted location.
Args:
match_traversal: list of MatchStep objects to... | [
"Return",
"a",
"prefix",
"of",
"the",
"given",
"traverse",
"excluding",
"any",
"blocks",
"after",
"an",
"omitted",
"optional",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L18-L82 |
246,901 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | convert_optional_traversals_to_compound_match_query | def convert_optional_traversals_to_compound_match_query(
match_query, complex_optional_roots, location_to_optional_roots):
"""Return 2^n distinct MatchQuery objects in a CompoundMatchQuery.
Given a MatchQuery containing `n` optional traverses that expand vertex fields,
construct `2^n` different Mat... | python | def convert_optional_traversals_to_compound_match_query(
match_query, complex_optional_roots, location_to_optional_roots):
tree = construct_optional_traversal_tree(
complex_optional_roots, location_to_optional_roots)
rooted_optional_root_location_subsets = tree.get_all_rooted_subtrees_as_lists()... | [
"def",
"convert_optional_traversals_to_compound_match_query",
"(",
"match_query",
",",
"complex_optional_roots",
",",
"location_to_optional_roots",
")",
":",
"tree",
"=",
"construct_optional_traversal_tree",
"(",
"complex_optional_roots",
",",
"location_to_optional_roots",
")",
"... | Return 2^n distinct MatchQuery objects in a CompoundMatchQuery.
Given a MatchQuery containing `n` optional traverses that expand vertex fields,
construct `2^n` different MatchQuery objects:
one for each possible subset of optional edges that can be followed.
For each edge `e` in a subset of optional ed... | [
"Return",
"2^n",
"distinct",
"MatchQuery",
"objects",
"in",
"a",
"CompoundMatchQuery",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L85-L151 |
246,902 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _get_present_locations | def _get_present_locations(match_traversals):
"""Return the set of locations and non-optional locations present in the given match traversals.
When enumerating the possibilities for optional traversals,
the resulting match traversals may have sections of the query omitted.
These locations will not be i... | python | def _get_present_locations(match_traversals):
present_locations = set()
present_non_optional_locations = set()
for match_traversal in match_traversals:
for step in match_traversal:
if step.as_block is not None:
location_name, _ = step.as_block.location.get_location_name(... | [
"def",
"_get_present_locations",
"(",
"match_traversals",
")",
":",
"present_locations",
"=",
"set",
"(",
")",
"present_non_optional_locations",
"=",
"set",
"(",
")",
"for",
"match_traversal",
"in",
"match_traversals",
":",
"for",
"step",
"in",
"match_traversal",
":... | Return the set of locations and non-optional locations present in the given match traversals.
When enumerating the possibilities for optional traversals,
the resulting match traversals may have sections of the query omitted.
These locations will not be included in the returned `present_locations`.
All ... | [
"Return",
"the",
"set",
"of",
"locations",
"and",
"non",
"-",
"optional",
"locations",
"present",
"in",
"the",
"given",
"match",
"traversals",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L154-L190 |
246,903 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | prune_non_existent_outputs | def prune_non_existent_outputs(compound_match_query):
"""Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery.
Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks,
For each of these, remove the outputs (that have been implicitly pruned... | python | def prune_non_existent_outputs(compound_match_query):
if len(compound_match_query.match_queries) == 1:
return compound_match_query
elif len(compound_match_query.match_queries) == 0:
raise AssertionError(u'Received CompoundMatchQuery with '
u'an empty list of MatchQue... | [
"def",
"prune_non_existent_outputs",
"(",
"compound_match_query",
")",
":",
"if",
"len",
"(",
"compound_match_query",
".",
"match_queries",
")",
"==",
"1",
":",
"return",
"compound_match_query",
"elif",
"len",
"(",
"compound_match_query",
".",
"match_queries",
")",
... | Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery.
Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks,
For each of these, remove the outputs (that have been implicitly pruned away) from each
corresponding ConstructResult block.
... | [
"Remove",
"non",
"-",
"existent",
"outputs",
"from",
"each",
"MatchQuery",
"in",
"the",
"given",
"CompoundMatchQuery",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L193-L266 |
246,904 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _construct_location_to_filter_list | def _construct_location_to_filter_list(match_query):
"""Return a dict mapping location -> list of filters applied at that location.
Args:
match_query: MatchQuery object from which to extract location -> filters dict
Returns:
dict mapping each location in match_query to a list of
... | python | def _construct_location_to_filter_list(match_query):
# For each location, all filters for that location should be applied at the first instance.
# This function collects a list of all filters corresponding to each location
# present in the given MatchQuery.
location_to_filters = {}
for match_travers... | [
"def",
"_construct_location_to_filter_list",
"(",
"match_query",
")",
":",
"# For each location, all filters for that location should be applied at the first instance.",
"# This function collects a list of all filters corresponding to each location",
"# present in the given MatchQuery.",
"location... | Return a dict mapping location -> list of filters applied at that location.
Args:
match_query: MatchQuery object from which to extract location -> filters dict
Returns:
dict mapping each location in match_query to a list of
Filter objects applied at that location | [
"Return",
"a",
"dict",
"mapping",
"location",
"-",
">",
"list",
"of",
"filters",
"applied",
"at",
"that",
"location",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L269-L291 |
246,905 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _filter_list_to_conjunction_expression | def _filter_list_to_conjunction_expression(filter_list):
"""Convert a list of filters to an Expression that is the conjunction of all of them."""
if not isinstance(filter_list, list):
raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list))
if any((not isinstance(filter_block, Fil... | python | def _filter_list_to_conjunction_expression(filter_list):
if not isinstance(filter_list, list):
raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list))
if any((not isinstance(filter_block, Filter) for filter_block in filter_list)):
raise AssertionError(u'Expected list of Filte... | [
"def",
"_filter_list_to_conjunction_expression",
"(",
"filter_list",
")",
":",
"if",
"not",
"isinstance",
"(",
"filter_list",
",",
"list",
")",
":",
"raise",
"AssertionError",
"(",
"u'Expected `list`, Received: {}.'",
".",
"format",
"(",
"filter_list",
")",
")",
"if... | Convert a list of filters to an Expression that is the conjunction of all of them. | [
"Convert",
"a",
"list",
"of",
"filters",
"to",
"an",
"Expression",
"that",
"is",
"the",
"conjunction",
"of",
"all",
"of",
"them",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L294-L302 |
246,906 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _apply_filters_to_first_location_occurrence | def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters,
already_filtered_locations):
"""Apply all filters for a specific location into its first occurrence in a given traversal.
For each location in the given match traversal,
con... | python | def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters,
already_filtered_locations):
new_match_traversal = []
newly_filtered_locations = set()
for match_step in match_traversal:
# Apply all filters for a location to the fi... | [
"def",
"_apply_filters_to_first_location_occurrence",
"(",
"match_traversal",
",",
"location_to_filters",
",",
"already_filtered_locations",
")",
":",
"new_match_traversal",
"=",
"[",
"]",
"newly_filtered_locations",
"=",
"set",
"(",
")",
"for",
"match_step",
"in",
"match... | Apply all filters for a specific location into its first occurrence in a given traversal.
For each location in the given match traversal,
construct a conjunction of all filters applied to that location,
and apply the resulting Filter to the first instance of the location.
Args:
match_traversal... | [
"Apply",
"all",
"filters",
"for",
"a",
"specific",
"location",
"into",
"its",
"first",
"occurrence",
"in",
"a",
"given",
"traversal",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L305-L355 |
246,907 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | collect_filters_to_first_location_occurrence | def collect_filters_to_first_location_occurrence(compound_match_query):
"""Collect all filters for a particular location to the first instance of the location.
Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may
result in filters being applied to locations after their ... | python | def collect_filters_to_first_location_occurrence(compound_match_query):
new_match_queries = []
# Each MatchQuery has a different set of locations, and associated Filters.
# Hence, each of them is processed independently.
for match_query in compound_match_query.match_queries:
# Construct mapping ... | [
"def",
"collect_filters_to_first_location_occurrence",
"(",
"compound_match_query",
")",
":",
"new_match_queries",
"=",
"[",
"]",
"# Each MatchQuery has a different set of locations, and associated Filters.",
"# Hence, each of them is processed independently.",
"for",
"match_query",
"in"... | Collect all filters for a particular location to the first instance of the location.
Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may
result in filters being applied to locations after their first occurence.
OrientDB does not resolve this behavior correctly. Therefo... | [
"Collect",
"all",
"filters",
"for",
"a",
"particular",
"location",
"to",
"the",
"first",
"instance",
"of",
"the",
"location",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L358-L402 |
246,908 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _update_context_field_binary_composition | def _update_context_field_binary_composition(present_locations, expression):
"""Lower BinaryCompositions involving non-existent ContextFields to True.
Args:
present_locations: set of all locations in the current MatchQuery that have not been pruned
expression: BinaryComposition with at least on... | python | def _update_context_field_binary_composition(present_locations, expression):
if not any((isinstance(expression.left, ContextField),
isinstance(expression.right, ContextField))):
raise AssertionError(u'Received a BinaryComposition {} without any ContextField '
u'o... | [
"def",
"_update_context_field_binary_composition",
"(",
"present_locations",
",",
"expression",
")",
":",
"if",
"not",
"any",
"(",
"(",
"isinstance",
"(",
"expression",
".",
"left",
",",
"ContextField",
")",
",",
"isinstance",
"(",
"expression",
".",
"right",
",... | Lower BinaryCompositions involving non-existent ContextFields to True.
Args:
present_locations: set of all locations in the current MatchQuery that have not been pruned
expression: BinaryComposition with at least one ContextField operand
Returns:
TrueLiteral iff either ContextField ope... | [
"Lower",
"BinaryCompositions",
"involving",
"non",
"-",
"existent",
"ContextFields",
"to",
"True",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L405-L433 |
246,909 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _simplify_non_context_field_binary_composition | def _simplify_non_context_field_binary_composition(expression):
"""Return a simplified BinaryComposition if either operand is a TrueLiteral.
Args:
expression: BinaryComposition without any ContextField operand(s)
Returns:
simplified expression if the given expression is a disjunction/conju... | python | def _simplify_non_context_field_binary_composition(expression):
if any((isinstance(expression.left, ContextField),
isinstance(expression.right, ContextField))):
raise AssertionError(u'Received a BinaryComposition {} with a ContextField '
u'operand. This should never ... | [
"def",
"_simplify_non_context_field_binary_composition",
"(",
"expression",
")",
":",
"if",
"any",
"(",
"(",
"isinstance",
"(",
"expression",
".",
"left",
",",
"ContextField",
")",
",",
"isinstance",
"(",
"expression",
".",
"right",
",",
"ContextField",
")",
")"... | Return a simplified BinaryComposition if either operand is a TrueLiteral.
Args:
expression: BinaryComposition without any ContextField operand(s)
Returns:
simplified expression if the given expression is a disjunction/conjunction
and one of it's operands is a TrueLiteral,
and t... | [
"Return",
"a",
"simplified",
"BinaryComposition",
"if",
"either",
"operand",
"is",
"a",
"TrueLiteral",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L436-L465 |
246,910 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _update_context_field_expression | def _update_context_field_expression(present_locations, expression):
"""Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result."""
no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable)
if isinstance(expression, BinaryComposition):
if isi... | python | def _update_context_field_expression(present_locations, expression):
no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable)
if isinstance(expression, BinaryComposition):
if isinstance(expression.left, ContextField) or isinstance(expression.right, ContextField):
ret... | [
"def",
"_update_context_field_expression",
"(",
"present_locations",
",",
"expression",
")",
":",
"no_op_blocks",
"=",
"(",
"ContextField",
",",
"Literal",
",",
"LocalField",
",",
"UnaryTransformation",
",",
"Variable",
")",
"if",
"isinstance",
"(",
"expression",
",... | Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result. | [
"Lower",
"Expressions",
"involving",
"non",
"-",
"existent",
"ContextFields",
"to",
"TrueLiteral",
"and",
"simplify",
"result",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L484-L508 |
246,911 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | _lower_non_existent_context_field_filters | def _lower_non_existent_context_field_filters(match_traversals, visitor_fn):
"""Return new match traversals, lowering filters involving non-existent ContextFields.
Expressions involving non-existent ContextFields are evaluated to TrueLiteral.
BinaryCompositions, where one of the operands is lowered to a Tr... | python | def _lower_non_existent_context_field_filters(match_traversals, visitor_fn):
new_match_traversals = []
for match_traversal in match_traversals:
new_match_traversal = []
for step in match_traversal:
if step.where_block is not None:
new_filter = step.where_block.visit_a... | [
"def",
"_lower_non_existent_context_field_filters",
"(",
"match_traversals",
",",
"visitor_fn",
")",
":",
"new_match_traversals",
"=",
"[",
"]",
"for",
"match_traversal",
"in",
"match_traversals",
":",
"new_match_traversal",
"=",
"[",
"]",
"for",
"step",
"in",
"match_... | Return new match traversals, lowering filters involving non-existent ContextFields.
Expressions involving non-existent ContextFields are evaluated to TrueLiteral.
BinaryCompositions, where one of the operands is lowered to a TrueLiteral,
are lowered appropriately based on the present operator (u'||' and u'... | [
"Return",
"new",
"match",
"traversals",
"lowering",
"filters",
"involving",
"non",
"-",
"existent",
"ContextFields",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L511-L544 |
246,912 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/optional_traversal.py | lower_context_field_expressions | def lower_context_field_expressions(compound_match_query):
"""Lower Expressons involving non-existent ContextFields."""
if len(compound_match_query.match_queries) == 0:
raise AssertionError(u'Received CompoundMatchQuery {} with no MatchQuery objects.'
.format(compound_match_... | python | def lower_context_field_expressions(compound_match_query):
if len(compound_match_query.match_queries) == 0:
raise AssertionError(u'Received CompoundMatchQuery {} with no MatchQuery objects.'
.format(compound_match_query))
elif len(compound_match_query.match_queries) == 1:
... | [
"def",
"lower_context_field_expressions",
"(",
"compound_match_query",
")",
":",
"if",
"len",
"(",
"compound_match_query",
".",
"match_queries",
")",
"==",
"0",
":",
"raise",
"AssertionError",
"(",
"u'Received CompoundMatchQuery {} with no MatchQuery objects.'",
".",
"forma... | Lower Expressons involving non-existent ContextFields. | [
"Lower",
"Expressons",
"involving",
"non",
"-",
"existent",
"ContextFields",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L547-L574 |
246,913 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | _validate_edges_do_not_have_extra_links | def _validate_edges_do_not_have_extra_links(class_name, properties):
"""Validate that edges do not have properties of Link type that aren't the edge endpoints."""
for property_name, property_descriptor in six.iteritems(properties):
if property_name in {EDGE_SOURCE_PROPERTY_NAME, EDGE_DESTINATION_PROPERT... | python | def _validate_edges_do_not_have_extra_links(class_name, properties):
for property_name, property_descriptor in six.iteritems(properties):
if property_name in {EDGE_SOURCE_PROPERTY_NAME, EDGE_DESTINATION_PROPERTY_NAME}:
continue
if property_descriptor.type_id == PROPERTY_TYPE_LINK_ID:
... | [
"def",
"_validate_edges_do_not_have_extra_links",
"(",
"class_name",
",",
"properties",
")",
":",
"for",
"property_name",
",",
"property_descriptor",
"in",
"six",
".",
"iteritems",
"(",
"properties",
")",
":",
"if",
"property_name",
"in",
"{",
"EDGE_SOURCE_PROPERTY_NA... | Validate that edges do not have properties of Link type that aren't the edge endpoints. | [
"Validate",
"that",
"edges",
"do",
"not",
"have",
"properties",
"of",
"Link",
"type",
"that",
"aren",
"t",
"the",
"edge",
"endpoints",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L44-L53 |
246,914 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | _validate_property_names | def _validate_property_names(class_name, properties):
"""Validate that properties do not have names that may cause problems in the GraphQL schema."""
for property_name in properties:
if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES):
raise IllegalSchemaStateErr... | python | def _validate_property_names(class_name, properties):
for property_name in properties:
if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES):
raise IllegalSchemaStateError(u'Class "{}" has a property with an illegal name: '
u'{... | [
"def",
"_validate_property_names",
"(",
"class_name",
",",
"properties",
")",
":",
"for",
"property_name",
"in",
"properties",
":",
"if",
"not",
"property_name",
"or",
"property_name",
".",
"startswith",
"(",
"ILLEGAL_PROPERTY_NAME_PREFIXES",
")",
":",
"raise",
"Ill... | Validate that properties do not have names that may cause problems in the GraphQL schema. | [
"Validate",
"that",
"properties",
"do",
"not",
"have",
"names",
"that",
"may",
"cause",
"problems",
"in",
"the",
"GraphQL",
"schema",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L56-L61 |
246,915 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | _validate_collections_have_default_values | def _validate_collections_have_default_values(class_name, property_name, property_descriptor):
"""Validate that if the property is of collection type, it has a specified default value."""
# We don't want properties of collection type having "null" values, since that may cause
# unexpected errors during Grap... | python | def _validate_collections_have_default_values(class_name, property_name, property_descriptor):
# We don't want properties of collection type having "null" values, since that may cause
# unexpected errors during GraphQL query execution and other operations.
if property_descriptor.type_id in COLLECTION_PROPER... | [
"def",
"_validate_collections_have_default_values",
"(",
"class_name",
",",
"property_name",
",",
"property_descriptor",
")",
":",
"# We don't want properties of collection type having \"null\" values, since that may cause",
"# unexpected errors during GraphQL query execution and other operati... | Validate that if the property is of collection type, it has a specified default value. | [
"Validate",
"that",
"if",
"the",
"property",
"is",
"of",
"collection",
"type",
"it",
"has",
"a",
"specified",
"default",
"value",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L64-L71 |
246,916 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | get_superclasses_from_class_definition | def get_superclasses_from_class_definition(class_definition):
"""Extract a list of all superclass names from a class definition dict."""
# New-style superclasses definition, supporting multiple-inheritance.
superclasses = class_definition.get('superClasses', None)
if superclasses:
return list(s... | python | def get_superclasses_from_class_definition(class_definition):
# New-style superclasses definition, supporting multiple-inheritance.
superclasses = class_definition.get('superClasses', None)
if superclasses:
return list(superclasses)
# Old-style superclass definition, single inheritance only.
... | [
"def",
"get_superclasses_from_class_definition",
"(",
"class_definition",
")",
":",
"# New-style superclasses definition, supporting multiple-inheritance.",
"superclasses",
"=",
"class_definition",
".",
"get",
"(",
"'superClasses'",
",",
"None",
")",
"if",
"superclasses",
":",
... | Extract a list of all superclass names from a class definition dict. | [
"Extract",
"a",
"list",
"of",
"all",
"superclass",
"names",
"from",
"a",
"class",
"definition",
"dict",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L74-L88 |
246,917 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaElement.freeze | def freeze(self):
"""Make the SchemaElement's connections immutable."""
self.in_connections = frozenset(self.in_connections)
self.out_connections = frozenset(self.out_connections) | python | def freeze(self):
self.in_connections = frozenset(self.in_connections)
self.out_connections = frozenset(self.out_connections) | [
"def",
"freeze",
"(",
"self",
")",
":",
"self",
".",
"in_connections",
"=",
"frozenset",
"(",
"self",
".",
"in_connections",
")",
"self",
".",
"out_connections",
"=",
"frozenset",
"(",
"self",
".",
"out_connections",
")"
] | Make the SchemaElement's connections immutable. | [
"Make",
"the",
"SchemaElement",
"s",
"connections",
"immutable",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L180-L183 |
246,918 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph.get_default_property_values | def get_default_property_values(self, classname):
"""Return a dict with default values for all properties declared on this class."""
schema_element = self.get_element_by_class_name(classname)
result = {
property_name: property_descriptor.default
for property_name, proper... | python | def get_default_property_values(self, classname):
schema_element = self.get_element_by_class_name(classname)
result = {
property_name: property_descriptor.default
for property_name, property_descriptor in six.iteritems(schema_element.properties)
}
if schema_elem... | [
"def",
"get_default_property_values",
"(",
"self",
",",
"classname",
")",
":",
"schema_element",
"=",
"self",
".",
"get_element_by_class_name",
"(",
"classname",
")",
"result",
"=",
"{",
"property_name",
":",
"property_descriptor",
".",
"default",
"for",
"property_n... | Return a dict with default values for all properties declared on this class. | [
"Return",
"a",
"dict",
"with",
"default",
"values",
"for",
"all",
"properties",
"declared",
"on",
"this",
"class",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L297-L311 |
246,919 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph._get_property_values_with_defaults | def _get_property_values_with_defaults(self, classname, property_values):
"""Return the property values for the class, with default values applied where needed."""
# To uphold OrientDB semantics, make a new dict with all property values set
# to their default values, which are None if no default... | python | def _get_property_values_with_defaults(self, classname, property_values):
# To uphold OrientDB semantics, make a new dict with all property values set
# to their default values, which are None if no default was set.
# Then, overwrite its data with the supplied property values.
final_valu... | [
"def",
"_get_property_values_with_defaults",
"(",
"self",
",",
"classname",
",",
"property_values",
")",
":",
"# To uphold OrientDB semantics, make a new dict with all property values set",
"# to their default values, which are None if no default was set.",
"# Then, overwrite its data with t... | Return the property values for the class, with default values applied where needed. | [
"Return",
"the",
"property",
"values",
"for",
"the",
"class",
"with",
"default",
"values",
"applied",
"where",
"needed",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L313-L320 |
246,920 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph.get_element_by_class_name_or_raise | def get_element_by_class_name_or_raise(self, class_name):
"""Return the SchemaElement for the specified class name, asserting that it exists."""
if class_name not in self._elements:
raise InvalidClassError(u'Class does not exist: {}'.format(class_name))
return self._elements[class_n... | python | def get_element_by_class_name_or_raise(self, class_name):
if class_name not in self._elements:
raise InvalidClassError(u'Class does not exist: {}'.format(class_name))
return self._elements[class_name] | [
"def",
"get_element_by_class_name_or_raise",
"(",
"self",
",",
"class_name",
")",
":",
"if",
"class_name",
"not",
"in",
"self",
".",
"_elements",
":",
"raise",
"InvalidClassError",
"(",
"u'Class does not exist: {}'",
".",
"format",
"(",
"class_name",
")",
")",
"re... | Return the SchemaElement for the specified class name, asserting that it exists. | [
"Return",
"the",
"SchemaElement",
"for",
"the",
"specified",
"class",
"name",
"asserting",
"that",
"it",
"exists",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L322-L327 |
246,921 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph.get_vertex_schema_element_or_raise | def get_vertex_schema_element_or_raise(self, vertex_classname):
"""Return the schema element with the given name, asserting that it's of vertex type."""
schema_element = self.get_element_by_class_name_or_raise(vertex_classname)
if not schema_element.is_vertex:
raise InvalidClassErro... | python | def get_vertex_schema_element_or_raise(self, vertex_classname):
schema_element = self.get_element_by_class_name_or_raise(vertex_classname)
if not schema_element.is_vertex:
raise InvalidClassError(u'Non-vertex class provided: {}'.format(vertex_classname))
return schema_element | [
"def",
"get_vertex_schema_element_or_raise",
"(",
"self",
",",
"vertex_classname",
")",
":",
"schema_element",
"=",
"self",
".",
"get_element_by_class_name_or_raise",
"(",
"vertex_classname",
")",
"if",
"not",
"schema_element",
".",
"is_vertex",
":",
"raise",
"InvalidCl... | Return the schema element with the given name, asserting that it's of vertex type. | [
"Return",
"the",
"schema",
"element",
"with",
"the",
"given",
"name",
"asserting",
"that",
"it",
"s",
"of",
"vertex",
"type",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L329-L336 |
246,922 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph.get_edge_schema_element_or_raise | def get_edge_schema_element_or_raise(self, edge_classname):
"""Return the schema element with the given name, asserting that it's of edge type."""
schema_element = self.get_element_by_class_name_or_raise(edge_classname)
if not schema_element.is_edge:
raise InvalidClassError(u'Non-ed... | python | def get_edge_schema_element_or_raise(self, edge_classname):
schema_element = self.get_element_by_class_name_or_raise(edge_classname)
if not schema_element.is_edge:
raise InvalidClassError(u'Non-edge class provided: {}'.format(edge_classname))
return schema_element | [
"def",
"get_edge_schema_element_or_raise",
"(",
"self",
",",
"edge_classname",
")",
":",
"schema_element",
"=",
"self",
".",
"get_element_by_class_name_or_raise",
"(",
"edge_classname",
")",
"if",
"not",
"schema_element",
".",
"is_edge",
":",
"raise",
"InvalidClassError... | Return the schema element with the given name, asserting that it's of edge type. | [
"Return",
"the",
"schema",
"element",
"with",
"the",
"given",
"name",
"asserting",
"that",
"it",
"s",
"of",
"edge",
"type",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L338-L345 |
246,923 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph.validate_is_non_abstract_vertex_type | def validate_is_non_abstract_vertex_type(self, vertex_classname):
"""Validate that a vertex classname corresponds to a non-abstract vertex class."""
element = self.get_vertex_schema_element_or_raise(vertex_classname)
if element.abstract:
raise InvalidClassError(u'Expected a non-abst... | python | def validate_is_non_abstract_vertex_type(self, vertex_classname):
element = self.get_vertex_schema_element_or_raise(vertex_classname)
if element.abstract:
raise InvalidClassError(u'Expected a non-abstract vertex class, but {} is abstract'
.format(vertex_c... | [
"def",
"validate_is_non_abstract_vertex_type",
"(",
"self",
",",
"vertex_classname",
")",
":",
"element",
"=",
"self",
".",
"get_vertex_schema_element_or_raise",
"(",
"vertex_classname",
")",
"if",
"element",
".",
"abstract",
":",
"raise",
"InvalidClassError",
"(",
"u... | Validate that a vertex classname corresponds to a non-abstract vertex class. | [
"Validate",
"that",
"a",
"vertex",
"classname",
"corresponds",
"to",
"a",
"non",
"-",
"abstract",
"vertex",
"class",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L355-L361 |
246,924 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph.validate_is_non_abstract_edge_type | def validate_is_non_abstract_edge_type(self, edge_classname):
"""Validate that a edge classname corresponds to a non-abstract edge class."""
element = self.get_edge_schema_element_or_raise(edge_classname)
if element.abstract:
raise InvalidClassError(u'Expected a non-abstract vertex ... | python | def validate_is_non_abstract_edge_type(self, edge_classname):
element = self.get_edge_schema_element_or_raise(edge_classname)
if element.abstract:
raise InvalidClassError(u'Expected a non-abstract vertex class, but {} is abstract'
.format(edge_classname)) | [
"def",
"validate_is_non_abstract_edge_type",
"(",
"self",
",",
"edge_classname",
")",
":",
"element",
"=",
"self",
".",
"get_edge_schema_element_or_raise",
"(",
"edge_classname",
")",
"if",
"element",
".",
"abstract",
":",
"raise",
"InvalidClassError",
"(",
"u'Expecte... | Validate that a edge classname corresponds to a non-abstract edge class. | [
"Validate",
"that",
"a",
"edge",
"classname",
"corresponds",
"to",
"a",
"non",
"-",
"abstract",
"edge",
"class",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L363-L369 |
246,925 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph.validate_properties_exist | def validate_properties_exist(self, classname, property_names):
"""Validate that the specified property names are indeed defined on the given class."""
schema_element = self.get_element_by_class_name(classname)
requested_properties = set(property_names)
available_properties = set(schema... | python | def validate_properties_exist(self, classname, property_names):
schema_element = self.get_element_by_class_name(classname)
requested_properties = set(property_names)
available_properties = set(schema_element.properties.keys())
non_existent_properties = requested_properties - available_p... | [
"def",
"validate_properties_exist",
"(",
"self",
",",
"classname",
",",
"property_names",
")",
":",
"schema_element",
"=",
"self",
".",
"get_element_by_class_name",
"(",
"classname",
")",
"requested_properties",
"=",
"set",
"(",
"property_names",
")",
"available_prope... | Validate that the specified property names are indeed defined on the given class. | [
"Validate",
"that",
"the",
"specified",
"property",
"names",
"are",
"indeed",
"defined",
"on",
"the",
"given",
"class",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L371-L381 |
246,926 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph._split_classes_by_kind | def _split_classes_by_kind(self, class_name_to_definition):
"""Assign each class to the vertex, edge or non-graph type sets based on its kind."""
for class_name in class_name_to_definition:
inheritance_set = self._inheritance_sets[class_name]
is_vertex = ORIENTDB_BASE_VERTEX_CLA... | python | def _split_classes_by_kind(self, class_name_to_definition):
for class_name in class_name_to_definition:
inheritance_set = self._inheritance_sets[class_name]
is_vertex = ORIENTDB_BASE_VERTEX_CLASS_NAME in inheritance_set
is_edge = ORIENTDB_BASE_EDGE_CLASS_NAME in inheritance_... | [
"def",
"_split_classes_by_kind",
"(",
"self",
",",
"class_name_to_definition",
")",
":",
"for",
"class_name",
"in",
"class_name_to_definition",
":",
"inheritance_set",
"=",
"self",
".",
"_inheritance_sets",
"[",
"class_name",
"]",
"is_vertex",
"=",
"ORIENTDB_BASE_VERTEX... | Assign each class to the vertex, edge or non-graph type sets based on its kind. | [
"Assign",
"each",
"class",
"to",
"the",
"vertex",
"edge",
"or",
"non",
"-",
"graph",
"type",
"sets",
"based",
"on",
"its",
"kind",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L440-L461 |
246,927 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph._create_descriptor_from_property_definition | def _create_descriptor_from_property_definition(self, class_name, property_definition,
class_name_to_definition):
"""Return a PropertyDescriptor corresponding to the given OrientDB property definition."""
name = property_definition['name']
type... | python | def _create_descriptor_from_property_definition(self, class_name, property_definition,
class_name_to_definition):
name = property_definition['name']
type_id = property_definition['type']
linked_class = property_definition.get('linkedClass', Non... | [
"def",
"_create_descriptor_from_property_definition",
"(",
"self",
",",
"class_name",
",",
"property_definition",
",",
"class_name_to_definition",
")",
":",
"name",
"=",
"property_definition",
"[",
"'name'",
"]",
"type_id",
"=",
"property_definition",
"[",
"'type'",
"]"... | Return a PropertyDescriptor corresponding to the given OrientDB property definition. | [
"Return",
"a",
"PropertyDescriptor",
"corresponding",
"to",
"the",
"given",
"OrientDB",
"property",
"definition",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L548-L616 |
246,928 | kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | SchemaGraph._link_vertex_and_edge_types | def _link_vertex_and_edge_types(self):
"""For each edge, link it to the vertex types it connects to each other."""
for edge_class_name in self._edge_class_names:
edge_element = self._elements[edge_class_name]
if (EDGE_SOURCE_PROPERTY_NAME not in edge_element.properties or
... | python | def _link_vertex_and_edge_types(self):
for edge_class_name in self._edge_class_names:
edge_element = self._elements[edge_class_name]
if (EDGE_SOURCE_PROPERTY_NAME not in edge_element.properties or
EDGE_DESTINATION_PROPERTY_NAME not in edge_element.properties):
... | [
"def",
"_link_vertex_and_edge_types",
"(",
"self",
")",
":",
"for",
"edge_class_name",
"in",
"self",
".",
"_edge_class_names",
":",
"edge_element",
"=",
"self",
".",
"_elements",
"[",
"edge_class_name",
"]",
"if",
"(",
"EDGE_SOURCE_PROPERTY_NAME",
"not",
"in",
"ed... | For each edge, link it to the vertex types it connects to each other. | [
"For",
"each",
"edge",
"link",
"it",
"to",
"the",
"vertex",
"types",
"it",
"connects",
"to",
"each",
"other",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L618-L646 |
246,929 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_query_execution.py | _is_local_filter | def _is_local_filter(filter_block):
"""Return True if the Filter block references no non-local fields, and False otherwise."""
# We need the "result" value of this function to be mutated within the "visitor_fn".
# Since we support both Python 2 and Python 3, we can't use the "nonlocal" keyword here:
# h... | python | def _is_local_filter(filter_block):
# We need the "result" value of this function to be mutated within the "visitor_fn".
# Since we support both Python 2 and Python 3, we can't use the "nonlocal" keyword here:
# https://www.python.org/dev/peps/pep-3104/
# Instead, we use a dict to store the value we nee... | [
"def",
"_is_local_filter",
"(",
"filter_block",
")",
":",
"# We need the \"result\" value of this function to be mutated within the \"visitor_fn\".",
"# Since we support both Python 2 and Python 3, we can't use the \"nonlocal\" keyword here:",
"# https://www.python.org/dev/peps/pep-3104/",
"# Inst... | Return True if the Filter block references no non-local fields, and False otherwise. | [
"Return",
"True",
"if",
"the",
"Filter",
"block",
"references",
"no",
"non",
"-",
"local",
"fields",
"and",
"False",
"otherwise",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L53-L78 |
246,930 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_query_execution.py | _calculate_type_bound_at_step | def _calculate_type_bound_at_step(match_step):
"""Return the GraphQL type bound at the given step, or None if no bound is given."""
current_type_bounds = []
if isinstance(match_step.root_block, QueryRoot):
# The QueryRoot start class is a type bound.
current_type_bounds.extend(match_step.ro... | python | def _calculate_type_bound_at_step(match_step):
current_type_bounds = []
if isinstance(match_step.root_block, QueryRoot):
# The QueryRoot start class is a type bound.
current_type_bounds.extend(match_step.root_block.start_class)
if match_step.coerce_type_block is not None:
# The Coe... | [
"def",
"_calculate_type_bound_at_step",
"(",
"match_step",
")",
":",
"current_type_bounds",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"match_step",
".",
"root_block",
",",
"QueryRoot",
")",
":",
"# The QueryRoot start class is a type bound.",
"current_type_bounds",
".",
"... | Return the GraphQL type bound at the given step, or None if no bound is given. | [
"Return",
"the",
"GraphQL",
"type",
"bound",
"at",
"the",
"given",
"step",
"or",
"None",
"if",
"no",
"bound",
"is",
"given",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L188-L205 |
246,931 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_query_execution.py | _assert_type_bounds_are_not_conflicting | def _assert_type_bounds_are_not_conflicting(current_type_bound, previous_type_bound,
location, match_query):
"""Ensure that the two bounds either are an exact match, or one of them is None."""
if all((current_type_bound is not None,
previous_type_bound is ... | python | def _assert_type_bounds_are_not_conflicting(current_type_bound, previous_type_bound,
location, match_query):
if all((current_type_bound is not None,
previous_type_bound is not None,
current_type_bound != previous_type_bound)):
raise Asserti... | [
"def",
"_assert_type_bounds_are_not_conflicting",
"(",
"current_type_bound",
",",
"previous_type_bound",
",",
"location",
",",
"match_query",
")",
":",
"if",
"all",
"(",
"(",
"current_type_bound",
"is",
"not",
"None",
",",
"previous_type_bound",
"is",
"not",
"None",
... | Ensure that the two bounds either are an exact match, or one of them is None. | [
"Ensure",
"that",
"the",
"two",
"bounds",
"either",
"are",
"an",
"exact",
"match",
"or",
"one",
"of",
"them",
"is",
"None",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L208-L216 |
246,932 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_query_execution.py | _expose_only_preferred_locations | def _expose_only_preferred_locations(match_query, location_types, coerced_locations,
preferred_locations, eligible_locations):
"""Return a MATCH query where only preferred locations are valid as query start locations."""
preferred_location_types = dict()
eligible_locatio... | python | def _expose_only_preferred_locations(match_query, location_types, coerced_locations,
preferred_locations, eligible_locations):
preferred_location_types = dict()
eligible_location_types = dict()
new_match_traversals = []
for current_traversal in match_query.match_tra... | [
"def",
"_expose_only_preferred_locations",
"(",
"match_query",
",",
"location_types",
",",
"coerced_locations",
",",
"preferred_locations",
",",
"eligible_locations",
")",
":",
"preferred_location_types",
"=",
"dict",
"(",
")",
"eligible_location_types",
"=",
"dict",
"(",... | Return a MATCH query where only preferred locations are valid as query start locations. | [
"Return",
"a",
"MATCH",
"query",
"where",
"only",
"preferred",
"locations",
"are",
"valid",
"as",
"query",
"start",
"locations",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L219-L308 |
246,933 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_query_execution.py | _expose_all_eligible_locations | def _expose_all_eligible_locations(match_query, location_types, eligible_locations):
"""Return a MATCH query where all eligible locations are valid as query start locations."""
eligible_location_types = dict()
new_match_traversals = []
for current_traversal in match_query.match_traversals:
new_... | python | def _expose_all_eligible_locations(match_query, location_types, eligible_locations):
eligible_location_types = dict()
new_match_traversals = []
for current_traversal in match_query.match_traversals:
new_traversal = []
for match_step in current_traversal:
new_step = match_step
... | [
"def",
"_expose_all_eligible_locations",
"(",
"match_query",
",",
"location_types",
",",
"eligible_locations",
")",
":",
"eligible_location_types",
"=",
"dict",
"(",
")",
"new_match_traversals",
"=",
"[",
"]",
"for",
"current_traversal",
"in",
"match_query",
".",
"mat... | Return a MATCH query where all eligible locations are valid as query start locations. | [
"Return",
"a",
"MATCH",
"query",
"where",
"all",
"eligible",
"locations",
"are",
"valid",
"as",
"query",
"start",
"locations",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L311-L350 |
246,934 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_query_execution.py | expose_ideal_query_execution_start_points | def expose_ideal_query_execution_start_points(compound_match_query, location_types,
coerced_locations):
"""Ensure that OrientDB only considers desirable query start points in query planning."""
new_queries = []
for match_query in compound_match_query.match_quer... | python | def expose_ideal_query_execution_start_points(compound_match_query, location_types,
coerced_locations):
new_queries = []
for match_query in compound_match_query.match_queries:
location_classification = _classify_query_locations(match_query)
preferre... | [
"def",
"expose_ideal_query_execution_start_points",
"(",
"compound_match_query",
",",
"location_types",
",",
"coerced_locations",
")",
":",
"new_queries",
"=",
"[",
"]",
"for",
"match_query",
"in",
"compound_match_query",
".",
"match_queries",
":",
"location_classification"... | Ensure that OrientDB only considers desirable query start points in query planning. | [
"Ensure",
"that",
"OrientDB",
"only",
"considers",
"desirable",
"query",
"start",
"points",
"in",
"query",
"planning",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L353-L384 |
246,935 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/between_lowering.py | _expression_list_to_conjunction | def _expression_list_to_conjunction(expression_list):
"""Return an Expression that is the `&&` of all the expressions in the given list."""
if not isinstance(expression_list, list):
raise AssertionError(u'Expected list. Received {}: '
u'{}'.format(type(expression_list).__nam... | python | def _expression_list_to_conjunction(expression_list):
if not isinstance(expression_list, list):
raise AssertionError(u'Expected list. Received {}: '
u'{}'.format(type(expression_list).__name__, expression_list))
if len(expression_list) == 0:
raise AssertionError(u'Re... | [
"def",
"_expression_list_to_conjunction",
"(",
"expression_list",
")",
":",
"if",
"not",
"isinstance",
"(",
"expression_list",
",",
"list",
")",
":",
"raise",
"AssertionError",
"(",
"u'Expected list. Received {}: '",
"u'{}'",
".",
"format",
"(",
"type",
"(",
"expres... | Return an Expression that is the `&&` of all the expressions in the given list. | [
"Return",
"an",
"Expression",
"that",
"is",
"the",
"&&",
"of",
"all",
"the",
"expressions",
"in",
"the",
"given",
"list",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L9-L22 |
246,936 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/between_lowering.py | _extract_conjuction_elements_from_expression | def _extract_conjuction_elements_from_expression(expression):
"""Return a generator for expressions that are connected by `&&`s in the given expression."""
if isinstance(expression, BinaryComposition) and expression.operator == u'&&':
for element in _extract_conjuction_elements_from_expression(expressio... | python | def _extract_conjuction_elements_from_expression(expression):
if isinstance(expression, BinaryComposition) and expression.operator == u'&&':
for element in _extract_conjuction_elements_from_expression(expression.left):
yield element
for element in _extract_conjuction_elements_from_expres... | [
"def",
"_extract_conjuction_elements_from_expression",
"(",
"expression",
")",
":",
"if",
"isinstance",
"(",
"expression",
",",
"BinaryComposition",
")",
"and",
"expression",
".",
"operator",
"==",
"u'&&'",
":",
"for",
"element",
"in",
"_extract_conjuction_elements_from... | Return a generator for expressions that are connected by `&&`s in the given expression. | [
"Return",
"a",
"generator",
"for",
"expressions",
"that",
"are",
"connected",
"by",
"&&",
"s",
"in",
"the",
"given",
"expression",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L25-L33 |
246,937 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/between_lowering.py | _construct_field_operator_expression_dict | def _construct_field_operator_expression_dict(expression_list):
"""Construct a mapping from local fields to specified operators, and corresponding expressions.
Args:
expression_list: list of expressions to analyze
Returns:
local_field_to_expressions:
dict mapping local field na... | python | def _construct_field_operator_expression_dict(expression_list):
between_operators = (u'<=', u'>=')
inverse_operator = {u'>=': u'<=', u'<=': u'>='}
local_field_to_expressions = {}
remaining_expression_list = deque([])
for expression in expression_list:
if all((
isinstance(expressi... | [
"def",
"_construct_field_operator_expression_dict",
"(",
"expression_list",
")",
":",
"between_operators",
"=",
"(",
"u'<='",
",",
"u'>='",
")",
"inverse_operator",
"=",
"{",
"u'>='",
":",
"u'<='",
",",
"u'<='",
":",
"u'>='",
"}",
"local_field_to_expressions",
"=",
... | Construct a mapping from local fields to specified operators, and corresponding expressions.
Args:
expression_list: list of expressions to analyze
Returns:
local_field_to_expressions:
dict mapping local field names to "operator -> list of BinaryComposition" dictionaries,
... | [
"Construct",
"a",
"mapping",
"from",
"local",
"fields",
"to",
"specified",
"operators",
"and",
"corresponding",
"expressions",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L36-L70 |
246,938 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/between_lowering.py | _lower_expressions_to_between | def _lower_expressions_to_between(base_expression):
"""Return a new expression, with any eligible comparisons lowered to `between` clauses."""
expression_list = list(_extract_conjuction_elements_from_expression(base_expression))
if len(expression_list) == 0:
raise AssertionError(u'Received empty exp... | python | def _lower_expressions_to_between(base_expression):
expression_list = list(_extract_conjuction_elements_from_expression(base_expression))
if len(expression_list) == 0:
raise AssertionError(u'Received empty expression_list {} from base_expression: '
u'{}'.format(expression_li... | [
"def",
"_lower_expressions_to_between",
"(",
"base_expression",
")",
":",
"expression_list",
"=",
"list",
"(",
"_extract_conjuction_elements_from_expression",
"(",
"base_expression",
")",
")",
"if",
"len",
"(",
"expression_list",
")",
"==",
"0",
":",
"raise",
"Asserti... | Return a new expression, with any eligible comparisons lowered to `between` clauses. | [
"Return",
"a",
"new",
"expression",
"with",
"any",
"eligible",
"comparisons",
"lowered",
"to",
"between",
"clauses",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L73-L103 |
246,939 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_match/between_lowering.py | lower_comparisons_to_between | def lower_comparisons_to_between(match_query):
"""Return a new MatchQuery, with all eligible comparison filters lowered to between clauses."""
new_match_traversals = []
for current_match_traversal in match_query.match_traversals:
new_traversal = []
for step in current_match_traversal:
... | python | def lower_comparisons_to_between(match_query):
new_match_traversals = []
for current_match_traversal in match_query.match_traversals:
new_traversal = []
for step in current_match_traversal:
if step.where_block:
expression = step.where_block.predicate
... | [
"def",
"lower_comparisons_to_between",
"(",
"match_query",
")",
":",
"new_match_traversals",
"=",
"[",
"]",
"for",
"current_match_traversal",
"in",
"match_query",
".",
"match_traversals",
":",
"new_traversal",
"=",
"[",
"]",
"for",
"step",
"in",
"current_match_travers... | Return a new MatchQuery, with all eligible comparison filters lowered to between clauses. | [
"Return",
"a",
"new",
"MatchQuery",
"with",
"all",
"eligible",
"comparison",
"filters",
"lowered",
"to",
"between",
"clauses",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L106-L122 |
246,940 | kensho-technologies/graphql-compiler | graphql_compiler/query_formatting/common.py | _ensure_arguments_are_provided | def _ensure_arguments_are_provided(expected_types, arguments):
"""Ensure that all arguments expected by the query were actually provided."""
# This function only checks that the arguments were specified,
# and does not check types. Type checking is done as part of the actual formatting step.
expected_ar... | python | def _ensure_arguments_are_provided(expected_types, arguments):
# This function only checks that the arguments were specified,
# and does not check types. Type checking is done as part of the actual formatting step.
expected_arg_names = set(six.iterkeys(expected_types))
provided_arg_names = set(six.iterk... | [
"def",
"_ensure_arguments_are_provided",
"(",
"expected_types",
",",
"arguments",
")",
":",
"# This function only checks that the arguments were specified,",
"# and does not check types. Type checking is done as part of the actual formatting step.",
"expected_arg_names",
"=",
"set",
"(",
... | Ensure that all arguments expected by the query were actually provided. | [
"Ensure",
"that",
"all",
"arguments",
"expected",
"by",
"the",
"query",
"were",
"actually",
"provided",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/common.py#L12-L24 |
246,941 | kensho-technologies/graphql-compiler | graphql_compiler/query_formatting/common.py | insert_arguments_into_query | def insert_arguments_into_query(compilation_result, arguments):
"""Insert the arguments into the compiled GraphQL query to form a complete query.
Args:
compilation_result: a CompilationResult object derived from the GraphQL compiler
arguments: dict, mapping argument name to its value, for every... | python | def insert_arguments_into_query(compilation_result, arguments):
_ensure_arguments_are_provided(compilation_result.input_metadata, arguments)
if compilation_result.language == MATCH_LANGUAGE:
return insert_arguments_into_match_query(compilation_result, arguments)
elif compilation_result.language == ... | [
"def",
"insert_arguments_into_query",
"(",
"compilation_result",
",",
"arguments",
")",
":",
"_ensure_arguments_are_provided",
"(",
"compilation_result",
".",
"input_metadata",
",",
"arguments",
")",
"if",
"compilation_result",
".",
"language",
"==",
"MATCH_LANGUAGE",
":"... | Insert the arguments into the compiled GraphQL query to form a complete query.
Args:
compilation_result: a CompilationResult object derived from the GraphQL compiler
arguments: dict, mapping argument name to its value, for every parameter the query expects.
Returns:
string, a query in ... | [
"Insert",
"the",
"arguments",
"into",
"the",
"compiled",
"GraphQL",
"query",
"to",
"form",
"a",
"complete",
"query",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/common.py#L31-L51 |
246,942 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/blocks.py | QueryRoot.validate | def validate(self):
"""Ensure that the QueryRoot block is valid."""
if not (isinstance(self.start_class, set) and
all(isinstance(x, six.string_types) for x in self.start_class)):
raise TypeError(u'Expected set of string start_class, got: {} {}'.format(
type(se... | python | def validate(self):
if not (isinstance(self.start_class, set) and
all(isinstance(x, six.string_types) for x in self.start_class)):
raise TypeError(u'Expected set of string start_class, got: {} {}'.format(
type(self.start_class).__name__, self.start_class))
fo... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"self",
".",
"start_class",
",",
"set",
")",
"and",
"all",
"(",
"isinstance",
"(",
"x",
",",
"six",
".",
"string_types",
")",
"for",
"x",
"in",
"self",
".",
"start_class",... | Ensure that the QueryRoot block is valid. | [
"Ensure",
"that",
"the",
"QueryRoot",
"block",
"is",
"valid",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L34-L42 |
246,943 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/blocks.py | CoerceType.validate | def validate(self):
"""Ensure that the CoerceType block is valid."""
if not (isinstance(self.target_class, set) and
all(isinstance(x, six.string_types) for x in self.target_class)):
raise TypeError(u'Expected set of string target_class, got: {} {}'.format(
typ... | python | def validate(self):
if not (isinstance(self.target_class, set) and
all(isinstance(x, six.string_types) for x in self.target_class)):
raise TypeError(u'Expected set of string target_class, got: {} {}'.format(
type(self.target_class).__name__, self.target_class))
... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"self",
".",
"target_class",
",",
"set",
")",
"and",
"all",
"(",
"isinstance",
"(",
"x",
",",
"six",
".",
"string_types",
")",
"for",
"x",
"in",
"self",
".",
"target_class... | Ensure that the CoerceType block is valid. | [
"Ensure",
"that",
"the",
"CoerceType",
"block",
"is",
"valid",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L79-L87 |
246,944 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/blocks.py | ConstructResult.validate | def validate(self):
"""Ensure that the ConstructResult block is valid."""
if not isinstance(self.fields, dict):
raise TypeError(u'Expected dict fields, got: {} {}'.format(
type(self.fields).__name__, self.fields))
for key, value in six.iteritems(self.fields):
... | python | def validate(self):
if not isinstance(self.fields, dict):
raise TypeError(u'Expected dict fields, got: {} {}'.format(
type(self.fields).__name__, self.fields))
for key, value in six.iteritems(self.fields):
validate_safe_string(key)
if not isinstance(v... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"fields",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected dict fields, got: {} {}'",
".",
"format",
"(",
"type",
"(",
"self",
".",
"fields",
")",
".",
"_... | Ensure that the ConstructResult block is valid. | [
"Ensure",
"that",
"the",
"ConstructResult",
"block",
"is",
"valid",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L120-L131 |
246,945 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/blocks.py | Filter.validate | def validate(self):
"""Ensure that the Filter block is valid."""
if not isinstance(self.predicate, Expression):
raise TypeError(u'Expected Expression predicate, got: {} {}'.format(
type(self.predicate).__name__, self.predicate)) | python | def validate(self):
if not isinstance(self.predicate, Expression):
raise TypeError(u'Expected Expression predicate, got: {} {}'.format(
type(self.predicate).__name__, self.predicate)) | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"predicate",
",",
"Expression",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected Expression predicate, got: {} {}'",
".",
"format",
"(",
"type",
"(",
"self",
".",
"predicate... | Ensure that the Filter block is valid. | [
"Ensure",
"that",
"the",
"Filter",
"block",
"is",
"valid",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L174-L178 |
246,946 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/blocks.py | Backtrack.validate | def validate(self):
"""Ensure that the Backtrack block is valid."""
validate_marked_location(self.location)
if not isinstance(self.optional, bool):
raise TypeError(u'Expected bool optional, got: {} {}'.format(
type(self.optional).__name__, self.optional)) | python | def validate(self):
validate_marked_location(self.location)
if not isinstance(self.optional, bool):
raise TypeError(u'Expected bool optional, got: {} {}'.format(
type(self.optional).__name__, self.optional)) | [
"def",
"validate",
"(",
"self",
")",
":",
"validate_marked_location",
"(",
"self",
".",
"location",
")",
"if",
"not",
"isinstance",
"(",
"self",
".",
"optional",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected bool optional, got: {} {}'",
".",
"f... | Ensure that the Backtrack block is valid. | [
"Ensure",
"that",
"the",
"Backtrack",
"block",
"is",
"valid",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L395-L400 |
246,947 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/blocks.py | Backtrack.to_gremlin | def to_gremlin(self):
"""Return a unicode object with the Gremlin representation of this BasicBlock."""
self.validate()
if self.optional:
operation = u'optional'
else:
operation = u'back'
mark_name, _ = self.location.get_location_name()
return u'... | python | def to_gremlin(self):
self.validate()
if self.optional:
operation = u'optional'
else:
operation = u'back'
mark_name, _ = self.location.get_location_name()
return u'{operation}({mark_name})'.format(
operation=operation,
mark_name=s... | [
"def",
"to_gremlin",
"(",
"self",
")",
":",
"self",
".",
"validate",
"(",
")",
"if",
"self",
".",
"optional",
":",
"operation",
"=",
"u'optional'",
"else",
":",
"operation",
"=",
"u'back'",
"mark_name",
",",
"_",
"=",
"self",
".",
"location",
".",
"get... | Return a unicode object with the Gremlin representation of this BasicBlock. | [
"Return",
"a",
"unicode",
"object",
"with",
"the",
"Gremlin",
"representation",
"of",
"this",
"BasicBlock",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L402-L414 |
246,948 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/blocks.py | Fold.validate | def validate(self):
"""Ensure the Fold block is valid."""
if not isinstance(self.fold_scope_location, FoldScopeLocation):
raise TypeError(u'Expected a FoldScopeLocation for fold_scope_location, got: {} '
u'{}'.format(type(self.fold_scope_location), self.fold_scope... | python | def validate(self):
if not isinstance(self.fold_scope_location, FoldScopeLocation):
raise TypeError(u'Expected a FoldScopeLocation for fold_scope_location, got: {} '
u'{}'.format(type(self.fold_scope_location), self.fold_scope_location)) | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"fold_scope_location",
",",
"FoldScopeLocation",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected a FoldScopeLocation for fold_scope_location, got: {} '",
"u'{}'",
".",
"format",
"(... | Ensure the Fold block is valid. | [
"Ensure",
"the",
"Fold",
"block",
"is",
"valid",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L446-L450 |
246,949 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | lower_ir | def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None):
"""Lower the IR blocks into a form that can be represented by a SQL query.
Args:
ir_blocks: list of IR blocks to lower into SQL-compatible form
query_metadata_table: QueryMetadataTable object containing all metadata col... | python | def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None):
_validate_all_blocks_supported(ir_blocks, query_metadata_table)
construct_result = _get_construct_result(ir_blocks)
query_path_to_location_info = _map_query_path_to_location_info(query_metadata_table)
query_path_to_output_fields... | [
"def",
"lower_ir",
"(",
"ir_blocks",
",",
"query_metadata_table",
",",
"type_equivalence_hints",
"=",
"None",
")",
":",
"_validate_all_blocks_supported",
"(",
"ir_blocks",
",",
"query_metadata_table",
")",
"construct_result",
"=",
"_get_construct_result",
"(",
"ir_blocks"... | Lower the IR blocks into a form that can be represented by a SQL query.
Args:
ir_blocks: list of IR blocks to lower into SQL-compatible form
query_metadata_table: QueryMetadataTable object containing all metadata collected during
query processing, including location me... | [
"Lower",
"the",
"IR",
"blocks",
"into",
"a",
"form",
"that",
"can",
"be",
"represented",
"by",
"a",
"SQL",
"query",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L17-L81 |
246,950 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | _validate_all_blocks_supported | def _validate_all_blocks_supported(ir_blocks, query_metadata_table):
"""Validate that all IR blocks and ConstructResult fields passed to the backend are supported.
Args:
ir_blocks: List[BasicBlock], IR blocks to validate.
query_metadata_table: QueryMetadataTable, object containing all metadata ... | python | def _validate_all_blocks_supported(ir_blocks, query_metadata_table):
if len(ir_blocks) < 3:
raise AssertionError(
u'Unexpectedly attempting to validate IR blocks with fewer than 3 blocks. A minimal '
u'query is expected to have at least a QueryRoot, GlobalOperationsStart, and '
... | [
"def",
"_validate_all_blocks_supported",
"(",
"ir_blocks",
",",
"query_metadata_table",
")",
":",
"if",
"len",
"(",
"ir_blocks",
")",
"<",
"3",
":",
"raise",
"AssertionError",
"(",
"u'Unexpectedly attempting to validate IR blocks with fewer than 3 blocks. A minimal '",
"u'que... | Validate that all IR blocks and ConstructResult fields passed to the backend are supported.
Args:
ir_blocks: List[BasicBlock], IR blocks to validate.
query_metadata_table: QueryMetadataTable, object containing all metadata collected during
query processing, including l... | [
"Validate",
"that",
"all",
"IR",
"blocks",
"and",
"ConstructResult",
"fields",
"passed",
"to",
"the",
"backend",
"are",
"supported",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L84-L121 |
246,951 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | _get_construct_result | def _get_construct_result(ir_blocks):
"""Return the ConstructResult block from a list of IR blocks."""
last_block = ir_blocks[-1]
if not isinstance(last_block, blocks.ConstructResult):
raise AssertionError(
u'The last IR block {} for IR blocks {} was unexpectedly not '
u'a Co... | python | def _get_construct_result(ir_blocks):
last_block = ir_blocks[-1]
if not isinstance(last_block, blocks.ConstructResult):
raise AssertionError(
u'The last IR block {} for IR blocks {} was unexpectedly not '
u'a ConstructResult block.'.format(last_block, ir_blocks))
return last_... | [
"def",
"_get_construct_result",
"(",
"ir_blocks",
")",
":",
"last_block",
"=",
"ir_blocks",
"[",
"-",
"1",
"]",
"if",
"not",
"isinstance",
"(",
"last_block",
",",
"blocks",
".",
"ConstructResult",
")",
":",
"raise",
"AssertionError",
"(",
"u'The last IR block {}... | Return the ConstructResult block from a list of IR blocks. | [
"Return",
"the",
"ConstructResult",
"block",
"from",
"a",
"list",
"of",
"IR",
"blocks",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L124-L131 |
246,952 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | _map_query_path_to_location_info | def _map_query_path_to_location_info(query_metadata_table):
"""Create a map from each query path to a LocationInfo at that path.
Args:
query_metadata_table: QueryMetadataTable, object containing all metadata collected during
query processing, including location metadata (e... | python | def _map_query_path_to_location_info(query_metadata_table):
query_path_to_location_info = {}
for location, location_info in query_metadata_table.registered_locations:
if not isinstance(location, Location):
continue
if location.query_path in query_path_to_location_info:
# ... | [
"def",
"_map_query_path_to_location_info",
"(",
"query_metadata_table",
")",
":",
"query_path_to_location_info",
"=",
"{",
"}",
"for",
"location",
",",
"location_info",
"in",
"query_metadata_table",
".",
"registered_locations",
":",
"if",
"not",
"isinstance",
"(",
"loca... | Create a map from each query path to a LocationInfo at that path.
Args:
query_metadata_table: QueryMetadataTable, object containing all metadata collected during
query processing, including location metadata (e.g. which locations
are folded or opt... | [
"Create",
"a",
"map",
"from",
"each",
"query",
"path",
"to",
"a",
"LocationInfo",
"at",
"that",
"path",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L134-L161 |
246,953 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | _location_infos_equal | def _location_infos_equal(left, right):
"""Return True if LocationInfo objects are equivalent for the SQL backend, False otherwise.
LocationInfo objects are considered equal for the SQL backend iff the optional scopes depth,
recursive scopes depth, types and parent query paths are equal.
Args:
... | python | def _location_infos_equal(left, right):
if not isinstance(left, LocationInfo) or not isinstance(right, LocationInfo):
raise AssertionError(
u'Unsupported LocationInfo comparison between types {} and {} '
u'with values {}, {}'.format(type(left), type(right), left, right))
optional... | [
"def",
"_location_infos_equal",
"(",
"left",
",",
"right",
")",
":",
"if",
"not",
"isinstance",
"(",
"left",
",",
"LocationInfo",
")",
"or",
"not",
"isinstance",
"(",
"right",
",",
"LocationInfo",
")",
":",
"raise",
"AssertionError",
"(",
"u'Unsupported Locati... | Return True if LocationInfo objects are equivalent for the SQL backend, False otherwise.
LocationInfo objects are considered equal for the SQL backend iff the optional scopes depth,
recursive scopes depth, types and parent query paths are equal.
Args:
left: LocationInfo, left location info object ... | [
"Return",
"True",
"if",
"LocationInfo",
"objects",
"are",
"equivalent",
"for",
"the",
"SQL",
"backend",
"False",
"otherwise",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L164-L196 |
246,954 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | _map_query_path_to_outputs | def _map_query_path_to_outputs(construct_result, query_path_to_location_info):
"""Assign the output fields of a ConstructResult block to their respective query_path."""
query_path_to_output_fields = {}
for output_name, field in six.iteritems(construct_result.fields):
field_name = field.location.fiel... | python | def _map_query_path_to_outputs(construct_result, query_path_to_location_info):
query_path_to_output_fields = {}
for output_name, field in six.iteritems(construct_result.fields):
field_name = field.location.field
output_query_path = field.location.query_path
output_field_info = constants.... | [
"def",
"_map_query_path_to_outputs",
"(",
"construct_result",
",",
"query_path_to_location_info",
")",
":",
"query_path_to_output_fields",
"=",
"{",
"}",
"for",
"output_name",
",",
"field",
"in",
"six",
".",
"iteritems",
"(",
"construct_result",
".",
"fields",
")",
... | Assign the output fields of a ConstructResult block to their respective query_path. | [
"Assign",
"the",
"output",
"fields",
"of",
"a",
"ConstructResult",
"block",
"to",
"their",
"respective",
"query_path",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L199-L211 |
246,955 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | _map_block_index_to_location | def _map_block_index_to_location(ir_blocks):
"""Associate each IR block with its corresponding location, by index."""
block_index_to_location = {}
# MarkLocation blocks occur after the blocks related to that location.
# The core approach here is to buffer blocks until their MarkLocation is encountered
... | python | def _map_block_index_to_location(ir_blocks):
block_index_to_location = {}
# MarkLocation blocks occur after the blocks related to that location.
# The core approach here is to buffer blocks until their MarkLocation is encountered
# after which all buffered blocks can be associated with the encountered M... | [
"def",
"_map_block_index_to_location",
"(",
"ir_blocks",
")",
":",
"block_index_to_location",
"=",
"{",
"}",
"# MarkLocation blocks occur after the blocks related to that location.",
"# The core approach here is to buffer blocks until their MarkLocation is encountered",
"# after which all bu... | Associate each IR block with its corresponding location, by index. | [
"Associate",
"each",
"IR",
"block",
"with",
"its",
"corresponding",
"location",
"by",
"index",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L214-L234 |
246,956 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | lower_unary_transformations | def lower_unary_transformations(ir_blocks):
"""Raise exception if any unary transformation block encountered."""
def visitor_fn(expression):
"""Raise error if current expression is a UnaryTransformation."""
if not isinstance(expression, expressions.UnaryTransformation):
return expres... | python | def lower_unary_transformations(ir_blocks):
def visitor_fn(expression):
"""Raise error if current expression is a UnaryTransformation."""
if not isinstance(expression, expressions.UnaryTransformation):
return expression
raise NotImplementedError(
u'UnaryTransformation... | [
"def",
"lower_unary_transformations",
"(",
"ir_blocks",
")",
":",
"def",
"visitor_fn",
"(",
"expression",
")",
":",
"\"\"\"Raise error if current expression is a UnaryTransformation.\"\"\"",
"if",
"not",
"isinstance",
"(",
"expression",
",",
"expressions",
".",
"UnaryTransf... | Raise exception if any unary transformation block encountered. | [
"Raise",
"exception",
"if",
"any",
"unary",
"transformation",
"block",
"encountered",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L237-L252 |
246,957 | kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_sql/__init__.py | lower_unsupported_metafield_expressions | def lower_unsupported_metafield_expressions(ir_blocks):
"""Raise exception if an unsupported metafield is encountered in any LocalField expression."""
def visitor_fn(expression):
"""Visitor function raising exception for any unsupported metafield."""
if not isinstance(expression, expressions.Loc... | python | def lower_unsupported_metafield_expressions(ir_blocks):
def visitor_fn(expression):
"""Visitor function raising exception for any unsupported metafield."""
if not isinstance(expression, expressions.LocalField):
return expression
if expression.field_name not in constants.UNSUPPORT... | [
"def",
"lower_unsupported_metafield_expressions",
"(",
"ir_blocks",
")",
":",
"def",
"visitor_fn",
"(",
"expression",
")",
":",
"\"\"\"Visitor function raising exception for any unsupported metafield.\"\"\"",
"if",
"not",
"isinstance",
"(",
"expression",
",",
"expressions",
"... | Raise exception if an unsupported metafield is encountered in any LocalField expression. | [
"Raise",
"exception",
"if",
"an",
"unsupported",
"metafield",
"is",
"encountered",
"in",
"any",
"LocalField",
"expression",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L255-L272 |
246,958 | kensho-technologies/graphql-compiler | graphql_compiler/__init__.py | get_graphql_schema_from_orientdb_schema_data | def get_graphql_schema_from_orientdb_schema_data(schema_data, class_to_field_type_overrides=None,
hidden_classes=None):
"""Construct a GraphQL schema from an OrientDB schema.
Args:
schema_data: list of dicts describing the classes in the OrientDB schema.... | python | def get_graphql_schema_from_orientdb_schema_data(schema_data, class_to_field_type_overrides=None,
hidden_classes=None):
if class_to_field_type_overrides is None:
class_to_field_type_overrides = dict()
if hidden_classes is None:
hidden_classes = se... | [
"def",
"get_graphql_schema_from_orientdb_schema_data",
"(",
"schema_data",
",",
"class_to_field_type_overrides",
"=",
"None",
",",
"hidden_classes",
"=",
"None",
")",
":",
"if",
"class_to_field_type_overrides",
"is",
"None",
":",
"class_to_field_type_overrides",
"=",
"dict"... | Construct a GraphQL schema from an OrientDB schema.
Args:
schema_data: list of dicts describing the classes in the OrientDB schema. The following
format is the way the data is structured in OrientDB 2. See
the README.md file for an example of how to query this data... | [
"Construct",
"a",
"GraphQL",
"schema",
"from",
"an",
"OrientDB",
"schema",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/__init__.py#L139-L199 |
246,959 | slackapi/python-slack-events-api | slackeventsapi/__init__.py | SlackEventAdapter.start | def start(self, host='127.0.0.1', port=None, debug=False, **kwargs):
"""
Start the built in webserver, bound to the host and port you'd like.
Default host is `127.0.0.1` and port 8080.
:param host: The host you want to bind the build in webserver to
:param port: The port number ... | python | def start(self, host='127.0.0.1', port=None, debug=False, **kwargs):
self.server.run(host=host, port=port, debug=debug, **kwargs) | [
"def",
"start",
"(",
"self",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"None",
",",
"debug",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"server",
".",
"run",
"(",
"host",
"=",
"host",
",",
"port",
"=",
"port",
",",
"... | Start the built in webserver, bound to the host and port you'd like.
Default host is `127.0.0.1` and port 8080.
:param host: The host you want to bind the build in webserver to
:param port: The port number you want the webserver to run on
:param debug: Set to `True` to enable debug leve... | [
"Start",
"the",
"built",
"in",
"webserver",
"bound",
"to",
"the",
"host",
"and",
"port",
"you",
"d",
"like",
".",
"Default",
"host",
"is",
"127",
".",
"0",
".",
"0",
".",
"1",
"and",
"port",
"8080",
"."
] | 1254d83181eb939f124a0e4746dafea7e14047c1 | https://github.com/slackapi/python-slack-events-api/blob/1254d83181eb939f124a0e4746dafea7e14047c1/slackeventsapi/__init__.py#L13-L23 |
246,960 | apragacz/django-rest-registration | rest_registration/api/views/login.py | login | def login(request):
'''
Logs in the user via given login and password.
'''
serializer_class = registration_settings.LOGIN_SERIALIZER_CLASS
serializer = serializer_class(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.get_authenticated_user()
if not user:
... | python | def login(request):
'''
Logs in the user via given login and password.
'''
serializer_class = registration_settings.LOGIN_SERIALIZER_CLASS
serializer = serializer_class(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.get_authenticated_user()
if not user:
... | [
"def",
"login",
"(",
"request",
")",
":",
"serializer_class",
"=",
"registration_settings",
".",
"LOGIN_SERIALIZER_CLASS",
"serializer",
"=",
"serializer_class",
"(",
"data",
"=",
"request",
".",
"data",
")",
"serializer",
".",
"is_valid",
"(",
"raise_exception",
... | Logs in the user via given login and password. | [
"Logs",
"in",
"the",
"user",
"via",
"given",
"login",
"and",
"password",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/login.py#L25-L39 |
246,961 | apragacz/django-rest-registration | rest_registration/api/views/login.py | logout | def logout(request):
'''
Logs out the user. returns an error if the user is not
authenticated.
'''
user = request.user
serializer = LogoutSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
data = serializer.validated_data
if should_authenticate_session():
... | python | def logout(request):
'''
Logs out the user. returns an error if the user is not
authenticated.
'''
user = request.user
serializer = LogoutSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
data = serializer.validated_data
if should_authenticate_session():
... | [
"def",
"logout",
"(",
"request",
")",
":",
"user",
"=",
"request",
".",
"user",
"serializer",
"=",
"LogoutSerializer",
"(",
"data",
"=",
"request",
".",
"data",
")",
"serializer",
".",
"is_valid",
"(",
"raise_exception",
"=",
"True",
")",
"data",
"=",
"s... | Logs out the user. returns an error if the user is not
authenticated. | [
"Logs",
"out",
"the",
"user",
".",
"returns",
"an",
"error",
"if",
"the",
"user",
"is",
"not",
"authenticated",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/login.py#L49-L67 |
246,962 | apragacz/django-rest-registration | rest_registration/utils/users.py | get_object_or_404 | def get_object_or_404(queryset, *filter_args, **filter_kwargs):
"""
Same as Django's standard shortcut, but make sure to also raise 404
if the filter_kwargs don't match the required types.
This function was copied from rest_framework.generics because of issue #36.
"""
try:
return _get_o... | python | def get_object_or_404(queryset, *filter_args, **filter_kwargs):
try:
return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
except (TypeError, ValueError, ValidationError):
raise Http404 | [
"def",
"get_object_or_404",
"(",
"queryset",
",",
"*",
"filter_args",
",",
"*",
"*",
"filter_kwargs",
")",
":",
"try",
":",
"return",
"_get_object_or_404",
"(",
"queryset",
",",
"*",
"filter_args",
",",
"*",
"*",
"filter_kwargs",
")",
"except",
"(",
"TypeErr... | Same as Django's standard shortcut, but make sure to also raise 404
if the filter_kwargs don't match the required types.
This function was copied from rest_framework.generics because of issue #36. | [
"Same",
"as",
"Django",
"s",
"standard",
"shortcut",
"but",
"make",
"sure",
"to",
"also",
"raise",
"404",
"if",
"the",
"filter_kwargs",
"don",
"t",
"match",
"the",
"required",
"types",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/utils/users.py#L13-L23 |
246,963 | apragacz/django-rest-registration | rest_registration/api/views/profile.py | profile | def profile(request):
'''
Get or set user profile.
'''
serializer_class = registration_settings.PROFILE_SERIALIZER_CLASS
if request.method in ['POST', 'PUT', 'PATCH']:
partial = request.method == 'PATCH'
serializer = serializer_class(
instance=request.user,
da... | python | def profile(request):
'''
Get or set user profile.
'''
serializer_class = registration_settings.PROFILE_SERIALIZER_CLASS
if request.method in ['POST', 'PUT', 'PATCH']:
partial = request.method == 'PATCH'
serializer = serializer_class(
instance=request.user,
da... | [
"def",
"profile",
"(",
"request",
")",
":",
"serializer_class",
"=",
"registration_settings",
".",
"PROFILE_SERIALIZER_CLASS",
"if",
"request",
".",
"method",
"in",
"[",
"'POST'",
",",
"'PUT'",
",",
"'PATCH'",
"]",
":",
"partial",
"=",
"request",
".",
"method"... | Get or set user profile. | [
"Get",
"or",
"set",
"user",
"profile",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/profile.py#L13-L30 |
246,964 | apragacz/django-rest-registration | rest_registration/api/views/register.py | register | def register(request):
'''
Register new user.
'''
serializer_class = registration_settings.REGISTER_SERIALIZER_CLASS
serializer = serializer_class(data=request.data)
serializer.is_valid(raise_exception=True)
kwargs = {}
if registration_settings.REGISTER_VERIFICATION_ENABLED:
ve... | python | def register(request):
'''
Register new user.
'''
serializer_class = registration_settings.REGISTER_SERIALIZER_CLASS
serializer = serializer_class(data=request.data)
serializer.is_valid(raise_exception=True)
kwargs = {}
if registration_settings.REGISTER_VERIFICATION_ENABLED:
ve... | [
"def",
"register",
"(",
"request",
")",
":",
"serializer_class",
"=",
"registration_settings",
".",
"REGISTER_SERIALIZER_CLASS",
"serializer",
"=",
"serializer_class",
"(",
"data",
"=",
"request",
".",
"data",
")",
"serializer",
".",
"is_valid",
"(",
"raise_exceptio... | Register new user. | [
"Register",
"new",
"user",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/register.py#L54-L86 |
246,965 | apragacz/django-rest-registration | rest_registration/api/views/register.py | verify_registration | def verify_registration(request):
"""
Verify registration via signature.
"""
user = process_verify_registration_data(request.data)
extra_data = None
if registration_settings.REGISTER_VERIFICATION_AUTO_LOGIN:
extra_data = perform_login(request, user)
return get_ok_response('User verif... | python | def verify_registration(request):
user = process_verify_registration_data(request.data)
extra_data = None
if registration_settings.REGISTER_VERIFICATION_AUTO_LOGIN:
extra_data = perform_login(request, user)
return get_ok_response('User verified successfully', extra_data=extra_data) | [
"def",
"verify_registration",
"(",
"request",
")",
":",
"user",
"=",
"process_verify_registration_data",
"(",
"request",
".",
"data",
")",
"extra_data",
"=",
"None",
"if",
"registration_settings",
".",
"REGISTER_VERIFICATION_AUTO_LOGIN",
":",
"extra_data",
"=",
"perfo... | Verify registration via signature. | [
"Verify",
"registration",
"via",
"signature",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/register.py#L98-L106 |
246,966 | apragacz/django-rest-registration | setup.py | get_requirements | def get_requirements(requirements_filepath):
'''
Return list of this package requirements via local filepath.
'''
requirements = []
with open(os.path.join(ROOT_DIR, requirements_filepath), 'rt') as f:
for line in f:
if line.startswith('#'):
continue
li... | python | def get_requirements(requirements_filepath):
'''
Return list of this package requirements via local filepath.
'''
requirements = []
with open(os.path.join(ROOT_DIR, requirements_filepath), 'rt') as f:
for line in f:
if line.startswith('#'):
continue
li... | [
"def",
"get_requirements",
"(",
"requirements_filepath",
")",
":",
"requirements",
"=",
"[",
"]",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"ROOT_DIR",
",",
"requirements_filepath",
")",
",",
"'rt'",
")",
"as",
"f",
":",
"for",
"line",
"i... | Return list of this package requirements via local filepath. | [
"Return",
"list",
"of",
"this",
"package",
"requirements",
"via",
"local",
"filepath",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/setup.py#L15-L28 |
246,967 | apragacz/django-rest-registration | rest_registration/api/views/reset_password.py | send_reset_password_link | def send_reset_password_link(request):
'''
Send email with reset password link.
'''
if not registration_settings.RESET_PASSWORD_VERIFICATION_ENABLED:
raise Http404()
serializer = SendResetPasswordLinkSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
login = seri... | python | def send_reset_password_link(request):
'''
Send email with reset password link.
'''
if not registration_settings.RESET_PASSWORD_VERIFICATION_ENABLED:
raise Http404()
serializer = SendResetPasswordLinkSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
login = seri... | [
"def",
"send_reset_password_link",
"(",
"request",
")",
":",
"if",
"not",
"registration_settings",
".",
"RESET_PASSWORD_VERIFICATION_ENABLED",
":",
"raise",
"Http404",
"(",
")",
"serializer",
"=",
"SendResetPasswordLinkSerializer",
"(",
"data",
"=",
"request",
".",
"d... | Send email with reset password link. | [
"Send",
"email",
"with",
"reset",
"password",
"link",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/reset_password.py#L61-L89 |
246,968 | apragacz/django-rest-registration | rest_registration/api/views/register_email.py | register_email | def register_email(request):
'''
Register new email.
'''
user = request.user
serializer = RegisterEmailSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
email = serializer.validated_data['email']
template_config = (
registration_settings.REGISTER_EMAIL_VE... | python | def register_email(request):
'''
Register new email.
'''
user = request.user
serializer = RegisterEmailSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
email = serializer.validated_data['email']
template_config = (
registration_settings.REGISTER_EMAIL_VE... | [
"def",
"register_email",
"(",
"request",
")",
":",
"user",
"=",
"request",
".",
"user",
"serializer",
"=",
"RegisterEmailSerializer",
"(",
"data",
"=",
"request",
".",
"data",
")",
"serializer",
".",
"is_valid",
"(",
"raise_exception",
"=",
"True",
")",
"ema... | Register new email. | [
"Register",
"new",
"email",
"."
] | 7373571264dd567c2a73a97ff4c45b64f113605b | https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/register_email.py#L33-L58 |
246,969 | nschloe/matplotlib2tikz | matplotlib2tikz/axes.py | _is_colorbar_heuristic | def _is_colorbar_heuristic(obj):
"""Find out if the object is in fact a color bar.
"""
# TODO come up with something more accurate here
# Might help:
# TODO Are the colorbars exactly the l.collections.PolyCollection's?
try:
aspect = float(obj.get_aspect())
except ValueError:
... | python | def _is_colorbar_heuristic(obj):
# TODO come up with something more accurate here
# Might help:
# TODO Are the colorbars exactly the l.collections.PolyCollection's?
try:
aspect = float(obj.get_aspect())
except ValueError:
# e.g., aspect == 'equal'
return False
# Assume t... | [
"def",
"_is_colorbar_heuristic",
"(",
"obj",
")",
":",
"# TODO come up with something more accurate here",
"# Might help:",
"# TODO Are the colorbars exactly the l.collections.PolyCollection's?",
"try",
":",
"aspect",
"=",
"float",
"(",
"obj",
".",
"get_aspect",
"(",
")",
")"... | Find out if the object is in fact a color bar. | [
"Find",
"out",
"if",
"the",
"object",
"is",
"in",
"fact",
"a",
"color",
"bar",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/axes.py#L582-L605 |
246,970 | nschloe/matplotlib2tikz | matplotlib2tikz/axes.py | _mpl_cmap2pgf_cmap | def _mpl_cmap2pgf_cmap(cmap, data):
"""Converts a color map as given in matplotlib to a color map as
represented in PGFPlots.
"""
if isinstance(cmap, mpl.colors.LinearSegmentedColormap):
return _handle_linear_segmented_color_map(cmap, data)
assert isinstance(
cmap, mpl.colors.Listed... | python | def _mpl_cmap2pgf_cmap(cmap, data):
if isinstance(cmap, mpl.colors.LinearSegmentedColormap):
return _handle_linear_segmented_color_map(cmap, data)
assert isinstance(
cmap, mpl.colors.ListedColormap
), "Only LinearSegmentedColormap and ListedColormap are supported"
return _handle_listed_... | [
"def",
"_mpl_cmap2pgf_cmap",
"(",
"cmap",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"cmap",
",",
"mpl",
".",
"colors",
".",
"LinearSegmentedColormap",
")",
":",
"return",
"_handle_linear_segmented_color_map",
"(",
"cmap",
",",
"data",
")",
"assert",
"isi... | Converts a color map as given in matplotlib to a color map as
represented in PGFPlots. | [
"Converts",
"a",
"color",
"map",
"as",
"given",
"in",
"matplotlib",
"to",
"a",
"color",
"map",
"as",
"represented",
"in",
"PGFPlots",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/axes.py#L608-L618 |
246,971 | nschloe/matplotlib2tikz | matplotlib2tikz/axes.py | _scale_to_int | def _scale_to_int(X, max_val=None):
"""
Scales the array X such that it contains only integers.
"""
if max_val is None:
X = X / _gcd_array(X)
else:
X = X / max(1 / max_val, _gcd_array(X))
return [int(entry) for entry in X] | python | def _scale_to_int(X, max_val=None):
if max_val is None:
X = X / _gcd_array(X)
else:
X = X / max(1 / max_val, _gcd_array(X))
return [int(entry) for entry in X] | [
"def",
"_scale_to_int",
"(",
"X",
",",
"max_val",
"=",
"None",
")",
":",
"if",
"max_val",
"is",
"None",
":",
"X",
"=",
"X",
"/",
"_gcd_array",
"(",
"X",
")",
"else",
":",
"X",
"=",
"X",
"/",
"max",
"(",
"1",
"/",
"max_val",
",",
"_gcd_array",
"... | Scales the array X such that it contains only integers. | [
"Scales",
"the",
"array",
"X",
"such",
"that",
"it",
"contains",
"only",
"integers",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/axes.py#L771-L780 |
246,972 | nschloe/matplotlib2tikz | matplotlib2tikz/axes.py | _gcd_array | def _gcd_array(X):
"""
Return the largest real value h such that all elements in x are integer
multiples of h.
"""
greatest_common_divisor = 0.0
for x in X:
greatest_common_divisor = _gcd(greatest_common_divisor, x)
return greatest_common_divisor | python | def _gcd_array(X):
greatest_common_divisor = 0.0
for x in X:
greatest_common_divisor = _gcd(greatest_common_divisor, x)
return greatest_common_divisor | [
"def",
"_gcd_array",
"(",
"X",
")",
":",
"greatest_common_divisor",
"=",
"0.0",
"for",
"x",
"in",
"X",
":",
"greatest_common_divisor",
"=",
"_gcd",
"(",
"greatest_common_divisor",
",",
"x",
")",
"return",
"greatest_common_divisor"
] | Return the largest real value h such that all elements in x are integer
multiples of h. | [
"Return",
"the",
"largest",
"real",
"value",
"h",
"such",
"that",
"all",
"elements",
"in",
"x",
"are",
"integer",
"multiples",
"of",
"h",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/axes.py#L783-L792 |
246,973 | nschloe/matplotlib2tikz | matplotlib2tikz/files.py | new_filename | def new_filename(data, file_kind, ext):
"""Returns an available filename.
:param file_kind: Name under which numbering is recorded, such as 'img' or
'table'.
:type file_kind: str
:param ext: Filename extension.
:type ext: str
:returns: (filename, rel_filepath) where file... | python | def new_filename(data, file_kind, ext):
nb_key = file_kind + "number"
if nb_key not in data.keys():
data[nb_key] = -1
if not data["override externals"]:
# Make sure not to overwrite anything.
file_exists = True
while file_exists:
data[nb_key] = data[nb_key] + 1
... | [
"def",
"new_filename",
"(",
"data",
",",
"file_kind",
",",
"ext",
")",
":",
"nb_key",
"=",
"file_kind",
"+",
"\"number\"",
"if",
"nb_key",
"not",
"in",
"data",
".",
"keys",
"(",
")",
":",
"data",
"[",
"nb_key",
"]",
"=",
"-",
"1",
"if",
"not",
"dat... | Returns an available filename.
:param file_kind: Name under which numbering is recorded, such as 'img' or
'table'.
:type file_kind: str
:param ext: Filename extension.
:type ext: str
:returns: (filename, rel_filepath) where filename is a path in the
filesystem ... | [
"Returns",
"an",
"available",
"filename",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/files.py#L12-L47 |
246,974 | nschloe/matplotlib2tikz | matplotlib2tikz/path.py | mpl_linestyle2pgfplots_linestyle | def mpl_linestyle2pgfplots_linestyle(line_style, line=None):
"""Translates a line style of matplotlib to the corresponding style
in PGFPlots.
"""
# linestyle is a string or dash tuple. Legal string values are
# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq) where onoffseq
# i... | python | def mpl_linestyle2pgfplots_linestyle(line_style, line=None):
# linestyle is a string or dash tuple. Legal string values are
# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq) where onoffseq
# is an even length tuple of on and off ink in points.
#
# solid: [(None, None), (None, None... | [
"def",
"mpl_linestyle2pgfplots_linestyle",
"(",
"line_style",
",",
"line",
"=",
"None",
")",
":",
"# linestyle is a string or dash tuple. Legal string values are",
"# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq) where onoffseq",
"# is an even length tuple of on and off ... | Translates a line style of matplotlib to the corresponding style
in PGFPlots. | [
"Translates",
"a",
"line",
"style",
"of",
"matplotlib",
"to",
"the",
"corresponding",
"style",
"in",
"PGFPlots",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/path.py#L296-L349 |
246,975 | nschloe/matplotlib2tikz | matplotlib2tikz/quadmesh.py | draw_quadmesh | def draw_quadmesh(data, obj):
"""Returns the PGFPlots code for an graphics environment holding a
rendering of the object.
"""
content = []
# Generate file name for current object
filename, rel_filepath = files.new_filename(data, "img", ".png")
# Get the dpi for rendering and store the o... | python | def draw_quadmesh(data, obj):
content = []
# Generate file name for current object
filename, rel_filepath = files.new_filename(data, "img", ".png")
# Get the dpi for rendering and store the original dpi of the figure
dpi = data["dpi"]
fig_dpi = obj.figure.get_dpi()
obj.figure.set_dpi(dpi)
... | [
"def",
"draw_quadmesh",
"(",
"data",
",",
"obj",
")",
":",
"content",
"=",
"[",
"]",
"# Generate file name for current object",
"filename",
",",
"rel_filepath",
"=",
"files",
".",
"new_filename",
"(",
"data",
",",
"\"img\"",
",",
"\".png\"",
")",
"# Get the dpi ... | Returns the PGFPlots code for an graphics environment holding a
rendering of the object. | [
"Returns",
"the",
"PGFPlots",
"code",
"for",
"an",
"graphics",
"environment",
"holding",
"a",
"rendering",
"of",
"the",
"object",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/quadmesh.py#L8-L66 |
246,976 | nschloe/matplotlib2tikz | matplotlib2tikz/color.py | mpl_color2xcolor | def mpl_color2xcolor(data, matplotlib_color):
"""Translates a matplotlib color specification into a proper LaTeX xcolor.
"""
# Convert it to RGBA.
my_col = numpy.array(mpl.colors.ColorConverter().to_rgba(matplotlib_color))
# If the alpha channel is exactly 0, then the color is really 'none'
# r... | python | def mpl_color2xcolor(data, matplotlib_color):
# Convert it to RGBA.
my_col = numpy.array(mpl.colors.ColorConverter().to_rgba(matplotlib_color))
# If the alpha channel is exactly 0, then the color is really 'none'
# regardless of the RGB channels.
if my_col[-1] == 0.0:
return data, "none", m... | [
"def",
"mpl_color2xcolor",
"(",
"data",
",",
"matplotlib_color",
")",
":",
"# Convert it to RGBA.",
"my_col",
"=",
"numpy",
".",
"array",
"(",
"mpl",
".",
"colors",
".",
"ColorConverter",
"(",
")",
".",
"to_rgba",
"(",
"matplotlib_color",
")",
")",
"# If the a... | Translates a matplotlib color specification into a proper LaTeX xcolor. | [
"Translates",
"a",
"matplotlib",
"color",
"specification",
"into",
"a",
"proper",
"LaTeX",
"xcolor",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/color.py#L9-L81 |
246,977 | nschloe/matplotlib2tikz | matplotlib2tikz/patch.py | draw_patch | def draw_patch(data, obj):
"""Return the PGFPlots code for patches.
"""
# Gather the draw options.
data, draw_options = mypath.get_draw_options(
data,
obj,
obj.get_edgecolor(),
obj.get_facecolor(),
obj.get_linestyle(),
obj.get_linewidth(),
)
if is... | python | def draw_patch(data, obj):
# Gather the draw options.
data, draw_options = mypath.get_draw_options(
data,
obj,
obj.get_edgecolor(),
obj.get_facecolor(),
obj.get_linestyle(),
obj.get_linewidth(),
)
if isinstance(obj, mpl.patches.Rectangle):
# recta... | [
"def",
"draw_patch",
"(",
"data",
",",
"obj",
")",
":",
"# Gather the draw options.",
"data",
",",
"draw_options",
"=",
"mypath",
".",
"get_draw_options",
"(",
"data",
",",
"obj",
",",
"obj",
".",
"get_edgecolor",
"(",
")",
",",
"obj",
".",
"get_facecolor",
... | Return the PGFPlots code for patches. | [
"Return",
"the",
"PGFPlots",
"code",
"for",
"patches",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/patch.py#L8-L32 |
246,978 | nschloe/matplotlib2tikz | matplotlib2tikz/patch.py | _draw_rectangle | def _draw_rectangle(data, obj, draw_options):
"""Return the PGFPlots code for rectangles.
"""
# Objects with labels are plot objects (from bar charts, etc). Even those without
# labels explicitly set have a label of "_nolegend_". Everything else should be
# skipped because they likely correspong t... | python | def _draw_rectangle(data, obj, draw_options):
# Objects with labels are plot objects (from bar charts, etc). Even those without
# labels explicitly set have a label of "_nolegend_". Everything else should be
# skipped because they likely correspong to axis/legend objects which are handled by
# PGFPlot... | [
"def",
"_draw_rectangle",
"(",
"data",
",",
"obj",
",",
"draw_options",
")",
":",
"# Objects with labels are plot objects (from bar charts, etc). Even those without",
"# labels explicitly set have a label of \"_nolegend_\". Everything else should be",
"# skipped because they likely corresp... | Return the PGFPlots code for rectangles. | [
"Return",
"the",
"PGFPlots",
"code",
"for",
"rectangles",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/patch.py#L91-L131 |
246,979 | nschloe/matplotlib2tikz | matplotlib2tikz/patch.py | _draw_ellipse | def _draw_ellipse(data, obj, draw_options):
"""Return the PGFPlots code for ellipses.
"""
if isinstance(obj, mpl.patches.Circle):
# circle specialization
return _draw_circle(data, obj, draw_options)
x, y = obj.center
ff = data["float format"]
if obj.angle != 0:
fmt = "ro... | python | def _draw_ellipse(data, obj, draw_options):
if isinstance(obj, mpl.patches.Circle):
# circle specialization
return _draw_circle(data, obj, draw_options)
x, y = obj.center
ff = data["float format"]
if obj.angle != 0:
fmt = "rotate around={{" + ff + ":(axis cs:" + ff + "," + ff + ... | [
"def",
"_draw_ellipse",
"(",
"data",
",",
"obj",
",",
"draw_options",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"mpl",
".",
"patches",
".",
"Circle",
")",
":",
"# circle specialization",
"return",
"_draw_circle",
"(",
"data",
",",
"obj",
",",
"draw_op... | Return the PGFPlots code for ellipses. | [
"Return",
"the",
"PGFPlots",
"code",
"for",
"ellipses",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/patch.py#L134-L158 |
246,980 | nschloe/matplotlib2tikz | matplotlib2tikz/patch.py | _draw_circle | def _draw_circle(data, obj, draw_options):
"""Return the PGFPlots code for circles.
"""
x, y = obj.center
ff = data["float format"]
cont = ("\\draw[{}] (axis cs:" + ff + "," + ff + ") circle (" + ff + ");\n").format(
",".join(draw_options), x, y, obj.get_radius()
)
return data, cont | python | def _draw_circle(data, obj, draw_options):
x, y = obj.center
ff = data["float format"]
cont = ("\\draw[{}] (axis cs:" + ff + "," + ff + ") circle (" + ff + ");\n").format(
",".join(draw_options), x, y, obj.get_radius()
)
return data, cont | [
"def",
"_draw_circle",
"(",
"data",
",",
"obj",
",",
"draw_options",
")",
":",
"x",
",",
"y",
"=",
"obj",
".",
"center",
"ff",
"=",
"data",
"[",
"\"float format\"",
"]",
"cont",
"=",
"(",
"\"\\\\draw[{}] (axis cs:\"",
"+",
"ff",
"+",
"\",\"",
"+",
"ff"... | Return the PGFPlots code for circles. | [
"Return",
"the",
"PGFPlots",
"code",
"for",
"circles",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/patch.py#L161-L169 |
246,981 | nschloe/matplotlib2tikz | matplotlib2tikz/image.py | draw_image | def draw_image(data, obj):
"""Returns the PGFPlots code for an image environment.
"""
content = []
filename, rel_filepath = files.new_filename(data, "img", ".png")
# store the image as in a file
img_array = obj.get_array()
dims = img_array.shape
if len(dims) == 2: # the values are gi... | python | def draw_image(data, obj):
content = []
filename, rel_filepath = files.new_filename(data, "img", ".png")
# store the image as in a file
img_array = obj.get_array()
dims = img_array.shape
if len(dims) == 2: # the values are given as one real number: look at cmap
clims = obj.get_clim()... | [
"def",
"draw_image",
"(",
"data",
",",
"obj",
")",
":",
"content",
"=",
"[",
"]",
"filename",
",",
"rel_filepath",
"=",
"files",
".",
"new_filename",
"(",
"data",
",",
"\"img\"",
",",
"\".png\"",
")",
"# store the image as in a file",
"img_array",
"=",
"obj"... | Returns the PGFPlots code for an image environment. | [
"Returns",
"the",
"PGFPlots",
"code",
"for",
"an",
"image",
"environment",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/image.py#L10-L64 |
246,982 | nschloe/matplotlib2tikz | matplotlib2tikz/util.py | get_legend_text | def get_legend_text(obj):
"""Check if line is in legend.
"""
leg = obj.axes.get_legend()
if leg is None:
return None
keys = [l.get_label() for l in leg.legendHandles if l is not None]
values = [l.get_text() for l in leg.texts]
label = obj.get_label()
d = dict(zip(keys, values))... | python | def get_legend_text(obj):
leg = obj.axes.get_legend()
if leg is None:
return None
keys = [l.get_label() for l in leg.legendHandles if l is not None]
values = [l.get_text() for l in leg.texts]
label = obj.get_label()
d = dict(zip(keys, values))
if label in d:
return d[label]... | [
"def",
"get_legend_text",
"(",
"obj",
")",
":",
"leg",
"=",
"obj",
".",
"axes",
".",
"get_legend",
"(",
")",
"if",
"leg",
"is",
"None",
":",
"return",
"None",
"keys",
"=",
"[",
"l",
".",
"get_label",
"(",
")",
"for",
"l",
"in",
"leg",
".",
"legen... | Check if line is in legend. | [
"Check",
"if",
"line",
"is",
"in",
"legend",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/util.py#L11-L26 |
246,983 | nschloe/matplotlib2tikz | matplotlib2tikz/save.py | _get_color_definitions | def _get_color_definitions(data):
"""Returns the list of custom color definitions for the TikZ file.
"""
definitions = []
fmt = "\\definecolor{{{}}}{{rgb}}{{" + ",".join(3 * [data["float format"]]) + "}}"
for name, rgb in data["custom colors"].items():
definitions.append(fmt.format(name, rgb... | python | def _get_color_definitions(data):
definitions = []
fmt = "\\definecolor{{{}}}{{rgb}}{{" + ",".join(3 * [data["float format"]]) + "}}"
for name, rgb in data["custom colors"].items():
definitions.append(fmt.format(name, rgb[0], rgb[1], rgb[2]))
return definitions | [
"def",
"_get_color_definitions",
"(",
"data",
")",
":",
"definitions",
"=",
"[",
"]",
"fmt",
"=",
"\"\\\\definecolor{{{}}}{{rgb}}{{\"",
"+",
"\",\"",
".",
"join",
"(",
"3",
"*",
"[",
"data",
"[",
"\"float format\"",
"]",
"]",
")",
"+",
"\"}}\"",
"for",
"na... | Returns the list of custom color definitions for the TikZ file. | [
"Returns",
"the",
"list",
"of",
"custom",
"color",
"definitions",
"for",
"the",
"TikZ",
"file",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/save.py#L283-L290 |
246,984 | nschloe/matplotlib2tikz | matplotlib2tikz/save.py | _print_pgfplot_libs_message | def _print_pgfplot_libs_message(data):
"""Prints message to screen indicating the use of PGFPlots and its
libraries."""
pgfplotslibs = ",".join(list(data["pgfplots libs"]))
tikzlibs = ",".join(list(data["tikz libs"]))
print(70 * "=")
print("Please add the following lines to your LaTeX preamble:... | python | def _print_pgfplot_libs_message(data):
pgfplotslibs = ",".join(list(data["pgfplots libs"]))
tikzlibs = ",".join(list(data["tikz libs"]))
print(70 * "=")
print("Please add the following lines to your LaTeX preamble:\n")
print("\\usepackage[utf8]{inputenc}")
print("\\usepackage{fontspec} % This ... | [
"def",
"_print_pgfplot_libs_message",
"(",
"data",
")",
":",
"pgfplotslibs",
"=",
"\",\"",
".",
"join",
"(",
"list",
"(",
"data",
"[",
"\"pgfplots libs\"",
"]",
")",
")",
"tikzlibs",
"=",
"\",\"",
".",
"join",
"(",
"list",
"(",
"data",
"[",
"\"tikz libs\""... | Prints message to screen indicating the use of PGFPlots and its
libraries. | [
"Prints",
"message",
"to",
"screen",
"indicating",
"the",
"use",
"of",
"PGFPlots",
"and",
"its",
"libraries",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/save.py#L293-L309 |
246,985 | nschloe/matplotlib2tikz | matplotlib2tikz/save.py | _ContentManager.extend | def extend(self, content, zorder):
""" Extends with a list and a z-order
"""
if zorder not in self._content:
self._content[zorder] = []
self._content[zorder].extend(content) | python | def extend(self, content, zorder):
if zorder not in self._content:
self._content[zorder] = []
self._content[zorder].extend(content) | [
"def",
"extend",
"(",
"self",
",",
"content",
",",
"zorder",
")",
":",
"if",
"zorder",
"not",
"in",
"self",
".",
"_content",
":",
"self",
".",
"_content",
"[",
"zorder",
"]",
"=",
"[",
"]",
"self",
".",
"_content",
"[",
"zorder",
"]",
".",
"extend"... | Extends with a list and a z-order | [
"Extends",
"with",
"a",
"list",
"and",
"a",
"z",
"-",
"order"
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/save.py#L322-L327 |
246,986 | nschloe/matplotlib2tikz | matplotlib2tikz/line2d.py | draw_line2d | def draw_line2d(data, obj):
"""Returns the PGFPlots code for an Line2D environment.
"""
content = []
addplot_options = []
# If line is of length 0, do nothing. Otherwise, an empty \addplot table will be
# created, which will be interpreted as an external data source in either the file
# ''... | python | def draw_line2d(data, obj):
content = []
addplot_options = []
# If line is of length 0, do nothing. Otherwise, an empty \addplot table will be
# created, which will be interpreted as an external data source in either the file
# '' or '.tex'. Instead, render nothing.
if len(obj.get_xdata()) ==... | [
"def",
"draw_line2d",
"(",
"data",
",",
"obj",
")",
":",
"content",
"=",
"[",
"]",
"addplot_options",
"=",
"[",
"]",
"# If line is of length 0, do nothing. Otherwise, an empty \\addplot table will be",
"# created, which will be interpreted as an external data source in either the ... | Returns the PGFPlots code for an Line2D environment. | [
"Returns",
"the",
"PGFPlots",
"code",
"for",
"an",
"Line2D",
"environment",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/line2d.py#L18-L85 |
246,987 | nschloe/matplotlib2tikz | matplotlib2tikz/line2d.py | draw_linecollection | def draw_linecollection(data, obj):
"""Returns Pgfplots code for a number of patch objects.
"""
content = []
edgecolors = obj.get_edgecolors()
linestyles = obj.get_linestyles()
linewidths = obj.get_linewidths()
paths = obj.get_paths()
for i, path in enumerate(paths):
color = ed... | python | def draw_linecollection(data, obj):
content = []
edgecolors = obj.get_edgecolors()
linestyles = obj.get_linestyles()
linewidths = obj.get_linewidths()
paths = obj.get_paths()
for i, path in enumerate(paths):
color = edgecolors[i] if i < len(edgecolors) else edgecolors[0]
style ... | [
"def",
"draw_linecollection",
"(",
"data",
",",
"obj",
")",
":",
"content",
"=",
"[",
"]",
"edgecolors",
"=",
"obj",
".",
"get_edgecolors",
"(",
")",
"linestyles",
"=",
"obj",
".",
"get_linestyles",
"(",
")",
"linewidths",
"=",
"obj",
".",
"get_linewidths"... | Returns Pgfplots code for a number of patch objects. | [
"Returns",
"Pgfplots",
"code",
"for",
"a",
"number",
"of",
"patch",
"objects",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/line2d.py#L88-L111 |
246,988 | nschloe/matplotlib2tikz | matplotlib2tikz/line2d.py | _mpl_marker2pgfp_marker | def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color):
"""Translates a marker style of matplotlib to the corresponding style
in PGFPlots.
"""
# try default list
try:
pgfplots_marker = _MP_MARKER2PGF_MARKER[mpl_marker]
except KeyError:
pass
else:
if (marker_... | python | def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color):
# try default list
try:
pgfplots_marker = _MP_MARKER2PGF_MARKER[mpl_marker]
except KeyError:
pass
else:
if (marker_face_color is not None) and pgfplots_marker == "o":
pgfplots_marker = "*"
d... | [
"def",
"_mpl_marker2pgfp_marker",
"(",
"data",
",",
"mpl_marker",
",",
"marker_face_color",
")",
":",
"# try default list",
"try",
":",
"pgfplots_marker",
"=",
"_MP_MARKER2PGF_MARKER",
"[",
"mpl_marker",
"]",
"except",
"KeyError",
":",
"pass",
"else",
":",
"if",
"... | Translates a marker style of matplotlib to the corresponding style
in PGFPlots. | [
"Translates",
"a",
"marker",
"style",
"of",
"matplotlib",
"to",
"the",
"corresponding",
"style",
"in",
"PGFPlots",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/line2d.py#L147-L182 |
246,989 | nschloe/matplotlib2tikz | matplotlib2tikz/text.py | draw_text | def draw_text(data, obj):
"""Paints text on the graph.
"""
content = []
properties = []
style = []
if isinstance(obj, mpl.text.Annotation):
_annotation(obj, data, content)
# 1: coordinates
# 2: properties (shapes, rotation, etc)
# 3: text style
# 4: the text
# ... | python | def draw_text(data, obj):
content = []
properties = []
style = []
if isinstance(obj, mpl.text.Annotation):
_annotation(obj, data, content)
# 1: coordinates
# 2: properties (shapes, rotation, etc)
# 3: text style
# 4: the text
# -------1--------2---3--4--
... | [
"def",
"draw_text",
"(",
"data",
",",
"obj",
")",
":",
"content",
"=",
"[",
"]",
"properties",
"=",
"[",
"]",
"style",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"obj",
",",
"mpl",
".",
"text",
".",
"Annotation",
")",
":",
"_annotation",
"(",
"obj",
... | Paints text on the graph. | [
"Paints",
"text",
"on",
"the",
"graph",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/text.py#L8-L126 |
246,990 | nschloe/matplotlib2tikz | matplotlib2tikz/text.py | _transform_positioning | def _transform_positioning(ha, va):
"""Converts matplotlib positioning to pgf node positioning.
Not quite accurate but the results are equivalent more or less."""
if ha == "center" and va == "center":
return None
ha_mpl_to_tikz = {"right": "east", "left": "west", "center": ""}
va_mpl_to_tik... | python | def _transform_positioning(ha, va):
if ha == "center" and va == "center":
return None
ha_mpl_to_tikz = {"right": "east", "left": "west", "center": ""}
va_mpl_to_tikz = {
"top": "north",
"bottom": "south",
"center": "",
"baseline": "base",
}
return "anchor={} ... | [
"def",
"_transform_positioning",
"(",
"ha",
",",
"va",
")",
":",
"if",
"ha",
"==",
"\"center\"",
"and",
"va",
"==",
"\"center\"",
":",
"return",
"None",
"ha_mpl_to_tikz",
"=",
"{",
"\"right\"",
":",
"\"east\"",
",",
"\"left\"",
":",
"\"west\"",
",",
"\"cen... | Converts matplotlib positioning to pgf node positioning.
Not quite accurate but the results are equivalent more or less. | [
"Converts",
"matplotlib",
"positioning",
"to",
"pgf",
"node",
"positioning",
".",
"Not",
"quite",
"accurate",
"but",
"the",
"results",
"are",
"equivalent",
"more",
"or",
"less",
"."
] | ac5daca6f38b834d757f6c6ae6cc34121956f46b | https://github.com/nschloe/matplotlib2tikz/blob/ac5daca6f38b834d757f6c6ae6cc34121956f46b/matplotlib2tikz/text.py#L129-L142 |
246,991 | turicas/rows | rows/plugins/plugin_json.py | import_from_json | def import_from_json(filename_or_fobj, encoding="utf-8", *args, **kwargs):
"""Import a JSON file or file-like object into a `rows.Table`.
If a file-like object is provided it MUST be open in text (non-binary) mode
on Python 3 and could be open in both binary or text mode on Python 2.
"""
source = ... | python | def import_from_json(filename_or_fobj, encoding="utf-8", *args, **kwargs):
source = Source.from_file(filename_or_fobj, mode="rb", plugin_name="json", encoding=encoding)
json_obj = json.load(source.fobj, encoding=source.encoding)
field_names = list(json_obj[0].keys())
table_rows = [[item[key] for key in... | [
"def",
"import_from_json",
"(",
"filename_or_fobj",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"source",
"=",
"Source",
".",
"from_file",
"(",
"filename_or_fobj",
",",
"mode",
"=",
"\"rb\"",
",",
"plugin_name",
... | Import a JSON file or file-like object into a `rows.Table`.
If a file-like object is provided it MUST be open in text (non-binary) mode
on Python 3 and could be open in both binary or text mode on Python 2. | [
"Import",
"a",
"JSON",
"file",
"or",
"file",
"-",
"like",
"object",
"into",
"a",
"rows",
".",
"Table",
"."
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/plugins/plugin_json.py#L33-L47 |
246,992 | turicas/rows | rows/plugins/plugin_json.py | export_to_json | def export_to_json(
table, filename_or_fobj=None, encoding="utf-8", indent=None, *args, **kwargs
):
"""Export a `rows.Table` to a JSON file or file-like object.
If a file-like object is provided it MUST be open in binary mode (like in
`open('myfile.json', mode='wb')`).
"""
# TODO: will work onl... | python | def export_to_json(
table, filename_or_fobj=None, encoding="utf-8", indent=None, *args, **kwargs
):
# TODO: will work only if table.fields is OrderedDict
fields = table.fields
prepared_table = prepare_to_export(table, *args, **kwargs)
field_names = next(prepared_table)
data = [
{
... | [
"def",
"export_to_json",
"(",
"table",
",",
"filename_or_fobj",
"=",
"None",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"indent",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: will work only if table.fields is OrderedDict",
"fields",
"=... | Export a `rows.Table` to a JSON file or file-like object.
If a file-like object is provided it MUST be open in binary mode (like in
`open('myfile.json', mode='wb')`). | [
"Export",
"a",
"rows",
".",
"Table",
"to",
"a",
"JSON",
"file",
"or",
"file",
"-",
"like",
"object",
"."
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/plugins/plugin_json.py#L68-L97 |
246,993 | turicas/rows | rows/utils.py | plugin_name_by_uri | def plugin_name_by_uri(uri):
"Return the plugin name based on the URI"
# TODO: parse URIs like 'sqlite://' also
parsed = urlparse(uri)
basename = os.path.basename(parsed.path)
if not basename.strip():
raise RuntimeError("Could not identify file format.")
plugin_name = basename.split("... | python | def plugin_name_by_uri(uri):
"Return the plugin name based on the URI"
# TODO: parse URIs like 'sqlite://' also
parsed = urlparse(uri)
basename = os.path.basename(parsed.path)
if not basename.strip():
raise RuntimeError("Could not identify file format.")
plugin_name = basename.split("... | [
"def",
"plugin_name_by_uri",
"(",
"uri",
")",
":",
"# TODO: parse URIs like 'sqlite://' also",
"parsed",
"=",
"urlparse",
"(",
"uri",
")",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"parsed",
".",
"path",
")",
"if",
"not",
"basename",
".",
"st... | Return the plugin name based on the URI | [
"Return",
"the",
"plugin",
"name",
"based",
"on",
"the",
"URI"
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L249-L263 |
246,994 | turicas/rows | rows/utils.py | extension_by_source | def extension_by_source(source, mime_type):
"Return the file extension used by this plugin"
# TODO: should get this information from the plugin
extension = source.plugin_name
if extension:
return extension
if mime_type:
return mime_type.split("/")[-1] | python | def extension_by_source(source, mime_type):
"Return the file extension used by this plugin"
# TODO: should get this information from the plugin
extension = source.plugin_name
if extension:
return extension
if mime_type:
return mime_type.split("/")[-1] | [
"def",
"extension_by_source",
"(",
"source",
",",
"mime_type",
")",
":",
"# TODO: should get this information from the plugin",
"extension",
"=",
"source",
".",
"plugin_name",
"if",
"extension",
":",
"return",
"extension",
"if",
"mime_type",
":",
"return",
"mime_type",
... | Return the file extension used by this plugin | [
"Return",
"the",
"file",
"extension",
"used",
"by",
"this",
"plugin"
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L266-L275 |
246,995 | turicas/rows | rows/utils.py | plugin_name_by_mime_type | def plugin_name_by_mime_type(mime_type, mime_name, file_extension):
"Return the plugin name based on the MIME type"
return MIME_TYPE_TO_PLUGIN_NAME.get(
normalize_mime_type(mime_type, mime_name, file_extension), None
) | python | def plugin_name_by_mime_type(mime_type, mime_name, file_extension):
"Return the plugin name based on the MIME type"
return MIME_TYPE_TO_PLUGIN_NAME.get(
normalize_mime_type(mime_type, mime_name, file_extension), None
) | [
"def",
"plugin_name_by_mime_type",
"(",
"mime_type",
",",
"mime_name",
",",
"file_extension",
")",
":",
"return",
"MIME_TYPE_TO_PLUGIN_NAME",
".",
"get",
"(",
"normalize_mime_type",
"(",
"mime_type",
",",
"mime_name",
",",
"file_extension",
")",
",",
"None",
")"
] | Return the plugin name based on the MIME type | [
"Return",
"the",
"plugin",
"name",
"based",
"on",
"the",
"MIME",
"type"
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L297-L302 |
246,996 | turicas/rows | rows/utils.py | detect_source | def detect_source(uri, verify_ssl, progress, timeout=5):
"""Return a `rows.Source` with information for a given URI
If URI starts with "http" or "https" the file will be downloaded.
This function should only be used if the URI already exists because it's
going to download/open the file to detect its e... | python | def detect_source(uri, verify_ssl, progress, timeout=5):
# TODO: should also supporte other schemes, like file://, sqlite:// etc.
if uri.lower().startswith("http://") or uri.lower().startswith("https://"):
return download_file(
uri, verify_ssl=verify_ssl, timeout=timeout, progress=progress,... | [
"def",
"detect_source",
"(",
"uri",
",",
"verify_ssl",
",",
"progress",
",",
"timeout",
"=",
"5",
")",
":",
"# TODO: should also supporte other schemes, like file://, sqlite:// etc.",
"if",
"uri",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"\"http://\"",
")",
... | Return a `rows.Source` with information for a given URI
If URI starts with "http" or "https" the file will be downloaded.
This function should only be used if the URI already exists because it's
going to download/open the file to detect its encoding and MIME type. | [
"Return",
"a",
"rows",
".",
"Source",
"with",
"information",
"for",
"a",
"given",
"URI"
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L439-L465 |
246,997 | turicas/rows | rows/utils.py | import_from_source | def import_from_source(source, default_encoding, *args, **kwargs):
"Import data described in a `rows.Source` into a `rows.Table`"
# TODO: test open_compressed
plugin_name = source.plugin_name
kwargs["encoding"] = (
kwargs.get("encoding", None) or source.encoding or default_encoding
)
t... | python | def import_from_source(source, default_encoding, *args, **kwargs):
"Import data described in a `rows.Source` into a `rows.Table`"
# TODO: test open_compressed
plugin_name = source.plugin_name
kwargs["encoding"] = (
kwargs.get("encoding", None) or source.encoding or default_encoding
)
t... | [
"def",
"import_from_source",
"(",
"source",
",",
"default_encoding",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: test open_compressed",
"plugin_name",
"=",
"source",
".",
"plugin_name",
"kwargs",
"[",
"\"encoding\"",
"]",
"=",
"(",
"kwargs",
... | Import data described in a `rows.Source` into a `rows.Table` | [
"Import",
"data",
"described",
"in",
"a",
"rows",
".",
"Source",
"into",
"a",
"rows",
".",
"Table"
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L468-L484 |
246,998 | turicas/rows | rows/utils.py | import_from_uri | def import_from_uri(
uri, default_encoding="utf-8", verify_ssl=True, progress=False, *args, **kwargs
):
"Given an URI, detects plugin and encoding and imports into a `rows.Table`"
# TODO: support '-' also
# TODO: (optimization) if `kwargs.get('encoding', None) is not None` we can
# skip encod... | python | def import_from_uri(
uri, default_encoding="utf-8", verify_ssl=True, progress=False, *args, **kwargs
):
"Given an URI, detects plugin and encoding and imports into a `rows.Table`"
# TODO: support '-' also
# TODO: (optimization) if `kwargs.get('encoding', None) is not None` we can
# skip encod... | [
"def",
"import_from_uri",
"(",
"uri",
",",
"default_encoding",
"=",
"\"utf-8\"",
",",
"verify_ssl",
"=",
"True",
",",
"progress",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: support '-' also",
"# TODO: (optimization) if `kwargs.get(... | Given an URI, detects plugin and encoding and imports into a `rows.Table` | [
"Given",
"an",
"URI",
"detects",
"plugin",
"and",
"encoding",
"and",
"imports",
"into",
"a",
"rows",
".",
"Table"
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L487-L496 |
246,999 | turicas/rows | rows/utils.py | open_compressed | def open_compressed(filename, mode="r", encoding=None):
"Return a text-based file object from a filename, even if compressed"
# TODO: integrate this function in the library itself, using
# get_filename_and_fobj
binary_mode = "b" in mode
extension = str(filename).split(".")[-1].lower()
if binary... | python | def open_compressed(filename, mode="r", encoding=None):
"Return a text-based file object from a filename, even if compressed"
# TODO: integrate this function in the library itself, using
# get_filename_and_fobj
binary_mode = "b" in mode
extension = str(filename).split(".")[-1].lower()
if binary... | [
"def",
"open_compressed",
"(",
"filename",
",",
"mode",
"=",
"\"r\"",
",",
"encoding",
"=",
"None",
")",
":",
"# TODO: integrate this function in the library itself, using",
"# get_filename_and_fobj",
"binary_mode",
"=",
"\"b\"",
"in",
"mode",
"extension",
"=",
"str",
... | Return a text-based file object from a filename, even if compressed | [
"Return",
"a",
"text",
"-",
"based",
"file",
"object",
"from",
"a",
"filename",
"even",
"if",
"compressed"
] | c74da41ae9ed091356b803a64f8a30c641c5fc45 | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L513-L557 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.