Esempio n. 1
0
 def write_normal(self, v):
     self.fh.write(asunicode(v))
Esempio n. 2
0
    ),
    ("color", "S2"),
    ("info", [("Name", "U8"), ("Value", "c16")]),
    ("y", "f8", (2, 2)),
    ("z", "u1"),
]

NbufferT = [
    # x     Info                                                color info        y                  z
    #       value y2 Info2                            name z2         Name Value
    #                name   value    y3       z3
    (
        [3, 2],
        (6j, 6.0, (asbytes("nn"), [6j, 4j], [6.0, 4.0], [1, 2]), asbytes("NN"), True),
        asbytes("cc"),
        (asunicode("NN"), 6j),
        [[6.0, 4.0], [6.0, 4.0]],
        8,
    ),
    (
        [4, 3],
        (7j, 7.0, (asbytes("oo"), [7j, 5j], [7.0, 5.0], [2, 1]), asbytes("OO"), False),
        asbytes("dd"),
        (asunicode("OO"), 7j),
        [[7.0, 5.0], [7.0, 5.0]],
        9,
    ),
]


byteorder = {"little": "<", "big": ">"}[sys.byteorder]
Esempio n. 3
0
            ('y3', 'f8', (2,)),
            ('z3', 'u4', (2,))]),
        ('name', 'S2'),
        ('z2', 'b1')]),
    ('color', 'S2'),
    ('info', [
        ('Name', 'U8'),
        ('Value', 'c16')]),
    ('y', 'f8', (2, 2)),
    ('z', 'u1')]

NbufferT = [
    # x     Info                                                color info        y                  z
    #       value y2 Info2                            name z2         Name Value
    #                name   value    y3       z3
    ([3,2], (6j, 6., (asbytes('nn'), [6j,4j], [6.,4.], [1,2]), asbytes('NN'), True), asbytes('cc'), (asunicode('NN'), 6j), [[6.,4.],[6.,4.]], 8),
    ([4,3], (7j, 7., (asbytes('oo'), [7j,5j], [7.,5.], [2,1]), asbytes('OO'), False), asbytes('dd'), (asunicode('OO'), 7j), [[7.,5.],[7.,5.]], 9),
    ]


byteorder = {'little':'<', 'big':'>'}[sys.byteorder]

def normalize_descr(descr):
    "Normalize a description adding the platform byteorder."

    out = []
    for item in descr:
        dtype = item[1]
        if isinstance(dtype, str):
            if dtype[0] not in ['|','<','>']:
                onebyte = dtype[1:] == "1"
Esempio n. 4
0
# The corresponding nested array description:
Ndescr = [('x', 'i4', (2, )),
          ('Info', [('value', 'c16'), ('y2', 'f8'),
                    ('Info2', [('name', 'S2'), ('value', 'c16', (2, )),
                               ('y3', 'f8', (2, )), ('z3', 'u4', (2, ))]),
                    ('name', 'S2'), ('z2', 'b1')]), ('color', 'S2'),
          ('info', [('Name', 'U8'), ('Value', 'c16')]), ('y', 'f8', (2, 2)),
          ('z', 'u1')]

NbufferT = [
    # x     Info                                                color info        y                  z
    #       value y2 Info2                            name z2         Name Value
    #                name   value    y3       z3
    ([3,
      2], (6j, 6., (asbytes('nn'), [6j, 4j], [6., 4.], [1, 2]), asbytes('NN'),
           True), asbytes('cc'), (asunicode('NN'), 6j), [[6., 4.], [6.,
                                                                    4.]], 8),
    ([4,
      3], (7j, 7., (asbytes('oo'), [7j, 5j], [7., 5.], [2, 1]), asbytes('OO'),
           False), asbytes('dd'), (asunicode('OO'), 7j), [[7., 5.], [7.,
                                                                     5.]], 9),
]

byteorder = {'little': '<', 'big': '>'}[sys.byteorder]


def normalize_descr(descr):
    "Normalize a description adding the platform byteorder."

    out = []
    for item in descr:
            ('y3', 'f8', (2,)),
            ('z3', 'u4', (2,))]),
        ('name', 'S2'),
        ('z2', 'b1')]),
    ('color', 'S2'),
    ('info', [
        ('Name', 'U8'),
        ('Value', 'c16')]),
    ('y', 'f8', (2, 2)),
    ('z', 'u1')]

NbufferT = [
    # x     Info                                                color info        y                  z
    #       value y2 Info2                            name z2         Name Value
    #                name   value    y3       z3
    ([3, 2], (6j, 6., (asbytes('nn'), [6j, 4j], [6., 4.], [1, 2]), asbytes('NN'), True), asbytes('cc'), (asunicode('NN'), 6j), [[6., 4.], [6., 4.]], 8),
    ([4, 3], (7j, 7., (asbytes('oo'), [7j, 5j], [7., 5.], [2, 1]), asbytes('OO'), False), asbytes('dd'), (asunicode('OO'), 7j), [[7., 5.], [7., 5.]], 9),
    ]


byteorder = {'little':'<', 'big':'>'}[sys.byteorder]

def normalize_descr(descr):
    "Normalize a description adding the platform byteorder."

    out = []
    for item in descr:
        dtype = item[1]
        if isinstance(dtype, str):
            if dtype[0] not in ['|', '<', '>']:
                onebyte = dtype[1:] == "1"
Esempio n. 6
0
            ('z3', 'u4', (2,))]),
        ('name', 'S2'),
        ('z2', 'b1')]),
    ('color', 'S2'),
    ('info', [
        ('Name', 'U8'),
        ('Value', 'c16')]),
    ('y', 'f8', (2, 2)),
    ('z', 'u1')]

NbufferT = [
    # x     Info                                                color info        y                  z
    #       value y2 Info2                            name z2         Name Value
    #                name   value    y3       z3
    ([3, 2], (6j, 6., (asbytes('nn'), [6j, 4j], [6., 4.], [1, 2]), asbytes('NN'), True), asbytes('cc'),
     (asunicode('NN'), 6j), [[6., 4.], [6., 4.]], 8),
    ([4, 3], (7j, 7., (asbytes('oo'), [7j, 5j], [7., 5.], [2, 1]), asbytes('OO'), False), asbytes('dd'),
     (asunicode('OO'), 7j), [[7., 5.], [7., 5.]], 9),
]

byteorder = {'little': '<', 'big': '>'}[sys.byteorder]


def normalize_descr(descr):
    "Normalize a description adding the platform byteorder."

    out = []
    for item in descr:
        dtype = item[1]
        if isinstance(dtype, str):
            if dtype[0] not in ['|', '<', '>']: