MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / const

Function const

src/ext/pynetworkmanager/NetworkManager.py:481–488  ·  view source on GitHub ↗
(prefix, val)

Source from the content-addressed store, hash-verified

479# interface_names = ['org.freedesktop.NetworkManager.VPN.Plugin']
480
481def const(prefix, val):
482 prefix = 'NM_' + prefix.upper() + '_'
483 for key, vval in globals().items():
484 if 'REASON' in key and 'REASON' not in prefix:
485 continue
486 if key.startswith(prefix) and val == vval:
487 return key.replace(prefix,'').lower()
488 raise ValueError("No constant found for %s* with value %d", (prefix, val))
489
490# Several fixer methods to make the data easier to handle in python
491# - SSID sent/returned as bytes (only encoding tried is utf-8)

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected