Logo SoCRocket

Transaction-Level Modeling Framework for Space Applications

Functions | Variables
usi.tools.hex Namespace Reference

Functions

def chunks
 
def chunkread
 
def genchunks
 
def dehex
 
def dump
 
def dumpgen
 
def dumps
 
def hexloads
 

Variables

string __version__ = '3.1'
 
string __author__ = 'anatoly techtonik <techtonik@gmail.com>'
 
string __license__ = 'Public Domain'
 
string __url__ = 'https://bitbucket.org/techtonik/hexdump/'
 
tuple PY3K = (3, 0)
 
tuple parser
 

Function Documentation

def usi.tools.hex.chunkread (   f,
  size 
)
Generator that reads from file like object. May return less
   data than requested on the last read.

Referenced by usi.tools.hex.genchunks().

def usi.tools.hex.chunks (   seq,
  size 
)
Generator that cuts sequence (bytes, memoryview, etc.)
   into chunks of given size. If `seq` length is not multiply
   of `size`, the lengh of the last chunk returned will be
   less than requested.

   >>> list( chunks([1,2,3,4,5,6,7], 3) )
   [[1, 2, 3], [4, 5, 6], [7]]

Referenced by usi.tools.hex.genchunks().

def usi.tools.hex.dehex (   hextext)
Convert from hex string to binary data stripping
whitespaces from `hextext` if necessary.

Referenced by usi.tools.hex.hexloads().

def usi.tools.hex.dump (   data,
  binary = False 
)
Convert binary data (bytes in Python 3 and str in
Python 2) to hex string like '00 DE AD BE EF'.

Referenced by usi.tools.hex.dumpgen().

def usi.tools.hex.dumpgen (   data,
  binary = False 
)
Generator that produces strings:

'00000000: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................'

References usi.tools.hex.dump(), and usi.tools.hex.genchunks().

Referenced by usi.tools.hex.dumps().

Here is the call graph for this function:

def usi.tools.hex.dumps (   data,
  result = 'print',
  binary = False 
)
Transform binary data to the hex dump text format:

00000000: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................

  [x] data argument as a binary string
  [x] data argument as a file like object

Returns result depending on the `result` argument:
  'print'     - prints line by line
  'return'    - returns single string
  'generator' - returns generator that produces lines

References usi.tools.hex.dumpgen().

Here is the call graph for this function:

def usi.tools.hex.genchunks (   mixed,
  size 
)
Generator to chunk binary sequences or file like objects.
   The size of the last chunk returned may be less than
   requested.

References usi.tools.hex.chunkread(), and usi.tools.hex.chunks().

Referenced by usi.tools.hex.dumpgen().

Here is the call graph for this function:

def usi.tools.hex.hexloads (   dump)
Restore binary data from a hex dump.
  [x] dump argument as a string
  [ ] dump argument as a line iterator

Supported formats:
  [x] hexdump.hexdump
  [x] Scapy
  [x] Far Manager

References usi.tools.hex.dehex().

Here is the call graph for this function:

Variable Documentation

string usi.tools.hex.__author__ = 'anatoly techtonik <techtonik@gmail.com>'
string usi.tools.hex.__license__ = 'Public Domain'
string usi.tools.hex.__url__ = 'https://bitbucket.org/techtonik/hexdump/'
string usi.tools.hex.__version__ = '3.1'
tuple usi.tools.hex.parser
Initial value:
1 = OptionParser(usage='''
2  %prog binfile
3  %prog -b binfile
4  %prog -r hexfile''', version=__version__)
tuple usi.tools.hex.PY3K = (3, 0)