• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(760)  |  Call(739)  |  Derive(0)  |  Import(21)
Unpack the buffer, containing packed C structure data, according to
fmt, starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt).

src/p/e/pendrell-0.3.3/lib/decoders.py   pendrell(Download)
from codecs import getincrementaldecoder as _getincrementaldecoder
from struct import calcsize, unpack, unpack_from, error as UnpackError
import gzip, zlib
 
from twisted.python import log, urlpath, util
 
from pendrell import log
    def _decodeHeaderPreamble(buffer):
        fmt = ">HBBIBB"
        bytes = calcsize(fmt)
        preamble = unpack_from(fmt, buffer, 0)
        return preamble, bytes
 
 
    @staticmethod
    def _decodeHeaderExtra(buffer):
        # Read & discard the extra field, if present
        # xlen is stored little-endian
        bytes = 0
        xlen = unpack_from(">H", buffer, extraLen)
    def _decodeHeaderExtra(buffer):
        # Read & discard the extra field, if present
        # xlen is stored little-endian
        bytes = 0
        xlen = unpack_from(">H", buffer, extraLen)
        bytes += 2
        extra = unpack_from("%ds" % xlen, buffer, extraLen)
    def _decodeHeaderStringy(buffer):
        EOS = "\000"
        stringy = str()
        length = 0
        char = None
        while char != EOS:
            char = unpack_from("c", buffer, length)

src/p/y/pypy3-HEAD/pypy/lib/array.py   pypy3(Download)
array(typecode [, initializer]) -- create a new array
"""
 
from struct import calcsize, pack, pack_into, unpack_from
import operator
 
# the buffer-like object to use internally: trying from
    def tolist(self):
        """Convert array to an ordinary list with the same items."""
        count = len(self._data) // self.itemsize
        return list(unpack_from('%d%s' % (count, self.typecode), self._data))
 
    def tostring(self):
        return self._data[:]
        if not (0 <= i < seqlength):
            raise IndexError(i)
        boundary = i * self.itemsize
        result = unpack_from(self.typecode, self._data, boundary)[0]
        newdata = bytebuffer(len(self._data) - self.itemsize)
        newdata[:boundary] = self._data[:boundary]
        newdata[boundary:] = self._data[boundary+self.itemsize:]
            if not (0 <= i < seqlength):
                raise IndexError(i)
            boundary = i * self.itemsize
            return unpack_from(self.typecode, self._data, boundary)[0]
 
    def __getslice__(self, i, j):
        return self.__getitem__(slice(i, j))
    def __iter__(self):
        p = 0
        typecode = self.typecode
        itemsize = self.itemsize
        while p < len(self._data):
            yield unpack_from(typecode, self._data, p)[0]
            p += itemsize

src/p/y/pypy-HEAD/lib_pypy/array.py   pypy(Download)
array(typecode [, initializer]) -- create a new array
"""
 
from struct import calcsize, pack, pack_into, unpack_from
import operator
 
# the buffer-like object to use internally: trying from
    def tolist(self):
        """Convert array to an ordinary list with the same items."""
        count = len(self._data) // self.itemsize
        return list(unpack_from('%d%s' % (count, self.typecode), self._data))
 
    def tostring(self):
        return self._data[:]
        if not (0 <= i < seqlength):
            raise IndexError(i)
        boundary = i * self.itemsize
        result = unpack_from(self.typecode, self._data, boundary)[0]
        newdata = bytebuffer(len(self._data) - self.itemsize)
        newdata[:boundary] = self._data[:boundary]
        newdata[boundary:] = self._data[boundary+self.itemsize:]
            if not (0 <= i < seqlength):
                raise IndexError(i)
            boundary = i * self.itemsize
            return unpack_from(self.typecode, self._data, boundary)[0]
 
    def __getslice__(self, i, j):
        return self.__getitem__(slice(i, j))
    def __iter__(self):
        p = 0
        typecode = self.typecode
        itemsize = self.itemsize
        while p < len(self._data):
            yield unpack_from(typecode, self._data, p)[0]
            p += itemsize

src/g/r/grotesque-HEAD/grotesque/trunk/src/treaty_of_babel/blorb.py   grotesque(Download)
from struct import unpack_from
 
