Example #1
0
def apply_textdelta(command, args):
    file_token = parse.string(args[0])

    base_checksum = None
    if len(args[1]) > 0:
        base_checksum = parse.string(args[1][0])

    command.apply_textdelta(file_token, base_checksum)
Example #2
0
def close_file(command, args):
    file_token = parse.string(args[0])

    text_checksum = None
    if len(args[1]) > 0:
        text_checksum = parse.string(args[1][0])

    command.close_file(file_token, text_checksum)
Example #3
0
def change_dir_prop(command, args):
    dir_token = parse.string(args[0])
    name = parse.string(args[1])

    value = None
    if len(args[2]) > 0:
        value = parse.string(args[2][0])

    command.change_dir_prop(dir_token, name, value)
Example #4
0
def open_dir(command, args):
    path = parse.string(args[0])
    parent_token = parse.string(args[1])
    child_token = parse.string(args[2])

    rev = None
    if len(args[3]) > 0:
        rev = int(args[3][0])

    command.open_dir(path, parent_token, child_token, rev)
Example #5
0
def open_file(command, args):
    path = parse.string(args[0])
    dir_token = parse.string(args[1])
    file_token = parse.string(args[2])

    rev = None
    if len(args[3]) > 0:
        rev = int(args[3][0])

    command.open_file(path, dir_token, file_token, rev)
Example #6
0
def add_dir(command, args):
    path = parse.string(args[0])
    parent_token = parse.string(args[1])
    child_token = parse.string(args[2])

    copy_path = None
    copy_rev = None
    if len(args[3]) > 0:
        copy_path = parse.string(args[3][0])
        copy_rev = int(args[3][1])

    command.add_dir(path, parent_token, child_token, copy_path, copy_rev)
Example #7
0
def add_file(command, args):
    path = parse.string(args[0])
    dir_token = parse.string(args[1])
    file_token = parse.string(args[2])

    copy_path = None
    copy_rev = None
    if len(args[3]) > 0:
        copy_path = parse.string(args[3][0])
        copy_rev = int(args[3][1])

    command.add_file(path, dir_token, file_token, copy_path, copy_rev)
Example #8
0
def set_path(command, args):
    path = parse.string(args[0])
    rev = int(args[1])
    start_empty = args[2].lower() == 'true'

    lock_token = None
    if len(args) > 3 and len(args[3]) != 0:
        lock_token = parse.string(args[3][0])

    depth = None
    if len(args) > 4:
        depth = args[4]

    command.report_set_path(path, rev, start_empty, lock_token, depth)
Example #9
0
def link_path(command, args):
    path = parse.string(args[0])
    url = parse.string(args[1])
    rev = int(args[2])
    start_empty = parse.bool(args[3])

    lock_token = None
    if len(args) > 4:
        lock_token = parse.string(args[4][0])

    depth = None
    if len(args) > 5:
        depth = args[5]

    command.report_link_path(path, url, rev, start_empty, lock_token, depth)
Example #10
0
def connect(link):
    # Send the announce message - we only support protocol version 2.
    """

    :type link: SvnRequestHandler
    """
    link.send_msg(gen.success(2, 2, gen.list(),
                              gen.list(*server_capabilities)))
    msg = parse.msg(link.read_msg())

    proto_ver = int(msg[0])
    client_caps = msg[1]
    url = parse.string(msg[2])

    print "ver: %d" % proto_ver
    print "caps: %s" % client_caps
    print "url: %s" % url

    if proto_ver != 2:
        raise BadProtoVersion()

    repo, path, base_url = link.server.find_repo(url)

    if repo is None:
        link.send_msg(
            gen.failure(
                gen.list(210005,
                         gen.string("No repository found in '%s'" % url),
                         gen.string('message.py'), 0)))

    return path, client_caps, repo, base_url
