signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def _validate_fold_has_outputs_or_count_filter(fold_scope_location, fold_has_count_filter, outputs): | <EOL>if fold_has_count_filter:<EOL><INDENT>return True<EOL><DEDENT>for output in six.itervalues(outputs):<EOL><INDENT>if output['<STR_LIT>'] == fold_scope_location:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>raise GraphQLCompilationError(u'<STR_LIT>'<EOL>u'<STR_LIT>'<EOL>u'<STR_LIT>'<EOL>.format(fold_scope_location))<... | Ensure the @fold scope has at least one output, or filters on the size of the fold. | f12656:m9 |
def _compile_fragment_ast(schema, current_schema_type, ast, location, context): | query_metadata_table = context['<STR_LIT>']<EOL>coerces_to_type_name = ast.type_condition.name.value<EOL>coerces_to_type_obj = schema.get_type(coerces_to_type_name)<EOL>basic_blocks = []<EOL>is_same_type_as_scope = current_schema_type.is_same_type(coerces_to_type_obj)<EOL>equivalent_union_type = context['<STR_LIT>'].ge... | 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.
... | f12656:m10 |
def _compile_ast_node_to_ir(schema, current_schema_type, ast, location, context): | basic_blocks = []<EOL>local_unique_directives = get_unique_directives(ast)<EOL>fields = _get_fields(ast)<EOL>vertex_fields, property_fields = fields<EOL>fragment = _get_inline_fragment(ast)<EOL>filter_operations = get_local_filter_directives(<EOL>ast, current_schema_type, vertex_fields)<EOL>fragment_exists = fragment i... | 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... | f12656:m11 |
def _validate_all_tags_are_used(metadata): | tag_names = set([tag_name for tag_name, _ in metadata.tags])<EOL>filter_arg_names = set()<EOL>for location, _ in metadata.registered_locations:<EOL><INDENT>for filter_info in metadata.get_filter_infos(location):<EOL><INDENT>for filter_arg in filter_info.args:<EOL><INDENT>if is_tag_argument(filter_arg):<EOL><INDENT>filt... | Ensure all tags are used in some filter. | f12656:m12 |
def _compile_root_ast_to_ir(schema, ast, type_equivalence_hints=None): | if len(ast.selection_set.selections) != <NUM_LIT:1>:<EOL><INDENT>raise GraphQLCompilationError(u'<STR_LIT>')<EOL><DEDENT>base_ast = ast.selection_set.selections[<NUM_LIT:0>]<EOL>base_start_type = get_ast_field_name(base_ast) <EOL>current_schema_type = get_field_type_from_schema(schema.get_query_type(), base_start_type... | Compile a full GraphQL abstract syntax tree (AST) to intermediate representation.
Args:
schema: GraphQL schema object, obtained from the graphql library
ast: the root GraphQL AST node for the query, obtained from the graphql library,
and already validated against the schema for type-co... | f12656:m13 |
def _compile_output_step(outputs): | if not outputs:<EOL><INDENT>raise GraphQLCompilationError(u'<STR_LIT>'<EOL>u'<STR_LIT>')<EOL><DEDENT>output_fields = {}<EOL>for output_name, output_context in six.iteritems(outputs):<EOL><INDENT>location = output_context['<STR_LIT:location>']<EOL>optional = output_context['<STR_LIT>']<EOL>graphql_type = output_context[... | 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); ... | f12656:m14 |
def _preprocess_graphql_string(graphql_string): | <EOL>return graphql_string + '<STR_LIT:\n>'<EOL> | Apply any necessary preprocessing to the input GraphQL string, returning the new version. | f12656:m15 |
def _validate_schema_and_ast(schema, ast): | core_graphql_errors = validate(schema, ast)<EOL>unsupported_default_directives = frozenset([<EOL>frozenset([<EOL>'<STR_LIT>',<EOL>frozenset(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']),<EOL>frozenset(['<STR_LIT>'])<EOL>]),<EOL>frozenset([<EOL>'<STR_LIT>',<EOL>frozenset(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']),<EOL>frozense... | 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... | f12656:m16 |
def graphql_to_ir(schema, graphql_string, type_equivalence_hints=None): | graphql_string = _preprocess_graphql_string(graphql_string)<EOL>try:<EOL><INDENT>ast = parse(graphql_string)<EOL><DEDENT>except GraphQLSyntaxError as e:<EOL><INDENT>raise GraphQLParsingError(e)<EOL><DEDENT>validation_errors = _validate_schema_and_ast(schema, ast)<EOL>if validation_errors:<EOL><INDENT>raise GraphQLValid... | 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... | f12656:m17 |
def __eq__(self, other): | <EOL>return self.type.is_same_type(other.type) and self.optional == other.optional<EOL> | Check another OutputMetadata object for equality against this one. | f12656:c0:m0 |
def __ne__(self, other): | return not self.__eq__(other)<EOL> | Check another OutputMetadata object for non-equality against this one. | f12656:c0:m1 |
def workaround_lowering_pass(ir_blocks, query_metadata_table): | new_ir_blocks = []<EOL>for block in ir_blocks:<EOL><INDENT>if isinstance(block, Filter):<EOL><INDENT>new_block = _process_filter_block(query_metadata_table, block)<EOL><DEDENT>else:<EOL><INDENT>new_block = block<EOL><DEDENT>new_ir_blocks.append(new_block)<EOL><DEDENT>return new_ir_blocks<EOL> | Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary. | f12657:m0 |
def _process_filter_block(query_metadata_table, block): | <EOL>base_predicate = block.predicate<EOL>ternary_conditionals = []<EOL>problematic_locations = []<EOL>def find_ternary_conditionals(expression):<EOL><INDENT>"""<STR_LIT>"""<EOL>if isinstance(expression, TernaryConditional):<EOL><INDENT>ternary_conditionals.append(expression)<EOL><DEDENT>return expression<EOL><DEDENT>d... | Rewrite the provided Filter block if necessary. | f12657:m1 |
def _create_tautological_expression_for_location(query_metadata_table, location): | location_type = query_metadata_table.get_location_info(location).type<EOL>location_exists = BinaryComposition(<EOL>u'<STR_LIT>', ContextField(location, location_type), NullLiteral)<EOL>location_does_not_exist = BinaryComposition(<EOL>u'<STR_LIT:=>', ContextField(location, location_type), NullLiteral)<EOL>return BinaryC... | For a given location, create a BinaryComposition that always evaluates to 'true'. | f12657:m2 |
def workaround_type_coercions_in_recursions(match_query): | <EOL>new_match_traversals = []<EOL>for current_traversal in match_query.match_traversals:<EOL><INDENT>new_traversal = []<EOL>for match_step in current_traversal:<EOL><INDENT>new_match_step = match_step<EOL>has_coerce_type = match_step.coerce_type_block is not None<EOL>has_recurse_root = isinstance(match_step.root_block... | Lower CoerceType blocks into Filter blocks within Recurse steps. | f12658:m0 |
def _is_local_filter(filter_block): | <EOL>result = {<EOL>'<STR_LIT>': True<EOL>}<EOL>filter_predicate = filter_block.predicate<EOL>def visitor_fn(expression):<EOL><INDENT>"""<STR_LIT>"""<EOL>non_local_expression_types = (ContextField, ContextFieldExistence)<EOL>if isinstance(expression, non_local_expression_types):<EOL><INDENT>result['<STR_LIT>'] = False<... | Return True if the Filter block references no non-local fields, and False otherwise. | f12659:m0 |
def _classify_query_locations(match_query): | preferred_locations = set()<EOL>eligible_locations = set()<EOL>ineligible_locations = set()<EOL>first_match_step = match_query.match_traversals[<NUM_LIT:0>][<NUM_LIT:0>]<EOL>if not isinstance(first_match_step.root_block, QueryRoot):<EOL><INDENT>raise AssertionError(u'<STR_LIT>'<EOL>u'<STR_LIT>'.format(first_match_step,... | Classify query locations into three groups: preferred, eligible, ineligible.
- Ineligible locations are ones that cannot be the starting point of query execution.
These include locations within recursions, locations that are the target of
an optional traversal, and locations with an associated "where:"... | f12659:m1 |
def _calculate_type_bound_at_step(match_step): | current_type_bounds = []<EOL>if isinstance(match_step.root_block, QueryRoot):<EOL><INDENT>current_type_bounds.extend(match_step.root_block.start_class)<EOL><DEDENT>if match_step.coerce_type_block is not None:<EOL><INDENT>current_type_bounds.extend(match_step.coerce_type_block.target_class)<EOL><DEDENT>if current_type_b... | Return the GraphQL type bound at the given step, or None if no bound is given. | f12659:m2 |
def _assert_type_bounds_are_not_conflicting(current_type_bound, previous_type_bound,<EOL>location, match_query): | if all((current_type_bound is not None,<EOL>previous_type_bound is not None,<EOL>current_type_bound != previous_type_bound)):<EOL><INDENT>raise AssertionError(<EOL>u'<STR_LIT>'<EOL>u'<STR_LIT>'.format(location, previous_type_bound, current_type_bound, match_query))<EOL><DEDENT> | Ensure that the two bounds either are an exact match, or one of them is None. | f12659:m3 |
def _expose_only_preferred_locations(match_query, location_types, coerced_locations,<EOL>preferred_locations, eligible_locations): | preferred_location_types = dict()<EOL>eligible_location_types = dict()<EOL>new_match_traversals = []<EOL>for current_traversal in match_query.match_traversals:<EOL><INDENT>new_traversal = []<EOL>for match_step in current_traversal:<EOL><INDENT>new_step = match_step<EOL>current_step_location = match_step.as_block.locati... | Return a MATCH query where only preferred locations are valid as query start locations. | f12659:m4 |
def _expose_all_eligible_locations(match_query, location_types, eligible_locations): | eligible_location_types = dict()<EOL>new_match_traversals = []<EOL>for current_traversal in match_query.match_traversals:<EOL><INDENT>new_traversal = []<EOL>for match_step in current_traversal:<EOL><INDENT>new_step = match_step<EOL>current_step_location = match_step.as_block.location<EOL>if current_step_location in eli... | Return a MATCH query where all eligible locations are valid as query start locations. | f12659:m5 |
def expose_ideal_query_execution_start_points(compound_match_query, location_types,<EOL>coerced_locations): | new_queries = []<EOL>for match_query in compound_match_query.match_queries:<EOL><INDENT>location_classification = _classify_query_locations(match_query)<EOL>preferred_locations, eligible_locations, _ = location_classification<EOL>if preferred_locations:<EOL><INDENT>new_query = _expose_only_preferred_locations(<EOL>matc... | Ensure that OrientDB only considers desirable query start points in query planning. | f12659:m6 |
def __init__(self, *args, **kwargs): | self._print_args = args<EOL>self._print_kwargs = kwargs<EOL> | Construct a new CompilerEntity. | f12660:c0:m0 |
@abstractmethod<EOL><INDENT>def validate(self):<DEDENT> | raise NotImplementedError()<EOL> | Ensure that the CompilerEntity is valid. | f12660:c0:m1 |
def __str__(self): | printed_args = []<EOL>if self._print_args:<EOL><INDENT>printed_args.append('<STR_LIT>')<EOL><DEDENT>if self._print_kwargs:<EOL><INDENT>printed_args.append('<STR_LIT>')<EOL><DEDENT>template = u'<STR_LIT>' + u'<STR_LIT:U+002CU+0020>'.join(printed_args) + u'<STR_LIT:)>'<EOL>return template.format(cls_name=type(self).__nam... | Return a human-readable unicode representation of this CompilerEntity. | f12660:c0:m2 |
def __repr__(self): | return self.__str__()<EOL> | Return a human-readable str representation of the CompilerEntity object. | f12660:c0:m3 |
def __eq__(self, other): | if type(self) != type(other):<EOL><INDENT>return False<EOL><DEDENT>if len(self._print_args) != len(other._print_args):<EOL><INDENT>return False<EOL><DEDENT>for self_arg, other_arg in six.moves.zip(self._print_args, other._print_args):<EOL><INDENT>if is_type(self_arg):<EOL><INDENT>if not self_arg.is_same_type(other_arg)... | Return True if the CompilerEntity objects are equal, and False otherwise. | f12660:c0:m4 |
def __ne__(self, other): | return not self.__eq__(other)<EOL> | Check another object for non-equality against this one. | f12660:c0:m5 |
@abstractmethod<EOL><INDENT>def to_gremlin(self):<DEDENT> | raise NotImplementedError()<EOL> | Return the Gremlin unicode string representation of this object. | f12660:c0:m6 |
def visit_and_update(self, visitor_fn): | <EOL>return visitor_fn(self)<EOL> | Create an updated version (if needed) of the Expression via the visitor pattern.
Args:
visitor_fn: function that takes an Expression argument, and returns an Expression.
This function is recursively called on all child Expressions that may
exist withi... | f12660:c1:m0 |
def visit_and_update_expressions(self, visitor_fn): | <EOL>return self<EOL> | Create an updated version (if needed) of the BasicBlock via the visitor pattern.
Args:
visitor_fn: function that takes an Expression argument, and returns an Expression.
This function is recursively called on all child Expressions that may
exist withi... | f12660:c2:m0 |
def to_gremlin(self): | return u'<STR_LIT>'<EOL> | Return the Gremlin representation of the block, which should almost always be empty.
The effect of MarkerBlocks is applied during optimization and code generation steps. | f12660:c3:m0 |
def __init__(self, start_class): | super(QueryRoot, self).__init__(start_class)<EOL>self.start_class = start_class<EOL>self.validate()<EOL> | Construct a QueryRoot object that starts querying at the specified class name.
Args:
start_class: set of string, class names from which to start the query.
This will generally be a set of length 1, except when using Gremlin
with a non-final class, w... | f12661:c0:m0 |
def validate(self): | if not (isinstance(self.start_class, set) and<EOL>all(isinstance(x, six.string_types) for x in self.start_class)):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.start_class).__name__, self.start_class))<EOL><DEDENT>for cls in self.start_class:<EOL><INDENT>validate_safe_string(cls)<EOL><DEDENT> | Ensure that the QueryRoot block is valid. | f12661:c0:m1 |
def to_gremlin(self): | self.validate()<EOL>if len(self.start_class) == <NUM_LIT:1>:<EOL><INDENT>start_class = list(self.start_class)[<NUM_LIT:0>]<EOL>return u'<STR_LIT>'.format('<STR_LIT>', safe_quoted_string(start_class))<EOL><DEDENT>else:<EOL><INDENT>start_classes_list = '<STR_LIT:U+002C>'.join(safe_quoted_string(x) for x in self.start_cla... | Return a unicode object with the Gremlin representation of this block. | f12661:c0:m2 |
def __init__(self, target_class): | super(CoerceType, self).__init__(target_class)<EOL>self.target_class = target_class<EOL>self.validate()<EOL> | Construct a CoerceType object that filters out any data that is not of the given types.
Args:
target_class: set of string, class names from which to start the query.
This will generally be a set of length 1, except when using Gremlin
with a non-fi... | f12661:c1:m0 |
def validate(self): | if not (isinstance(self.target_class, set) and<EOL>all(isinstance(x, six.string_types) for x in self.target_class)):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.target_class).__name__, self.target_class))<EOL><DEDENT>for cls in self.target_class:<EOL><INDENT>validate_safe_string(cls)<EOL><DEDENT> | Ensure that the CoerceType block is valid. | f12661:c1:m1 |
def to_gremlin(self): | raise AssertionError(u'<STR_LIT>'<EOL>u'<STR_LIT>')<EOL> | Not implemented, should not be used. | f12661:c1:m2 |
def __init__(self, fields): | self.fields = {<EOL>ensure_unicode_string(key): value<EOL>for key, value in six.iteritems(fields)<EOL>}<EOL>super(ConstructResult, self).__init__(self.fields)<EOL>self.validate()<EOL> | Construct a ConstructResult object that maps the given field names to their expressions.
Args:
fields: dict, variable name string -> Expression
see rules for variable names in validate_safe_string().
Returns:
new ConstructResult object | f12661:c2:m0 |
def validate(self): | if not isinstance(self.fields, dict):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.fields).__name__, self.fields))<EOL><DEDENT>for key, value in six.iteritems(self.fields):<EOL><INDENT>validate_safe_string(key)<EOL>if not isinstance(value, Expression):<EOL><INDENT>raise TypeError(<EOL>u'<STR_LIT>'<EOL... | Ensure that the ConstructResult block is valid. | f12661:c2:m1 |
def visit_and_update_expressions(self, visitor_fn): | new_fields = {}<EOL>for key, value in six.iteritems(self.fields):<EOL><INDENT>new_value = value.visit_and_update(visitor_fn)<EOL>if new_value is not value:<EOL><INDENT>new_fields[key] = new_value<EOL><DEDENT><DEDENT>if new_fields:<EOL><INDENT>return ConstructResult(dict(self.fields, **new_fields))<EOL><DEDENT>else:<EOL... | Create an updated version (if needed) of the ConstructResult via the visitor pattern. | f12661:c2:m2 |
def to_gremlin(self): | self.validate()<EOL>template = (<EOL>u'<STR_LIT>'<EOL>u'<STR_LIT>'<EOL>u'<STR_LIT>')<EOL>field_representations = (<EOL>u'<STR_LIT>'.format(name=key, expr=self.fields[key].to_gremlin())<EOL>for key in sorted(self.fields.keys()) <EOL>)<EOL>return template.format(u'<STR_LIT:U+002CU+0020>'.join(field_representations))<EOL... | Return a unicode object with the Gremlin representation of this block. | f12661:c2:m3 |
def __init__(self, predicate): | super(Filter, self).__init__(predicate)<EOL>self.predicate = predicate<EOL>self.validate()<EOL> | Create a new Filter with the specified Expression as a predicate. | f12661:c3:m0 |
def validate(self): | if not isinstance(self.predicate, Expression):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.predicate).__name__, self.predicate))<EOL><DEDENT> | Ensure that the Filter block is valid. | f12661:c3:m1 |
def visit_and_update_expressions(self, visitor_fn): | new_predicate = self.predicate.visit_and_update(visitor_fn)<EOL>if new_predicate is not self.predicate:<EOL><INDENT>return Filter(new_predicate)<EOL><DEDENT>else:<EOL><INDENT>return self<EOL><DEDENT> | Create an updated version (if needed) of the Filter via the visitor pattern. | f12661:c3:m2 |
def to_gremlin(self): | self.validate()<EOL>return u'<STR_LIT>'.format(self.predicate.to_gremlin())<EOL> | Return a unicode object with the Gremlin representation of this block. | f12661:c3:m3 |
def __init__(self, location): | super(MarkLocation, self).__init__(location)<EOL>self.location = location<EOL>self.validate()<EOL> | Create a new MarkLocation at the specified Location.
Args:
location: Location object, must not be at a property field in the query
Returns:
new MarkLocation object | f12661:c4:m0 |
def validate(self): | validate_marked_location(self.location)<EOL> | Ensure that the MarkLocation block is valid. | f12661:c4:m1 |
def to_gremlin(self): | self.validate()<EOL>mark_name, _ = self.location.get_location_name()<EOL>return u'<STR_LIT>'.format(safe_quoted_string(mark_name))<EOL> | Return a unicode object with the Gremlin representation of this block. | f12661:c4:m2 |
def __init__(self, direction, edge_name, optional=False, within_optional_scope=False): | super(Traverse, self).__init__(<EOL>direction, edge_name, optional=optional, within_optional_scope=within_optional_scope)<EOL>self.direction = direction<EOL>self.edge_name = edge_name<EOL>self.optional = optional<EOL>self.within_optional_scope = within_optional_scope<EOL>self.validate()<EOL> | Create a new Traverse block in the given direction and across the given edge.
Args:
direction: string, 'in' or 'out'
edge_name: string obeying variable name rules (see validate_safe_string).
optional: optional bool, specifying whether the traversal to the given location
... | f12661:c5:m0 |
def validate(self): | if not isinstance(self.direction, six.string_types):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.direction).__name__, self.direction))<EOL><DEDENT>validate_edge_direction(self.direction)<EOL>validate_safe_string(self.edge_name)<EOL>if not isinstance(self.optional, bool):<EOL><INDENT>raise TypeError(u... | Ensure that the Traverse block is valid. | f12661:c5:m1 |
def get_field_name(self): | return u'<STR_LIT>'.format(self.direction, self.edge_name)<EOL> | Return the field name corresponding to the edge being traversed. | f12661:c5:m2 |
def to_gremlin(self): | self.validate()<EOL>if self.optional:<EOL><INDENT>return (u'<STR_LIT>'<EOL>u'<STR_LIT>'.format(<EOL>direction=self.direction,<EOL>edge_name=self.edge_name,<EOL>edge_quoted=safe_quoted_string(self.edge_name)))<EOL><DEDENT>elif self.within_optional_scope:<EOL><INDENT>return (u'<STR_LIT>'<EOL>u'<STR_LIT>'.format(<EOL>dire... | Return a unicode object with the Gremlin representation of this block. | f12661:c5:m3 |
def __init__(self, direction, edge_name, depth, within_optional_scope=False): | super(Recurse, self).__init__(<EOL>direction, edge_name, depth, within_optional_scope=within_optional_scope)<EOL>self.direction = direction<EOL>self.edge_name = edge_name<EOL>self.depth = depth<EOL>self.within_optional_scope = within_optional_scope<EOL>self.validate()<EOL> | Create a new Recurse block which traverses the given edge up to "depth" times.
Args:
direction: string, 'in' or 'out'.
edge_name: string obeying variable name rules (see validate_safe_string).
depth: int, always greater than or equal to 1.
Returns:
new R... | f12661:c6:m0 |
def validate(self): | validate_edge_direction(self.direction)<EOL>validate_safe_string(self.edge_name)<EOL>if not isinstance(self.within_optional_scope, bool):<EOL><INDENT>raise TypeError(u'<STR_LIT>'<EOL>u'<STR_LIT:{}>'.format(type(self.within_optional_scope).__name__,<EOL>self.within_optional_scope))<EOL><DEDENT>if not isinstance(self.dep... | Ensure that the Traverse block is valid. | f12661:c6:m1 |
def to_gremlin(self): | self.validate()<EOL>template = '<STR_LIT>'<EOL>recurse_base = '<STR_LIT>'<EOL>recurse_traversal = '<STR_LIT>'.format(<EOL>direction=self.direction, edge_name=self.edge_name)<EOL>recurse_steps = [<EOL>recurse_base + (recurse_traversal * i)<EOL>for i in six.moves.xrange(self.depth + <NUM_LIT:1>)<EOL>]<EOL>recursion_strin... | Return a unicode object with the Gremlin representation of this block. | f12661:c6:m2 |
def __init__(self, location, optional=False): | super(Backtrack, self).__init__(location, optional=optional)<EOL>self.location = location<EOL>self.optional = optional<EOL>self.validate()<EOL> | Create a new Backtrack block, returning to the given location in the query.
Args:
location: Location object, specifying where to backtrack to
optional: optional bool, specifying whether the steps between the current location
and the location to which Backtrack is r... | f12661:c7:m0 |
def validate(self): | validate_marked_location(self.location)<EOL>if not isinstance(self.optional, bool):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.optional).__name__, self.optional))<EOL><DEDENT> | Ensure that the Backtrack block is valid. | f12661:c7:m1 |
def to_gremlin(self): | self.validate()<EOL>if self.optional:<EOL><INDENT>operation = u'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>operation = u'<STR_LIT>'<EOL><DEDENT>mark_name, _ = self.location.get_location_name()<EOL>return u'<STR_LIT>'.format(<EOL>operation=operation,<EOL>mark_name=safe_quoted_string(mark_name))<EOL> | Return a unicode object with the Gremlin representation of this BasicBlock. | f12661:c7:m2 |
def validate(self): | pass<EOL> | Validate the OutputSource block. An OutputSource block is always valid in isolation. | f12661:c8:m0 |
def __init__(self, fold_scope_location): | super(Fold, self).__init__(fold_scope_location)<EOL>self.fold_scope_location = fold_scope_location<EOL>self.validate()<EOL> | Create a new Fold block rooted at the given location. | f12661:c9:m0 |
def validate(self): | if not isinstance(self.fold_scope_location, FoldScopeLocation):<EOL><INDENT>raise TypeError(u'<STR_LIT>'<EOL>u'<STR_LIT:{}>'.format(type(self.fold_scope_location), self.fold_scope_location))<EOL><DEDENT> | Ensure the Fold block is valid. | f12661:c9:m1 |
def validate(self): | pass<EOL> | Unfold blocks are always valid in isolation. | f12661:c10:m0 |
def validate(self): | pass<EOL> | In isolation, EndOptional blocks are always valid. | f12661:c11:m0 |
def validate(self): | pass<EOL> | In isolation, GlobalOperationsStart blocks are always valid. | f12661:c12:m0 |
def make_replacement_visitor(find_expression, replace_expression): | def visitor_fn(expression):<EOL><INDENT>"""<STR_LIT>"""<EOL>if expression == find_expression:<EOL><INDENT>return replace_expression<EOL><DEDENT>else:<EOL><INDENT>return expression<EOL><DEDENT><DEDENT>return visitor_fn<EOL> | Return a visitor function that replaces every instance of one expression with another one. | f12662:m0 |
def make_type_replacement_visitor(find_types, replacement_func): | def visitor_fn(expression):<EOL><INDENT>"""<STR_LIT>"""<EOL>if isinstance(expression, find_types):<EOL><INDENT>return replacement_func(expression)<EOL><DEDENT>else:<EOL><INDENT>return expression<EOL><DEDENT><DEDENT>return visitor_fn<EOL> | Return a visitor function that replaces expressions of a given type with new expressions. | f12662:m1 |
def _validate_operator_name(operator, supported_operators): | if not isinstance(operator, six.text_type):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(operator).__name__, operator))<EOL><DEDENT>if operator not in supported_operators:<EOL><INDENT>raise GraphQLCompilationError(u'<STR_LIT>'.format(operator))<EOL><DEDENT> | Ensure the named operator is valid and supported. | f12662:m2 |
def __init__(self, value): | super(Literal, self).__init__(value)<EOL>self.value = value<EOL>self.validate()<EOL> | Construct a new Literal object with the given value. | f12662:c0:m0 |
def validate(self): | <EOL>if self.value is None or self.value is True or self.value is False:<EOL><INDENT>return<EOL><DEDENT>if isinstance(self.value, six.string_types):<EOL><INDENT>validate_safe_string(self.value)<EOL>return<EOL><DEDENT>if isinstance(self.value, int):<EOL><INDENT>return<EOL><DEDENT>if isinstance(self.value, list):<EOL><IN... | Validate that the Literal is correctly representable. | f12662:c0:m1 |
def _to_output_code(self): | <EOL>self.validate()<EOL>if self.value is None:<EOL><INDENT>return u'<STR_LIT:null>'<EOL><DEDENT>elif self.value is True:<EOL><INDENT>return u'<STR_LIT:true>'<EOL><DEDENT>elif self.value is False:<EOL><INDENT>return u'<STR_LIT:false>'<EOL><DEDENT>elif isinstance(self.value, six.string_types):<EOL><INDENT>return safe_qu... | Return a unicode object with the Gremlin/MATCH representation of this Literal. | f12662:c0:m2 |
def __init__(self, variable_name, inferred_type): | variable_name = ensure_unicode_string(variable_name)<EOL>super(Variable, self).__init__(variable_name, inferred_type)<EOL>self.variable_name = variable_name<EOL>self.inferred_type = inferred_type<EOL>self.validate()<EOL> | Construct a new Variable object for the given variable name.
Args:
variable_name: string, should start with '$' and then obey variable naming rules
(see validate_safe_string())
inferred_type: GraphQL type object, specifying the inferred type of the variable
... | f12662:c1:m0 |
def validate(self): | <EOL>if not self.variable_name.startswith(u'<STR_LIT:$>'):<EOL><INDENT>raise GraphQLCompilationError(u'<STR_LIT>'<EOL>u'<STR_LIT:{}>'.format(self.variable_name))<EOL><DEDENT>if self.variable_name in RESERVED_MATCH_KEYWORDS:<EOL><INDENT>raise GraphQLCompilationError(u'<STR_LIT>'<EOL>u'<STR_LIT>'.format(self.variable_nam... | Validate that the Variable is correctly representable. | f12662:c1:m1 |
def to_match(self): | self.validate()<EOL>variable_with_no_dollar_sign = self.variable_name[<NUM_LIT:1>:]<EOL>match_variable_name = '<STR_LIT>' % (six.text_type(variable_with_no_dollar_sign),)<EOL>if GraphQLDate.is_same_type(self.inferred_type):<EOL><INDENT>return u'<STR_LIT>' % (match_variable_name, STANDARD_DATE_FORMAT)<EOL><DEDENT>elif G... | Return a unicode object with the MATCH representation of this Variable. | f12662:c1:m2 |
def to_gremlin(self): | <EOL>if GraphQLDate.is_same_type(self.inferred_type):<EOL><INDENT>return u'<STR_LIT>'.format(STANDARD_DATE_FORMAT, self.variable_name)<EOL><DEDENT>elif GraphQLDateTime.is_same_type(self.inferred_type):<EOL><INDENT>return u'<STR_LIT>'.format(STANDARD_DATETIME_FORMAT, self.variable_name)<EOL><DEDENT>else:<EOL><INDENT>ret... | Return a unicode object with the Gremlin representation of this expression. | f12662:c1:m3 |
def __eq__(self, other): | <EOL>return (type(self) == type(other) and<EOL>self.variable_name == other.variable_name and<EOL>self.inferred_type.is_same_type(other.inferred_type))<EOL> | Return True if the given object is equal to this one, and False otherwise. | f12662:c1:m4 |
def __ne__(self, other): | return not self.__eq__(other)<EOL> | Check another object for non-equality against this one. | f12662:c1:m5 |
def __init__(self, field_name): | super(LocalField, self).__init__(field_name)<EOL>self.field_name = field_name<EOL>self.validate()<EOL> | Construct a new LocalField object that references a field at the current position. | f12662:c2:m0 |
def get_local_object_gremlin_name(self): | return u'<STR_LIT>'<EOL> | Return the Gremlin name of the local object whose field is being produced. | f12662:c2:m1 |
def validate(self): | validate_safe_string(self.field_name)<EOL> | Validate that the LocalField is correctly representable. | f12662:c2:m2 |
def to_match(self): | self.validate()<EOL>return six.text_type(self.field_name)<EOL> | Return a unicode object with the MATCH representation of this LocalField. | f12662:c2:m3 |
def to_gremlin(self): | self.validate()<EOL>local_object_name = self.get_local_object_gremlin_name()<EOL>if self.field_name == '<STR_LIT>':<EOL><INDENT>return local_object_name<EOL><DEDENT>if '<STR_LIT:@>' in self.field_name:<EOL><INDENT>return u'<STR_LIT>'.format(local_object_name, self.field_name)<EOL><DEDENT>else:<EOL><INDENT>return u'<STR... | Return a unicode object with the Gremlin representation of this expression. | f12662:c2:m4 |
def __init__(self, location, field_type): | super(GlobalContextField, self).__init__(location, field_type)<EOL>self.location = location<EOL>self.field_type = field_type<EOL>self.validate()<EOL> | Construct a new GlobalContextField object that references a field at a given location.
Args:
location: Location, specifying where the field was declared.
Returns:
new GlobalContextField object | f12662:c3:m0 |
def validate(self): | if not isinstance(self.location, Location):<EOL><INDENT>raise TypeError(u'<STR_LIT>'<EOL>.format(type(self.location).__name__, self.location))<EOL><DEDENT>if self.location.field is None:<EOL><INDENT>raise AssertionError(u'<STR_LIT>'<EOL>.format(self.location))<EOL><DEDENT>if not is_graphql_type(self.field_type):<EOL><I... | Validate that the GlobalContextField is correctly representable. | f12662:c3:m1 |
def to_match(self): | self.validate()<EOL>mark_name, field_name = self.location.get_location_name()<EOL>validate_safe_string(mark_name)<EOL>validate_safe_string(field_name)<EOL>return u'<STR_LIT>' % (mark_name, field_name)<EOL> | Return a unicode object with the MATCH representation of this GlobalContextField. | f12662:c3:m2 |
def to_gremlin(self): | raise AssertionError(u'<STR_LIT>'<EOL>u'<STR_LIT>')<EOL> | Not implemented, should not be used. | f12662:c3:m3 |
def __init__(self, location, field_type): | super(ContextField, self).__init__(location, field_type)<EOL>self.location = location<EOL>self.field_type = field_type<EOL>self.validate()<EOL> | Construct a new ContextField object that references a field from the global context.
Args:
location: Location, specifying where the field was declared. If the Location points
to a vertex, the field refers to the data captured at the location vertex.
Other... | f12662:c4:m0 |
def validate(self): | if not isinstance(self.location, Location):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.location).__name__, self.location))<EOL><DEDENT>if not is_graphql_type(self.field_type):<EOL><INDENT>raise ValueError(u'<STR_LIT>'.format(self.field_type))<EOL><DEDENT> | Validate that the ContextField is correctly representable. | f12662:c4:m1 |
def to_match(self): | self.validate()<EOL>mark_name, field_name = self.location.get_location_name()<EOL>validate_safe_string(mark_name)<EOL>if field_name is None:<EOL><INDENT>return u'<STR_LIT>' % (mark_name,)<EOL><DEDENT>else:<EOL><INDENT>validate_safe_string(field_name)<EOL>return u'<STR_LIT>' % (mark_name, field_name)<EOL><DEDENT> | Return a unicode object with the MATCH representation of this ContextField. | f12662:c4:m2 |
def to_gremlin(self): | self.validate()<EOL>mark_name, field_name = self.location.get_location_name()<EOL>if field_name is not None:<EOL><INDENT>validate_safe_string(field_name)<EOL>if '<STR_LIT:@>' in field_name:<EOL><INDENT>template = u'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>template = u'<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>te... | Return a unicode object with the Gremlin representation of this expression. | f12662:c4:m3 |
def __init__(self, location, field_type): | super(OutputContextField, self).__init__(location, field_type)<EOL>self.location = location<EOL>self.field_type = field_type<EOL>self.validate()<EOL> | Construct a new OutputContextField object for the field at the given location.
Args:
location: Location, specifying where the field was declared. The Location
must point to a property, and that property's value is output as the result.
field_type: GraphQL type obje... | f12662:c5:m0 |
def validate(self): | if not isinstance(self.location, Location):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.location).__name__, self.location))<EOL><DEDENT>if not self.location.field:<EOL><INDENT>raise ValueError(u'<STR_LIT>'<EOL>u'<STR_LIT:{}>'.format(self.location))<EOL><DEDENT>if not is_graphql_type(self.field_type):... | Validate that the OutputContextField is correctly representable. | f12662:c5:m1 |
def to_match(self): | self.validate()<EOL>mark_name, field_name = self.location.get_location_name()<EOL>validate_safe_string(mark_name)<EOL>validate_safe_string(field_name)<EOL>stripped_field_type = strip_non_null_from_type(self.field_type)<EOL>if GraphQLDate.is_same_type(stripped_field_type):<EOL><INDENT>return u'<STR_LIT>' % (mark_name, f... | Return a unicode object with the MATCH representation of this expression. | f12662:c5:m2 |
def to_gremlin(self): | self.validate()<EOL>mark_name, field_name = self.location.get_location_name()<EOL>validate_safe_string(mark_name)<EOL>validate_safe_string(field_name)<EOL>if '<STR_LIT:@>' in field_name:<EOL><INDENT>template = u'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>template = u'<STR_LIT>'<EOL><DEDENT>format_value = None<EOL>strippe... | Return a unicode object with the Gremlin representation of this expression. | f12662:c5:m3 |
def __eq__(self, other): | <EOL>return (type(self) == type(other) and<EOL>self.location == other.location and<EOL>self.field_type.is_same_type(other.field_type))<EOL> | Return True if the given object is equal to this one, and False otherwise. | f12662:c5:m4 |
def __ne__(self, other): | return not self.__eq__(other)<EOL> | Check another object for non-equality against this one. | f12662:c5:m5 |
def __init__(self, fold_scope_location, field_type): | super(FoldedContextField, self).__init__(fold_scope_location, field_type)<EOL>self.fold_scope_location = fold_scope_location<EOL>self.field_type = field_type<EOL>self.validate()<EOL> | Construct a new FoldedContextField object for this folded field.
Args:
fold_scope_location: FoldScopeLocation specifying the location of
the context field being output.
field_type: GraphQL type object, specifying the type of the field being output.
... | f12662:c6:m0 |
def validate(self): | if not isinstance(self.fold_scope_location, FoldScopeLocation):<EOL><INDENT>raise TypeError(u'<STR_LIT>'.format(<EOL>type(self.fold_scope_location), self.fold_scope_location))<EOL><DEDENT>if self.fold_scope_location.field is None:<EOL><INDENT>raise ValueError(u'<STR_LIT>'<EOL>.format(self.fold_scope_location))<EOL><DED... | Validate that the FoldedContextField is correctly representable. | f12662:c6:m1 |
def to_match(self): | self.validate()<EOL>mark_name, field_name = self.fold_scope_location.get_location_name()<EOL>validate_safe_string(mark_name)<EOL>template = u'<STR_LIT>'<EOL>template_data = {<EOL>'<STR_LIT>': mark_name,<EOL>}<EOL>if field_name == COUNT_META_FIELD_NAME:<EOL><INDENT>template_data['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>el... | Return a unicode object with the MATCH representation of this expression. | f12662:c6:m2 |
def to_gremlin(self): | raise NotImplementedError()<EOL> | Must never be called. | f12662:c6:m3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.