https://github.com/sunpinyin/sunpinyin/issues/111 --- /wrapper/ibus/setup/main.py +++ /wrapper/ibus/setup/main.py @@ -63,7 +63,7 @@ class Logger: @staticmethod def pr(message): - print >> sys.stderr, message + print(message, file=sys.stderr) class Option(object): @@ -73,10 +73,10 @@ """ config = ibus.Bus().get_config() __wrappers = { - type(True): glib.Variant.new_boolean, - type(1): glib.Variant.new_int32, - type('str'): glib.Variant.new_string, - type([]): glib.Variant.new_strv, + bool: glib.Variant.new_boolean, + int: glib.Variant.new_int32, + str: glib.Variant.new_string, + list: glib.Variant.new_strv, } def __init__(self, name, default): @@ -258,7 +258,7 @@ def read_config(self): if not self.saved_pairs: self.saved_pairs = self.read() - keys = set([pair.split(':')[0] for pair in self.saved_pairs]) + keys = {pair.split(':')[0] for pair in self.saved_pairs} for opt in self.options: opt.is_enabled = (opt.key() in keys) # throw away unknown pair @@ -445,28 +445,28 @@ # TODO: the UI should looks like a virtual keyboard, # user are allowed to choose the mappings to all punctuation keys. def __init__(self): - mappings = [MappingInfo('togglebutton1', [('`',None), ('~',u'~')]), + mappings = [MappingInfo('togglebutton1', [('`', None), ('~', '~')]), MappingInfo('togglebutton2', []), - MappingInfo('togglebutton3', [('2',None), ('@',u'@')]), - MappingInfo('togglebutton4', [('3',None), ('#',u'#')]), - MappingInfo('togglebutton5', [('4',None), ('$',u'¥' )]), - MappingInfo('togglebutton6', [('5',None), ('%',u'%')]), - MappingInfo('togglebutton7', [('6',None), ('^',u'…')]), - MappingInfo('togglebutton8', [('7',None), ('&',u'&')]), - MappingInfo('togglebutton9', [('8',None), ('*',u'*')]), - MappingInfo('togglebutton10', [('9',None), ('*',u'(')]), - MappingInfo('togglebutton11', [('0',None), ('*',u')')]), - MappingInfo('togglebutton12', [('-',u'-'), ('_',u'——')]), - MappingInfo('togglebutton13', [('=',u'='), ('+',u'+')]), - MappingInfo('togglebutton14', [('\\',None), ('|',u'‖')]), - MappingInfo('togglebutton27', [('[',u'〔'), ('{',u'{')]), - MappingInfo('togglebutton28', [(']',u'〕'), ('}',u'}')]), + MappingInfo('togglebutton3', [('2', None), ('@', '@')]), + MappingInfo('togglebutton4', [('3', None), ('#', '#')]), + MappingInfo('togglebutton5', [('4', None), ('$', '¥' )]), + MappingInfo('togglebutton6', [('5', None), ('%', '%')]), + MappingInfo('togglebutton7', [('6', None), ('^', '…')]), + MappingInfo('togglebutton8', [('7', None), ('&', '&')]), + MappingInfo('togglebutton9', [('8', None), ('*', '*')]), + MappingInfo('togglebutton10', [('9', None), ('*', '(')]), + MappingInfo('togglebutton11', [('0', None), ('*', ')')]), + MappingInfo('togglebutton12', [('-', '-'), ('_', '——')]), + MappingInfo('togglebutton13', [('=', '='), ('+', '+')]), + MappingInfo('togglebutton14', [('\\', None), ('|', '‖')]), + MappingInfo('togglebutton27', [('[', '〔'), ('{', '{')]), + MappingInfo('togglebutton28', [(']', '〕'), ('}', '}')]), MappingInfo('togglebutton39', []), MappingInfo('togglebutton40', []), - MappingInfo('togglebutton50', [(',',None), ('<',u'〈')]), - MappingInfo('togglebutton51', [('.',u'·'), ('>',u'〉')]), - MappingInfo('togglebutton52', [('/',u'/'), ('?',None)])] - #'\'',(u'‘',u'’'), + MappingInfo('togglebutton50', [(',', None), ('<', '〈')]), + MappingInfo('togglebutton51', [('.', '·'), ('>', '〉')]), + MappingInfo('togglebutton52', [('/', '/'), ('?', None)])] + #'\'', ('‘', '’'), MultiCheckDialog.__init__(self, ui_name="punctmapping", config_name="General/PunctMapping/Mappings", mappings=mappings,