Example #11
0
def get(line: str):
    '''
    generates all edges in a query, with some nodes variable,

    >>> store.save('causes', 'piracetam', '+ ACh')
    >>> store.save('causes', 'choline', '+ ACh')

    >>> list(get('piracetam'))
    [('causes', 'piracetam', '+ ACh')]

    >>> list(get('_ -> + ACh'))
    [('causes', 'piracetam', '+ ACh'), ('causes', 'choline', '+ ACh')]

    '''

    parsed = parse.string(line)
    variable_edges, constant_nodes, constant_edges = querify(
        parsed.graph.edges)

    for edge in variable_edges:
        yield from from_edge(edge)

    for edge in constant_edges:
        yield from from_edge(edge)

    for node in constant_nodes:
        yield from from_node(node)
Example #12
0
def connect(link):
    # Send the announce message - we only support protocol version 2.
    """

    :type link: SvnRequestHandler
    """
    link.send_msg(gen.success(2, 2, gen.list(), gen.list(*server_capabilities)))
    msg = parse.msg(link.read_msg())

    proto_ver = int(msg[0])
    client_caps = msg[1]
    url = parse.string(msg[2])

    print "ver: %d" % proto_ver
    print "caps: %s" % client_caps
    print "url: %s" % url

    if proto_ver != 2:
        raise BadProtoVersion()

    repo, path, base_url = link.server.find_repo(url)

    if repo is None:
        link.send_msg(gen.failure(gen.list(210005,
                                           gen.string("No repository found in '%s'" % url),
                                           gen.string('message.py'), 0)))

    return path, client_caps, repo, base_url
Example #13
0
def open_root(command, args):
    rev = None
    if len(args[0]) > 0:
        rev = int(args[0][0])

    root_token = parse.string(args[1])

    command.open_root(rev, root_token)
Example #14
0
def delete_path(command, args):
    path = parse.string(args[0])

    command.report_delete_path(path)
Example #15
0
def absent_dir(command, args):
    path = parse.string(args[0])
    parent_token = parse.string(args[1])

    command.absent_dir(path, parent_token)
Example #16
0
def close_dir(command, args):
    dir_token = parse.string(args[0])

    command.close_dir(dir_token)
Example #17
0
def main():
    args = get_args()

    if args.test:
        print()
        print('= = = = = = = = = = = = = = = = = = = = ')
        print('= = = = = = = = TESTING = = = = = = = =')
        print('= = = = = = = = = = = = = = = = = = = = ')
        print()
        args.files = ['test/example.note']
        args.note = True
        args.write = True
        args.visualize = True
        db.test()

    if args.parse:
        args.files = [args.parse]

    files = disk.read_files(args.files)
    notes = N.make_notes(files)

    if args.english:
        line = args.english
        tree = nlp.parse(line)
        nlp.show(line, tree)

    if args.destroy:
        if args.test: h1('DESTROY')
        print(db.collection().remove())

    if args.head:
        if args.test: h1('HEAD')
        print_heads(notes)

    if args.freqs:
        if args.test: h1('FREQS')
        print_first_token_frequencies(notes)

    if args.w:
        note, *_ = N.make_notes([('$', args.w)])
        N.write_notes_to_database([note])

    if args.write:
        db.collection().remove()  #HACK addToSet duplicates
        if args.test: h1('WRITE')
        N.write_notes_to_database(notes)

    if args.p:
        head = parse.string(args.p)
        print_parse(head)

    if args.parse:
        print()
        for note in notes:
            head, body = parse.note(note)
            print(head.graph.edges)
            for limb in body:
                print(limb.graph.edges)
            print()

    if args.get:
        if args.test: h1('GET')

        print()
        results = N.get(args.get)

        for result in results:
            print(result)

        print()

    if args.note:
        if args.test: h1('NOTES')
        N.print_notes(notes)

    if args.visualize:
        if args.test: h1('GRAPH')
        nodes, edges = db.graph()
        graph = visualization.logic_graph_to_visual_graph(nodes, edges)
        print(graph)
        print()
Example #18
0
def textdelta_chunk(command, args):
    file_token = parse.string(args[0])
    chunk = parse.string(args[1])

    command.textdelta_chunk(file_token, chunk)
Example #19
0
def textdelta_end(command, args):
    file_token = parse.string(args[0])

    command.textdelta_end(file_token)
Example #20
0
def delete_entry(command, args):
    path = parse.string(args[0])
    rev = int(args[1][0])
    dir_token = parse.string(args[2])

    command.delete_entry(path, rev, dir_token)