Commits

Anonymous committed 298f674

Fix trailing spaces, tabs to spaces, add docstrings, remove useless brackets.

  • Participants
  • Parent commits bd5aa0f

Comments (0)

Files changed (1)

File dbfpy/dbfpy/binnum.py

-'''\
-functions for binary encoding/decoding of numeric values
+"""Functions for binary encoding/decoding of numeric values
 mocons.lib.utils.binnum.py
-jjk  02/03/98  001  from mdcutil.py
-jjk  02/13/98  002  add unsigned 2,4 from Intel
-jjk  02/19/98  003  add unsigned as Intel 2,4 
-jjk  11/15/99  004  documentation updates
+"""
+
+"""History (most recent first):
+06-jun-2005 [easy]  Fix trailing spaces, tabs to spaces,
+                    add docstrings, remove useless brackets;
+15-nov-1999 [jjk]   Documentation updates
+19-feb-1998 [jjk]   Add unsigned as Intel 2,4
+13-feb-1998 [jjk]   Add unsigned 2,4 from Inter
+03-feb-1998 [jjk]   From mdcutil.py
 
 Equivalent built-in python functions may be available.
 If so, I wrote these before they were available, or
 *** !! NO WARRANTIES WHATSOEVER !! ***
 
 Jeff Kunce <kuncej@mail.conservation.state.mo.us>
-'''
+"""
+
+__version__ = "$Revision$"[11:-2]
+__date__ = "$Date$"[7:-2]
+
 
 def integers_from_char1(int_string):
-	# return list of integers decoded from 1-byte-format string
-	# jjk  12/08/95
-        lst = []
-	pos = 0
-	while (pos < len(int_string)):
-		lst.append(integer_from_char1(int_string[pos]))
-		pos = pos + 1
-	return(lst)
+    """Return list of integers decoded from 1-byte-format string
+
+    jjk  12/08/95
+    """
+    lst = []
+    pos = 0
+    while (pos < len(int_string)):
+        lst.append(integer_from_char1(int_string[pos]))
+        pos = pos + 1
+    return lst
 
 def integer_from_char1(int_string):
-	# return first integer decoded from 1-byte-format string
-	# jjk  12/08/95
-	return(ord(int_string))
+    """Return first integer decoded from 1-byte-format string
+
+    jjk  12/08/95
+    """
+    return ord(int_string)
 
 def integers_from_Intel2(int_string):
-	# return list of integers decoded from 2-byte-intel-format string
-	# jjk  12/08/95
-        lst = []
-	pos = 2
-	while (pos <= len(int_string)):
-		lst.append(integer_from_Intel2(int_string[pos-2:pos]))
-		pos = pos + 2
-	return(lst)
+    """Return list of integers decoded from 2-byte-intel-format string
+
+    jjk  12/08/95
+    """
+    lst = []
+    pos = 2
+    while (pos <= len(int_string)):
+        lst.append(integer_from_Intel2(int_string[pos-2:pos]))
+        pos = pos + 2
+    return lst
 
 def integer_from_Intel(int_string):
-	# return signed integer decoded from n-byte-intel-format string
-	# jjk  04/25/96  handles negative #'s
-		value = 0
-		isNegative = 0
-		if (len(int_string) > 0):
-			bytes = map(ord,int_string)
-			bytes.reverse()
-			if (bytes[0] >= 0x80):
-				isNegative = 1
-				bytes[0] = bytes[0] - 0x80
-			for byte in bytes:
-				value = (value * 256) + byte
-		if isNegative:
-			value = -value
-		return value
+    """Return signed integer decoded from n-byte-intel-format string
+
+    jjk  04/25/96  handles negative #'s
+    """
+    value = 0
+    isNegative = 0
+    if (len(int_string) > 0):
+        bytes = map(ord,int_string)
+        bytes.reverse()
+        if (bytes[0] >= 0x80):
+            isNegative = 1
+            bytes[0] = bytes[0] - 0x80
+        for byte in bytes:
+            value = (value * 256) + byte
+    if isNegative:
+        value = -value
+    return value
 
 def integer_from_Intel2(int_string):
-	# return first integer decoded from 2-byte-intel-format string
-	# jjk  04/25/96  
-		return integer_from_Intel(int_string[:2])
+    """Return first integer decoded from 2-byte-intel-format string
+
+    jjk  04/25/96
+    """
+    return integer_from_Intel(int_string[:2])
 
 def integers_from_Intel4(int_string):
-	# return list of integers decoded from 4-byte-intel-format string
-	# jjk  01/11/96
-		lst = []
-		pos = 0
-		while (pos <= len(int_string)):
-			lst.append(integer_from_Intel4(int_string[pos:(pos+4)]))
-			pos = pos + 4
-		return(lst)
+    """Return list of integers decoded from 4-byte-intel-format string
+
+    jjk  01/11/96
+    """
+    lst = []
+    pos = 0
+    while (pos <= len(int_string)):
+        lst.append(integer_from_Intel4(int_string[pos:(pos+4)]))
+        pos = pos + 4
+    return lst
 
 def integer_from_Intel4(int_string):
-	# return first integer decoded from 4-byte-intel-format string
-	# jjk  04/25/96
-		return integer_from_Intel(int_string[:4])
+    """Return first integer decoded from 4-byte-intel-format string
+
+    jjk  04/25/96
+    """
+    return integer_from_Intel(int_string[:4])
 
 def unsigned_from_Intel2(int_string):
-	'''return unsigned signed integer decoded from 2-byte-intel-format string
-	jjk 11/05/97  from mdcutil.py'''
-	return ord(int_string[0]) + (256 * ord(int_string[1]))
+    """Return unsigned signed integer decoded from 2-byte-intel-format string
+
+    jjk 11/05/97  from mdcutil.py
+    """
+    return ord(int_string[0]) + (256 * ord(int_string[1]))
 
 def unsigned_from_Intel4(int_string):
-	'''return unsigned signed integer decoded from 2-byte-intel-format string
-	jjk 11/05/97  from mdcutil.py'''
-	return (unsigned_from_Intel2(int_string[:2]) + 
-		(65536 * unsigned_from_Intel2(int_string[2:])))
+    """Return unsigned signed integer decoded from 2-byte-intel-format string
+
+    jjk 11/05/97  from mdcutil.py
+    """
+    return unsigned_from_Intel2(int_string[:2]) + \
+        (65536 * unsigned_from_Intel2(int_string[2:]))
 
 def unsigned_as_Intel2(uint):
-	'''return 2-byte-intel-format string encoded from unsigned signed integer 
-	jjk  02/19/98'''
-	encInt = int(abs(uint))	#enforce unsingned integer
-	hiByte = encInt/256
-	loByte = encInt%256
-	return(chr(loByte)+chr(hiByte))
+    """Return 2-byte-intel-format string encoded from unsigned signed integer
+
+    jjk  02/19/98
+    """
+    encInt = int(abs(uint)) #enforce unsingned integer
+    hiByte = encInt/256
+    loByte = encInt%256
+    return chr(loByte) + chr(hiByte)
 
 def unsigned_as_Intel4(uint):
-	'''return 4-byte-intel-format string encoded from unsigned signed integer 
-	jjk  02/19/98'''
-	encInt = int(abs(uint))	#enforce unsingned integer
-	hiWord = encInt/65536
-	loWord = encInt%65536
-	return(unsigned_as_Intel2(loWord)+unsigned_as_Intel2(hiWord))
+    """Return 4-byte-intel-format string encoded from unsigned signed integer
+
+    jjk  02/19/98
+    """
+    encInt = int(abs(uint)) #enforce unsingned integer
+    hiWord = encInt/65536
+    loWord = encInt%65536
+    return unsigned_as_Intel2(loWord) + unsigned_as_Intel2(hiWord)
+
+# vim: set sts=4 sw=4 et :