Code Duplication    Length = 24-24 lines in 2 locations

examples/samples_py.py 1 location

@@ 103-126 (lines=24) @@
100
        sample_console.ch[:] = np.random.randint(
101
            low=ord('a'), high=ord('z') + 1,
102
            size=sample_console.ch.size,
103
            dtype=np.intc,
104
            ).reshape(sample_console.ch.shape)
105
106
    def print_banner(self):
107
        # print text on top of samples
108
        sample_console.default_bg = libtcod.grey
109
        sample_console.print_rect(
110
            x=sample_console.width // 2, y=5,
111
            width=sample_console.width - 2, height=sample_console.height - 1,
112
            string="The Doryen library uses 24 bits colors, for both "
113
                   "background and foreground.",
114
            bg_blend=libtcod.BKGND_MULTIPLY, alignment=libtcod.CENTER,
115
            )
116
117
#############################################
118
# offscreen console sample
119
#############################################
120
121
class OffscreenConsoleSample(Sample):
122
123
    def __init__(self):
124
        self.name = 'Offscreen console'
125
        self.secondary = libtcod.console.Console(sample_console.width // 2,
126
                                                 sample_console.height // 2)
127
        self.screenshot = libtcod.console.Console(sample_console.width,
128
                                                  sample_console.height)
129
        self.counter = 0

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__':