コード例 #1
0
ファイル: __main__.py プロジェクト: prashik-s/client-python
def main() -> int:
    args = setup()
    if not args.disable_bblfsh_autorun:
        ensure_bblfsh_is_running()

    client = BblfshClient(args.endpoint)
    ctx = client.parse(args.file, args.language)

    if args.query:
        run_query(ctx, args.query, array=args.array)
    else:
        pprint.pprint(ctx.load())

    return 0
コード例 #2
0
def main():
    args = setup()
    if not args.disable_bblfsh_autorun:
        ensure_bblfsh_is_running()

    client = BblfshClient(args.endpoint)
    response = client.parse(args.file, args.language)
    root = response.uast
    if len(response.errors):
        sys.stderr.write("\n".join(response.errors) + "\n")
    query = args.query
    if query:
        run_query(root, query, args.mapn, args.array)
    else:
        print(root)
コード例 #3
0
ファイル: base.py プロジェクト: ufwt/ast2vec
def ensure_bblfsh_is_running_noexc():
    """
    Launches the Babelfish server, if it is possible and needed.

    :return: None
    """
    try:
        ensure_bblfsh_is_running()
    except:
        log = logging.getLogger("bblfsh")
        message = "Failed to ensure that the Babelfish server is running."
        if log.isEnabledFor(logging.DEBUG):
            log.exception(message)
        else:
            log.warning(message)
コード例 #4
0
ファイル: base.py プロジェクト: fineguy/ast2vec
def ensure_bblfsh_is_running_noexc(bblfsh_endpoint=None):
    """
    Launches the Babelfish server, if it is possible and needed.

    :param bblfsh_endpoint: bblfsh endpoint to check.
    :return: None
    """
    if resolve_bblfsh_endpoint(bblfsh_endpoint) != DEFAULT_BBLFSH_ENDPOINTS[0]:
        return
    try:
        ensure_bblfsh_is_running()
    except:
        log = logging.getLogger("bblfsh")
        message = "Failed to ensure that the Babelfish server is running."
        if log.isEnabledFor(logging.DEBUG):
            log.exception(message)
        else:
            log.warning(message)
コード例 #5
0
def main() -> int:
    args = setup()
    # TODO: parse the address properly
    localAddrs = ('localhost', '0.0.0.0', '127.0.0.1', '[::1]')
    if args.endpoint.startswith(
            localAddrs) and not args.disable_bblfsh_autorun:
        if not ensure_bblfsh_is_running():
            return 1

    client = BblfshClient(args.endpoint)
    ctx = client.parse(args.file, args.language)

    if args.query:
        run_query(ctx, args.query, array=args.array)
    else:
        pprint.pprint(ctx.load())

    return 0
コード例 #6
0
ファイル: test.py プロジェクト: zurk/python-client
 def setUpClass(cls: t.Any) -> None:
     cls.BBLFSH_SERVER_EXISTED = ensure_bblfsh_is_running()
コード例 #7
0
 def setUpClass(cls):
     cls.BBLFSH_SERVER_EXISTED = ensure_bblfsh_is_running()