How to use the s2protocol.versions.build function in s2protocol

To help you get started, we’ve selected a few s2protocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blizzard / s2protocol / tests / test_versions.py View on Github external
def test_specific(self):
        p = _versions.build(58400)
        self.assertIsNotNone(p)
github Blizzard / s2protocol / s2protocol / s2_cli.py View on Github external
filters.insert(0, StatCollectionFilter())

    def process_event(event):
        for f in filters:
            event = f.process(event)
        
    # Read the protocol header, this can be read with any protocol
    contents = archive.header['user_data_header']['content']
    header = latest().decode_replay_header(contents)
    if args.header:
        process_event(header)

    # The header's baseBuild determines which protocol to use
    baseBuild = header['m_version']['m_baseBuild']
    try:
        protocol = build(baseBuild)
    except Exception as e:
        print('Unsupported base build: {0} ({1!s})'.format(baseBuild, e),
              file=sys.stderr)
        sys.exit(1)

    # Process game metadata
    if args.all or args.metadata:
        contents = read_contents(archive, 'replay.gamemetadata.json')
        process_event(json.loads(contents))

    # Print protocol details
    if args.all or args.details:
        contents = read_contents(archive, 'replay.details')
        details = protocol.decode_replay_details(contents)
        details = process_details_data(details)
        process_event(details)
github Blizzard / s2protocol / s2protocol / diff.py View on Github external
def diff(protocol_a_ver, protocol_b_ver):
    print(
        "Comparing {} to {}".format(
            protocol_a_ver, protocol_b_ver
        )
    )

    protocol_a = build(protocol_a_ver)
    protocol_b = build(protocol_b_ver)
    count_a = len(protocol_a.typeinfos)
    count_b = len(protocol_b.typeinfos)
    print("Count of typeinfos: {} {}".format(count_a, count_b))
    for index in range(max(count_a, count_b)):
        if index >= count_a:
            print("Protocol {} missing typeinfo {}".format(protocol_a_ver, index))
            continue
        if index >= count_b:
            print("Protocol {} missing typeinfo {}".format(protocol_b_ver, index))
            continue
        a = protocol_a.typeinfos[index]
        b = protocol_b.typeinfos[index]
        diff_things(index, a, b)
github Blizzard / s2protocol / s2protocol / diff.py View on Github external
def diff(protocol_a_ver, protocol_b_ver):
    print(
        "Comparing {} to {}".format(
            protocol_a_ver, protocol_b_ver
        )
    )

    protocol_a = build(protocol_a_ver)
    protocol_b = build(protocol_b_ver)
    count_a = len(protocol_a.typeinfos)
    count_b = len(protocol_b.typeinfos)
    print("Count of typeinfos: {} {}".format(count_a, count_b))
    for index in range(max(count_a, count_b)):
        if index >= count_a:
            print("Protocol {} missing typeinfo {}".format(protocol_a_ver, index))
            continue
        if index >= count_b:
            print("Protocol {} missing typeinfo {}".format(protocol_b_ver, index))
            continue
        a = protocol_a.typeinfos[index]
        b = protocol_b.typeinfos[index]
        diff_things(index, a, b)