x Sorry, these patches are not available anymore due to data migration. Please run a fresh inspection.

Code Duplication    Length = 24-24 lines in 2 locations

examples/samples_libtcodpy.py 1 location

@@ 103-126 (lines=24) @@
100
101
    # custom listener
102
    print ('***** Custom listener *****')
103
    class MyListener:
104
        def new_struct(self, struct, name):
105
            print ('new structure type', libtcod.struct_get_name(struct), \
106
                  ' named ', name )
107
            return True
108
        def new_flag(self, name):
109
            print ('new flag named ', name)
110
            return True
111
        def new_property(self,name, typ, value):
112
            type_names = ['NONE', 'BOOL', 'CHAR', 'INT', 'FLOAT', 'STRING', \
113
                          'COLOR', 'DICE']
114
            type_name = type_names[typ & 0xff]
115
            if typ & libtcod.TYPE_LIST:
116
                type_name = 'LIST<%s>' % type_name
117
            print ('new property named ', name,' type ',type_name, \
118
                      ' value ', value)
119
            return True
120
        def end_struct(self, struct, name):
121
            print ('end structure type', libtcod.struct_get_name(struct), \
122
                  ' named ', name)
123
            return True
124
        def error(self,msg):
125
            print ('error : ', msg)
126
            return True
127
    libtcod.parser_run(parser, os.path.join(b'data',b'cfg',b'sample.cfg'), MyListener())
128
#############################################
129
# end of parser unit test

tests/test_parser.py 1 location

@@ 76-99 (lines=24) @@
73
74
    # custom listener
75
    print ('***** Custom listener *****')
76
    class MyListener:
77
        def new_struct(self, struct, name):
78
            print ('new structure type', libtcod.struct_get_name(struct), \
79
                  ' named ', name )
80
            return True
81
        def new_flag(self, name):
82
            print ('new flag named ', name)
83
            return True
84
        def new_property(self,name, typ, value):
85
            type_names = ['NONE', 'BOOL', 'CHAR', 'INT', 'FLOAT', 'STRING', \
86
                          'COLOR', 'DICE']
87
            type_name = type_names[typ & 0xff]
88
            if typ & libtcod.TYPE_LIST:
89
                type_name = 'LIST<%s>' % type_name
90
            print ('new property named ', name,' type ',type_name, \
91
                      ' value ', value)
92
            return True
93
        def end_struct(self, struct, name):
94
            print ('end structure type', libtcod.struct_get_name(struct), \
95
                  ' named ', name)
96
            return True
97
        def error(self,msg):
98
            print ('error : ', msg)
99
            return True
100
    libtcod.parser_run(parser, os.path.join('libtcod','data','cfg','sample.cfg'), MyListener())
101
102
if __name__ == '__main__':