コード例 #1
0
ファイル: node.py プロジェクト: jhgg/graphql-relay-py
def fromGlobalId(globalId):
    '''
    Takes the "global ID" created by toGlobalID, and retuns the type name and ID
    used to create it.
    '''
    unbasedGlobalId = unbase64(globalId)
    _type, _id = unbasedGlobalId.split(':', 1)
    return ResolvedGlobalId(_type, _id)
コード例 #2
0
def cursorToOffset(cursor):
    '''
    Rederives the offset from the cursor string.
    '''
    try:
        return int(unbase64(cursor)[len(PREFIX):len(PREFIX)+10])
    except:
        return None
コード例 #3
0
ファイル: node.py プロジェクト: Globegitter/graphql-relay-py
def from_global_id(global_id):
    '''
    Takes the "global ID" created by toGlobalID, and retuns the type name and ID
    used to create it.
    '''
    unbased_global_id = unbase64(global_id)
    _type, _id = unbased_global_id.split(':', 1)
    return _type, _id
コード例 #4
0
def from_global_id(global_id):
    """return a db int id"""
    if isinstance(global_id, int) or global_id.isdigit():
        return global_id

    unbased_global_id = unbase64(global_id)
    _type, _id = unbased_global_id.split(':', 1)
    return _type, _id
コード例 #5
0
ファイル: node.py プロジェクト: sjhewitt/graphql-relay-py
def from_global_id(global_id):
    '''
    Takes the "global ID" created by toGlobalID, and retuns the type name and ID
    used to create it.
    '''
    unbased_global_id = unbase64(global_id)
    _type, _id = unbased_global_id.split(':', 1)
    return _type, _id
コード例 #6
0
 def converts_invalid_base64_to_empty_string():
     assert unbase64("") == ""
     assert unbase64("invalid") == ""
     assert unbase64(example_base64[-1:]) == ""
     assert unbase64(example_base64[1:]) == ""
     assert unbase64("!" + example_base64[1:]) == ""
     assert unbase64("Ü" + example_base64[1:]) == ""
コード例 #7
0
def from_global_cursor(cursor) -> List[str]:
    values = unbase64(cursor)
    return json.loads(values)
コード例 #8
0
 def converts_from_base_64_to_unicode():
     assert unbase64(example_base64) == example_unicode
コード例 #9
0
 def converts_from_base64_as_bytes_to_unicode():
     bytes_example_code = example_base64.encode("ascii")
     assert unbase64(bytes_example_code) == example_unicode  # type: ignore
     bytearray_example_code = bytearray(bytes_example_code)
     assert unbase64(
         bytearray_example_code) == example_unicode  # type: ignore