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
232,900
alejandroautalan/pygubu
pygubudesigner/uitreeeditor.py
WidgetsTreeEditor.load_file
def load_file(self, filename): """Load file into treeview""" self.counter.clear() # python2 issues try: etree = ET.parse(filename) except ET.ParseError: parser = ET.XMLParser(encoding='UTF-8') etree = ET.parse(filename, parser) eroot =...
python
def load_file(self, filename): """Load file into treeview""" self.counter.clear() # python2 issues try: etree = ET.parse(filename) except ET.ParseError: parser = ET.XMLParser(encoding='UTF-8') etree = ET.parse(filename, parser) eroot =...
[ "def", "load_file", "(", "self", ",", "filename", ")", ":", "self", ".", "counter", ".", "clear", "(", ")", "# python2 issues", "try", ":", "etree", "=", "ET", ".", "parse", "(", "filename", ")", "except", "ET", ".", "ParseError", ":", "parser", "=", ...
Load file into treeview
[ "Load", "file", "into", "treeview" ]
41c8fb37ef973736ec5d68cbe1cd4ecb78712e40
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L501-L523
232,901
alejandroautalan/pygubu
pygubudesigner/uitreeeditor.py
WidgetsTreeEditor.populate_tree
def populate_tree(self, master, parent, element,from_file=False): """Reads xml nodes and populates tree item""" data = WidgetDescr(None, None) data.from_xml_node(element) cname = data.get_class() uniqueid = self.get_unique_id(cname, data.get_id()) data.set_property('id',...
python
def populate_tree(self, master, parent, element,from_file=False): """Reads xml nodes and populates tree item""" data = WidgetDescr(None, None) data.from_xml_node(element) cname = data.get_class() uniqueid = self.get_unique_id(cname, data.get_id()) data.set_property('id',...
[ "def", "populate_tree", "(", "self", ",", "master", ",", "parent", ",", "element", ",", "from_file", "=", "False", ")", ":", "data", "=", "WidgetDescr", "(", "None", ",", "None", ")", "data", ".", "from_xml_node", "(", "element", ")", "cname", "=", "da...
Reads xml nodes and populates tree item
[ "Reads", "xml", "nodes", "and", "populates", "tree", "item" ]
41c8fb37ef973736ec5d68cbe1cd4ecb78712e40
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L525-L544
232,902
alejandroautalan/pygubu
pygubudesigner/uitreeeditor.py
WidgetsTreeEditor.update_event
def update_event(self, hint, obj): """Updates tree colums when itemdata is changed.""" tree = self.treeview data = obj item = self.get_item_by_data(obj) if item: if data.get_id() != tree.item(item, 'text'): tree.item(item, text=data.get_id()) ...
python
def update_event(self, hint, obj): """Updates tree colums when itemdata is changed.""" tree = self.treeview data = obj item = self.get_item_by_data(obj) if item: if data.get_id() != tree.item(item, 'text'): tree.item(item, text=data.get_id()) ...
[ "def", "update_event", "(", "self", ",", "hint", ",", "obj", ")", ":", "tree", "=", "self", ".", "treeview", "data", "=", "obj", "item", "=", "self", ".", "get_item_by_data", "(", "obj", ")", "if", "item", ":", "if", "data", ".", "get_id", "(", ")"...
Updates tree colums when itemdata is changed.
[ "Updates", "tree", "colums", "when", "itemdata", "is", "changed", "." ]
41c8fb37ef973736ec5d68cbe1cd4ecb78712e40
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L586-L604
232,903
alejandroautalan/pygubu
pygubudesigner/uitreeeditor.py
WidgetsTreeEditor._reatach
def _reatach(self): """Reinsert the hidden items.""" for item, p, idx in self._detached: # The item may have been deleted. if self.treeview.exists(item) and self.treeview.exists(p): self.treeview.move(item, p, idx) self._detached = []
python
def _reatach(self): """Reinsert the hidden items.""" for item, p, idx in self._detached: # The item may have been deleted. if self.treeview.exists(item) and self.treeview.exists(p): self.treeview.move(item, p, idx) self._detached = []
[ "def", "_reatach", "(", "self", ")", ":", "for", "item", ",", "p", ",", "idx", "in", "self", ".", "_detached", ":", "# The item may have been deleted.", "if", "self", ".", "treeview", ".", "exists", "(", "item", ")", "and", "self", ".", "treeview", ".", ...
Reinsert the hidden items.
[ "Reinsert", "the", "hidden", "items", "." ]
41c8fb37ef973736ec5d68cbe1cd4ecb78712e40
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L741-L747
232,904
alejandroautalan/pygubu
pygubudesigner/uitreeeditor.py
WidgetsTreeEditor._detach
def _detach(self, item): """Hide items from treeview that do not match the search string.""" to_detach = [] children_det = [] children_match = False match_found = False value = self.filtervar.get() txt = self.treeview.item(item, 'text').lower() if value i...
python
def _detach(self, item): """Hide items from treeview that do not match the search string.""" to_detach = [] children_det = [] children_match = False match_found = False value = self.filtervar.get() txt = self.treeview.item(item, 'text').lower() if value i...
[ "def", "_detach", "(", "self", ",", "item", ")", ":", "to_detach", "=", "[", "]", "children_det", "=", "[", "]", "children_match", "=", "False", "match_found", "=", "False", "value", "=", "self", ".", "filtervar", ".", "get", "(", ")", "txt", "=", "s...
Hide items from treeview that do not match the search string.
[ "Hide", "items", "from", "treeview", "that", "do", "not", "match", "the", "search", "string", "." ]
41c8fb37ef973736ec5d68cbe1cd4ecb78712e40
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L749-L785
232,905
alejandroautalan/pygubu
pygubudesigner/main.py
PygubuUI.load_file
def load_file(self, filename): """Load xml into treeview""" self.tree_editor.load_file(filename) self.project_name.configure(text=filename) self.currentfile = filename self.is_changed = False
python
def load_file(self, filename): """Load xml into treeview""" self.tree_editor.load_file(filename) self.project_name.configure(text=filename) self.currentfile = filename self.is_changed = False
[ "def", "load_file", "(", "self", ",", "filename", ")", ":", "self", ".", "tree_editor", ".", "load_file", "(", "filename", ")", "self", ".", "project_name", ".", "configure", "(", "text", "=", "filename", ")", "self", ".", "currentfile", "=", "filename", ...
Load xml into treeview
[ "Load", "xml", "into", "treeview" ]
41c8fb37ef973736ec5d68cbe1cd4ecb78712e40
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/main.py#L514-L520
232,906
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_gremlin/__init__.py
lower_ir
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR into an IR form that can be represented in Gremlin queries. Args: ir_blocks: list of IR blocks to lower into Gremlin-compatible form query_metadata_table: QueryMetadataTable object containing all metadat...
python
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR into an IR form that can be represented in Gremlin queries. Args: ir_blocks: list of IR blocks to lower into Gremlin-compatible form query_metadata_table: QueryMetadataTable object containing all metadat...
[ "def", "lower_ir", "(", "ir_blocks", ",", "query_metadata_table", ",", "type_equivalence_hints", "=", "None", ")", ":", "sanity_check_ir_blocks_from_frontend", "(", "ir_blocks", ",", "query_metadata_table", ")", "ir_blocks", "=", "lower_context_field_existence", "(", "ir_...
Lower the IR into an IR form that can be represented in Gremlin queries. Args: ir_blocks: list of IR blocks to lower into Gremlin-compatible form query_metadata_table: QueryMetadataTable object containing all metadata collected during query processing, including locati...
[ "Lower", "the", "IR", "into", "an", "IR", "form", "that", "can", "be", "represented", "in", "Gremlin", "queries", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/__init__.py#L13-L53
232,907
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py
lower_coerce_type_block_type_data
def lower_coerce_type_block_type_data(ir_blocks, type_equivalence_hints): """Rewrite CoerceType blocks to explicitly state which types are allowed in the coercion.""" allowed_key_type_spec = (GraphQLInterfaceType, GraphQLObjectType) allowed_value_type_spec = GraphQLUnionType # Validate that the type_eq...
python
def lower_coerce_type_block_type_data(ir_blocks, type_equivalence_hints): """Rewrite CoerceType blocks to explicitly state which types are allowed in the coercion.""" allowed_key_type_spec = (GraphQLInterfaceType, GraphQLObjectType) allowed_value_type_spec = GraphQLUnionType # Validate that the type_eq...
[ "def", "lower_coerce_type_block_type_data", "(", "ir_blocks", ",", "type_equivalence_hints", ")", ":", "allowed_key_type_spec", "=", "(", "GraphQLInterfaceType", ",", "GraphQLObjectType", ")", "allowed_value_type_spec", "=", "GraphQLUnionType", "# Validate that the type_equivalen...
Rewrite CoerceType blocks to explicitly state which types are allowed in the coercion.
[ "Rewrite", "CoerceType", "blocks", "to", "explicitly", "state", "which", "types", "are", "allowed", "in", "the", "coercion", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L31-L65
232,908
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py
lower_coerce_type_blocks
def lower_coerce_type_blocks(ir_blocks): """Lower CoerceType blocks into Filter blocks with a type-check predicate.""" new_ir_blocks = [] for block in ir_blocks: new_block = block if isinstance(block, CoerceType): predicate = BinaryComposition( u'contains', Liter...
python
def lower_coerce_type_blocks(ir_blocks): """Lower CoerceType blocks into Filter blocks with a type-check predicate.""" new_ir_blocks = [] for block in ir_blocks: new_block = block if isinstance(block, CoerceType): predicate = BinaryComposition( u'contains', Liter...
[ "def", "lower_coerce_type_blocks", "(", "ir_blocks", ")", ":", "new_ir_blocks", "=", "[", "]", "for", "block", "in", "ir_blocks", ":", "new_block", "=", "block", "if", "isinstance", "(", "block", ",", "CoerceType", ")", ":", "predicate", "=", "BinaryCompositio...
Lower CoerceType blocks into Filter blocks with a type-check predicate.
[ "Lower", "CoerceType", "blocks", "into", "Filter", "blocks", "with", "a", "type", "-", "check", "predicate", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L68-L81
232,909
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py
rewrite_filters_in_optional_blocks
def rewrite_filters_in_optional_blocks(ir_blocks): """In optional contexts, add a check for null that allows non-existent optional data through. Optional traversals in Gremlin represent missing optional data by setting the current vertex to null until the exit from the optional scope. Therefore, filtering ...
python
def rewrite_filters_in_optional_blocks(ir_blocks): """In optional contexts, add a check for null that allows non-existent optional data through. Optional traversals in Gremlin represent missing optional data by setting the current vertex to null until the exit from the optional scope. Therefore, filtering ...
[ "def", "rewrite_filters_in_optional_blocks", "(", "ir_blocks", ")", ":", "new_ir_blocks", "=", "[", "]", "optional_context_depth", "=", "0", "for", "block", "in", "ir_blocks", ":", "new_block", "=", "block", "if", "isinstance", "(", "block", ",", "CoerceType", "...
In optional contexts, add a check for null that allows non-existent optional data through. Optional traversals in Gremlin represent missing optional data by setting the current vertex to null until the exit from the optional scope. Therefore, filtering and type coercions (which should have been lowered int...
[ "In", "optional", "contexts", "add", "a", "check", "for", "null", "that", "allows", "non", "-", "existent", "optional", "data", "through", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L84-L122
232,910
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py
lower_folded_outputs
def lower_folded_outputs(ir_blocks): """Lower standard folded output fields into GremlinFoldedContextField objects.""" folds, remaining_ir_blocks = extract_folds_from_ir_blocks(ir_blocks) if not remaining_ir_blocks: raise AssertionError(u'Expected at least one non-folded block to remain: {} {} ' ...
python
def lower_folded_outputs(ir_blocks): """Lower standard folded output fields into GremlinFoldedContextField objects.""" folds, remaining_ir_blocks = extract_folds_from_ir_blocks(ir_blocks) if not remaining_ir_blocks: raise AssertionError(u'Expected at least one non-folded block to remain: {} {} ' ...
[ "def", "lower_folded_outputs", "(", "ir_blocks", ")", ":", "folds", ",", "remaining_ir_blocks", "=", "extract_folds_from_ir_blocks", "(", "ir_blocks", ")", "if", "not", "remaining_ir_blocks", ":", "raise", "AssertionError", "(", "u'Expected at least one non-folded block to ...
Lower standard folded output fields into GremlinFoldedContextField objects.
[ "Lower", "standard", "folded", "output", "fields", "into", "GremlinFoldedContextField", "objects", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L319-L355
232,911
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py
GremlinFoldedContextField.validate
def validate(self): """Validate that the GremlinFoldedContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_locatio...
python
def validate(self): """Validate that the GremlinFoldedContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_locatio...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "fold_scope_location", ",", "FoldScopeLocation", ")", ":", "raise", "TypeError", "(", "u'Expected FoldScopeLocation fold_scope_location, got: {} {}'", ".", "format", "(", "type", ...
Validate that the GremlinFoldedContextField is correctly representable.
[ "Validate", "that", "the", "GremlinFoldedContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L137-L159
232,912
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py
GremlinFoldedTraverse.from_traverse
def from_traverse(cls, traverse_block): """Create a GremlinFoldedTraverse block as a copy of the given Traverse block.""" if isinstance(traverse_block, Traverse): return cls(traverse_block.direction, traverse_block.edge_name) else: raise AssertionError(u'Tried to initiali...
python
def from_traverse(cls, traverse_block): """Create a GremlinFoldedTraverse block as a copy of the given Traverse block.""" if isinstance(traverse_block, Traverse): return cls(traverse_block.direction, traverse_block.edge_name) else: raise AssertionError(u'Tried to initiali...
[ "def", "from_traverse", "(", "cls", ",", "traverse_block", ")", ":", "if", "isinstance", "(", "traverse_block", ",", "Traverse", ")", ":", "return", "cls", "(", "traverse_block", ".", "direction", ",", "traverse_block", ".", "edge_name", ")", "else", ":", "r...
Create a GremlinFoldedTraverse block as a copy of the given Traverse block.
[ "Create", "a", "GremlinFoldedTraverse", "block", "as", "a", "copy", "of", "the", "given", "Traverse", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L258-L264
232,913
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_get_referenced_type_equivalences
def _get_referenced_type_equivalences(graphql_types, type_equivalence_hints): """Filter union types with no edges from the type equivalence hints dict.""" referenced_types = set() for graphql_type in graphql_types.values(): if isinstance(graphql_type, (GraphQLObjectType, GraphQLInterfaceType)): ...
python
def _get_referenced_type_equivalences(graphql_types, type_equivalence_hints): """Filter union types with no edges from the type equivalence hints dict.""" referenced_types = set() for graphql_type in graphql_types.values(): if isinstance(graphql_type, (GraphQLObjectType, GraphQLInterfaceType)): ...
[ "def", "_get_referenced_type_equivalences", "(", "graphql_types", ",", "type_equivalence_hints", ")", ":", "referenced_types", "=", "set", "(", ")", "for", "graphql_type", "in", "graphql_types", ".", "values", "(", ")", ":", "if", "isinstance", "(", "graphql_type", ...
Filter union types with no edges from the type equivalence hints dict.
[ "Filter", "union", "types", "with", "no", "edges", "from", "the", "type", "equivalence", "hints", "dict", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L24-L36
232,914
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_get_inherited_field_types
def _get_inherited_field_types(class_to_field_type_overrides, schema_graph): """Return a dictionary describing the field type overrides in subclasses.""" inherited_field_type_overrides = dict() for superclass_name, field_type_overrides in class_to_field_type_overrides.items(): for subclass_name in s...
python
def _get_inherited_field_types(class_to_field_type_overrides, schema_graph): """Return a dictionary describing the field type overrides in subclasses.""" inherited_field_type_overrides = dict() for superclass_name, field_type_overrides in class_to_field_type_overrides.items(): for subclass_name in s...
[ "def", "_get_inherited_field_types", "(", "class_to_field_type_overrides", ",", "schema_graph", ")", ":", "inherited_field_type_overrides", "=", "dict", "(", ")", "for", "superclass_name", ",", "field_type_overrides", "in", "class_to_field_type_overrides", ".", "items", "("...
Return a dictionary describing the field type overrides in subclasses.
[ "Return", "a", "dictionary", "describing", "the", "field", "type", "overrides", "in", "subclasses", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L39-L46
232,915
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_validate_overriden_fields_are_not_defined_in_superclasses
def _validate_overriden_fields_are_not_defined_in_superclasses(class_to_field_type_overrides, schema_graph): """Assert that the fields we want to override are not defined in superclasses.""" for class_name, field_type_overrides in six.iteritems(clas...
python
def _validate_overriden_fields_are_not_defined_in_superclasses(class_to_field_type_overrides, schema_graph): """Assert that the fields we want to override are not defined in superclasses.""" for class_name, field_type_overrides in six.iteritems(clas...
[ "def", "_validate_overriden_fields_are_not_defined_in_superclasses", "(", "class_to_field_type_overrides", ",", "schema_graph", ")", ":", "for", "class_name", ",", "field_type_overrides", "in", "six", ".", "iteritems", "(", "class_to_field_type_overrides", ")", ":", "for", ...
Assert that the fields we want to override are not defined in superclasses.
[ "Assert", "that", "the", "fields", "we", "want", "to", "override", "are", "not", "defined", "in", "superclasses", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L49-L61
232,916
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_property_descriptor_to_graphql_type
def _property_descriptor_to_graphql_type(property_obj): """Return the best GraphQL type representation for an OrientDB property descriptor.""" property_type = property_obj.type_id scalar_types = { PROPERTY_TYPE_BOOLEAN_ID: GraphQLBoolean, PROPERTY_TYPE_DATE_ID: GraphQLDate, PROPERTY_...
python
def _property_descriptor_to_graphql_type(property_obj): """Return the best GraphQL type representation for an OrientDB property descriptor.""" property_type = property_obj.type_id scalar_types = { PROPERTY_TYPE_BOOLEAN_ID: GraphQLBoolean, PROPERTY_TYPE_DATE_ID: GraphQLDate, PROPERTY_...
[ "def", "_property_descriptor_to_graphql_type", "(", "property_obj", ")", ":", "property_type", "=", "property_obj", ".", "type_id", "scalar_types", "=", "{", "PROPERTY_TYPE_BOOLEAN_ID", ":", "GraphQLBoolean", ",", "PROPERTY_TYPE_DATE_ID", ":", "GraphQLDate", ",", "PROPERT...
Return the best GraphQL type representation for an OrientDB property descriptor.
[ "Return", "the", "best", "GraphQL", "type", "representation", "for", "an", "OrientDB", "property", "descriptor", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L64-L96
232,917
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_get_union_type_name
def _get_union_type_name(type_names_to_union): """Construct a unique union type name based on the type names being unioned.""" if not type_names_to_union: raise AssertionError(u'Expected a non-empty list of type names to union, received: ' u'{}'.format(type_names_to_union)) ...
python
def _get_union_type_name(type_names_to_union): """Construct a unique union type name based on the type names being unioned.""" if not type_names_to_union: raise AssertionError(u'Expected a non-empty list of type names to union, received: ' u'{}'.format(type_names_to_union)) ...
[ "def", "_get_union_type_name", "(", "type_names_to_union", ")", ":", "if", "not", "type_names_to_union", ":", "raise", "AssertionError", "(", "u'Expected a non-empty list of type names to union, received: '", "u'{}'", ".", "format", "(", "type_names_to_union", ")", ")", "re...
Construct a unique union type name based on the type names being unioned.
[ "Construct", "a", "unique", "union", "type", "name", "based", "on", "the", "type", "names", "being", "unioned", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L99-L104
232,918
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_get_fields_for_class
def _get_fields_for_class(schema_graph, graphql_types, field_type_overrides, hidden_classes, cls_name): """Return a dict from field name to GraphQL field type, for the specified graph class.""" properties = schema_graph.get_element_by_class_name(cls_name).properties # Add leaf Gra...
python
def _get_fields_for_class(schema_graph, graphql_types, field_type_overrides, hidden_classes, cls_name): """Return a dict from field name to GraphQL field type, for the specified graph class.""" properties = schema_graph.get_element_by_class_name(cls_name).properties # Add leaf Gra...
[ "def", "_get_fields_for_class", "(", "schema_graph", ",", "graphql_types", ",", "field_type_overrides", ",", "hidden_classes", ",", "cls_name", ")", ":", "properties", "=", "schema_graph", ".", "get_element_by_class_name", "(", "cls_name", ")", ".", "properties", "# A...
Return a dict from field name to GraphQL field type, for the specified graph class.
[ "Return", "a", "dict", "from", "field", "name", "to", "GraphQL", "field", "type", "for", "the", "specified", "graph", "class", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L107-L172
232,919
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_create_field_specification
def _create_field_specification(schema_graph, graphql_types, field_type_overrides, hidden_classes, cls_name): """Return a function that specifies the fields present on the given type.""" def field_maker_func(): """Create and return the fields for the given GraphQL type.""...
python
def _create_field_specification(schema_graph, graphql_types, field_type_overrides, hidden_classes, cls_name): """Return a function that specifies the fields present on the given type.""" def field_maker_func(): """Create and return the fields for the given GraphQL type.""...
[ "def", "_create_field_specification", "(", "schema_graph", ",", "graphql_types", ",", "field_type_overrides", ",", "hidden_classes", ",", "cls_name", ")", ":", "def", "field_maker_func", "(", ")", ":", "\"\"\"Create and return the fields for the given GraphQL type.\"\"\"", "r...
Return a function that specifies the fields present on the given type.
[ "Return", "a", "function", "that", "specifies", "the", "fields", "present", "on", "the", "given", "type", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L175-L189
232,920
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_create_interface_specification
def _create_interface_specification(schema_graph, graphql_types, hidden_classes, cls_name): """Return a function that specifies the interfaces implemented by the given type.""" def interface_spec(): """Return a list of GraphQL interface types implemented by the type named 'cls_name'.""" abstract...
python
def _create_interface_specification(schema_graph, graphql_types, hidden_classes, cls_name): """Return a function that specifies the interfaces implemented by the given type.""" def interface_spec(): """Return a list of GraphQL interface types implemented by the type named 'cls_name'.""" abstract...
[ "def", "_create_interface_specification", "(", "schema_graph", ",", "graphql_types", ",", "hidden_classes", ",", "cls_name", ")", ":", "def", "interface_spec", "(", ")", ":", "\"\"\"Return a list of GraphQL interface types implemented by the type named 'cls_name'.\"\"\"", "abstra...
Return a function that specifies the interfaces implemented by the given type.
[ "Return", "a", "function", "that", "specifies", "the", "interfaces", "implemented", "by", "the", "given", "type", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L192-L209
232,921
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
_create_union_types_specification
def _create_union_types_specification(schema_graph, graphql_types, hidden_classes, base_name): """Return a function that gives the types in the union type rooted at base_name.""" # When edges point to vertices of type base_name, and base_name is both non-abstract and # has subclasses, we need to represent t...
python
def _create_union_types_specification(schema_graph, graphql_types, hidden_classes, base_name): """Return a function that gives the types in the union type rooted at base_name.""" # When edges point to vertices of type base_name, and base_name is both non-abstract and # has subclasses, we need to represent t...
[ "def", "_create_union_types_specification", "(", "schema_graph", ",", "graphql_types", ",", "hidden_classes", ",", "base_name", ")", ":", "# When edges point to vertices of type base_name, and base_name is both non-abstract and", "# has subclasses, we need to represent the edge endpoint ty...
Return a function that gives the types in the union type rooted at base_name.
[ "Return", "a", "function", "that", "gives", "the", "types", "in", "the", "union", "type", "rooted", "at", "base_name", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L212-L225
232,922
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/graphql_schema.py
get_graphql_schema_from_schema_graph
def get_graphql_schema_from_schema_graph(schema_graph, class_to_field_type_overrides, hidden_classes): """Return a GraphQL schema object corresponding to the schema of the given schema graph. Args: schema_graph: SchemaGraph class_to_field_type_overrides:...
python
def get_graphql_schema_from_schema_graph(schema_graph, class_to_field_type_overrides, hidden_classes): """Return a GraphQL schema object corresponding to the schema of the given schema graph. Args: schema_graph: SchemaGraph class_to_field_type_overrides:...
[ "def", "get_graphql_schema_from_schema_graph", "(", "schema_graph", ",", "class_to_field_type_overrides", ",", "hidden_classes", ")", ":", "_validate_overriden_fields_are_not_defined_in_superclasses", "(", "class_to_field_type_overrides", ",", "schema_graph", ")", "# The field types ...
Return a GraphQL schema object corresponding to the schema of the given schema graph. Args: schema_graph: SchemaGraph class_to_field_type_overrides: dict, class name -> {field name -> field type}, (string -> {string -> GraphQLType}). Used to override the ...
[ "Return", "a", "GraphQL", "schema", "object", "corresponding", "to", "the", "schema", "of", "the", "given", "schema", "graph", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L228-L383
232,923
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py
workaround_lowering_pass
def workaround_lowering_pass(ir_blocks, query_metadata_table): """Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary.""" new_ir_blocks = [] for block in ir_blocks: if isinstance(block, Filter): new_block = _process_filter_block(query_metadata_table, ...
python
def workaround_lowering_pass(ir_blocks, query_metadata_table): """Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary.""" new_ir_blocks = [] for block in ir_blocks: if isinstance(block, Filter): new_block = _process_filter_block(query_metadata_table, ...
[ "def", "workaround_lowering_pass", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "new_ir_blocks", "=", "[", "]", "for", "block", "in", "ir_blocks", ":", "if", "isinstance", "(", "block", ",", "Filter", ")", ":", "new_block", "=", "_process_filter_bloc...
Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary.
[ "Extract", "locations", "from", "TernaryConditionals", "and", "rewrite", "their", "Filter", "blocks", "as", "necessary", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py#L19-L30
232,924
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py
_process_filter_block
def _process_filter_block(query_metadata_table, block): """Rewrite the provided Filter block if necessary.""" # For a given Filter block with BinaryComposition predicate expression X, # let L be the set of all Locations referenced in any TernaryConditional # predicate expression enclosed in X. # For...
python
def _process_filter_block(query_metadata_table, block): """Rewrite the provided Filter block if necessary.""" # For a given Filter block with BinaryComposition predicate expression X, # let L be the set of all Locations referenced in any TernaryConditional # predicate expression enclosed in X. # For...
[ "def", "_process_filter_block", "(", "query_metadata_table", ",", "block", ")", ":", "# For a given Filter block with BinaryComposition predicate expression X,", "# let L be the set of all Locations referenced in any TernaryConditional", "# predicate expression enclosed in X.", "# For each loc...
Rewrite the provided Filter block if necessary.
[ "Rewrite", "the", "provided", "Filter", "block", "if", "necessary", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py#L33-L98
232,925
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py
_create_tautological_expression_for_location
def _create_tautological_expression_for_location(query_metadata_table, location): """For a given location, create a BinaryComposition that always evaluates to 'true'.""" location_type = query_metadata_table.get_location_info(location).type location_exists = BinaryComposition( u'!=', ContextField(lo...
python
def _create_tautological_expression_for_location(query_metadata_table, location): """For a given location, create a BinaryComposition that always evaluates to 'true'.""" location_type = query_metadata_table.get_location_info(location).type location_exists = BinaryComposition( u'!=', ContextField(lo...
[ "def", "_create_tautological_expression_for_location", "(", "query_metadata_table", ",", "location", ")", ":", "location_type", "=", "query_metadata_table", ".", "get_location_info", "(", "location", ")", ".", "type", "location_exists", "=", "BinaryComposition", "(", "u'!...
For a given location, create a BinaryComposition that always evaluates to 'true'.
[ "For", "a", "given", "location", "create", "a", "BinaryComposition", "that", "always", "evaluates", "to", "true", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py#L101-L109
232,926
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
get_only_element_from_collection
def get_only_element_from_collection(one_element_collection): """Assert that the collection has exactly one element, then return that element.""" if len(one_element_collection) != 1: raise AssertionError(u'Expected a collection with exactly one element, but got: {}' .format(...
python
def get_only_element_from_collection(one_element_collection): """Assert that the collection has exactly one element, then return that element.""" if len(one_element_collection) != 1: raise AssertionError(u'Expected a collection with exactly one element, but got: {}' .format(...
[ "def", "get_only_element_from_collection", "(", "one_element_collection", ")", ":", "if", "len", "(", "one_element_collection", ")", "!=", "1", ":", "raise", "AssertionError", "(", "u'Expected a collection with exactly one element, but got: {}'", ".", "format", "(", "one_el...
Assert that the collection has exactly one element, then return that element.
[ "Assert", "that", "the", "collection", "has", "exactly", "one", "element", "then", "return", "that", "element", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L37-L42
232,927
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
get_ast_field_name
def get_ast_field_name(ast): """Return the normalized field name for the given AST node.""" replacements = { # We always rewrite the following field names into their proper underlying counterparts. TYPENAME_META_FIELD_NAME: '@class' } base_field_name = ast.name.value normalized_name ...
python
def get_ast_field_name(ast): """Return the normalized field name for the given AST node.""" replacements = { # We always rewrite the following field names into their proper underlying counterparts. TYPENAME_META_FIELD_NAME: '@class' } base_field_name = ast.name.value normalized_name ...
[ "def", "get_ast_field_name", "(", "ast", ")", ":", "replacements", "=", "{", "# We always rewrite the following field names into their proper underlying counterparts.", "TYPENAME_META_FIELD_NAME", ":", "'@class'", "}", "base_field_name", "=", "ast", ".", "name", ".", "value",...
Return the normalized field name for the given AST node.
[ "Return", "the", "normalized", "field", "name", "for", "the", "given", "AST", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L45-L53
232,928
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
get_field_type_from_schema
def get_field_type_from_schema(schema_type, field_name): """Return the type of the field in the given type, accounting for field name normalization.""" if field_name == '@class': return GraphQLString else: if field_name not in schema_type.fields: raise AssertionError(u'Field {} p...
python
def get_field_type_from_schema(schema_type, field_name): """Return the type of the field in the given type, accounting for field name normalization.""" if field_name == '@class': return GraphQLString else: if field_name not in schema_type.fields: raise AssertionError(u'Field {} p...
[ "def", "get_field_type_from_schema", "(", "schema_type", ",", "field_name", ")", ":", "if", "field_name", "==", "'@class'", ":", "return", "GraphQLString", "else", ":", "if", "field_name", "not", "in", "schema_type", ".", "fields", ":", "raise", "AssertionError", ...
Return the type of the field in the given type, accounting for field name normalization.
[ "Return", "the", "type", "of", "the", "field", "in", "the", "given", "type", "accounting", "for", "field", "name", "normalization", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L63-L73
232,929
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
get_vertex_field_type
def get_vertex_field_type(current_schema_type, vertex_field_name): """Return the type of the vertex within the specified vertex field name of the given type.""" # According to the schema, the vertex field itself is of type GraphQLList, and this is # what get_field_type_from_schema returns. We care about wha...
python
def get_vertex_field_type(current_schema_type, vertex_field_name): """Return the type of the vertex within the specified vertex field name of the given type.""" # According to the schema, the vertex field itself is of type GraphQLList, and this is # what get_field_type_from_schema returns. We care about wha...
[ "def", "get_vertex_field_type", "(", "current_schema_type", ",", "vertex_field_name", ")", ":", "# According to the schema, the vertex field itself is of type GraphQLList, and this is", "# what get_field_type_from_schema returns. We care about what the type *inside* the list is,", "# i.e., the t...
Return the type of the vertex within the specified vertex field name of the given type.
[ "Return", "the", "type", "of", "the", "vertex", "within", "the", "specified", "vertex", "field", "name", "of", "the", "given", "type", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L76-L91
232,930
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
get_edge_direction_and_name
def get_edge_direction_and_name(vertex_field_name): """Get the edge direction and name from a non-root vertex field name.""" edge_direction = None edge_name = None if vertex_field_name.startswith(OUTBOUND_EDGE_FIELD_PREFIX): edge_direction = OUTBOUND_EDGE_DIRECTION edge_name = vertex_fie...
python
def get_edge_direction_and_name(vertex_field_name): """Get the edge direction and name from a non-root vertex field name.""" edge_direction = None edge_name = None if vertex_field_name.startswith(OUTBOUND_EDGE_FIELD_PREFIX): edge_direction = OUTBOUND_EDGE_DIRECTION edge_name = vertex_fie...
[ "def", "get_edge_direction_and_name", "(", "vertex_field_name", ")", ":", "edge_direction", "=", "None", "edge_name", "=", "None", "if", "vertex_field_name", ".", "startswith", "(", "OUTBOUND_EDGE_FIELD_PREFIX", ")", ":", "edge_direction", "=", "OUTBOUND_EDGE_DIRECTION", ...
Get the edge direction and name from a non-root vertex field name.
[ "Get", "the", "edge", "direction", "and", "name", "from", "a", "non", "-", "root", "vertex", "field", "name", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L101-L116
232,931
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
is_vertex_field_type
def is_vertex_field_type(graphql_type): """Return True if the argument is a vertex field type, and False otherwise.""" # This will need to change if we ever support complex embedded types or edge field types. underlying_type = strip_non_null_from_type(graphql_type) return isinstance(underlying_type, (Gr...
python
def is_vertex_field_type(graphql_type): """Return True if the argument is a vertex field type, and False otherwise.""" # This will need to change if we ever support complex embedded types or edge field types. underlying_type = strip_non_null_from_type(graphql_type) return isinstance(underlying_type, (Gr...
[ "def", "is_vertex_field_type", "(", "graphql_type", ")", ":", "# This will need to change if we ever support complex embedded types or edge field types.", "underlying_type", "=", "strip_non_null_from_type", "(", "graphql_type", ")", "return", "isinstance", "(", "underlying_type", "...
Return True if the argument is a vertex field type, and False otherwise.
[ "Return", "True", "if", "the", "argument", "is", "a", "vertex", "field", "type", "and", "False", "otherwise", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L127-L131
232,932
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
ensure_unicode_string
def ensure_unicode_string(value): """Ensure the value is a string, and return it as unicode.""" if not isinstance(value, six.string_types): raise TypeError(u'Expected string value, got: {}'.format(value)) return six.text_type(value)
python
def ensure_unicode_string(value): """Ensure the value is a string, and return it as unicode.""" if not isinstance(value, six.string_types): raise TypeError(u'Expected string value, got: {}'.format(value)) return six.text_type(value)
[ "def", "ensure_unicode_string", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "u'Expected string value, got: {}'", ".", "format", "(", "value", ")", ")", "return", "six", ...
Ensure the value is a string, and return it as unicode.
[ "Ensure", "the", "value", "is", "a", "string", "and", "return", "it", "as", "unicode", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L140-L144
232,933
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
get_uniquely_named_objects_by_name
def get_uniquely_named_objects_by_name(object_list): """Return dict of name -> object pairs from a list of objects with unique names. Args: object_list: list of objects, each X of which has a unique name accessible as X.name.value Returns: dict, { X.name.value: X for x in object_list } ...
python
def get_uniquely_named_objects_by_name(object_list): """Return dict of name -> object pairs from a list of objects with unique names. Args: object_list: list of objects, each X of which has a unique name accessible as X.name.value Returns: dict, { X.name.value: X for x in object_list } ...
[ "def", "get_uniquely_named_objects_by_name", "(", "object_list", ")", ":", "if", "not", "object_list", ":", "return", "dict", "(", ")", "result", "=", "dict", "(", ")", "for", "obj", "in", "object_list", ":", "name", "=", "obj", ".", "name", ".", "value", ...
Return dict of name -> object pairs from a list of objects with unique names. Args: object_list: list of objects, each X of which has a unique name accessible as X.name.value Returns: dict, { X.name.value: X for x in object_list } If the list is empty or None, returns an empty dict.
[ "Return", "dict", "of", "name", "-", ">", "object", "pairs", "from", "a", "list", "of", "objects", "with", "unique", "names", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L147-L168
232,934
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
validate_safe_string
def validate_safe_string(value): """Ensure the provided string does not have illegal characters.""" # The following strings are explicitly allowed, despite having otherwise-illegal chars. legal_strings_with_special_chars = frozenset({'@rid', '@class', '@this', '%'}) if not isinstance(value, six.string_...
python
def validate_safe_string(value): """Ensure the provided string does not have illegal characters.""" # The following strings are explicitly allowed, despite having otherwise-illegal chars. legal_strings_with_special_chars = frozenset({'@rid', '@class', '@this', '%'}) if not isinstance(value, six.string_...
[ "def", "validate_safe_string", "(", "value", ")", ":", "# The following strings are explicitly allowed, despite having otherwise-illegal chars.", "legal_strings_with_special_chars", "=", "frozenset", "(", "{", "'@rid'", ",", "'@class'", ",", "'@this'", ",", "'%'", "}", ")", ...
Ensure the provided string does not have illegal characters.
[ "Ensure", "the", "provided", "string", "does", "not", "have", "illegal", "characters", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L177-L194
232,935
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
validate_edge_direction
def validate_edge_direction(edge_direction): """Ensure the provided edge direction is either "in" or "out".""" if not isinstance(edge_direction, six.string_types): raise TypeError(u'Expected string edge_direction, got: {} {}'.format( type(edge_direction), edge_direction)) if...
python
def validate_edge_direction(edge_direction): """Ensure the provided edge direction is either "in" or "out".""" if not isinstance(edge_direction, six.string_types): raise TypeError(u'Expected string edge_direction, got: {} {}'.format( type(edge_direction), edge_direction)) if...
[ "def", "validate_edge_direction", "(", "edge_direction", ")", ":", "if", "not", "isinstance", "(", "edge_direction", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "u'Expected string edge_direction, got: {} {}'", ".", "format", "(", "type", "(...
Ensure the provided edge direction is either "in" or "out".
[ "Ensure", "the", "provided", "edge", "direction", "is", "either", "in", "or", "out", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L205-L212
232,936
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
validate_marked_location
def validate_marked_location(location): """Validate that a Location object is safe for marking, and not at a field.""" if not isinstance(location, (Location, FoldScopeLocation)): raise TypeError(u'Expected Location or FoldScopeLocation location, got: {} {}'.format( type(location).__name__, l...
python
def validate_marked_location(location): """Validate that a Location object is safe for marking, and not at a field.""" if not isinstance(location, (Location, FoldScopeLocation)): raise TypeError(u'Expected Location or FoldScopeLocation location, got: {} {}'.format( type(location).__name__, l...
[ "def", "validate_marked_location", "(", "location", ")", ":", "if", "not", "isinstance", "(", "location", ",", "(", "Location", ",", "FoldScopeLocation", ")", ")", ":", "raise", "TypeError", "(", "u'Expected Location or FoldScopeLocation location, got: {} {}'", ".", "...
Validate that a Location object is safe for marking, and not at a field.
[ "Validate", "that", "a", "Location", "object", "is", "safe", "for", "marking", "and", "not", "at", "a", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L215-L222
232,937
kensho-technologies/graphql-compiler
graphql_compiler/compiler/helpers.py
invert_dict
def invert_dict(invertible_dict): """Invert a dict. A dict is invertible if values are unique and hashable.""" inverted = {} for k, v in six.iteritems(invertible_dict): if not isinstance(v, Hashable): raise TypeError(u'Expected an invertible dict, but value at key {} has type {}'.format(...
python
def invert_dict(invertible_dict): """Invert a dict. A dict is invertible if values are unique and hashable.""" inverted = {} for k, v in six.iteritems(invertible_dict): if not isinstance(v, Hashable): raise TypeError(u'Expected an invertible dict, but value at key {} has type {}'.format(...
[ "def", "invert_dict", "(", "invertible_dict", ")", ":", "inverted", "=", "{", "}", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "invertible_dict", ")", ":", "if", "not", "isinstance", "(", "v", ",", "Hashable", ")", ":", "raise", "TypeErro...
Invert a dict. A dict is invertible if values are unique and hashable.
[ "Invert", "a", "dict", ".", "A", "dict", "is", "invertible", "if", "values", "are", "unique", "and", "hashable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L230-L242
232,938
kensho-technologies/graphql-compiler
setup.py
read_file
def read_file(filename): """Read package file as text to get name and version""" # intentionally *not* adding an encoding option to open # see here: # https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690 here = os.path.abspath(os.path.dirname(__file__)) with codecs.open(os.path.joi...
python
def read_file(filename): """Read package file as text to get name and version""" # intentionally *not* adding an encoding option to open # see here: # https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690 here = os.path.abspath(os.path.dirname(__file__)) with codecs.open(os.path.joi...
[ "def", "read_file", "(", "filename", ")", ":", "# intentionally *not* adding an encoding option to open", "# see here:", "# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690", "here", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dir...
Read package file as text to get name and version
[ "Read", "package", "file", "as", "text", "to", "get", "name", "and", "version" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L13-L20
232,939
kensho-technologies/graphql-compiler
setup.py
find_version
def find_version(): """Only define version in one place""" version_file = read_file('__init__.py') version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']', version_file, re.M) if version_match: return version_match.group(1) raise RuntimeError('Unable to ...
python
def find_version(): """Only define version in one place""" version_file = read_file('__init__.py') version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']', version_file, re.M) if version_match: return version_match.group(1) raise RuntimeError('Unable to ...
[ "def", "find_version", "(", ")", ":", "version_file", "=", "read_file", "(", "'__init__.py'", ")", "version_match", "=", "re", ".", "search", "(", "r'^__version__ = [\"\\']([^\"\\']*)[\"\\']'", ",", "version_file", ",", "re", ".", "M", ")", "if", "version_match", ...
Only define version in one place
[ "Only", "define", "version", "in", "one", "place" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L23-L30
232,940
kensho-technologies/graphql-compiler
setup.py
find_name
def find_name(): """Only define name in one place""" name_file = read_file('__init__.py') name_match = re.search(r'^__package_name__ = ["\']([^"\']*)["\']', name_file, re.M) if name_match: return name_match.group(1) raise RuntimeError('Unable to find name string.')
python
def find_name(): """Only define name in one place""" name_file = read_file('__init__.py') name_match = re.search(r'^__package_name__ = ["\']([^"\']*)["\']', name_file, re.M) if name_match: return name_match.group(1) raise RuntimeError('Unable to find name string.')
[ "def", "find_name", "(", ")", ":", "name_file", "=", "read_file", "(", "'__init__.py'", ")", "name_match", "=", "re", ".", "search", "(", "r'^__package_name__ = [\"\\']([^\"\\']*)[\"\\']'", ",", "name_file", ",", "re", ".", "M", ")", "if", "name_match", ":", "...
Only define name in one place
[ "Only", "define", "name", "in", "one", "place" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L33-L40
232,941
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_class_with_while.py
workaround_type_coercions_in_recursions
def workaround_type_coercions_in_recursions(match_query): """Lower CoerceType blocks into Filter blocks within Recurse steps.""" # This step is required to work around an OrientDB bug that causes queries with both # "while:" and "class:" in the same query location to fail to parse correctly. # # Thi...
python
def workaround_type_coercions_in_recursions(match_query): """Lower CoerceType blocks into Filter blocks within Recurse steps.""" # This step is required to work around an OrientDB bug that causes queries with both # "while:" and "class:" in the same query location to fail to parse correctly. # # Thi...
[ "def", "workaround_type_coercions_in_recursions", "(", "match_query", ")", ":", "# This step is required to work around an OrientDB bug that causes queries with both", "# \"while:\" and \"class:\" in the same query location to fail to parse correctly.", "#", "# This bug is reported upstream: https...
Lower CoerceType blocks into Filter blocks within Recurse steps.
[ "Lower", "CoerceType", "blocks", "into", "Filter", "blocks", "within", "Recurse", "steps", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_class_with_while.py#L11-L42
232,942
kensho-technologies/graphql-compiler
graphql_compiler/tool.py
main
def main(): """Read a GraphQL query from standard input, and output it pretty-printed to standard output.""" query = ' '.join(sys.stdin.readlines()) sys.stdout.write(pretty_print_graphql(query))
python
def main(): """Read a GraphQL query from standard input, and output it pretty-printed to standard output.""" query = ' '.join(sys.stdin.readlines()) sys.stdout.write(pretty_print_graphql(query))
[ "def", "main", "(", ")", ":", "query", "=", "' '", ".", "join", "(", "sys", ".", "stdin", ".", "readlines", "(", ")", ")", "sys", ".", "stdout", ".", "write", "(", "pretty_print_graphql", "(", "query", ")", ")" ]
Read a GraphQL query from standard input, and output it pretty-printed to standard output.
[ "Read", "a", "GraphQL", "query", "from", "standard", "input", "and", "output", "it", "pretty", "-", "printed", "to", "standard", "output", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/tool.py#L12-L16
232,943
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/gremlin_formatting.py
_safe_gremlin_string
def _safe_gremlin_string(value): """Sanitize and represent a string argument in Gremlin.""" if not isinstance(value, six.string_types): if isinstance(value, bytes): # should only happen in py3 value = value.decode('utf-8') else: raise GraphQLInvalidArgumentError(u'Attemp...
python
def _safe_gremlin_string(value): """Sanitize and represent a string argument in Gremlin.""" if not isinstance(value, six.string_types): if isinstance(value, bytes): # should only happen in py3 value = value.decode('utf-8') else: raise GraphQLInvalidArgumentError(u'Attemp...
[ "def", "_safe_gremlin_string", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "# should only happen in py3", "value", "=", "value", ".", ...
Sanitize and represent a string argument in Gremlin.
[ "Sanitize", "and", "represent", "a", "string", "argument", "in", "Gremlin", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L18-L48
232,944
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/gremlin_formatting.py
_safe_gremlin_list
def _safe_gremlin_list(inner_type, argument_value): """Represent the list of "inner_type" objects in Gremlin form.""" if not isinstance(argument_value, list): raise GraphQLInvalidArgumentError(u'Attempting to represent a non-list as a list: ' u'{}'.format(argume...
python
def _safe_gremlin_list(inner_type, argument_value): """Represent the list of "inner_type" objects in Gremlin form.""" if not isinstance(argument_value, list): raise GraphQLInvalidArgumentError(u'Attempting to represent a non-list as a list: ' u'{}'.format(argume...
[ "def", "_safe_gremlin_list", "(", "inner_type", ",", "argument_value", ")", ":", "if", "not", "isinstance", "(", "argument_value", ",", "list", ")", ":", "raise", "GraphQLInvalidArgumentError", "(", "u'Attempting to represent a non-list as a list: '", "u'{}'", ".", "for...
Represent the list of "inner_type" objects in Gremlin form.
[ "Represent", "the", "list", "of", "inner_type", "objects", "in", "Gremlin", "form", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L81-L92
232,945
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/gremlin_formatting.py
_safe_gremlin_argument
def _safe_gremlin_argument(expected_type, argument_value): """Return a Gremlin string representing the given argument value.""" if GraphQLString.is_same_type(expected_type): return _safe_gremlin_string(argument_value) elif GraphQLID.is_same_type(expected_type): # IDs can be strings or number...
python
def _safe_gremlin_argument(expected_type, argument_value): """Return a Gremlin string representing the given argument value.""" if GraphQLString.is_same_type(expected_type): return _safe_gremlin_string(argument_value) elif GraphQLID.is_same_type(expected_type): # IDs can be strings or number...
[ "def", "_safe_gremlin_argument", "(", "expected_type", ",", "argument_value", ")", ":", "if", "GraphQLString", ".", "is_same_type", "(", "expected_type", ")", ":", "return", "_safe_gremlin_string", "(", "argument_value", ")", "elif", "GraphQLID", ".", "is_same_type", ...
Return a Gremlin string representing the given argument value.
[ "Return", "a", "Gremlin", "string", "representing", "the", "given", "argument", "value", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L95-L131
232,946
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/gremlin_formatting.py
insert_arguments_into_gremlin_query
def insert_arguments_into_gremlin_query(compilation_result, arguments): """Insert the arguments into the compiled Gremlin query to form a complete query. The GraphQL compiler attempts to use single-quoted string literals ('abc') in Gremlin output. Double-quoted strings allow inline interpolation with the $...
python
def insert_arguments_into_gremlin_query(compilation_result, arguments): """Insert the arguments into the compiled Gremlin query to form a complete query. The GraphQL compiler attempts to use single-quoted string literals ('abc') in Gremlin output. Double-quoted strings allow inline interpolation with the $...
[ "def", "insert_arguments_into_gremlin_query", "(", "compilation_result", ",", "arguments", ")", ":", "if", "compilation_result", ".", "language", "!=", "GREMLIN_LANGUAGE", ":", "raise", "AssertionError", "(", "u'Unexpected query output language: {}'", ".", "format", "(", ...
Insert the arguments into the compiled Gremlin query to form a complete query. The GraphQL compiler attempts to use single-quoted string literals ('abc') in Gremlin output. Double-quoted strings allow inline interpolation with the $ symbol, see here for details: http://www.groovy-lang.org/syntax.html#all-s...
[ "Insert", "the", "arguments", "into", "the", "compiled", "Gremlin", "query", "to", "form", "a", "complete", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L138-L167
232,947
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_get_vertex_location_name
def _get_vertex_location_name(location): """Get the location name from a location that is expected to point to a vertex.""" mark_name, field_name = location.get_location_name() if field_name is not None: raise AssertionError(u'Location unexpectedly pointed to a field: {}'.format(location)) retu...
python
def _get_vertex_location_name(location): """Get the location name from a location that is expected to point to a vertex.""" mark_name, field_name = location.get_location_name() if field_name is not None: raise AssertionError(u'Location unexpectedly pointed to a field: {}'.format(location)) retu...
[ "def", "_get_vertex_location_name", "(", "location", ")", ":", "mark_name", ",", "field_name", "=", "location", ".", "get_location_name", "(", ")", "if", "field_name", "is", "not", "None", ":", "raise", "AssertionError", "(", "u'Location unexpectedly pointed to a fiel...
Get the location name from a location that is expected to point to a vertex.
[ "Get", "the", "location", "name", "from", "a", "location", "that", "is", "expected", "to", "point", "to", "a", "vertex", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L12-L18
232,948
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_first_step_to_match
def _first_step_to_match(match_step): """Transform the very first MATCH step into a MATCH query string.""" parts = [] if match_step.root_block is not None: if not isinstance(match_step.root_block, QueryRoot): raise AssertionError(u'Expected None or QueryRoot root block, received: ' ...
python
def _first_step_to_match(match_step): """Transform the very first MATCH step into a MATCH query string.""" parts = [] if match_step.root_block is not None: if not isinstance(match_step.root_block, QueryRoot): raise AssertionError(u'Expected None or QueryRoot root block, received: ' ...
[ "def", "_first_step_to_match", "(", "match_step", ")", ":", "parts", "=", "[", "]", "if", "match_step", ".", "root_block", "is", "not", "None", ":", "if", "not", "isinstance", "(", "match_step", ".", "root_block", ",", "QueryRoot", ")", ":", "raise", "Asse...
Transform the very first MATCH step into a MATCH query string.
[ "Transform", "the", "very", "first", "MATCH", "step", "into", "a", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L21-L50
232,949
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_represent_match_traversal
def _represent_match_traversal(match_traversal): """Emit MATCH query code for an entire MATCH traversal sequence.""" output = [] output.append(_first_step_to_match(match_traversal[0])) for step in match_traversal[1:]: output.append(_subsequent_step_to_match(step)) return u''.join(output)
python
def _represent_match_traversal(match_traversal): """Emit MATCH query code for an entire MATCH traversal sequence.""" output = [] output.append(_first_step_to_match(match_traversal[0])) for step in match_traversal[1:]: output.append(_subsequent_step_to_match(step)) return u''.join(output)
[ "def", "_represent_match_traversal", "(", "match_traversal", ")", ":", "output", "=", "[", "]", "output", ".", "append", "(", "_first_step_to_match", "(", "match_traversal", "[", "0", "]", ")", ")", "for", "step", "in", "match_traversal", "[", "1", ":", "]",...
Emit MATCH query code for an entire MATCH traversal sequence.
[ "Emit", "MATCH", "query", "code", "for", "an", "entire", "MATCH", "traversal", "sequence", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L94-L102
232,950
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_represent_fold
def _represent_fold(fold_location, fold_ir_blocks): """Emit a LET clause corresponding to the IR blocks for a @fold scope.""" start_let_template = u'$%(mark_name)s = %(base_location)s' traverse_edge_template = u'.%(direction)s("%(edge_name)s")' base_template = start_let_template + traverse_edge_template...
python
def _represent_fold(fold_location, fold_ir_blocks): """Emit a LET clause corresponding to the IR blocks for a @fold scope.""" start_let_template = u'$%(mark_name)s = %(base_location)s' traverse_edge_template = u'.%(direction)s("%(edge_name)s")' base_template = start_let_template + traverse_edge_template...
[ "def", "_represent_fold", "(", "fold_location", ",", "fold_ir_blocks", ")", ":", "start_let_template", "=", "u'$%(mark_name)s = %(base_location)s'", "traverse_edge_template", "=", "u'.%(direction)s(\"%(edge_name)s\")'", "base_template", "=", "start_let_template", "+", "traverse_e...
Emit a LET clause corresponding to the IR blocks for a @fold scope.
[ "Emit", "a", "LET", "clause", "corresponding", "to", "the", "IR", "blocks", "for", "a" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L105-L147
232,951
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_construct_output_to_match
def _construct_output_to_match(output_block): """Transform a ConstructResult block into a MATCH query string.""" output_block.validate() selections = ( u'%s AS `%s`' % (output_block.fields[key].to_match(), key) for key in sorted(output_block.fields.keys()) # Sort keys for deterministic out...
python
def _construct_output_to_match(output_block): """Transform a ConstructResult block into a MATCH query string.""" output_block.validate() selections = ( u'%s AS `%s`' % (output_block.fields[key].to_match(), key) for key in sorted(output_block.fields.keys()) # Sort keys for deterministic out...
[ "def", "_construct_output_to_match", "(", "output_block", ")", ":", "output_block", ".", "validate", "(", ")", "selections", "=", "(", "u'%s AS `%s`'", "%", "(", "output_block", ".", "fields", "[", "key", "]", ".", "to_match", "(", ")", ",", "key", ")", "f...
Transform a ConstructResult block into a MATCH query string.
[ "Transform", "a", "ConstructResult", "block", "into", "a", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L150-L159
232,952
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_construct_where_to_match
def _construct_where_to_match(where_block): """Transform a Filter block into a MATCH query string.""" if where_block.predicate == TrueLiteral: raise AssertionError(u'Received WHERE block with TrueLiteral predicate: {}' .format(where_block)) return u'WHERE ' + where_block...
python
def _construct_where_to_match(where_block): """Transform a Filter block into a MATCH query string.""" if where_block.predicate == TrueLiteral: raise AssertionError(u'Received WHERE block with TrueLiteral predicate: {}' .format(where_block)) return u'WHERE ' + where_block...
[ "def", "_construct_where_to_match", "(", "where_block", ")", ":", "if", "where_block", ".", "predicate", "==", "TrueLiteral", ":", "raise", "AssertionError", "(", "u'Received WHERE block with TrueLiteral predicate: {}'", ".", "format", "(", "where_block", ")", ")", "ret...
Transform a Filter block into a MATCH query string.
[ "Transform", "a", "Filter", "block", "into", "a", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L162-L167
232,953
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
emit_code_from_multiple_match_queries
def emit_code_from_multiple_match_queries(match_queries): """Return a MATCH query string from a list of MatchQuery namedtuples.""" optional_variable_base_name = '$optional__' union_variable_name = '$result' query_data = deque([u'SELECT EXPAND(', union_variable_name, u')', u' LET ']) optional_variab...
python
def emit_code_from_multiple_match_queries(match_queries): """Return a MATCH query string from a list of MatchQuery namedtuples.""" optional_variable_base_name = '$optional__' union_variable_name = '$result' query_data = deque([u'SELECT EXPAND(', union_variable_name, u')', u' LET ']) optional_variab...
[ "def", "emit_code_from_multiple_match_queries", "(", "match_queries", ")", ":", "optional_variable_base_name", "=", "'$optional__'", "union_variable_name", "=", "'$result'", "query_data", "=", "deque", "(", "[", "u'SELECT EXPAND('", ",", "union_variable_name", ",", "u')'", ...
Return a MATCH query string from a list of MatchQuery namedtuples.
[ "Return", "a", "MATCH", "query", "string", "from", "a", "list", "of", "MatchQuery", "namedtuples", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L218-L241
232,954
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
emit_code_from_ir
def emit_code_from_ir(compound_match_query, compiler_metadata): """Return a MATCH query string from a CompoundMatchQuery.""" # If the compound match query contains only one match query, # just call `emit_code_from_single_match_query` # If there are multiple match queries, construct the query string for ...
python
def emit_code_from_ir(compound_match_query, compiler_metadata): """Return a MATCH query string from a CompoundMatchQuery.""" # If the compound match query contains only one match query, # just call `emit_code_from_single_match_query` # If there are multiple match queries, construct the query string for ...
[ "def", "emit_code_from_ir", "(", "compound_match_query", ",", "compiler_metadata", ")", ":", "# If the compound match query contains only one match query,", "# just call `emit_code_from_single_match_query`", "# If there are multiple match queries, construct the query string for each", "# indiv...
Return a MATCH query string from a CompoundMatchQuery.
[ "Return", "a", "MATCH", "query", "string", "from", "a", "CompoundMatchQuery", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L244-L276
232,955
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
_serialize_date
def _serialize_date(value): """Serialize a Date object to its proper ISO-8601 representation.""" if not isinstance(value, date): raise ValueError(u'The received object was not a date: ' u'{} {}'.format(type(value), value)) return value.isoformat()
python
def _serialize_date(value): """Serialize a Date object to its proper ISO-8601 representation.""" if not isinstance(value, date): raise ValueError(u'The received object was not a date: ' u'{} {}'.format(type(value), value)) return value.isoformat()
[ "def", "_serialize_date", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "date", ")", ":", "raise", "ValueError", "(", "u'The received object was not a date: '", "u'{} {}'", ".", "format", "(", "type", "(", "value", ")", ",", "value", ...
Serialize a Date object to its proper ISO-8601 representation.
[ "Serialize", "a", "Date", "object", "to", "its", "proper", "ISO", "-", "8601", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L201-L206
232,956
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
_serialize_datetime
def _serialize_datetime(value): """Serialize a DateTime object to its proper ISO-8601 representation.""" if not isinstance(value, (datetime, arrow.Arrow)): raise ValueError(u'The received object was not a datetime: ' u'{} {}'.format(type(value), value)) return value.isoforma...
python
def _serialize_datetime(value): """Serialize a DateTime object to its proper ISO-8601 representation.""" if not isinstance(value, (datetime, arrow.Arrow)): raise ValueError(u'The received object was not a datetime: ' u'{} {}'.format(type(value), value)) return value.isoforma...
[ "def", "_serialize_datetime", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "datetime", ",", "arrow", ".", "Arrow", ")", ")", ":", "raise", "ValueError", "(", "u'The received object was not a datetime: '", "u'{} {}'", ".", "format", ...
Serialize a DateTime object to its proper ISO-8601 representation.
[ "Serialize", "a", "DateTime", "object", "to", "its", "proper", "ISO", "-", "8601", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L214-L219
232,957
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
_parse_datetime_value
def _parse_datetime_value(value): """Deserialize a DateTime object from its proper ISO-8601 representation.""" if value.endswith('Z'): # Arrow doesn't support the "Z" literal to denote UTC time. # Strip the "Z" and add an explicit time zone instead. value = value[:-1] + '+00:00' ret...
python
def _parse_datetime_value(value): """Deserialize a DateTime object from its proper ISO-8601 representation.""" if value.endswith('Z'): # Arrow doesn't support the "Z" literal to denote UTC time. # Strip the "Z" and add an explicit time zone instead. value = value[:-1] + '+00:00' ret...
[ "def", "_parse_datetime_value", "(", "value", ")", ":", "if", "value", ".", "endswith", "(", "'Z'", ")", ":", "# Arrow doesn't support the \"Z\" literal to denote UTC time.", "# Strip the \"Z\" and add an explicit time zone instead.", "value", "=", "value", "[", ":", "-", ...
Deserialize a DateTime object from its proper ISO-8601 representation.
[ "Deserialize", "a", "DateTime", "object", "from", "its", "proper", "ISO", "-", "8601", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L222-L229
232,958
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
insert_meta_fields_into_existing_schema
def insert_meta_fields_into_existing_schema(graphql_schema): """Add compiler-specific meta-fields into all interfaces and types of the specified schema. It is preferable to use the EXTENDED_META_FIELD_DEFINITIONS constant above to directly inject the meta-fields during the initial process of building the s...
python
def insert_meta_fields_into_existing_schema(graphql_schema): """Add compiler-specific meta-fields into all interfaces and types of the specified schema. It is preferable to use the EXTENDED_META_FIELD_DEFINITIONS constant above to directly inject the meta-fields during the initial process of building the s...
[ "def", "insert_meta_fields_into_existing_schema", "(", "graphql_schema", ")", ":", "root_type_name", "=", "graphql_schema", ".", "get_query_type", "(", ")", ".", "name", "for", "type_name", ",", "type_obj", "in", "six", ".", "iteritems", "(", "graphql_schema", ".", ...
Add compiler-specific meta-fields into all interfaces and types of the specified schema. It is preferable to use the EXTENDED_META_FIELD_DEFINITIONS constant above to directly inject the meta-fields during the initial process of building the schema, as that approach is more robust. This function does its b...
[ "Add", "compiler", "-", "specific", "meta", "-", "fields", "into", "all", "interfaces", "and", "types", "of", "the", "specified", "schema", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L302-L338
232,959
kensho-technologies/graphql-compiler
graphql_compiler/compiler/context_helpers.py
validate_context_for_visiting_vertex_field
def validate_context_for_visiting_vertex_field(parent_location, vertex_field_name, context): """Ensure that the current context allows for visiting a vertex field.""" if is_in_fold_innermost_scope(context): raise GraphQLCompilationError( u'Traversing inside a @fold block after filtering on {...
python
def validate_context_for_visiting_vertex_field(parent_location, vertex_field_name, context): """Ensure that the current context allows for visiting a vertex field.""" if is_in_fold_innermost_scope(context): raise GraphQLCompilationError( u'Traversing inside a @fold block after filtering on {...
[ "def", "validate_context_for_visiting_vertex_field", "(", "parent_location", ",", "vertex_field_name", ",", "context", ")", ":", "if", "is_in_fold_innermost_scope", "(", "context", ")", ":", "raise", "GraphQLCompilationError", "(", "u'Traversing inside a @fold block after filte...
Ensure that the current context allows for visiting a vertex field.
[ "Ensure", "that", "the", "current", "context", "allows", "for", "visiting", "a", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/context_helpers.py#L95-L101
232,960
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/graphql_formatting.py
pretty_print_graphql
def pretty_print_graphql(query, use_four_spaces=True): """Take a GraphQL query, pretty print it, and return it.""" # Use our custom visitor, which fixes directive argument order # to get the canonical representation output = visit(parse(query), CustomPrintingVisitor()) # Using four spaces for inden...
python
def pretty_print_graphql(query, use_four_spaces=True): """Take a GraphQL query, pretty print it, and return it.""" # Use our custom visitor, which fixes directive argument order # to get the canonical representation output = visit(parse(query), CustomPrintingVisitor()) # Using four spaces for inden...
[ "def", "pretty_print_graphql", "(", "query", ",", "use_four_spaces", "=", "True", ")", ":", "# Use our custom visitor, which fixes directive argument order", "# to get the canonical representation", "output", "=", "visit", "(", "parse", "(", "query", ")", ",", "CustomPrinti...
Take a GraphQL query, pretty print it, and return it.
[ "Take", "a", "GraphQL", "query", "pretty", "print", "it", "and", "return", "it", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/graphql_formatting.py#L10-L20
232,961
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/graphql_formatting.py
fix_indentation_depth
def fix_indentation_depth(query): """Make indentation use 4 spaces, rather than the 2 spaces GraphQL normally uses.""" lines = query.split('\n') final_lines = [] for line in lines: consecutive_spaces = 0 for char in line: if char == ' ': consecutive_spaces +=...
python
def fix_indentation_depth(query): """Make indentation use 4 spaces, rather than the 2 spaces GraphQL normally uses.""" lines = query.split('\n') final_lines = [] for line in lines: consecutive_spaces = 0 for char in line: if char == ' ': consecutive_spaces +=...
[ "def", "fix_indentation_depth", "(", "query", ")", ":", "lines", "=", "query", ".", "split", "(", "'\\n'", ")", "final_lines", "=", "[", "]", "for", "line", "in", "lines", ":", "consecutive_spaces", "=", "0", "for", "char", "in", "line", ":", "if", "ch...
Make indentation use 4 spaces, rather than the 2 spaces GraphQL normally uses.
[ "Make", "indentation", "use", "4", "spaces", "rather", "than", "the", "2", "spaces", "GraphQL", "normally", "uses", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/graphql_formatting.py#L67-L86
232,962
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/graphql_formatting.py
CustomPrintingVisitor.leave_Directive
def leave_Directive(self, node, *args): """Call when exiting a directive node in the ast.""" name_to_arg_value = { # Taking [0] is ok here because the GraphQL parser checks for the # existence of ':' in directive arguments. arg.split(':', 1)[0]: arg for ar...
python
def leave_Directive(self, node, *args): """Call when exiting a directive node in the ast.""" name_to_arg_value = { # Taking [0] is ok here because the GraphQL parser checks for the # existence of ':' in directive arguments. arg.split(':', 1)[0]: arg for ar...
[ "def", "leave_Directive", "(", "self", ",", "node", ",", "*", "args", ")", ":", "name_to_arg_value", "=", "{", "# Taking [0] is ok here because the GraphQL parser checks for the", "# existence of ':' in directive arguments.", "arg", ".", "split", "(", "':'", ",", "1", "...
Call when exiting a directive node in the ast.
[ "Call", "when", "exiting", "a", "directive", "node", "in", "the", "ast", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/graphql_formatting.py#L32-L64
232,963
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/__init__.py
lower_ir
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR into an IR form that can be represented in MATCH queries. Args: ir_blocks: list of IR blocks to lower into MATCH-compatible form query_metadata_table: QueryMetadataTable object containing all metadata co...
python
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR into an IR form that can be represented in MATCH queries. Args: ir_blocks: list of IR blocks to lower into MATCH-compatible form query_metadata_table: QueryMetadataTable object containing all metadata co...
[ "def", "lower_ir", "(", "ir_blocks", ",", "query_metadata_table", ",", "type_equivalence_hints", "=", "None", ")", ":", "sanity_check_ir_blocks_from_frontend", "(", "ir_blocks", ",", "query_metadata_table", ")", "# Construct the mapping of each location to its corresponding Graph...
Lower the IR into an IR form that can be represented in MATCH queries. Args: ir_blocks: list of IR blocks to lower into MATCH-compatible form query_metadata_table: QueryMetadataTable object containing all metadata collected during query processing, including location m...
[ "Lower", "the", "IR", "into", "an", "IR", "form", "that", "can", "be", "represented", "in", "MATCH", "queries", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/__init__.py#L31-L128
232,964
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/utils.py
toposort_classes
def toposort_classes(classes): """Sort class metadatas so that a superclass is always before the subclass""" def get_class_topolist(class_name, name_to_class, processed_classes, current_trace): """Return a topologically sorted list of this class's dependencies and class itself Args: ...
python
def toposort_classes(classes): """Sort class metadatas so that a superclass is always before the subclass""" def get_class_topolist(class_name, name_to_class, processed_classes, current_trace): """Return a topologically sorted list of this class's dependencies and class itself Args: ...
[ "def", "toposort_classes", "(", "classes", ")", ":", "def", "get_class_topolist", "(", "class_name", ",", "name_to_class", ",", "processed_classes", ",", "current_trace", ")", ":", "\"\"\"Return a topologically sorted list of this class's dependencies and class itself\n\n ...
Sort class metadatas so that a superclass is always before the subclass
[ "Sort", "class", "metadatas", "so", "that", "a", "superclass", "is", "always", "before", "the", "subclass" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/utils.py#L11-L63
232,965
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/utils.py
_list_superclasses
def _list_superclasses(class_def): """Return a list of the superclasses of the given class""" superclasses = class_def.get('superClasses', []) if superclasses: # Make sure to duplicate the list return list(superclasses) sup = class_def.get('superClass', None) if sup: return ...
python
def _list_superclasses(class_def): """Return a list of the superclasses of the given class""" superclasses = class_def.get('superClasses', []) if superclasses: # Make sure to duplicate the list return list(superclasses) sup = class_def.get('superClass', None) if sup: return ...
[ "def", "_list_superclasses", "(", "class_def", ")", ":", "superclasses", "=", "class_def", ".", "get", "(", "'superClasses'", ",", "[", "]", ")", "if", "superclasses", ":", "# Make sure to duplicate the list", "return", "list", "(", "superclasses", ")", "sup", "...
Return a list of the superclasses of the given class
[ "Return", "a", "list", "of", "the", "superclasses", "of", "the", "given", "class" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/utils.py#L66-L77
232,966
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_construct_location_stack_entry
def _construct_location_stack_entry(location, num_traverses): """Return a LocationStackEntry namedtuple with the specified parameters.""" if not isinstance(num_traverses, int) or num_traverses < 0: raise AssertionError(u'Attempted to create a LocationStackEntry namedtuple with an invalid ' ...
python
def _construct_location_stack_entry(location, num_traverses): """Return a LocationStackEntry namedtuple with the specified parameters.""" if not isinstance(num_traverses, int) or num_traverses < 0: raise AssertionError(u'Attempted to create a LocationStackEntry namedtuple with an invalid ' ...
[ "def", "_construct_location_stack_entry", "(", "location", ",", "num_traverses", ")", ":", "if", "not", "isinstance", "(", "num_traverses", ",", "int", ")", "or", "num_traverses", "<", "0", ":", "raise", "AssertionError", "(", "u'Attempted to create a LocationStackEnt...
Return a LocationStackEntry namedtuple with the specified parameters.
[ "Return", "a", "LocationStackEntry", "namedtuple", "with", "the", "specified", "parameters", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L103-L113
232,967
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_get_fields
def _get_fields(ast): """Return a list of vertex fields, and a list of property fields, for the given AST node. Also verifies that all property fields for the AST node appear before all vertex fields, raising GraphQLCompilationError if that is not the case. Args: ast: GraphQL AST node, obtaine...
python
def _get_fields(ast): """Return a list of vertex fields, and a list of property fields, for the given AST node. Also verifies that all property fields for the AST node appear before all vertex fields, raising GraphQLCompilationError if that is not the case. Args: ast: GraphQL AST node, obtaine...
[ "def", "_get_fields", "(", "ast", ")", ":", "if", "not", "ast", ".", "selection_set", ":", "# There are no child fields.", "return", "[", "]", ",", "[", "]", "property_fields", "=", "[", "]", "vertex_fields", "=", "[", "]", "seen_field_names", "=", "set", ...
Return a list of vertex fields, and a list of property fields, for the given AST node. Also verifies that all property fields for the AST node appear before all vertex fields, raising GraphQLCompilationError if that is not the case. Args: ast: GraphQL AST node, obtained from the graphql library ...
[ "Return", "a", "list", "of", "vertex", "fields", "and", "a", "list", "of", "property", "fields", "for", "the", "given", "AST", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L142-L187
232,968
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_get_inline_fragment
def _get_inline_fragment(ast): """Return the inline fragment at the current AST node, or None if no fragment exists.""" if not ast.selection_set: # There is nothing selected here, so no fragment. return None fragments = [ ast_node for ast_node in ast.selection_set.selections...
python
def _get_inline_fragment(ast): """Return the inline fragment at the current AST node, or None if no fragment exists.""" if not ast.selection_set: # There is nothing selected here, so no fragment. return None fragments = [ ast_node for ast_node in ast.selection_set.selections...
[ "def", "_get_inline_fragment", "(", "ast", ")", ":", "if", "not", "ast", ".", "selection_set", ":", "# There is nothing selected here, so no fragment.", "return", "None", "fragments", "=", "[", "ast_node", "for", "ast_node", "in", "ast", ".", "selection_set", ".", ...
Return the inline fragment at the current AST node, or None if no fragment exists.
[ "Return", "the", "inline", "fragment", "at", "the", "current", "AST", "node", "or", "None", "if", "no", "fragment", "exists", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L190-L209
232,969
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_process_output_source_directive
def _process_output_source_directive(schema, current_schema_type, ast, location, context, local_unique_directives): """Process the output_source directive, modifying the context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library ...
python
def _process_output_source_directive(schema, current_schema_type, ast, location, context, local_unique_directives): """Process the output_source directive, modifying the context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library ...
[ "def", "_process_output_source_directive", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ",", "local_unique_directives", ")", ":", "# The 'ast' variable is only for function signature uniformity, and is currently not used.", "output_source_...
Process the output_source directive, modifying the context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: GraphQL AST node, obtained from the graphql library locati...
[ "Process", "the", "output_source", "directive", "modifying", "the", "context", "as", "appropriate", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L217-L244
232,970
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_property_ast
def _compile_property_ast(schema, current_schema_type, ast, location, context, unique_local_directives): """Process property directives at this AST node, updating the query context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library c...
python
def _compile_property_ast(schema, current_schema_type, ast, location, context, unique_local_directives): """Process property directives at this AST node, updating the query context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library c...
[ "def", "_compile_property_ast", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ",", "unique_local_directives", ")", ":", "validate_property_directives", "(", "unique_local_directives", ")", "if", "location", ".", "field", "==",...
Process property directives at this AST node, updating the query context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: GraphQL AST node, obtained from the graphql library....
[ "Process", "property", "directives", "at", "this", "AST", "node", "updating", "the", "query", "context", "as", "appropriate", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L247-L320
232,971
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_get_recurse_directive_depth
def _get_recurse_directive_depth(field_name, field_directives): """Validate and return the depth parameter of the recurse directive.""" recurse_directive = field_directives['recurse'] optional_directive = field_directives.get('optional', None) if optional_directive: raise GraphQLCompilationErro...
python
def _get_recurse_directive_depth(field_name, field_directives): """Validate and return the depth parameter of the recurse directive.""" recurse_directive = field_directives['recurse'] optional_directive = field_directives.get('optional', None) if optional_directive: raise GraphQLCompilationErro...
[ "def", "_get_recurse_directive_depth", "(", "field_name", ",", "field_directives", ")", ":", "recurse_directive", "=", "field_directives", "[", "'recurse'", "]", "optional_directive", "=", "field_directives", ".", "get", "(", "'optional'", ",", "None", ")", "if", "o...
Validate and return the depth parameter of the recurse directive.
[ "Validate", "and", "return", "the", "depth", "parameter", "of", "the", "recurse", "directive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L323-L338
232,972
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_validate_recurse_directive_types
def _validate_recurse_directive_types(current_schema_type, field_schema_type, context): """Perform type checks on the enclosing type and the recursed type for a recurse directive. Args: current_schema_type: GraphQLType, the schema type at the current location field_schema_type: GraphQLType, the...
python
def _validate_recurse_directive_types(current_schema_type, field_schema_type, context): """Perform type checks on the enclosing type and the recursed type for a recurse directive. Args: current_schema_type: GraphQLType, the schema type at the current location field_schema_type: GraphQLType, the...
[ "def", "_validate_recurse_directive_types", "(", "current_schema_type", ",", "field_schema_type", ",", "context", ")", ":", "# Get the set of all allowed types in the current scope.", "type_hints", "=", "context", "[", "'type_equivalence_hints'", "]", ".", "get", "(", "field_...
Perform type checks on the enclosing type and the recursed type for a recurse directive. Args: current_schema_type: GraphQLType, the schema type at the current location field_schema_type: GraphQLType, the schema type at the inner scope context: dict, various per-compilation data (e.g. decla...
[ "Perform", "type", "checks", "on", "the", "enclosing", "type", "and", "the", "recursed", "type", "for", "a", "recurse", "directive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L341-L376
232,973
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_fragment_ast
def _compile_fragment_ast(schema, current_schema_type, ast, location, context): """Return a list of basic blocks corresponding to the inline fragment at this AST node. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the...
python
def _compile_fragment_ast(schema, current_schema_type, ast, location, context): """Return a list of basic blocks corresponding to the inline fragment at this AST node. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the...
[ "def", "_compile_fragment_ast", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ")", ":", "query_metadata_table", "=", "context", "[", "'metadata'", "]", "# step F-2. Emit a type coercion block if appropriate,", "# then recu...
Return a list of basic blocks corresponding to the inline fragment at this AST node. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: GraphQL AST node, obtained from the graphql library. ...
[ "Return", "a", "list", "of", "basic", "blocks", "corresponding", "to", "the", "inline", "fragment", "at", "this", "AST", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L583-L626
232,974
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_ast_node_to_ir
def _compile_ast_node_to_ir(schema, current_schema_type, ast, location, context): """Compile the given GraphQL AST node into a list of basic blocks. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ...
python
def _compile_ast_node_to_ir(schema, current_schema_type, ast, location, context): """Compile the given GraphQL AST node into a list of basic blocks. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ...
[ "def", "_compile_ast_node_to_ir", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ")", ":", "basic_blocks", "=", "[", "]", "# step 0: preprocessing", "local_unique_directives", "=", "get_unique_directives", "(", "ast", ")", "f...
Compile the given GraphQL AST node into a list of basic blocks. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: the current GraphQL AST node, obtained from the graphql library locat...
[ "Compile", "the", "given", "GraphQL", "AST", "node", "into", "a", "list", "of", "basic", "blocks", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L629-L720
232,975
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_validate_all_tags_are_used
def _validate_all_tags_are_used(metadata): """Ensure all tags are used in some filter.""" tag_names = set([tag_name for tag_name, _ in metadata.tags]) filter_arg_names = set() for location, _ in metadata.registered_locations: for filter_info in metadata.get_filter_infos(location): fo...
python
def _validate_all_tags_are_used(metadata): """Ensure all tags are used in some filter.""" tag_names = set([tag_name for tag_name, _ in metadata.tags]) filter_arg_names = set() for location, _ in metadata.registered_locations: for filter_info in metadata.get_filter_infos(location): fo...
[ "def", "_validate_all_tags_are_used", "(", "metadata", ")", ":", "tag_names", "=", "set", "(", "[", "tag_name", "for", "tag_name", ",", "_", "in", "metadata", ".", "tags", "]", ")", "filter_arg_names", "=", "set", "(", ")", "for", "location", ",", "_", "...
Ensure all tags are used in some filter.
[ "Ensure", "all", "tags", "are", "used", "in", "some", "filter", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L723-L738
232,976
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_output_step
def _compile_output_step(outputs): """Construct the final ConstructResult basic block that defines the output format of the query. Args: outputs: dict, output name (string) -> output data dict, specifying the location from where to get the data, and whether the data is optional (and th...
python
def _compile_output_step(outputs): """Construct the final ConstructResult basic block that defines the output format of the query. Args: outputs: dict, output name (string) -> output data dict, specifying the location from where to get the data, and whether the data is optional (and th...
[ "def", "_compile_output_step", "(", "outputs", ")", ":", "if", "not", "outputs", ":", "raise", "GraphQLCompilationError", "(", "u'No fields were selected for output! Please mark at least '", "u'one field with the @output directive.'", ")", "output_fields", "=", "{", "}", "for...
Construct the final ConstructResult basic block that defines the output format of the query. Args: outputs: dict, output name (string) -> output data dict, specifying the location from where to get the data, and whether the data is optional (and therefore may be missing); ...
[ "Construct", "the", "final", "ConstructResult", "basic", "block", "that", "defines", "the", "output", "format", "of", "the", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L866-L912
232,977
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_validate_schema_and_ast
def _validate_schema_and_ast(schema, ast): """Validate the supplied graphql schema and ast. This method wraps around graphql-core's validation to enforce a stricter requirement of the schema -- all directives supported by the compiler must be declared by the schema, regardless of whether each directive...
python
def _validate_schema_and_ast(schema, ast): """Validate the supplied graphql schema and ast. This method wraps around graphql-core's validation to enforce a stricter requirement of the schema -- all directives supported by the compiler must be declared by the schema, regardless of whether each directive...
[ "def", "_validate_schema_and_ast", "(", "schema", ",", "ast", ")", ":", "core_graphql_errors", "=", "validate", "(", "schema", ",", "ast", ")", "# The following directives appear in the core-graphql library, but are not supported by the", "# graphql compiler.", "unsupported_defau...
Validate the supplied graphql schema and ast. This method wraps around graphql-core's validation to enforce a stricter requirement of the schema -- all directives supported by the compiler must be declared by the schema, regardless of whether each directive is used in the query or not. Args: s...
[ "Validate", "the", "supplied", "graphql", "schema", "and", "ast", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L922-L996
232,978
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
graphql_to_ir
def graphql_to_ir(schema, graphql_string, type_equivalence_hints=None): """Convert the given GraphQL string into compiler IR, using the given schema object. Args: schema: GraphQL schema object, created using the GraphQL library graphql_string: string containing the GraphQL to compile to compile...
python
def graphql_to_ir(schema, graphql_string, type_equivalence_hints=None): """Convert the given GraphQL string into compiler IR, using the given schema object. Args: schema: GraphQL schema object, created using the GraphQL library graphql_string: string containing the GraphQL to compile to compile...
[ "def", "graphql_to_ir", "(", "schema", ",", "graphql_string", ",", "type_equivalence_hints", "=", "None", ")", ":", "graphql_string", "=", "_preprocess_graphql_string", "(", "graphql_string", ")", "try", ":", "ast", "=", "parse", "(", "graphql_string", ")", "excep...
Convert the given GraphQL string into compiler IR, using the given schema object. Args: schema: GraphQL schema object, created using the GraphQL library graphql_string: string containing the GraphQL to compile to compiler IR type_equivalence_hints: optional dict of GraphQL interface or type...
[ "Convert", "the", "given", "GraphQL", "string", "into", "compiler", "IR", "using", "the", "given", "schema", "object", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L1003-L1059
232,979
kensho-technologies/graphql-compiler
graphql_compiler/debugging_utils.py
pretty_print_gremlin
def pretty_print_gremlin(gremlin): """Return a human-readable representation of a gremlin command string.""" gremlin = remove_custom_formatting(gremlin) too_many_parts = re.split(r'([)}]|scatter)[ ]?\.', gremlin) # Put the ) and } back on. parts = [ too_many_parts[i] + too_many_parts[i + 1]...
python
def pretty_print_gremlin(gremlin): """Return a human-readable representation of a gremlin command string.""" gremlin = remove_custom_formatting(gremlin) too_many_parts = re.split(r'([)}]|scatter)[ ]?\.', gremlin) # Put the ) and } back on. parts = [ too_many_parts[i] + too_many_parts[i + 1]...
[ "def", "pretty_print_gremlin", "(", "gremlin", ")", ":", "gremlin", "=", "remove_custom_formatting", "(", "gremlin", ")", "too_many_parts", "=", "re", ".", "split", "(", "r'([)}]|scatter)[ ]?\\.'", ",", "gremlin", ")", "# Put the ) and } back on.", "parts", "=", "["...
Return a human-readable representation of a gremlin command string.
[ "Return", "a", "human", "-", "readable", "representation", "of", "a", "gremlin", "command", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/debugging_utils.py#L13-L44
232,980
kensho-technologies/graphql-compiler
graphql_compiler/debugging_utils.py
pretty_print_match
def pretty_print_match(match, parameterized=True): """Return a human-readable representation of a parameterized MATCH query string.""" left_curly = '{{' if parameterized else '{' right_curly = '}}' if parameterized else '}' match = remove_custom_formatting(match) parts = re.split('({}|{})'.format(le...
python
def pretty_print_match(match, parameterized=True): """Return a human-readable representation of a parameterized MATCH query string.""" left_curly = '{{' if parameterized else '{' right_curly = '}}' if parameterized else '}' match = remove_custom_formatting(match) parts = re.split('({}|{})'.format(le...
[ "def", "pretty_print_match", "(", "match", ",", "parameterized", "=", "True", ")", ":", "left_curly", "=", "'{{'", "if", "parameterized", "else", "'{'", "right_curly", "=", "'}}'", "if", "parameterized", "else", "'}'", "match", "=", "remove_custom_formatting", "...
Return a human-readable representation of a parameterized MATCH query string.
[ "Return", "a", "human", "-", "readable", "representation", "of", "a", "parameterized", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/debugging_utils.py#L47-L96
232,981
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/representations.py
represent_float_as_str
def represent_float_as_str(value): """Represent a float as a string without losing precision.""" # In Python 2, calling str() on a float object loses precision: # # In [1]: 1.23456789012345678 # Out[1]: 1.2345678901234567 # # In [2]: 1.2345678901234567 # Out[2]: 1.2345678901234567 # ...
python
def represent_float_as_str(value): """Represent a float as a string without losing precision.""" # In Python 2, calling str() on a float object loses precision: # # In [1]: 1.23456789012345678 # Out[1]: 1.2345678901234567 # # In [2]: 1.2345678901234567 # Out[2]: 1.2345678901234567 # ...
[ "def", "represent_float_as_str", "(", "value", ")", ":", "# In Python 2, calling str() on a float object loses precision:", "#", "# In [1]: 1.23456789012345678", "# Out[1]: 1.2345678901234567", "#", "# In [2]: 1.2345678901234567", "# Out[2]: 1.2345678901234567", "#", "# In [3]: str(1.234...
Represent a float as a string without losing precision.
[ "Represent", "a", "float", "as", "a", "string", "without", "losing", "precision", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/representations.py#L8-L29
232,982
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/representations.py
coerce_to_decimal
def coerce_to_decimal(value): """Attempt to coerce the value to a Decimal, or raise an error if unable to do so.""" if isinstance(value, decimal.Decimal): return value else: try: return decimal.Decimal(value) except decimal.InvalidOperation as e: raise GraphQL...
python
def coerce_to_decimal(value): """Attempt to coerce the value to a Decimal, or raise an error if unable to do so.""" if isinstance(value, decimal.Decimal): return value else: try: return decimal.Decimal(value) except decimal.InvalidOperation as e: raise GraphQL...
[ "def", "coerce_to_decimal", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "decimal", ".", "Decimal", ")", ":", "return", "value", "else", ":", "try", ":", "return", "decimal", ".", "Decimal", "(", "value", ")", "except", "decimal", ".", ...
Attempt to coerce the value to a Decimal, or raise an error if unable to do so.
[ "Attempt", "to", "coerce", "the", "value", "to", "a", "Decimal", "or", "raise", "an", "error", "if", "unable", "to", "do", "so", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/representations.py#L41-L49
232,983
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
make_replacement_visitor
def make_replacement_visitor(find_expression, replace_expression): """Return a visitor function that replaces every instance of one expression with another one.""" def visitor_fn(expression): """Return the replacement if this expression matches the expression we're looking for.""" if expression ...
python
def make_replacement_visitor(find_expression, replace_expression): """Return a visitor function that replaces every instance of one expression with another one.""" def visitor_fn(expression): """Return the replacement if this expression matches the expression we're looking for.""" if expression ...
[ "def", "make_replacement_visitor", "(", "find_expression", ",", "replace_expression", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "\"\"\"Return the replacement if this expression matches the expression we're looking for.\"\"\"", "if", "expression", "==", "find_exp...
Return a visitor function that replaces every instance of one expression with another one.
[ "Return", "a", "visitor", "function", "that", "replaces", "every", "instance", "of", "one", "expression", "with", "another", "one", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L29-L38
232,984
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
make_type_replacement_visitor
def make_type_replacement_visitor(find_types, replacement_func): """Return a visitor function that replaces expressions of a given type with new expressions.""" def visitor_fn(expression): """Return a replacement expression if the original expression is of the correct type.""" if isinstance(expr...
python
def make_type_replacement_visitor(find_types, replacement_func): """Return a visitor function that replaces expressions of a given type with new expressions.""" def visitor_fn(expression): """Return a replacement expression if the original expression is of the correct type.""" if isinstance(expr...
[ "def", "make_type_replacement_visitor", "(", "find_types", ",", "replacement_func", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "\"\"\"Return a replacement expression if the original expression is of the correct type.\"\"\"", "if", "isinstance", "(", "expression",...
Return a visitor function that replaces expressions of a given type with new expressions.
[ "Return", "a", "visitor", "function", "that", "replaces", "expressions", "of", "a", "given", "type", "with", "new", "expressions", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L41-L50
232,985
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
_validate_operator_name
def _validate_operator_name(operator, supported_operators): """Ensure the named operator is valid and supported.""" if not isinstance(operator, six.text_type): raise TypeError(u'Expected operator as unicode string, got: {} {}'.format( type(operator).__name__, operator)) if operator not ...
python
def _validate_operator_name(operator, supported_operators): """Ensure the named operator is valid and supported.""" if not isinstance(operator, six.text_type): raise TypeError(u'Expected operator as unicode string, got: {} {}'.format( type(operator).__name__, operator)) if operator not ...
[ "def", "_validate_operator_name", "(", "operator", ",", "supported_operators", ")", ":", "if", "not", "isinstance", "(", "operator", ",", "six", ".", "text_type", ")", ":", "raise", "TypeError", "(", "u'Expected operator as unicode string, got: {} {}'", ".", "format",...
Ensure the named operator is valid and supported.
[ "Ensure", "the", "named", "operator", "is", "valid", "and", "supported", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L665-L672
232,986
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
Literal.validate
def validate(self): """Validate that the Literal is correctly representable.""" # Literals representing boolean values or None are correctly representable and supported. if self.value is None or self.value is True or self.value is False: return # Literal safe strings are cor...
python
def validate(self): """Validate that the Literal is correctly representable.""" # Literals representing boolean values or None are correctly representable and supported. if self.value is None or self.value is True or self.value is False: return # Literal safe strings are cor...
[ "def", "validate", "(", "self", ")", ":", "# Literals representing boolean values or None are correctly representable and supported.", "if", "self", ".", "value", "is", "None", "or", "self", ".", "value", "is", "True", "or", "self", ".", "value", "is", "False", ":",...
Validate that the Literal is correctly representable.
[ "Validate", "that", "the", "Literal", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L72-L95
232,987
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
Variable.validate
def validate(self): """Validate that the Variable is correctly representable.""" # Get the first letter, or empty string if it doesn't exist. if not self.variable_name.startswith(u'$'): raise GraphQLCompilationError(u'Expected variable name to start with $, but was: ' ...
python
def validate(self): """Validate that the Variable is correctly representable.""" # Get the first letter, or empty string if it doesn't exist. if not self.variable_name.startswith(u'$'): raise GraphQLCompilationError(u'Expected variable name to start with $, but was: ' ...
[ "def", "validate", "(", "self", ")", ":", "# Get the first letter, or empty string if it doesn't exist.", "if", "not", "self", ".", "variable_name", ".", "startswith", "(", "u'$'", ")", ":", "raise", "GraphQLCompilationError", "(", "u'Expected variable name to start with $,...
Validate that the Variable is correctly representable.
[ "Validate", "that", "the", "Variable", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L154-L183
232,988
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
Variable.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this Variable.""" self.validate() # We don't want the dollar sign as part of the variable name. variable_with_no_dollar_sign = self.variable_name[1:] match_variable_name = '{%s}' % (six.text_type(va...
python
def to_match(self): """Return a unicode object with the MATCH representation of this Variable.""" self.validate() # We don't want the dollar sign as part of the variable name. variable_with_no_dollar_sign = self.variable_name[1:] match_variable_name = '{%s}' % (six.text_type(va...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "# We don't want the dollar sign as part of the variable name.", "variable_with_no_dollar_sign", "=", "self", ".", "variable_name", "[", "1", ":", "]", "match_variable_name", "=", "'{%s}'", "...
Return a unicode object with the MATCH representation of this Variable.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "Variable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L185-L204
232,989
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
GlobalContextField.validate
def validate(self): """Validate that the GlobalContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}' .format(type(self.location).__name__, self.location)) if self....
python
def validate(self): """Validate that the GlobalContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}' .format(type(self.location).__name__, self.location)) if self....
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "location", ",", "Location", ")", ":", "raise", "TypeError", "(", "u'Expected Location location, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "location", ")...
Validate that the GlobalContextField is correctly representable.
[ "Validate", "that", "the", "GlobalContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L289-L300
232,990
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
GlobalContextField.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this GlobalContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) validate_safe_string(field_name) return u'%s.%s' % (mark...
python
def to_match(self): """Return a unicode object with the MATCH representation of this GlobalContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) validate_safe_string(field_name) return u'%s.%s' % (mark...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "mark_name", ",", "field_name", "=", "self", ".", "location", ".", "get_location_name", "(", ")", "validate_safe_string", "(", "mark_name", ")", "validate_safe_string", "(", "field_na...
Return a unicode object with the MATCH representation of this GlobalContextField.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "GlobalContextField", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L302-L310
232,991
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
ContextField.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this ContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) if field_name is None: return u'$matched.%s' % (mark_name,...
python
def to_match(self): """Return a unicode object with the MATCH representation of this ContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) if field_name is None: return u'$matched.%s' % (mark_name,...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "mark_name", ",", "field_name", "=", "self", ".", "location", ".", "get_location_name", "(", ")", "validate_safe_string", "(", "mark_name", ")", "if", "field_name", "is", "None", ...
Return a unicode object with the MATCH representation of this ContextField.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "ContextField", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L350-L361
232,992
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
OutputContextField.validate
def validate(self): """Validate that the OutputContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if not self.location...
python
def validate(self): """Validate that the OutputContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if not self.location...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "location", ",", "Location", ")", ":", "raise", "TypeError", "(", "u'Expected Location location, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "location", ")...
Validate that the OutputContextField is correctly representable.
[ "Validate", "that", "the", "OutputContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L404-L427
232,993
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
FoldedContextField.validate
def validate(self): """Validate that the FoldedContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), sel...
python
def validate(self): """Validate that the FoldedContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), sel...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "fold_scope_location", ",", "FoldScopeLocation", ")", ":", "raise", "TypeError", "(", "u'Expected FoldScopeLocation fold_scope_location, got: {} {}'", ".", "format", "(", "type", ...
Validate that the FoldedContextField is correctly representable.
[ "Validate", "that", "the", "FoldedContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L505-L530
232,994
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
FoldCountContextField.validate
def validate(self): """Validate that the FoldCountContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), ...
python
def validate(self): """Validate that the FoldCountContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), ...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "fold_scope_location", ",", "FoldScopeLocation", ")", ":", "raise", "TypeError", "(", "u'Expected FoldScopeLocation fold_scope_location, got: {} {}'", ".", "format", "(", "type", ...
Validate that the FoldCountContextField is correctly representable.
[ "Validate", "that", "the", "FoldCountContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L596-L605
232,995
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
ContextFieldExistence.validate
def validate(self): """Validate that the ContextFieldExistence is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if self.location....
python
def validate(self): """Validate that the ContextFieldExistence is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if self.location....
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "location", ",", "Location", ")", ":", "raise", "TypeError", "(", "u'Expected Location location, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "location", ")...
Validate that the ContextFieldExistence is correctly representable.
[ "Validate", "that", "the", "ContextFieldExistence", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L646-L654
232,996
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
UnaryTransformation.validate
def validate(self): """Validate that the UnaryTransformation is correctly representable.""" _validate_operator_name(self.operator, UnaryTransformation.SUPPORTED_OPERATORS) if not isinstance(self.inner_expression, Expression): raise TypeError(u'Expected Expression inner_expression, g...
python
def validate(self): """Validate that the UnaryTransformation is correctly representable.""" _validate_operator_name(self.operator, UnaryTransformation.SUPPORTED_OPERATORS) if not isinstance(self.inner_expression, Expression): raise TypeError(u'Expected Expression inner_expression, g...
[ "def", "validate", "(", "self", ")", ":", "_validate_operator_name", "(", "self", ".", "operator", ",", "UnaryTransformation", ".", "SUPPORTED_OPERATORS", ")", "if", "not", "isinstance", "(", "self", ".", "inner_expression", ",", "Expression", ")", ":", "raise",...
Validate that the UnaryTransformation is correctly representable.
[ "Validate", "that", "the", "UnaryTransformation", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L688-L694
232,997
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
UnaryTransformation.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this UnaryTransformation.""" self.validate() translation_table = { u'size': u'size()', } match_operator = translation_table.get(self.operator) if not match_operator: r...
python
def to_match(self): """Return a unicode object with the MATCH representation of this UnaryTransformation.""" self.validate() translation_table = { u'size': u'size()', } match_operator = translation_table.get(self.operator) if not match_operator: r...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "translation_table", "=", "{", "u'size'", ":", "u'size()'", ",", "}", "match_operator", "=", "translation_table", ".", "get", "(", "self", ".", "operator", ")", "if", "not", "ma...
Return a unicode object with the MATCH representation of this UnaryTransformation.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "UnaryTransformation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L705-L722
232,998
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
BinaryComposition.validate
def validate(self): """Validate that the BinaryComposition is correctly representable.""" _validate_operator_name(self.operator, BinaryComposition.SUPPORTED_OPERATORS) if not isinstance(self.left, Expression): raise TypeError(u'Expected Expression left, got: {} {} {}'.format( ...
python
def validate(self): """Validate that the BinaryComposition is correctly representable.""" _validate_operator_name(self.operator, BinaryComposition.SUPPORTED_OPERATORS) if not isinstance(self.left, Expression): raise TypeError(u'Expected Expression left, got: {} {} {}'.format( ...
[ "def", "validate", "(", "self", ")", ":", "_validate_operator_name", "(", "self", ".", "operator", ",", "BinaryComposition", ".", "SUPPORTED_OPERATORS", ")", "if", "not", "isinstance", "(", "self", ".", "left", ",", "Expression", ")", ":", "raise", "TypeError"...
Validate that the BinaryComposition is correctly representable.
[ "Validate", "that", "the", "BinaryComposition", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L769-L779
232,999
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
BinaryComposition.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this BinaryComposition.""" self.validate() # The MATCH versions of some operators require an inverted order of arguments. # pylint: disable=unused-variable regular_operator_format = '(%(left)s %(oper...
python
def to_match(self): """Return a unicode object with the MATCH representation of this BinaryComposition.""" self.validate() # The MATCH versions of some operators require an inverted order of arguments. # pylint: disable=unused-variable regular_operator_format = '(%(left)s %(oper...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "# The MATCH versions of some operators require an inverted order of arguments.", "# pylint: disable=unused-variable", "regular_operator_format", "=", "'(%(left)s %(operator)s %(right)s)'", "inverted_operato...
Return a unicode object with the MATCH representation of this BinaryComposition.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "BinaryComposition", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L791-L836