Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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