- if line[0] != '#' and line.strip() != "":
- # Note: backslashes in the string literals with r prefix are not escaped,
- # so one backslash in the source file equals one backslash in memory.
- # Without r prefix backslahses are escaped, so two backslashes in the
- # source file equal one backslash in memory.
- line=line.replace(' "',' ') # remove all quotation marks with spaces before
- line=line.replace('" ',' ') # remove all quotation marks with spaces after
- line=line.replace(r'\"','"') # unescape "
- line=line.replace(r'\\','\\') # unescape \
- try:
- [ucs4,command,dead] = line.split(None,2)
- if command[0:1] != "\\":
- continue
- if (line.find("notermination=text") < 0 and
- line.find("notermination=both") < 0 and command[-1] != "}"):
- command = command + "{}"
- spec_chars.append([command, unichr(eval(ucs4))])
- except:
+ if not line.strip() or line.startswith('#'):
+ # skip empty lines and comments
+ continue
+ # Note: backslashes in the string literals with r prefix are not escaped,
+ # so one backslash in the source file equals one backslash in memory.
+ # Without r prefix backslahses are escaped, so two backslashes in the
+ # source file equal one backslash in memory.
+ line=line.replace(' "',' ') # remove all quotation marks with spaces before
+ line=line.replace('" ',' ') # remove all quotation marks with spaces after
+ line=line.replace(r'\"','"') # unescape "
+ line=line.replace(r'\\','\\') # unescape \
+ try:
+ [ucs4,command,dead] = line.split(None,2)
+ if command[0:1] != "\\":