id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
5,701 | loc | def loc(parser, start):
"""Returns a location object, used to identify the place in
the source that created a given parsed object."""
if parser.options['no_location']:
return None
if parser.options['no_source']:
return Loc(start, parser.prev_end)
return Loc(start, parser.prev_end, parser.source) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 66 | 75 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,702 | advance | def advance(parser):
"""Moves the internal parser object to the next lexed token."""
prev_end = parser.token.end
parser.prev_end = prev_end
parser.token = parser.lexer.next_token(prev_end) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 78 | 82 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,703 | peek | def peek(parser, kind):
"""Determines if the next token is of a given kind"""
return parser.token.kind == kind | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 85 | 87 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,704 | skip | def skip(parser, kind):
"""If the next token is of the given kind, return true after advancing
the parser. Otherwise, do not change the parser state
and throw an error."""
match = parser.token.kind == kind
if match:
advance(parser)
return match | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 90 | 98 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,705 | expect | def expect(parser, kind):
"""If the next token is of the given kind, return that token after
advancing the parser. Otherwise, do not change the parser state and
return False."""
token = parser.token
if token.kind == kind:
advance(parser)
return token
raise GraphQLSyntaxError(
parser.source,
token.start,
u'Expected {}, found {}'.format(
get_token_kind_desc(kind),
get_token_desc(token)
)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 101 | 117 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,706 | expect_keyword | def expect_keyword(parser, value):
"""If the next token is a keyword with the given value, return that
token after advancing the parser. Otherwise, do not change the parser
state and return False."""
token = parser.token
if token.kind == TokenKind.NAME and token.value == value:
advance(parser)
return token
raise GraphQLSyntaxError(
parser.source,
token.start,
u'Expected "{}", found {}'.format(value, get_token_desc(token))
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 120 | 133 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,707 | unexpected | def unexpected(parser, at_token=None):
"""Helper function for creating an error when an unexpected lexed token
is encountered."""
token = at_token or parser.token
return GraphQLSyntaxError(
parser.source,
token.start,
u'Unexpected {}'.format(get_token_desc(token))
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 136 | 144 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,708 | any | def any(parser, open_kind, parse_fn, close_kind):
"""Returns a possibly empty list of parse nodes, determined by
the parse_fn. This list begins with a lex token of openKind
and ends with a lex token of closeKind. Advances the parser
to the next lex token after the closing token."""
expect(parser, open_kind)
nodes = []
while not skip(parser, close_kind):
nodes.append(parse_fn(parser))
return nodes | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 147 | 157 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,709 | many | def many(parser, open_kind, parse_fn, close_kind):
"""Returns a non-empty list of parse nodes, determined by
the parse_fn. This list begins with a lex token of openKind
and ends with a lex token of closeKind. Advances the parser
to the next lex token after the closing token."""
expect(parser, open_kind)
nodes = [parse_fn(parser)]
while not skip(parser, close_kind):
nodes.append(parse_fn(parser))
return nodes | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 160 | 170 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,710 | parse_name | def parse_name(parser):
"""Converts a name lex token into a name parse node."""
token = expect(parser, TokenKind.NAME)
return ast.Name(
value=token.value,
loc=loc(parser, token.start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 173 | 179 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,711 | parse_document | def parse_document(parser):
start = parser.token.start
definitions = []
while True:
definitions.append(parse_definition(parser))
if skip(parser, TokenKind.EOF):
break
return ast.Document(
definitions=definitions,
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 184 | 196 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,712 | parse_definition | def parse_definition(parser):
if peek(parser, TokenKind.BRACE_L):
return parse_operation_definition(parser)
if peek(parser, TokenKind.NAME):
name = parser.token.value
if name in ('query', 'mutation', 'subscription'):
return parse_operation_definition(parser)
elif name == 'fragment':
return parse_fragment_definition(parser)
elif name in ('schema', 'scalar', 'type', 'interface', 'union', 'enum', 'input', 'extend', 'directive'):
return parse_type_system_definition(parser)
raise unexpected(parser) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 199 | 213 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,713 | parse_operation_definition | def parse_operation_definition(parser):
start = parser.token.start
if peek(parser, TokenKind.BRACE_L):
return ast.OperationDefinition(
operation='query',
name=None,
variable_definitions=None,
directives=[],
selection_set=parse_selection_set(parser),
loc=loc(parser, start)
)
operation = parse_operation_type(parser)
name = None
if peek(parser, TokenKind.NAME):
name = parse_name(parser)
return ast.OperationDefinition(
operation=operation,
name=name,
variable_definitions=parse_variable_definitions(parser),
directives=parse_directives(parser),
selection_set=parse_selection_set(parser),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 217 | 242 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,714 | parse_operation_type | def parse_operation_type(parser):
operation_token = expect(parser, TokenKind.NAME)
operation = operation_token.value
if operation == 'query':
return 'query'
elif operation == 'mutation':
return 'mutation'
elif operation == 'subscription':
return 'subscription'
raise unexpected(parser, operation_token) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 245 | 255 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,715 | parse_variable_definitions | def parse_variable_definitions(parser):
if peek(parser, TokenKind.PAREN_L):
return many(
parser,
TokenKind.PAREN_L,
parse_variable_definition,
TokenKind.PAREN_R
)
return [] | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 258 | 267 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,716 | parse_variable_definition | def parse_variable_definition(parser):
start = parser.token.start
return ast.VariableDefinition(
variable=parse_variable(parser),
type=expect(parser, TokenKind.COLON) and parse_type(parser),
default_value=parse_value_literal(parser, True) if skip(parser, TokenKind.EQUALS) else None,
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 270 | 278 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,717 | parse_variable | def parse_variable(parser):
start = parser.token.start
expect(parser, TokenKind.DOLLAR)
return ast.Variable(
name=parse_name(parser),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 281 | 288 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,718 | parse_selection_set | def parse_selection_set(parser):
start = parser.token.start
return ast.SelectionSet(
selections=many(parser, TokenKind.BRACE_L, parse_selection, TokenKind.BRACE_R),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 291 | 296 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,719 | parse_selection | def parse_selection(parser):
if peek(parser, TokenKind.SPREAD):
return parse_fragment(parser)
else:
return parse_field(parser) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 299 | 303 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,720 | parse_field | def parse_field(parser):
# Corresponds to both Field and Alias in the spec
start = parser.token.start
name_or_alias = parse_name(parser)
if skip(parser, TokenKind.COLON):
alias = name_or_alias
name = parse_name(parser)
else:
alias = None
name = name_or_alias
return ast.Field(
alias=alias,
name=name,
arguments=parse_arguments(parser),
directives=parse_directives(parser),
selection_set=parse_selection_set(parser) if peek(parser, TokenKind.BRACE_L) else None,
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 306 | 325 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,721 | parse_arguments | def parse_arguments(parser):
if peek(parser, TokenKind.PAREN_L):
return many(
parser, TokenKind.PAREN_L,
parse_argument, TokenKind.PAREN_R)
return [] | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 328 | 334 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,722 | parse_argument | def parse_argument(parser):
start = parser.token.start
return ast.Argument(
name=parse_name(parser),
value=expect(parser, TokenKind.COLON) and parse_value_literal(parser, False),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 337 | 344 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,723 | parse_fragment | def parse_fragment(parser):
# Corresponds to both FragmentSpread and InlineFragment in the spec
start = parser.token.start
expect(parser, TokenKind.SPREAD)
if peek(parser, TokenKind.NAME) and parser.token.value != 'on':
return ast.FragmentSpread(
name=parse_fragment_name(parser),
directives=parse_directives(parser),
loc=loc(parser, start)
)
type_condition = None
if parser.token.value == 'on':
advance(parser)
type_condition = parse_named_type(parser)
return ast.InlineFragment(
type_condition=type_condition,
directives=parse_directives(parser),
selection_set=parse_selection_set(parser),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 349 | 371 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,724 | parse_fragment_definition | def parse_fragment_definition(parser):
start = parser.token.start
expect_keyword(parser, 'fragment')
return ast.FragmentDefinition(
name=parse_fragment_name(parser),
type_condition=expect_keyword(parser, 'on') and parse_named_type(parser),
directives=parse_directives(parser),
selection_set=parse_selection_set(parser),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 374 | 384 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,725 | parse_fragment_name | def parse_fragment_name(parser):
if parser.token.value == 'on':
raise unexpected(parser)
return parse_name(parser) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 387 | 391 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,726 | parse_value_literal | def parse_value_literal(parser, is_const):
token = parser.token
if token.kind == TokenKind.BRACKET_L:
return parse_list(parser, is_const)
elif token.kind == TokenKind.BRACE_L:
return parse_object(parser, is_const)
elif token.kind == TokenKind.INT:
advance(parser)
return ast.IntValue(value=token.value, loc=loc(parser, token.start))
elif token.kind == TokenKind.FLOAT:
advance(parser)
return ast.FloatValue(value=token.value, loc=loc(parser, token.start))
elif token.kind == TokenKind.STRING:
advance(parser)
return ast.StringValue(value=token.value, loc=loc(parser, token.start))
elif token.kind == TokenKind.NAME:
if token.value in ('true', 'false'):
advance(parser)
return ast.BooleanValue(value=token.value == 'true', loc=loc(parser, token.start))
if token.value != 'null':
advance(parser)
return ast.EnumValue(value=token.value, loc=loc(parser, token.start))
elif token.kind == TokenKind.DOLLAR:
if not is_const:
return parse_variable(parser)
raise unexpected(parser) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 394 | 427 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,727 | parse_variable_value | def parse_variable_value(parser):
return parse_value_literal(parser, False) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 431 | 432 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,728 | parse_const_value | def parse_const_value(parser):
return parse_value_literal(parser, True) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 435 | 436 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,729 | parse_list | def parse_list(parser, is_const):
start = parser.token.start
item = parse_const_value if is_const else parse_variable_value
return ast.ListValue(
values=any(
parser, TokenKind.BRACKET_L,
item, TokenKind.BRACKET_R),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 439 | 448 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,730 | parse_object | def parse_object(parser, is_const):
start = parser.token.start
expect(parser, TokenKind.BRACE_L)
fields = []
while not skip(parser, TokenKind.BRACE_R):
fields.append(parse_object_field(parser, is_const))
return ast.ObjectValue(fields=fields, loc=loc(parser, start)) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 451 | 459 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,731 | parse_object_field | def parse_object_field(parser, is_const):
start = parser.token.start
return ast.ObjectField(
name=parse_name(parser),
value=expect(parser, TokenKind.COLON) and parse_value_literal(parser, is_const),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 462 | 468 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,732 | parse_directives | def parse_directives(parser):
directives = []
while peek(parser, TokenKind.AT):
directives.append(parse_directive(parser))
return directives | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 473 | 477 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,733 | parse_directive | def parse_directive(parser):
start = parser.token.start
expect(parser, TokenKind.AT)
return ast.Directive(
name=parse_name(parser),
arguments=parse_arguments(parser),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 480 | 488 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,734 | parse_type | def parse_type(parser):
"""Handles the 'Type': TypeName, ListType, and NonNullType
parsing rules."""
start = parser.token.start
if skip(parser, TokenKind.BRACKET_L):
ast_type = parse_type(parser)
expect(parser, TokenKind.BRACKET_R)
ast_type = ast.ListType(type=ast_type, loc=loc(parser, start))
else:
ast_type = parse_named_type(parser)
if skip(parser, TokenKind.BANG):
return ast.NonNullType(type=ast_type, loc=loc(parser, start))
return ast_type | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 492 | 507 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,735 | parse_named_type | def parse_named_type(parser):
start = parser.token.start
return ast.NamedType(
name=parse_name(parser),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 510 | 515 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,736 | parse_type_system_definition | def parse_type_system_definition(parser):
'''
TypeSystemDefinition :
- SchemaDefinition
- TypeDefinition
- TypeExtensionDefinition
- DirectiveDefinition
TypeDefinition :
- ScalarTypeDefinition
- ObjectTypeDefinition
- InterfaceTypeDefinition
- UnionTypeDefinition
- EnumTypeDefinition
- InputObjectTypeDefinition
'''
if not peek(parser, TokenKind.NAME):
raise unexpected(parser)
name = parser.token.value
if name == 'schema':
return parse_schema_definition(parser)
elif name == 'scalar':
return parse_scalar_type_definition(parser)
elif name == 'type':
return parse_object_type_definition(parser)
elif name == 'interface':
return parse_interface_type_definition(parser)
elif name == 'union':
return parse_union_type_definition(parser)
elif name == 'enum':
return parse_enum_type_definition(parser)
elif name == 'input':
return parse_input_object_type_definition(parser)
elif name == 'extend':
return parse_type_extension_definition(parser)
elif name == 'directive':
return parse_directive_definition(parser)
raise unexpected(parser) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 518 | 566 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,737 | parse_schema_definition | def parse_schema_definition(parser):
start = parser.token.start
expect_keyword(parser, 'schema')
directives = parse_directives(parser)
operation_types = many(
parser,
TokenKind.BRACE_L,
parse_operation_type_definition,
TokenKind.BRACE_R
)
return ast.SchemaDefinition(
directives=directives,
operation_types=operation_types,
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 569 | 584 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,738 | parse_operation_type_definition | def parse_operation_type_definition(parser):
start = parser.token.start
operation = parse_operation_type(parser)
expect(parser, TokenKind.COLON)
return ast.OperationTypeDefinition(
operation=operation,
type=parse_named_type(parser),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 587 | 596 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,739 | parse_scalar_type_definition | def parse_scalar_type_definition(parser):
start = parser.token.start
expect_keyword(parser, 'scalar')
return ast.ScalarTypeDefinition(
name=parse_name(parser),
directives=parse_directives(parser),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 599 | 607 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,740 | parse_object_type_definition | def parse_object_type_definition(parser):
start = parser.token.start
expect_keyword(parser, 'type')
return ast.ObjectTypeDefinition(
name=parse_name(parser),
interfaces=parse_implements_interfaces(parser),
directives=parse_directives(parser),
fields=any(
parser,
TokenKind.BRACE_L,
parse_field_definition,
TokenKind.BRACE_R
),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 610 | 624 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,741 | parse_implements_interfaces | def parse_implements_interfaces(parser):
types = []
if parser.token.value == 'implements':
advance(parser)
while True:
types.append(parse_named_type(parser))
if not peek(parser, TokenKind.NAME):
break
return types | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 627 | 638 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,742 | parse_field_definition | def parse_field_definition(parser):
start = parser.token.start
return ast.FieldDefinition(
name=parse_name(parser),
arguments=parse_argument_defs(parser),
type=expect(parser, TokenKind.COLON) and parse_type(parser),
directives=parse_directives(parser),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 641 | 650 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,743 | parse_argument_defs | def parse_argument_defs(parser):
if not peek(parser, TokenKind.PAREN_L):
return []
return many(parser, TokenKind.PAREN_L, parse_input_value_def, TokenKind.PAREN_R) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 653 | 657 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,744 | parse_input_value_def | def parse_input_value_def(parser):
start = parser.token.start
return ast.InputValueDefinition(
name=parse_name(parser),
type=expect(parser, TokenKind.COLON) and parse_type(parser),
default_value=parse_const_value(parser) if skip(parser, TokenKind.EQUALS) else None,
directives=parse_directives(parser),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 660 | 669 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,745 | parse_interface_type_definition | def parse_interface_type_definition(parser):
start = parser.token.start
expect_keyword(parser, 'interface')
return ast.InterfaceTypeDefinition(
name=parse_name(parser),
directives=parse_directives(parser),
fields=any(parser, TokenKind.BRACE_L, parse_field_definition, TokenKind.BRACE_R),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 672 | 681 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,746 | parse_union_type_definition | def parse_union_type_definition(parser):
start = parser.token.start
expect_keyword(parser, 'union')
return ast.UnionTypeDefinition(
name=parse_name(parser),
directives=parse_directives(parser),
types=expect(parser, TokenKind.EQUALS) and parse_union_members(parser),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 684 | 693 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,747 | parse_union_members | def parse_union_members(parser):
members = []
while True:
members.append(parse_named_type(parser))
if not skip(parser, TokenKind.PIPE):
break
return members | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 696 | 705 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,748 | parse_enum_type_definition | def parse_enum_type_definition(parser):
start = parser.token.start
expect_keyword(parser, 'enum')
return ast.EnumTypeDefinition(
name=parse_name(parser),
directives=parse_directives(parser),
values=many(parser, TokenKind.BRACE_L, parse_enum_value_definition, TokenKind.BRACE_R),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 708 | 717 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,749 | parse_enum_value_definition | def parse_enum_value_definition(parser):
start = parser.token.start
return ast.EnumValueDefinition(
name=parse_name(parser),
directives=parse_directives(parser),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 720 | 727 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,750 | parse_input_object_type_definition | def parse_input_object_type_definition(parser):
start = parser.token.start
expect_keyword(parser, 'input')
return ast.InputObjectTypeDefinition(
name=parse_name(parser),
directives=parse_directives(parser),
fields=any(parser, TokenKind.BRACE_L, parse_input_value_def, TokenKind.BRACE_R),
loc=loc(parser, start),
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 730 | 739 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,751 | parse_type_extension_definition | def parse_type_extension_definition(parser):
start = parser.token.start
expect_keyword(parser, 'extend')
return ast.TypeExtensionDefinition(
definition=parse_object_type_definition(parser),
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 742 | 749 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,752 | parse_directive_definition | def parse_directive_definition(parser):
start = parser.token.start
expect_keyword(parser, 'directive')
expect(parser, TokenKind.AT)
name = parse_name(parser)
args = parse_argument_defs(parser)
expect_keyword(parser, 'on')
locations = parse_directive_locations(parser)
return ast.DirectiveDefinition(
name=name,
locations=locations,
arguments=args,
loc=loc(parser, start)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 752 | 767 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,753 | parse_directive_locations | def parse_directive_locations(parser):
locations = []
while True:
locations.append(parse_name(parser))
if not skip(parser, TokenKind.PIPE):
break
return locations | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py | 770 | 779 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,754 | __init__ | def __init__(self, line, column):
self.line = line
self.column = column | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py | 7 | 9 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,755 | __repr__ | def __repr__(self):
return '<SourceLocation line={} column={}>'.format(self.line, self.column) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py | 11 | 12 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,756 | __eq__ | def __eq__(self, other):
return (
isinstance(other, SourceLocation) and
self.line == other.line and
self.column == other.column
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py | 14 | 19 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,757 | get_location | def get_location(source, position):
lines = source.body[:position].splitlines()
if lines:
line = len(lines)
column = len(lines[-1]) + 1
else:
line = 1
column = 1
return SourceLocation(line, column) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py | 22 | 30 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,758 | __nonzero__ | def __nonzero__(self):
return False | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 9 | 10 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,759 | __bool__ | def __bool__(self):
return False | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 12 | 13 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,760 | __init__ | def __init__(self, in_array, index, keys, edits, prev):
self.in_array = in_array
self.index = index
self.keys = keys
self.edits = edits
self.prev = prev | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 23 | 28 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,761 | visit | def visit(root, visitor, key_map=None):
visitor_keys = key_map or QUERY_DOCUMENT_KEYS
stack = None
in_array = isinstance(root, list)
keys = [root]
index = -1
edits = []
parent = None
path = []
ancestors = []
new_root = root
leave = visitor.leave
enter = visitor.enter
path_pop = path.pop
ancestors_pop = ancestors.pop
path_append = path.append
ancestors_append = ancestors.append
while True:
index += 1
is_leaving = index == len(keys)
is_edited = is_leaving and edits
if is_leaving:
key = path_pop() if ancestors else None
node = parent
parent = ancestors_pop() if ancestors else None
if is_edited:
if in_array:
node = list(node)
else:
node = copy(node)
edit_offset = 0
for edit_key, edit_value in edits:
if in_array:
edit_key -= edit_offset
if in_array and edit_value is REMOVE:
node.pop(edit_key)
edit_offset += 1
else:
if isinstance(node, list):
node[edit_key] = edit_value
else:
setattr(node, edit_key, edit_value)
index = stack.index
keys = stack.keys
edits = stack.edits
in_array = stack.in_array
stack = stack.prev
else:
if parent:
key = index if in_array else keys[index]
if isinstance(parent, list):
node = parent[key]
else:
node = getattr(parent, key, None)
else:
key = None
node = new_root
if node is REMOVE or node is None:
continue
if parent:
path_append(key)
result = None
if not isinstance(node, list):
assert isinstance(node, ast.Node), 'Invalid AST Node: ' + repr(node)
if is_leaving:
result = leave(node, key, parent, path, ancestors)
else:
result = enter(node, key, parent, path, ancestors)
if result is BREAK:
break
if result is False:
if not is_leaving:
path_pop()
continue
elif result is not None:
edits.append((key, result))
if not is_leaving:
if isinstance(result, ast.Node):
node = result
else:
path_pop()
continue
if result is None and is_edited:
edits.append((key, node))
if not is_leaving:
stack = Stack(in_array, index, keys, edits, stack)
in_array = isinstance(node, list)
keys = node if in_array else visitor_keys.get(type(node), None) or []
index = -1
edits = []
if parent:
ancestors_append(parent)
parent = node
if not stack:
break
if edits:
new_root = edits[-1][1]
return new_root | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 31 | 156 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,762 | enter | def enter(self, node, key, parent, path, ancestors):
method = self._get_enter_handler(type(node))
if method:
return method(self, node, key, parent, path, ancestors) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 162 | 165 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,763 | leave | def leave(self, node, key, parent, path, ancestors):
method = self._get_leave_handler(type(node))
if method:
return method(self, node, key, parent, path, ancestors) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 167 | 170 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,764 | __init__ | def __init__(self, visitors):
self.visitors = visitors
self.skipping = [None] * len(visitors) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 176 | 178 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,765 | enter | def enter(self, node, key, parent, path, ancestors):
for i, visitor in enumerate(self.visitors):
if not self.skipping[i]:
result = visitor.enter(node, key, parent, path, ancestors)
if result is False:
self.skipping[i] = node
elif result is BREAK:
self.skipping[i] = BREAK
elif result is not None:
return result | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 180 | 189 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,766 | leave | def leave(self, node, key, parent, path, ancestors):
for i, visitor in enumerate(self.visitors):
if not self.skipping[i]:
result = visitor.leave(node, key, parent, path, ancestors)
if result is BREAK:
self.skipping[i] = BREAK
elif result is not None and result is not False:
return result
elif self.skipping[i] == node:
self.skipping[i] = REMOVE | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 191 | 200 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,767 | __init__ | def __init__(self, type_info, visitor):
self.type_info = type_info
self.visitor = visitor | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 206 | 208 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,768 | enter | def enter(self, node, key, parent, path, ancestors):
self.type_info.enter(node)
result = self.visitor.enter(node, key, parent, path, ancestors)
if result is not None:
self.type_info.leave(node)
if isinstance(result, ast.Node):
self.type_info.enter(result)
return result | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 210 | 217 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,769 | leave | def leave(self, node, key, parent, path, ancestors):
result = self.visitor.leave(node, key, parent, path, ancestors)
self.type_info.leave(node)
return result | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py | 219 | 222 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,770 | __init__ | def __init__(self, kind, start, end, value=None):
self.kind = kind
self.start = start
self.end = end
self.value = value | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 12 | 16 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,771 | __repr__ | def __repr__(self):
return u'<Token kind={} at {}..{} value={}>'.format(
get_token_kind_desc(self.kind),
self.start,
self.end,
repr(self.value)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 18 | 24 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,772 | __eq__ | def __eq__(self, other):
return (self.kind == other.kind and
self.start == other.start and
self.end == other.end and
self.value == other.value) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 26 | 30 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,773 | __init__ | def __init__(self, source):
self.source = source
self.prev_position = 0 | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 36 | 38 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,774 | next_token | def next_token(self, reset_position=None):
if reset_position is None:
reset_position = self.prev_position
token = read_token(self.source, reset_position)
self.prev_position = token.end
return token | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 40 | 45 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,775 | get_token_desc | def get_token_desc(token):
if token.value:
return u'{} "{}"'.format(
get_token_kind_desc(token.kind),
token.value
)
else:
return get_token_kind_desc(token.kind) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 70 | 77 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,776 | get_token_kind_desc | def get_token_kind_desc(kind):
return TOKEN_DESCRIPTION[kind] | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 80 | 81 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,777 | char_code_at | def char_code_at(s, pos):
if 0 <= pos < len(s):
return ord(s[pos])
return None | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 107 | 111 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,778 | print_char_code | def print_char_code(code):
if code is None:
return '<EOF>'
if code < 0x007F:
return json.dumps(chr(code))
return '"\\u%04X"' % code | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 130 | 137 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,779 | read_token | def read_token(source, from_position):
"""Gets the next token from the source starting at the given position.
This skips over whitespace and comments until it finds the next lexable
token, then lexes punctuators immediately or calls the appropriate
helper fucntion for more complicated tokens."""
body = source.body
body_length = len(body)
position = position_after_whitespace(body, from_position)
if position >= body_length:
return Token(TokenKind.EOF, position, position)
code = char_code_at(body, position)
if code < 0x0020 and code not in (0x0009, 0x000A, 0x000D):
raise GraphQLSyntaxError(
source, position,
u'Invalid character {}.'.format(print_char_code(code))
)
kind = PUNCT_CODE_TO_KIND.get(code)
if kind is not None:
return Token(kind, position, position + 1)
if code == 46: # .
if char_code_at(body, position + 1) == char_code_at(body, position + 2) == 46:
return Token(TokenKind.SPREAD, position, position + 3)
elif 65 <= code <= 90 or code == 95 or 97 <= code <= 122:
# A-Z, _, a-z
return read_name(source, position)
elif code == 45 or 48 <= code <= 57: # -, 0-9
return read_number(source, position, code)
elif code == 34: # "
return read_string(source, position)
raise GraphQLSyntaxError(
source, position,
u'Unexpected character {}.'.format(print_char_code(code))) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 140 | 182 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,780 | position_after_whitespace | def position_after_whitespace(body, start_position):
"""Reads from body starting at start_position until it finds a
non-whitespace or commented character, then returns the position of
that character for lexing."""
body_length = len(body)
position = start_position
while position < body_length:
code = char_code_at(body, position)
if code in ignored_whitespace_characters:
position += 1
elif code == 35: # #, skip comments
position += 1
while position < body_length:
code = char_code_at(body, position)
if not (code is not None and (code > 0x001F or code == 0x0009) and code not in (0x000A, 0x000D)):
break
position += 1
else:
break
return position | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 199 | 220 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,781 | read_number | def read_number(source, start, first_code):
"""Reads a number token from the source file, either a float
or an int depending on whether a decimal point appears.
Int: -?(0|[1-9][0-9]*)
Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?"""
code = first_code
body = source.body
position = start
is_float = False
if code == 45: # -
position += 1
code = char_code_at(body, position)
if code == 48: # 0
position += 1
code = char_code_at(body, position)
if code is not None and 48 <= code <= 57:
raise GraphQLSyntaxError(
source,
position,
u'Invalid number, unexpected digit after 0: {}.'.format(print_char_code(code))
)
else:
position = read_digits(source, position, code)
code = char_code_at(body, position)
if code == 46: # .
is_float = True
position += 1
code = char_code_at(body, position)
position = read_digits(source, position, code)
code = char_code_at(body, position)
if code in (69, 101): # E e
is_float = True
position += 1
code = char_code_at(body, position)
if code in (43, 45): # + -
position += 1
code = char_code_at(body, position)
position = read_digits(source, position, code)
return Token(
TokenKind.FLOAT if is_float else TokenKind.INT,
start,
position,
body[start:position]
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 223 | 275 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,782 | read_digits | def read_digits(source, start, first_code):
body = source.body
position = start
code = first_code
if code is not None and 48 <= code <= 57: # 0 - 9
while True:
position += 1
code = char_code_at(body, position)
if not (code is not None and 48 <= code <= 57):
break
return position
raise GraphQLSyntaxError(
source,
position,
u'Invalid number, expected digit but got: {}.'.format(print_char_code(code))
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 278 | 297 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,783 | read_string | def read_string(source, start):
"""Reads a string token from the source file.
"([^"\\\u000A\u000D\u2028\u2029]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
"""
body = source.body
body_length = len(body)
position = start + 1
chunk_start = position
code = 0
value = []
append = value.append
while position < body_length:
code = char_code_at(body, position)
if not (
code is not None and
code not in (
# LineTerminator
0x000A, 0x000D,
# Quote
34
)
):
break
if code < 0x0020 and code != 0x0009:
raise GraphQLSyntaxError(
source,
position,
u'Invalid character within String: {}.'.format(print_char_code(code))
)
position += 1
if code == 92: # \
append(body[chunk_start:position - 1])
code = char_code_at(body, position)
escaped = ESCAPED_CHAR_CODES.get(code)
if escaped is not None:
append(escaped)
elif code == 117: # u
char_code = uni_char_code(
char_code_at(body, position + 1) or 0,
char_code_at(body, position + 2) or 0,
char_code_at(body, position + 3) or 0,
char_code_at(body, position + 4) or 0,
)
if char_code < 0:
raise GraphQLSyntaxError(
source, position,
u'Invalid character escape sequence: \\u{}.'.format(body[position + 1: position + 5])
)
append(chr(char_code))
position += 4
else:
raise GraphQLSyntaxError(
source, position,
u'Invalid character escape sequence: \\{}.'.format(chr(code))
)
position += 1
chunk_start = position
if code != 34: # Quote (")
raise GraphQLSyntaxError(source, position, 'Unterminated string')
append(body[chunk_start:position])
return Token(TokenKind.STRING, start, position + 1, u''.join(value)) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 312 | 384 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,784 | uni_char_code | def uni_char_code(a, b, c, d):
"""Converts four hexidecimal chars to the integer that the
string represents. For example, uniCharCode('0','0','0','f')
will return 15, and uniCharCode('0','0','f','f') returns 255.
Returns a negative number on error, if a char was invalid.
This is implemented by noting that char2hex() returns -1 on error,
which means the result of ORing the char2hex() will also be negative.
"""
return (char2hex(a) << 12 | char2hex(b) << 8 |
char2hex(c) << 4 | char2hex(d)) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 387 | 398 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,785 | char2hex | def char2hex(a):
"""Converts a hex character to its integer value.
'0' becomes 0, '9' becomes 9
'A' becomes 10, 'F' becomes 15
'a' becomes 10, 'f' becomes 15
Returns -1 on error."""
if 48 <= a <= 57: # 0-9
return a - 48
elif 65 <= a <= 70: # A-F
return a - 55
elif 97 <= a <= 102: # a-f
return a - 87
return -1 | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 401 | 414 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,786 | read_name | def read_name(source, position):
"""Reads an alphanumeric + underscore name from the source.
[_A-Za-z][_0-9A-Za-z]*"""
body = source.body
body_length = len(body)
end = position + 1
while end != body_length:
code = char_code_at(body, end)
if not (code is not None and (
code == 95 or # _
48 <= code <= 57 or # 0-9
65 <= code <= 90 or # A-Z
97 <= code <= 122 # a-z
)):
break
end += 1
return Token(TokenKind.NAME, position, end, body[position:end]) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py | 417 | 437 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,787 | __new__ | def __new__(cls, name, bases, attrs):
enter_handlers = {}
leave_handlers = {}
for base in bases:
if hasattr(base, '_enter_handlers'):
enter_handlers.update(base._enter_handlers)
if hasattr(base, '_leave_handlers'):
leave_handlers.update(base._leave_handlers)
for attr, val in attrs.items():
if attr.startswith('enter_'):
ast_kind = attr[6:]
ast_type = AST_KIND_TO_TYPE.get(ast_kind)
enter_handlers[ast_type] = val
elif attr.startswith('leave_'):
ast_kind = attr[6:]
ast_type = AST_KIND_TO_TYPE.get(ast_kind)
leave_handlers[ast_type] = val
attrs['_enter_handlers'] = enter_handlers
attrs['_leave_handlers'] = leave_handlers
attrs['_get_enter_handler'] = enter_handlers.get
attrs['_get_leave_handler'] = leave_handlers.get
return super(VisitorMeta, cls).__new__(cls, name, bases, attrs) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor_meta.py | 56 | 82 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,788 | __init__ | def __init__(self, definitions, loc=None):
self.loc = loc
self.definitions = definitions | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 17 | 19 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,789 | __eq__ | def __eq__(self, other):
return (
self is other or (
isinstance(other, Document) and
# self.loc == other.loc and
self.definitions == other.definitions
)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 21 | 28 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,790 | __repr__ | def __repr__(self):
return ('Document('
'definitions={self.definitions!r}'
')').format(self=self) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 30 | 33 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,791 | __copy__ | def __copy__(self):
return type(self)(
self.definitions,
self.loc
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 35 | 39 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,792 | __hash__ | def __hash__(self):
return id(self) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 41 | 42 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,793 | __init__ | def __init__(self, operation, selection_set, name=None, variable_definitions=None, directives=None, loc=None):
self.loc = loc
self.operation = operation
self.name = name
self.variable_definitions = variable_definitions
self.directives = directives
self.selection_set = selection_set | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 49 | 55 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,794 | __eq__ | def __eq__(self, other):
return (
self is other or (
isinstance(other, OperationDefinition) and
# self.loc == other.loc and
self.operation == other.operation and
self.name == other.name and
self.variable_definitions == other.variable_definitions and
self.directives == other.directives and
self.selection_set == other.selection_set
)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 57 | 68 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,795 | __repr__ | def __repr__(self):
return ('OperationDefinition('
'operation={self.operation!r}'
', name={self.name!r}'
', variable_definitions={self.variable_definitions!r}'
', directives={self.directives!r}'
', selection_set={self.selection_set!r}'
')').format(self=self) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 70 | 77 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,796 | __copy__ | def __copy__(self):
return type(self)(
self.operation,
self.selection_set,
self.name,
self.variable_definitions,
self.directives,
self.loc
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 79 | 87 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,797 | __hash__ | def __hash__(self):
return id(self) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 89 | 90 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,798 | __init__ | def __init__(self, variable, type, default_value=None, loc=None):
self.loc = loc
self.variable = variable
self.type = type
self.default_value = default_value | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 97 | 101 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,799 | __eq__ | def __eq__(self, other):
return (
self is other or (
isinstance(other, VariableDefinition) and
# self.loc == other.loc and
self.variable == other.variable and
self.type == other.type and
self.default_value == other.default_value
)
) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 103 | 112 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,800 | __repr__ | def __repr__(self):
return ('VariableDefinition('
'variable={self.variable!r}'
', type={self.type!r}'
', default_value={self.default_value!r}'
')').format(self=self) | python | wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py | 114 | 119 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.