class Blorb:
    def __init__(self, data):
        self.data = data
        if len(self.data) < 16 or not self.data.startswith('FORM') \
                or not self.data[8:12] == 'IFRS':
            raise Exception('Not a BLORB.')
 
    def get_chunk(self, id):
        i = 12
        while i < len(self.data) - 8:
            length = unpack_from('>I', self.data, i + 4)[0]
    def get_resource(self, resource, n):
        index = self.get_chunk('RIdx')
        number_resources = unpack_from('>I', index)[0]
        i = 0
        while (i < number_resources):
            if index[4 + i * 12:8 + i * 12] == resource \
                    and unpack_from('>I', index, 8 + i * 12)[0] == n:
                rsc_start = unpack_from('>I', index, 12 + i * 12)[0]
                rsc_length = unpack_from('>I', self.data, rsc_start + 4)[0]
    def get_resources(self):
        index = self.get_chunk('RIdx')
        number_resources = unpack_from('>I', index)[0]
        result = []
 
        for i in xrange(0, number_resources):
            rsc_name = index[4 + i * 12:8 + i * 12]
            rsc_number = unpack_from('>I', index, 8 + i * 12)[0]

src/w/a/warpwing-HEAD/releases/warpwing1.1.0/software/lib/motetalk.py   warpwing(Download)
  pass
 
import serial
from struct import calcsize, unpack_from
import sys
import time
import ginacmd
        if parse and (len(pkg) >= calcsize(self.fmt)): # 3 stars => write package in file
          self.last = pkg
          self.ts = t
          self.arr = list(unpack_from(self.fmt, pkg))
          return self.arr, t
        elif parse:
          return None, t

src/w/a/warpwing-HEAD/releases/warpwing1.1.0-src/software/lib/motetalk.py   warpwing(Download)
  pass
 
import serial
from struct import calcsize, unpack_from
import sys
import time
import ginacmd
        if parse and (len(pkg) >= calcsize(self.fmt)): # 3 stars => write package in file
          self.last = pkg
          self.ts = t
          self.arr = list(unpack_from(self.fmt, pkg))
          return self.arr, t
        elif parse:
          return None, t

src/w/a/warpwing-HEAD/releases/warpwing1.0.0/software/lib/motetalk.py   warpwing(Download)
  pass
 
import serial
from struct import calcsize, unpack_from
import sys
import time
import ginacmd
        if parse and (len(pkg) >= calcsize(self.fmt)): # 3 stars => write package in file
          self.last = pkg
          self.ts = t
          self.arr = list(unpack_from(self.fmt, pkg))
          return self.arr, t
        elif parse:
          return None, t

src/w/a/warpwing-HEAD/releases/warpwing1.0.0-src/software/lib/motetalk.py   warpwing(Download)
  pass
 
import serial
from struct import calcsize, unpack_from
import sys
import time
import ginacmd
        if parse and (len(pkg) >= calcsize(self.fmt)): # 3 stars => write package in file
          self.last = pkg
          self.ts = t
          self.arr = list(unpack_from(self.fmt, pkg))
          return self.arr, t
        elif parse:
          return None, t

src/w/a/warpwing-HEAD/gina2.2c/software/lib/motetalk.py   warpwing(Download)
  pass
 
import serial
from struct import calcsize, unpack_from
import sys
import time
import ginacmd
        if parse and (len(pkg) >= calcsize(self.fmt)): # 3 stars => write package in file
          self.last = pkg
          self.ts = t
          self.arr = list(unpack_from(self.fmt, pkg))
          return self.arr, t, crc(map(ord,pkg[:-5]))
        elif parse:
          return None, t, 0

src/w/a/warpwing-HEAD/gina2.1/software/lib/motetalk.py   warpwing(Download)
  pass
 
import serial
from struct import calcsize, unpack_from
import sys
import time
import ginacmd
        if parse and (len(pkg) >= calcsize(self.fmt)): # 3 stars => write package in file
          self.last = pkg
          self.ts = t
          self.arr = list(unpack_from(self.fmt, pkg))
          return self.arr, t, crc(map(ord,pkg[:-5]))
        elif parse:
          return None, t, 0

  1 | 2 | 3  Next