lists.arthurdejong.org
RSS feed

python-stdnum commit: r82 - python-stdnum/stdnum

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum commit: r82 - python-stdnum/stdnum



Author: arthur
Date: Fri Sep 23 20:29:11 2011
New Revision: 82
URL: http://arthurdejong.org/viewvc/python-stdnum?revision=82&view=revision

Log:
implement a imei.split() function that splits the number into a TAC, serian 
number and checksum or software version

Modified:
   python-stdnum/stdnum/imei.py

Modified: python-stdnum/stdnum/imei.py
==============================================================================
--- python-stdnum/stdnum/imei.py        Fri Sep 23 16:52:31 2011        (r81)
+++ python-stdnum/stdnum/imei.py        Fri Sep 23 20:29:11 2011        (r82)
@@ -33,6 +33,8 @@
 '35-686800-004141-8'
 >>> imei_type('35686800-004141-20')
 'IMEISV'
+>>> split('35686800-004141')
+('35686800', '004141', '')
 """
 
 
@@ -66,6 +68,14 @@
     return imei_type(number) is not None
 
 
+def split(number):
+    """Split the number into a Type Allocation Code (TAC), serial number
+    and either the checksum (for IMEI) or the software version number (for
+    IMEISV)."""
+    number = compact(number)
+    return (number[:8], number[8:14], number[14:])
+
+
 def format(number, separator='-', add_check_digit=False):
     """Reformat the passed number to the standard format."""
     number = compact(number)
-- 
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/python-stdnum-commits/