How to use the s2protocol.attributes.__dict__ 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 / s2protocol / s2_cli.py View on Github external
def process_scope_attributes(all_scopes, event_fn):
    # Build up the reverse attribute mapping
    attr_id_to_name = {}
    for sym in _attr.__dict__:
        if sym.startswith('_'):
            continue
        attr_id_to_name[_attr.__dict__.get(sym)] = sym.lower()

    # Each scope represents a slot in the lobby
    for scope, scope_dict in all_scopes.items():
        scope_doc = { 'scope': scope }
        # Convert all other attributes to symbolic representation
        for attr_id, val_dict in scope_dict.items():
            val = val_dict[0]['value'] 
            attr_name = attr_id_to_name.get(attr_id, None)
            if attr_name is not None:
                scope_doc[attr_name] = val
            else:
                scope_doc['unknown_{}'.format(attr_id)] = val

        # Pass the scope doc as a new event 
        event_fn(scope_doc)
github Blizzard / s2protocol / s2protocol / s2_cli.py View on Github external
def process_scope_attributes(all_scopes, event_fn):
    # Build up the reverse attribute mapping
    attr_id_to_name = {}
    for sym in _attr.__dict__:
        if sym.startswith('_'):
            continue
        attr_id_to_name[_attr.__dict__.get(sym)] = sym.lower()

    # Each scope represents a slot in the lobby
    for scope, scope_dict in all_scopes.items():
        scope_doc = { 'scope': scope }
        # Convert all other attributes to symbolic representation
        for attr_id, val_dict in scope_dict.items():
            val = val_dict[0]['value'] 
            attr_name = attr_id_to_name.get(attr_id, None)
            if attr_name is not None:
                scope_doc[attr_name] = val
            else:
                scope_doc['unknown_{}'.format(attr_id)] = val