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
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
233,100
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): """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...
[ "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
233,101
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): """Make the SchemaElement's connections immutable.""" 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
233,102
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): """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...
[ "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
233,103
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): """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...
[ "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
233,104
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): """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...
[ "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
233,105
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): """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...
[ "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
233,106
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): """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...
[ "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
233,107
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): """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...
[ "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
233,108
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): """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 ...
[ "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
233,109
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): """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...
[ "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
233,110
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): """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...
[ "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
233,111
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): """Return a PropertyDescriptor corresponding to the given OrientDB property definition.""" name = property_definition['name'] type...
[ "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
233,112
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 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 ...
[ "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
233,113
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): """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...
[ "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
233,114
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): """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...
[ "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
233,115
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): """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 ...
[ "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
233,116
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): """Return a MATCH query where only preferred locations are valid as query start locations.""" preferred_location_types = dict() eligible_locatio...
[ "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
233,117
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): """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_...
[ "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
233,118
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): """Ensure that OrientDB only considers desirable query start points in query planning.""" new_queries = [] for match_query in compound_match_query.match_quer...
[ "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
233,119
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): """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...
[ "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
233,120
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): """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...
[ "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
233,121
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): """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...
[ "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
233,122
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): """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...
[ "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
233,123
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): """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: ...
[ "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
233,124
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): """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...
[ "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
233,125
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): """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...
[ "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
233,126
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): """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...
[ "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
233,127
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): """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...
[ "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
233,128
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): """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): ...
[ "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
233,129
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): """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))
[ "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
233,130
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): """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))
[ "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
233,131
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): """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'...
[ "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
233,132
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): """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...
[ "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
233,133
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): """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...
[ "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
233,134
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): """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 ...
[ "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
233,135
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): """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...
[ "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
233,136
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): """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...
[ "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
233,137
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): """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: ...
[ "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
233,138
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): """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...
[ "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
233,139
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): """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 ...
[ "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
233,140
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): """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...
[ "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
233,141
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): """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...
[ "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
233,142
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): """Construct a GraphQL schema from an OrientDB schema. Args: schema_data: list of dicts describing the classes in the OrientDB schema....
[ "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
233,143
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): """ 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 ...
[ "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
233,144
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
233,145
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
233,146
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): """ 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...
[ "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
233,147
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
233,148
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
233,149
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): """ 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...
[ "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
233,150
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
233,151
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
233,152
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
233,153
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): """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: ...
[ "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
233,154
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): """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...
[ "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
233,155
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): """ 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]
[ "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
233,156
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): """ 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
[ "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
233,157
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): """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...
[ "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
233,158
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): """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...
[ "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
233,159
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): """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...
[ "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
233,160
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): """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...
[ "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
233,161
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): """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...
[ "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
233,162
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): """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...
[ "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
233,163
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): """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...
[ "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
233,164
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): """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
[ "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
233,165
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): """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...
[ "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
233,166
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): """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))...
[ "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
233,167
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): """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...
[ "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
233,168
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): """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:...
[ "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
233,169
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): """ Extends with a list and a z-order """ 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
233,170
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): """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 # ''...
[ "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
233,171
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): """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...
[ "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
233,172
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): """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_...
[ "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
233,173
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): """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 # ...
[ "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
233,174
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): """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...
[ "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
233,175
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): """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 = ...
[ "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
233,176
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 ): """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...
[ "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
233,177
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
233,178
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
233,179
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
233,180
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): """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...
[ "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
233,181
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
233,182
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
233,183
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
233,184
turicas/rows
rows/utils.py
csv_to_sqlite
def csv_to_sqlite( input_filename, output_filename, samples=None, dialect=None, batch_size=10000, encoding="utf-8", callback=None, force_types=None, chunk_size=8388608, table_name="table1", schema=None, ): "Export a CSV file to SQLite, based on field type detection from s...
python
def csv_to_sqlite( input_filename, output_filename, samples=None, dialect=None, batch_size=10000, encoding="utf-8", callback=None, force_types=None, chunk_size=8388608, table_name="table1", schema=None, ): "Export a CSV file to SQLite, based on field type detection from s...
[ "def", "csv_to_sqlite", "(", "input_filename", ",", "output_filename", ",", "samples", "=", "None", ",", "dialect", "=", "None", ",", "batch_size", "=", "10000", ",", "encoding", "=", "\"utf-8\"", ",", "callback", "=", "None", ",", "force_types", "=", "None"...
Export a CSV file to SQLite, based on field type detection from samples
[ "Export", "a", "CSV", "file", "to", "SQLite", "based", "on", "field", "type", "detection", "from", "samples" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L560-L613
233,185
turicas/rows
rows/utils.py
sqlite_to_csv
def sqlite_to_csv( input_filename, table_name, output_filename, dialect=csv.excel, batch_size=10000, encoding="utf-8", callback=None, query=None, ): """Export a table inside a SQLite database to CSV""" # TODO: should be able to specify fields # TODO: should be able to specif...
python
def sqlite_to_csv( input_filename, table_name, output_filename, dialect=csv.excel, batch_size=10000, encoding="utf-8", callback=None, query=None, ): """Export a table inside a SQLite database to CSV""" # TODO: should be able to specify fields # TODO: should be able to specif...
[ "def", "sqlite_to_csv", "(", "input_filename", ",", "table_name", ",", "output_filename", ",", "dialect", "=", "csv", ".", "excel", ",", "batch_size", "=", "10000", ",", "encoding", "=", "\"utf-8\"", ",", "callback", "=", "None", ",", "query", "=", "None", ...
Export a table inside a SQLite database to CSV
[ "Export", "a", "table", "inside", "a", "SQLite", "database", "to", "CSV" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L616-L650
233,186
turicas/rows
rows/utils.py
execute_command
def execute_command(command): """Execute a command and return its output""" command = shlex.split(command) try: process = subprocess.Popen( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) except FileNotFou...
python
def execute_command(command): """Execute a command and return its output""" command = shlex.split(command) try: process = subprocess.Popen( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) except FileNotFou...
[ "def", "execute_command", "(", "command", ")", ":", "command", "=", "shlex", ".", "split", "(", "command", ")", "try", ":", "process", "=", "subprocess", ".", "Popen", "(", "command", ",", "stdin", "=", "subprocess", ".", "PIPE", ",", "stdout", "=", "s...
Execute a command and return its output
[ "Execute", "a", "command", "and", "return", "its", "output" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L706-L724
233,187
turicas/rows
rows/utils.py
uncompressed_size
def uncompressed_size(filename): """Return the uncompressed size for a file by executing commands Note: due to a limitation in gzip format, uncompressed files greather than 4GiB will have a wrong value. """ quoted_filename = shlex.quote(filename) # TODO: get filetype from file-magic, if avail...
python
def uncompressed_size(filename): """Return the uncompressed size for a file by executing commands Note: due to a limitation in gzip format, uncompressed files greather than 4GiB will have a wrong value. """ quoted_filename = shlex.quote(filename) # TODO: get filetype from file-magic, if avail...
[ "def", "uncompressed_size", "(", "filename", ")", ":", "quoted_filename", "=", "shlex", ".", "quote", "(", "filename", ")", "# TODO: get filetype from file-magic, if available", "if", "str", "(", "filename", ")", ".", "lower", "(", ")", ".", "endswith", "(", "\"...
Return the uncompressed size for a file by executing commands Note: due to a limitation in gzip format, uncompressed files greather than 4GiB will have a wrong value.
[ "Return", "the", "uncompressed", "size", "for", "a", "file", "by", "executing", "commands" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L727-L755
233,188
turicas/rows
rows/utils.py
pgimport
def pgimport( filename, database_uri, table_name, encoding="utf-8", dialect=None, create_table=True, schema=None, callback=None, timeout=0.1, chunk_size=8388608, max_samples=10000, ): """Import data from CSV into PostgreSQL using the fastest method Required: psql com...
python
def pgimport( filename, database_uri, table_name, encoding="utf-8", dialect=None, create_table=True, schema=None, callback=None, timeout=0.1, chunk_size=8388608, max_samples=10000, ): """Import data from CSV into PostgreSQL using the fastest method Required: psql com...
[ "def", "pgimport", "(", "filename", ",", "database_uri", ",", "table_name", ",", "encoding", "=", "\"utf-8\"", ",", "dialect", "=", "None", ",", "create_table", "=", "True", ",", "schema", "=", "None", ",", "callback", "=", "None", ",", "timeout", "=", "...
Import data from CSV into PostgreSQL using the fastest method Required: psql command
[ "Import", "data", "from", "CSV", "into", "PostgreSQL", "using", "the", "fastest", "method" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L831-L924
233,189
turicas/rows
rows/utils.py
pgexport
def pgexport( database_uri, table_name, filename, encoding="utf-8", dialect=csv.excel, callback=None, timeout=0.1, chunk_size=8388608, ): """Export data from PostgreSQL into a CSV file using the fastest method Required: psql command """ if isinstance(dialect, six.text_t...
python
def pgexport( database_uri, table_name, filename, encoding="utf-8", dialect=csv.excel, callback=None, timeout=0.1, chunk_size=8388608, ): """Export data from PostgreSQL into a CSV file using the fastest method Required: psql command """ if isinstance(dialect, six.text_t...
[ "def", "pgexport", "(", "database_uri", ",", "table_name", ",", "filename", ",", "encoding", "=", "\"utf-8\"", ",", "dialect", "=", "csv", ".", "excel", ",", "callback", "=", "None", ",", "timeout", "=", "0.1", ",", "chunk_size", "=", "8388608", ",", ")"...
Export data from PostgreSQL into a CSV file using the fastest method Required: psql command
[ "Export", "data", "from", "PostgreSQL", "into", "a", "CSV", "file", "using", "the", "fastest", "method" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L927-L980
233,190
turicas/rows
rows/utils.py
load_schema
def load_schema(filename, context=None): """Load schema from file in any of the supported formats The table must have at least the fields `field_name` and `field_type`. `context` is a `dict` with field_type as key pointing to field class, like: {"text": rows.fields.TextField, "value": MyCustomField...
python
def load_schema(filename, context=None): """Load schema from file in any of the supported formats The table must have at least the fields `field_name` and `field_type`. `context` is a `dict` with field_type as key pointing to field class, like: {"text": rows.fields.TextField, "value": MyCustomField...
[ "def", "load_schema", "(", "filename", ",", "context", "=", "None", ")", ":", "table", "=", "import_from_uri", "(", "filename", ")", "field_names", "=", "table", ".", "field_names", "assert", "\"field_name\"", "in", "field_names", "assert", "\"field_type\"", "in...
Load schema from file in any of the supported formats The table must have at least the fields `field_name` and `field_type`. `context` is a `dict` with field_type as key pointing to field class, like: {"text": rows.fields.TextField, "value": MyCustomField}
[ "Load", "schema", "from", "file", "in", "any", "of", "the", "supported", "formats" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L1082-L1104
233,191
turicas/rows
rows/fields.py
slug
def slug(text, separator="_", permitted_chars=SLUG_CHARS): """Generate a slug for the `text`. >>> slug(' ÁLVARO justen% ') 'alvaro_justen' >>> slug(' ÁLVARO justen% ', separator='-') 'alvaro-justen' """ text = six.text_type(text or "") # Strip non-ASCII characters # Example: u' ...
python
def slug(text, separator="_", permitted_chars=SLUG_CHARS): """Generate a slug for the `text`. >>> slug(' ÁLVARO justen% ') 'alvaro_justen' >>> slug(' ÁLVARO justen% ', separator='-') 'alvaro-justen' """ text = six.text_type(text or "") # Strip non-ASCII characters # Example: u' ...
[ "def", "slug", "(", "text", ",", "separator", "=", "\"_\"", ",", "permitted_chars", "=", "SLUG_CHARS", ")", ":", "text", "=", "six", ".", "text_type", "(", "text", "or", "\"\"", ")", "# Strip non-ASCII characters", "# Example: u' ÁLVARO justen% ' -> ' ALVARO juste...
Generate a slug for the `text`. >>> slug(' ÁLVARO justen% ') 'alvaro_justen' >>> slug(' ÁLVARO justen% ', separator='-') 'alvaro-justen'
[ "Generate", "a", "slug", "for", "the", "text", "." ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/fields.py#L520-L553
233,192
turicas/rows
rows/fields.py
make_unique_name
def make_unique_name(name, existing_names, name_format="{name}_{index}", start=2): """Return a unique name based on `name_format` and `name`.""" index = start new_name = name while new_name in existing_names: new_name = name_format.format(name=name, index=index) index += 1 return ne...
python
def make_unique_name(name, existing_names, name_format="{name}_{index}", start=2): """Return a unique name based on `name_format` and `name`.""" index = start new_name = name while new_name in existing_names: new_name = name_format.format(name=name, index=index) index += 1 return ne...
[ "def", "make_unique_name", "(", "name", ",", "existing_names", ",", "name_format", "=", "\"{name}_{index}\"", ",", "start", "=", "2", ")", ":", "index", "=", "start", "new_name", "=", "name", "while", "new_name", "in", "existing_names", ":", "new_name", "=", ...
Return a unique name based on `name_format` and `name`.
[ "Return", "a", "unique", "name", "based", "on", "name_format", "and", "name", "." ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/fields.py#L556-L564
233,193
turicas/rows
rows/fields.py
make_header
def make_header(field_names, permit_not=False): """Return unique and slugged field names.""" slug_chars = SLUG_CHARS if not permit_not else SLUG_CHARS + "^" header = [ slug(field_name, permitted_chars=slug_chars) for field_name in field_names ] result = [] for index, field_name in enume...
python
def make_header(field_names, permit_not=False): """Return unique and slugged field names.""" slug_chars = SLUG_CHARS if not permit_not else SLUG_CHARS + "^" header = [ slug(field_name, permitted_chars=slug_chars) for field_name in field_names ] result = [] for index, field_name in enume...
[ "def", "make_header", "(", "field_names", ",", "permit_not", "=", "False", ")", ":", "slug_chars", "=", "SLUG_CHARS", "if", "not", "permit_not", "else", "SLUG_CHARS", "+", "\"^\"", "header", "=", "[", "slug", "(", "field_name", ",", "permitted_chars", "=", "...
Return unique and slugged field names.
[ "Return", "unique", "and", "slugged", "field", "names", "." ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/fields.py#L567-L587
233,194
turicas/rows
rows/fields.py
Field.deserialize
def deserialize(cls, value, *args, **kwargs): """Deserialize a value just after importing it `cls.deserialize` should always return a value of type `cls.TYPE` or `None`. """ if isinstance(value, cls.TYPE): return value elif is_null(value): return...
python
def deserialize(cls, value, *args, **kwargs): """Deserialize a value just after importing it `cls.deserialize` should always return a value of type `cls.TYPE` or `None`. """ if isinstance(value, cls.TYPE): return value elif is_null(value): return...
[ "def", "deserialize", "(", "cls", ",", "value", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "value", ",", "cls", ".", "TYPE", ")", ":", "return", "value", "elif", "is_null", "(", "value", ")", ":", "return", "None"...
Deserialize a value just after importing it `cls.deserialize` should always return a value of type `cls.TYPE` or `None`.
[ "Deserialize", "a", "value", "just", "after", "importing", "it" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/fields.py#L91-L103
233,195
turicas/rows
rows/plugins/plugin_pdf.py
ExtractionAlgorithm.selected_objects
def selected_objects(self): """Filter out objects outside table boundaries""" return [ obj for obj in self.text_objects if contains_or_overlap(self.table_bbox, obj.bbox) ]
python
def selected_objects(self): """Filter out objects outside table boundaries""" return [ obj for obj in self.text_objects if contains_or_overlap(self.table_bbox, obj.bbox) ]
[ "def", "selected_objects", "(", "self", ")", ":", "return", "[", "obj", "for", "obj", "in", "self", ".", "text_objects", "if", "contains_or_overlap", "(", "self", ".", "table_bbox", ",", "obj", ".", "bbox", ")", "]" ]
Filter out objects outside table boundaries
[ "Filter", "out", "objects", "outside", "table", "boundaries" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/plugins/plugin_pdf.py#L446-L453
233,196
turicas/rows
examples/library/extract_links.py
transform
def transform(row, table): 'Extract links from "project" field and remove HTML from all' data = row._asdict() data["links"] = " ".join(extract_links(row.project)) for key, value in data.items(): if isinstance(value, six.text_type): data[key] = extract_text(value) return data
python
def transform(row, table): 'Extract links from "project" field and remove HTML from all' data = row._asdict() data["links"] = " ".join(extract_links(row.project)) for key, value in data.items(): if isinstance(value, six.text_type): data[key] = extract_text(value) return data
[ "def", "transform", "(", "row", ",", "table", ")", ":", "data", "=", "row", ".", "_asdict", "(", ")", "data", "[", "\"links\"", "]", "=", "\" \"", ".", "join", "(", "extract_links", "(", "row", ".", "project", ")", ")", "for", "key", ",", "value", ...
Extract links from "project" field and remove HTML from all
[ "Extract", "links", "from", "project", "field", "and", "remove", "HTML", "from", "all" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/examples/library/extract_links.py#L24-L32
233,197
turicas/rows
examples/library/brazilian_cities_wikipedia.py
transform
def transform(row, table): 'Transform row "link" into full URL and add "state" based on "name"' data = row._asdict() data["link"] = urljoin("https://pt.wikipedia.org", data["link"]) data["name"], data["state"] = regexp_city_state.findall(data["name"])[0] return data
python
def transform(row, table): 'Transform row "link" into full URL and add "state" based on "name"' data = row._asdict() data["link"] = urljoin("https://pt.wikipedia.org", data["link"]) data["name"], data["state"] = regexp_city_state.findall(data["name"])[0] return data
[ "def", "transform", "(", "row", ",", "table", ")", ":", "data", "=", "row", ".", "_asdict", "(", ")", "data", "[", "\"link\"", "]", "=", "urljoin", "(", "\"https://pt.wikipedia.org\"", ",", "data", "[", "\"link\"", "]", ")", "data", "[", "\"name\"", "]...
Transform row "link" into full URL and add "state" based on "name"
[ "Transform", "row", "link", "into", "full", "URL", "and", "add", "state", "based", "on", "name" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/examples/library/brazilian_cities_wikipedia.py#L34-L40
233,198
turicas/rows
rows/plugins/plugin_parquet.py
import_from_parquet
def import_from_parquet(filename_or_fobj, *args, **kwargs): """Import data from a Parquet file and return with rows.Table.""" source = Source.from_file(filename_or_fobj, plugin_name="parquet", mode="rb") # TODO: should look into `schema.converted_type` also types = OrderedDict( [ (s...
python
def import_from_parquet(filename_or_fobj, *args, **kwargs): """Import data from a Parquet file and return with rows.Table.""" source = Source.from_file(filename_or_fobj, plugin_name="parquet", mode="rb") # TODO: should look into `schema.converted_type` also types = OrderedDict( [ (s...
[ "def", "import_from_parquet", "(", "filename_or_fobj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "source", "=", "Source", ".", "from_file", "(", "filename_or_fobj", ",", "plugin_name", "=", "\"parquet\"", ",", "mode", "=", "\"rb\"", ")", "# TODO: ...
Import data from a Parquet file and return with rows.Table.
[ "Import", "data", "from", "a", "Parquet", "file", "and", "return", "with", "rows", ".", "Table", "." ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/plugins/plugin_parquet.py#L47-L65
233,199
turicas/rows
rows/plugins/dicts.py
import_from_dicts
def import_from_dicts(data, samples=None, *args, **kwargs): """Import data from a iterable of dicts The algorithm will use the `samples` first `dict`s to determine the field names (if `samples` is `None` all `dict`s will be used). """ data = iter(data) cached_rows, headers = [], [] for in...
python
def import_from_dicts(data, samples=None, *args, **kwargs): """Import data from a iterable of dicts The algorithm will use the `samples` first `dict`s to determine the field names (if `samples` is `None` all `dict`s will be used). """ data = iter(data) cached_rows, headers = [], [] for in...
[ "def", "import_from_dicts", "(", "data", ",", "samples", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "iter", "(", "data", ")", "cached_rows", ",", "headers", "=", "[", "]", ",", "[", "]", "for", "index", ",", "r...
Import data from a iterable of dicts The algorithm will use the `samples` first `dict`s to determine the field names (if `samples` is `None` all `dict`s will be used).
[ "Import", "data", "from", "a", "iterable", "of", "dicts" ]
c74da41ae9ed091356b803a64f8a30c641c5fc45
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/plugins/dicts.py#L25-L52