/usr/lib/python3/dist-packages/pydbus/identifier.py is in python3-pydbus 0.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | try:
isident = str.isidentifier
except:
import re
isidentre = re.compile("^[a-zA-Z_][a-zA-Z0-9_]*$")
def isident(s):
return isidentre.match(s) is not None
def filter_identifier(name):
name = name.replace("-", "_")
safe_name = ""
for c in name:
if not safe_name:
if isident(c):
safe_name += c
else:
if isident("a" + c):
safe_name += c
return safe_name
|