Code Duplication    Length = 14-14 lines in 2 locations

tcod/libtcodpy.py 2 locations

@@ 1029-1042 (lines=14) @@
1026
    """
1027
    if len(r) != len(g) or len(r) != len(b):
1028
        raise TypeError('R, G and B must all have the same size.')
1029
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
1030
        isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)):
1031
        #numpy arrays, use numpy's ctypes functions
1032
        r = _numpy.ascontiguousarray(r, dtype=_numpy.intc)
1033
        g = _numpy.ascontiguousarray(g, dtype=_numpy.intc)
1034
        b = _numpy.ascontiguousarray(b, dtype=_numpy.intc)
1035
        cr = ffi.cast('int *', r.ctypes.data)
1036
        cg = ffi.cast('int *', g.ctypes.data)
1037
        cb = ffi.cast('int *', b.ctypes.data)
1038
    else:
1039
        # otherwise convert using ffi arrays
1040
        cr = ffi.new('int[]', r)
1041
        cg = ffi.new('int[]', g)
1042
        cb = ffi.new('int[]', b)
1043
1044
    lib.TCOD_console_fill_background(_cdata(con), cr, cg, cb)
1045
@@ 1001-1014 (lines=14) @@
998
    """
999
    if len(r) != len(g) or len(r) != len(b):
1000
        raise TypeError('R, G and B must all have the same size.')
1001
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
1002
        isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)):
1003
        #numpy arrays, use numpy's ctypes functions
1004
        r = _numpy.ascontiguousarray(r, dtype=_numpy.intc)
1005
        g = _numpy.ascontiguousarray(g, dtype=_numpy.intc)
1006
        b = _numpy.ascontiguousarray(b, dtype=_numpy.intc)
1007
        cr = ffi.cast('int *', r.ctypes.data)
1008
        cg = ffi.cast('int *', g.ctypes.data)
1009
        cb = ffi.cast('int *', b.ctypes.data)
1010
    else:
1011
        # otherwise convert using ffi arrays
1012
        cr = ffi.new('int[]', r)
1013
        cg = ffi.new('int[]', g)
1014
        cb = ffi.new('int[]', b)
1015
1016
    lib.TCOD_console_fill_foreground(_cdata(con), cr, cg, cb)
1017