Beispiel #1
0
 def __call__(self, name, endian='!'):
     factory = array_factory(Integer)
     return factory(name, self.sign, self.length, endian)
Beispiel #2
0
 def __call__(self, name, endian='!'):
     factory = array_factory(Float)
     return factory(name, self.length, endian)
Beispiel #3
0
    .. todo:: examples
    """

    def __init__(self, length):
        if length != 4 and length != 8:
            raise ValueError("Floats can only have length 4 or 8")
        else: NumberFactory.__init__(self, True, length)

    def __call__(self, name, endian='!'):
        factory = array_factory(Float)
        return factory(name, self.length, endian)


for i in [1, 2, 4, 8]:
    # auto-generate shorthand factory's and inject into module namespace
    locals()['uint%d' % (i * 8)] = IntegerFactory(False, i)
    locals()['int%d' % (i * 8)] = IntegerFactory(True, i)

single = FloatFactory(4)
double = FloatFactory(8)

Bytes = String

Struct = array_factory(Struct)

try:
    from striptease.bitstring import Bitfield
except ImportError:
    pass # Ignore