def main(argv):
    if len(argv) < 1:
        sys.stderr.write(
            "Usage: %s <protocol-1> [<protocol-2> [, <protocol-3>...]] <output-file>\n"
            % sys.argv[0])
        return 1

    domains = []
    version = None
    for protocol in argv[:-1]:
        file_name = os.path.normpath(protocol)
        if not os.path.isfile(file_name):
            sys.stderr.write("Cannot find %s\n" % file_name)
            return 1
        input_file = open(file_name, "r")
        parsed_json = pdl.loads(input_file.read(), file_name)
        domains += parsed_json["domains"]
        version = parsed_json["version"]

    output_file = open(argv[-1], "w")
    json.dump({
        "version": version,
        "domains": domains
    },
              output_file,
              indent=4,
              sort_keys=False,
              separators=(',', ': '))
    output_file.close()
def load_schema(file_name, domains):
    # pylint: disable=W0613
    if not os.path.isfile(file_name):
        return
    input_file = open(file_name, "r")
    parsed_json = pdl.loads(input_file.read(), file_name)
    input_file.close()
    domains += parsed_json["domains"]
    return parsed_json["version"]
def load_schema(file_name, domains):
    # pylint: disable=W0613
    if not os.path.isfile(file_name):
        return
    input_file = open(file_name, "r")
    parsed_json = pdl.loads(input_file.read(), file_name)
    input_file.close()
    domains += parsed_json["domains"]
    return parsed_json["version"]
예제 #4
0
 def read_protocol_file(self, file_name):
     input_file = open(file_name, "r")
     parsed_json = pdl.loads(input_file.read(), file_name)
     input_file.close()
     version = parsed_json["version"]["major"] + "." + parsed_json["version"]["minor"]
     domains = []
     for domain in parsed_json["domains"]:
         domains.append(domain["domain"])
         domain["version"] = version
     self.json_api["domains"] += parsed_json["domains"]
     return domains
예제 #5
0
def main(argv):
    if len(argv) < 2:
        sys.stderr.write("Usage: %s <protocol.pdl> <protocol.json>\n" %
                         sys.argv[0])
        return 1
    file_name = os.path.normpath(argv[0])
    input_file = open(file_name, "r")
    pdl_string = input_file.read()
    protocol = pdl.loads(pdl_string, file_name)
    input_file.close()

    output_file = open(os.path.normpath(argv[1]), 'wb')
    json.dump(protocol, output_file, indent=4, separators=(',', ': '))
    output_file.close()
def main(argv):
    parser = argparse.ArgumentParser(description=("Converts from .pdl to .json by invoking the pdl Python module."))
    parser.add_argument("--pdl_file", help="The .pdl input file to parse.")
    parser.add_argument("--json_file", help="The .json output file write.")
    args = parser.parse_args(argv)
    file_name = os.path.normpath(args.pdl_file)
    input_file = open(file_name, "r")
    pdl_string = input_file.read()
    protocol = pdl.loads(pdl_string, file_name, True)
    input_file.close()

    output_file = open(os.path.normpath(args.json_file), 'w')
    json.dump(protocol, output_file, indent=4, separators=(',', ': '))
    output_file.close()
예제 #7
0
def main(argv):
    if len(argv) < 2:
        sys.stderr.write("Usage: %s <protocol.pdl> <protocol.json>\n" % sys.argv[0])
        return 1
    file_name = os.path.normpath(argv[0])
    input_file = open(file_name, "r")
    pdl_string = input_file.read()
    protocol = pdl.loads(pdl_string, file_name)
    input_file.close()
    output_file = open(argv[0].replace('.pdl', '.json'), 'wb')
    json.dump(protocol, output_file, indent=4, separators=(',', ': '))
    output_file.close()

    output_file = open(os.path.normpath(argv[1]), 'wb')
    json.dump(protocol, output_file, indent=4, separators=(',', ': '))
    output_file.close()
def main(argv):
    parser = argparse.ArgumentParser(description=(
        "Converts from .pdl to .json by invoking the pdl Python module."))
    parser.add_argument('--map_binary_to_string', type=bool,
                        help=('If set, binary in the .pdl is mapped to a '
                              'string in .json. Client code will have to '
                              'base64 decode the string to get the payload.'))
    parser.add_argument("pdl_file", help="The .pdl input file to parse.")
    parser.add_argument("json_file", help="The .json output file write.")
    args = parser.parse_args(argv)
    file_name = os.path.normpath(args.pdl_file)
    with open(file_name, "r") as input_file:
        pdl_string = input_file.read()
    protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string)

    with open(os.path.normpath(args.json_file), 'w') as output_file:
        json.dump(protocol, output_file, indent=4, separators=(',', ': '))
예제 #9
0
def main(argv):
    parser = argparse.ArgumentParser(description=(
        "Converts from .pdl to .json by invoking the pdl Python module."))
    parser.add_argument('--map_binary_to_string', type=bool,
                        help=('If set, binary in the .pdl is mapped to a '
                              'string in .json. Client code will have to '
                              'base64 decode the string to get the payload.'))
    parser.add_argument("pdl_file", help="The .pdl input file to parse.")
    parser.add_argument("json_file", help="The .json output file write.")
    args = parser.parse_args(argv)
    file_name = os.path.normpath(args.pdl_file)
    input_file = open(file_name, "r")
    pdl_string = input_file.read()
    protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string)
    input_file.close()

    output_file = open(os.path.normpath(args.json_file), 'wb')
    json.dump(protocol, output_file, indent=4, separators=(',', ': '))
    output_file.close()
예제 #10
0
def main(argv):
    if len(argv) < 1:
        sys.stderr.write("Usage: %s <protocol-1> [<protocol-2> [, <protocol-3>...]] <output-file>\n" % sys.argv[0])
        return 1

    domains = []
    version = None
    for protocol in argv[:-1]:
        file_name = os.path.normpath(protocol)
        if not os.path.isfile(file_name):
            sys.stderr.write("Cannot find %s\n" % file_name)
            return 1
        input_file = open(file_name, "r")
        parsed_json = pdl.loads(input_file.read(), file_name)
        domains += parsed_json["domains"]
        version = parsed_json["version"]

    output_file = open(argv[-1], "w")
    json.dump({"version": version, "domains": domains}, output_file, indent=4, sort_keys=False, separators=(',', ': '))
    output_file.close()
예제 #11
0
def load_schema(file, domains):
    input_file = open(file, "r")
    parsed_json = pdl.loads(input_file.read(), file)
    input_file.close()
    domains.extend(parsed_json["domains"])
예제 #12
0
import json
import os.path
import urllib.request

# To use this, download and copy pdl.py from here beside this file
# https://github.com/nodejs/node/blob/e31a99f01b8a92615ce79b845441949424cd1dda/tools/inspector_protocol/pdl.py
import pdl

inspector_pdl_url = "https://raw.githubusercontent.com/nodejs/node/master/src/inspector/node_protocol.pdl"
with urllib.request.urlopen(inspector_pdl_url) as r:
    pdl_contents = pdl.loads(r.read().decode("utf-8"), "node_protocol.pdl",
                             True)
    with open(os.path.join(os.path.dirname(__file__), "nodeCustom.ts"),
              "w") as o:
        o.write(
            "/*---------------------------------------------------------\n")
        o.write(
            " * Copyright (C) Microsoft Corporation. All rights reserved.\n")
        o.write(
            " *--------------------------------------------------------*/\n")
        o.write("\n")
        o.write("export default ")
        json.dump(pdl_contents, o, indent=2, separators=(",", ": "))
예제 #13
0
import json
import os.path
import urllib.request

# To use this, download and copy pdl.py from here beside this file
# https://github.com/nodejs/node/blob/e31a99f01b8a92615ce79b845441949424cd1dda/tools/inspector_protocol/pdl.py
import pdl

with open(
        os.path.join(os.path.dirname(__file__), "..", "adapter",
                     "cdpProxy.pdl")) as r:
    pdl_contents = pdl.loads(r.read(), "node_protocol.pdl", True)
    with open(os.path.join(os.path.dirname(__file__), "jsDebugCustom.ts"),
              "w") as o:
        o.write(
            "/*---------------------------------------------------------\n")
        o.write(
            " * Copyright (C) Microsoft Corporation. All rights reserved.\n")
        o.write(
            " *--------------------------------------------------------*/\n")
        o.write("\n")
        o.write("export default ")
        json.dump(pdl_contents, o, indent=2, separators=(",", ": "))