├── INSTALL ├── ISO8583 ├── ISO8583.py ├── ISOErrors.py └── __init__.py ├── LICENCE ├── MANIFEST ├── MANIFEST.in ├── README ├── TODO ├── doc ├── ISO8583.ISO8583.html ├── ISO8583.ISOErrors.html └── ISO8583.html ├── examples ├── echoClient.py ├── echoServer.py ├── example1.py ├── example2.py ├── example3.py └── example4.py └── setup.py /INSTALL: -------------------------------------------------------------------------------- 1 | (C) Copyright 2009 Igor V. Custodio 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program. If not, see . 15 | 16 | ======================================================================== 17 | 18 | To install is very simple: 19 | 20 | 1) Download the package 21 | 2) Un-compress it 22 | 3) Go to the folder where setup.py is 23 | 4) Build the package with the command: "python setup.py build" 24 | 5) Install with the command: "python setup.py install" 25 | 6) That's it! 26 | 7) Enjoy, read, learn the examples in the "examples" directory. 27 | 28 | 29 | ======================================================================== 30 | 31 | If you need more information about how to build a package, read 32 | http://docs.python.org/distutils/sourcedist.html 33 | -------------------------------------------------------------------------------- /ISO8583/ISO8583.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ 19 | 20 | __author__ = 'Igor Vitorio Custodio ' 21 | __version__ = '1.3.1' 22 | __licence__ = 'GPL V3' 23 | 24 | from ISOErrors import * 25 | import struct 26 | 27 | 28 | class ISO8583: 29 | """Main Class to work with ISO8583 packages. 30 | Used to create, change, send, receive, parse or work with ISO8593 Package version 1993. 31 | It's 100% Python :) 32 | Enjoy it! 33 | Thanks to: Vulcanno IT Solutions 34 | Licence: GPL Version 3 35 | More information: http://code.google.com/p/iso8583py/ 36 | 37 | Example: 38 | from ISO8583.ISO8583 import ISO8583 39 | from ISO8583.ISOErrors import * 40 | 41 | iso = ISO8583() 42 | try: 43 | iso.setMTI('0800') 44 | iso.setBit(2,2) 45 | iso.setBit(4,4) 46 | iso.setBit(12,12) 47 | iso.setBit(21,21) 48 | iso.setBit(17,17) 49 | iso.setBit(49,986) 50 | iso.setBit(99,99) 51 | except ValueToLarge, e: 52 | print ('Value too large :( %s' % e) 53 | except InvalidMTI, i: 54 | print ('This MTI is wrong :( %s' % i) 55 | 56 | print ('The Message Type Indication is = %s' %iso.getMTI()) 57 | 58 | print ('The Bitmap is = %s' %iso.getBitmap()) 59 | iso.showIsoBits(); 60 | print ('This is the ISO8583 complete package %s' % iso.getRawIso()) 61 | print ('This is the ISO8583 complete package to sent over the TCPIP network %s' % iso.getNetworkISO()) 62 | 63 | """ 64 | # Attributes 65 | # Bitsto be set 00000000 -> _BIT_POSITION_1 ... _BIT_POSITION_8 66 | _BIT_POSITION_1 = 128 # 10 00 00 00 67 | _BIT_POSITION_2 = 64 # 01 00 00 00 68 | _BIT_POSITION_3 = 32 # 00 10 00 00 69 | _BIT_POSITION_4 = 16 # 00 01 00 00 70 | _BIT_POSITION_5 = 8 # 00 00 10 00 71 | _BIT_POSITION_6 = 4 # 00 00 01 00 72 | _BIT_POSITION_7 = 2 # 00 00 00 10 73 | _BIT_POSITION_8 = 1 # 00 00 00 01 74 | 75 | # Array to translate bit to position 76 | _TMP = [0, _BIT_POSITION_8, _BIT_POSITION_1, _BIT_POSITION_2, _BIT_POSITION_3, _BIT_POSITION_4, _BIT_POSITION_5, 77 | _BIT_POSITION_6, _BIT_POSITION_7] 78 | _BIT_DEFAULT_VALUE = 0 79 | 80 | # ISO8583 contants 81 | _BITS_VALUE_TYPE = {} 82 | # Every _BITS_VALUE_TYPE has: 83 | # _BITS_VALUE_TYPE[N] = [ X,Y, Z, W,K] 84 | # N = bitnumber 85 | # X = smallStr representation of the bit meanning 86 | # Y = large str representation 87 | # Z = type of the bit (B, N, A, AN, ANS, LL, LLL) 88 | # W = size of the information that N need to has 89 | # K = type os values a, an, n, ansb, b 90 | _BITS_VALUE_TYPE[1] = ['BME', 'Bit Map Extended', 'B', 16, 'b'] 91 | _BITS_VALUE_TYPE[2] = ['2', 'Primary account number (PAN)', 'LL', 19, 'n'] 92 | _BITS_VALUE_TYPE[3] = ['3', 'Precessing code', 'N', 6, 'n'] 93 | _BITS_VALUE_TYPE[4] = ['4', 'Amount transaction', 'N', 12, 'n'] 94 | _BITS_VALUE_TYPE[5] = ['5', 'Amount reconciliation', 'N', 12, 'n'] 95 | _BITS_VALUE_TYPE[6] = ['6', 'Amount cardholder billing', 'N', 12, 'n'] 96 | _BITS_VALUE_TYPE[7] = ['7', 'Date and time transmission', 'N', 10, 'n'] 97 | _BITS_VALUE_TYPE[8] = ['8', 'Amount cardholder billing fee', 'N', 8, 'n'] 98 | _BITS_VALUE_TYPE[9] = ['9', 'Conversion rate reconciliation', 'N', 8, 'n'] 99 | _BITS_VALUE_TYPE[10] = ['10', 'Conversion rate cardholder billing', 'N', 8, 'n'] 100 | _BITS_VALUE_TYPE[11] = ['11', 'Systems trace audit number', 'N', 6, 'n'] 101 | _BITS_VALUE_TYPE[12] = ['12', 'Date and time local transaction', 'N', 6, 'n'] 102 | _BITS_VALUE_TYPE[13] = ['13', 'Date effective', 'N', 4, 'n'] 103 | _BITS_VALUE_TYPE[14] = ['14', 'Date expiration', 'N', 4, 'n'] 104 | _BITS_VALUE_TYPE[15] = ['15', 'Date settlement', 'N', 4, 'n'] 105 | _BITS_VALUE_TYPE[16] = ['16', 'Date conversion', 'N', 4, 'n'] 106 | _BITS_VALUE_TYPE[17] = ['17', 'Date capture', 'N', 4, 'n'] 107 | _BITS_VALUE_TYPE[18] = ['18', 'Message error indicator', 'N', 4, 'n'] 108 | _BITS_VALUE_TYPE[19] = ['19', 'Country code acquiring institution', 'N', 3, 'n'] 109 | _BITS_VALUE_TYPE[20] = ['20', 'Country code primary account number (PAN)', 'N', 3, 'n'] 110 | _BITS_VALUE_TYPE[21] = ['21', 'Transaction life cycle identification data', 'ANS', 3, 'n'] 111 | _BITS_VALUE_TYPE[22] = ['22', 'Point of service data code', 'N', 3, 'n'] 112 | _BITS_VALUE_TYPE[23] = ['23', 'Card sequence number', 'N', 3, 'n'] 113 | _BITS_VALUE_TYPE[24] = ['24', 'Function code', 'N', 3, 'n'] 114 | _BITS_VALUE_TYPE[25] = ['25', 'Message reason code', 'N', 2, 'n'] 115 | _BITS_VALUE_TYPE[26] = ['26', 'Merchant category code', 'N', 2, 'n'] 116 | _BITS_VALUE_TYPE[27] = ['27', 'Point of service capability', 'N', 1, 'n'] 117 | _BITS_VALUE_TYPE[28] = ['28', 'Date reconciliation', 'N', 8, 'n'] 118 | _BITS_VALUE_TYPE[29] = ['29', 'Reconciliation indicator', 'N', 8, 'n'] 119 | _BITS_VALUE_TYPE[30] = ['30', 'Amounts original', 'N', 8, 'n'] 120 | _BITS_VALUE_TYPE[31] = ['31', 'Acquirer reference number', 'N', 8, 'n'] 121 | _BITS_VALUE_TYPE[32] = ['32', 'Acquiring institution identification code', 'LL', 11, 'n'] 122 | _BITS_VALUE_TYPE[33] = ['33', 'Forwarding institution identification code', 'LL', 11, 'n'] 123 | _BITS_VALUE_TYPE[34] = ['34', 'Electronic commerce data', 'LL', 28, 'n'] 124 | _BITS_VALUE_TYPE[35] = ['35', 'Track 2 data', 'LL', 37, 'n'] 125 | _BITS_VALUE_TYPE[36] = ['36', 'Track 3 data', 'LLL', 104, 'n'] 126 | _BITS_VALUE_TYPE[37] = ['37', 'Retrieval reference number', 'N', 12, 'an'] 127 | _BITS_VALUE_TYPE[38] = ['38', 'Approval code', 'N', 6, 'an'] 128 | _BITS_VALUE_TYPE[39] = ['39', 'Action code', 'A', 2, 'an'] 129 | _BITS_VALUE_TYPE[40] = ['40', 'Service code', 'N', 3, 'an'] 130 | _BITS_VALUE_TYPE[41] = ['41', 'Card acceptor terminal identification', 'N', 8, 'ans'] 131 | _BITS_VALUE_TYPE[42] = ['42', 'Card acceptor identification code', 'A', 15, 'ans'] 132 | _BITS_VALUE_TYPE[43] = ['43', 'Card acceptor name/location', 'A', 40, 'asn'] 133 | _BITS_VALUE_TYPE[44] = ['44', 'Additional response data', 'LL', 25, 'an'] 134 | _BITS_VALUE_TYPE[45] = ['45', 'Track 1 data', 'LL', 76, 'an'] 135 | _BITS_VALUE_TYPE[46] = ['46', 'Amounts fees', 'LLL', 999, 'an'] 136 | _BITS_VALUE_TYPE[47] = ['47', 'Additional data national', 'LLL', 999, 'an'] 137 | _BITS_VALUE_TYPE[48] = ['48', 'Additional data private', 'LLL', 999, 'an'] 138 | _BITS_VALUE_TYPE[49] = ['49', 'Verification data', 'A', 3, 'a'] 139 | _BITS_VALUE_TYPE[50] = ['50', 'Currency code, settlement', 'AN', 3, 'an'] 140 | _BITS_VALUE_TYPE[51] = ['51', 'Currency code, cardholder billing', 'A', 3, 'a'] 141 | _BITS_VALUE_TYPE[52] = ['52', 'Personal identification number (PIN) data', 'B', 16, 'b'] 142 | _BITS_VALUE_TYPE[53] = ['53', 'Security related control information', 'LL', 18, 'n'] 143 | _BITS_VALUE_TYPE[54] = ['54', 'Amounts additional', 'LLL', 120, 'an'] 144 | _BITS_VALUE_TYPE[55] = ['55', 'Integrated circuit card (ICC) system related data', 'LLL', 999, 'ans'] 145 | _BITS_VALUE_TYPE[56] = ['56', 'Original data elements', 'LLL', 999, 'ans'] 146 | _BITS_VALUE_TYPE[57] = ['57', 'Authorisation life cycle code', 'LLL', 999, 'ans'] 147 | _BITS_VALUE_TYPE[58] = ['58', 'Authorising agent institution identification code', 'LLL', 999, 'ans'] 148 | _BITS_VALUE_TYPE[59] = ['59', 'Transport data', 'LLL', 999, 'ans'] 149 | _BITS_VALUE_TYPE[60] = ['60', 'Reserved for national use', 'LL', 7, 'ans'] 150 | _BITS_VALUE_TYPE[61] = ['61', 'Reserved for national use', 'LLL', 999, 'ans'] 151 | _BITS_VALUE_TYPE[62] = ['62', 'Reserved for private use', 'LLL', 999, 'ans'] 152 | _BITS_VALUE_TYPE[63] = ['63', 'Reserved for private use', 'LLL', 999, 'ans'] 153 | _BITS_VALUE_TYPE[64] = ['64', 'Message authentication code (MAC) field', 'B', 16, 'b'] 154 | _BITS_VALUE_TYPE[65] = ['65', 'Bitmap tertiary', 'B', 16, 'b'] 155 | _BITS_VALUE_TYPE[66] = ['66', 'Settlement code', 'N', 1, 'n'] 156 | _BITS_VALUE_TYPE[67] = ['67', 'Extended payment data', 'N', 2, 'n'] 157 | _BITS_VALUE_TYPE[68] = ['68', 'Receiving institution country code', 'N', 3, 'n'] 158 | _BITS_VALUE_TYPE[69] = ['69', 'Settlement institution county code', 'N', 3, 'n'] 159 | _BITS_VALUE_TYPE[70] = ['70', 'Network management Information code', 'N', 3, 'n'] 160 | _BITS_VALUE_TYPE[71] = ['71', 'Message number', 'N', 4, 'n'] 161 | _BITS_VALUE_TYPE[72] = ['72', 'Data record', 'LLL', 999, 'ans'] 162 | _BITS_VALUE_TYPE[73] = ['73', 'Date action', 'N', 6, 'n'] 163 | _BITS_VALUE_TYPE[74] = ['74', 'Credits, number', 'N', 10, 'n'] 164 | _BITS_VALUE_TYPE[75] = ['75', 'Credits, reversal number', 'N', 10, 'n'] 165 | _BITS_VALUE_TYPE[76] = ['76', 'Debits, number', 'N', 10, 'n'] 166 | _BITS_VALUE_TYPE[77] = ['77', 'Debits, reversal number', 'N', 10, 'n'] 167 | _BITS_VALUE_TYPE[78] = ['78', 'Transfer number', 'N', 10, 'n'] 168 | _BITS_VALUE_TYPE[79] = ['79', 'Transfer, reversal number', 'N', 10, 'n'] 169 | _BITS_VALUE_TYPE[80] = ['80', 'Inquiries number', 'N', 10, 'n'] 170 | _BITS_VALUE_TYPE[81] = ['81', 'Authorizations, number', 'N', 10, 'n'] 171 | _BITS_VALUE_TYPE[82] = ['82', 'Credits, processing fee amount', 'N', 12, 'n'] 172 | _BITS_VALUE_TYPE[83] = ['83', 'Credits, transaction fee amount', 'N', 12, 'n'] 173 | _BITS_VALUE_TYPE[84] = ['84', 'Debits, processing fee amount', 'N', 12, 'n'] 174 | _BITS_VALUE_TYPE[85] = ['85', 'Debits, transaction fee amount', 'N', 12, 'n'] 175 | _BITS_VALUE_TYPE[86] = ['86', 'Credits, amount', 'N', 15, 'n'] 176 | _BITS_VALUE_TYPE[87] = ['87', 'Credits, reversal amount', 'N', 15, 'n'] 177 | _BITS_VALUE_TYPE[88] = ['88', 'Debits, amount', 'N', 15, 'n'] 178 | _BITS_VALUE_TYPE[89] = ['89', 'Debits, reversal amount', 'N', 15, 'n'] 179 | _BITS_VALUE_TYPE[90] = ['90', 'Original data elements', 'N', 42, 'n'] 180 | _BITS_VALUE_TYPE[91] = ['91', 'File update code', 'AN', 1, 'an'] 181 | _BITS_VALUE_TYPE[92] = ['92', 'File security code', 'N', 2, 'n'] 182 | _BITS_VALUE_TYPE[93] = ['93', 'Response indicator', 'N', 5, 'n'] 183 | _BITS_VALUE_TYPE[94] = ['94', 'Service indicator', 'AN', 7, 'an'] 184 | _BITS_VALUE_TYPE[95] = ['95', 'Replacement amounts', 'AN', 42, 'an'] 185 | _BITS_VALUE_TYPE[96] = ['96', 'Message security code', 'AN', 8, 'an'] 186 | _BITS_VALUE_TYPE[97] = ['97', 'Amount, net settlement', 'N', 16, 'n'] 187 | _BITS_VALUE_TYPE[98] = ['98', 'Payee', 'ANS', 25, 'ans'] 188 | _BITS_VALUE_TYPE[99] = ['99', 'Settlement institution identification code', 'LL', 11, 'n'] 189 | _BITS_VALUE_TYPE[100] = ['100', 'Receiving institution identification code', 'LL', 11, 'n'] 190 | _BITS_VALUE_TYPE[101] = ['101', 'File name', 'ANS', 17, 'ans'] 191 | _BITS_VALUE_TYPE[102] = ['102', 'Account identification 1', 'LL', 28, 'ans'] 192 | _BITS_VALUE_TYPE[103] = ['103', 'Account identification 2', 'LL', 28, 'ans'] 193 | _BITS_VALUE_TYPE[104] = ['104', 'Transaction description', 'LLL', 100, 'ans'] 194 | _BITS_VALUE_TYPE[105] = ['105', 'Reserved for ISO use', 'LLL', 999, 'ans'] 195 | _BITS_VALUE_TYPE[106] = ['106', 'Reserved for ISO use', 'LLL', 999, 'ans'] 196 | _BITS_VALUE_TYPE[107] = ['107', 'Reserved for ISO use', 'LLL', 999, 'ans'] 197 | _BITS_VALUE_TYPE[108] = ['108', 'Reserved for ISO use', 'LLL', 999, 'ans'] 198 | _BITS_VALUE_TYPE[109] = ['109', 'Reserved for ISO use', 'LLL', 999, 'ans'] 199 | _BITS_VALUE_TYPE[110] = ['110', 'Reserved for ISO use', 'LLL', 999, 'ans'] 200 | _BITS_VALUE_TYPE[111] = ['111', 'Reserved for private use', 'LLL', 999, 'ans'] 201 | _BITS_VALUE_TYPE[112] = ['112', 'Reserved for private use', 'LLL', 999, 'ans'] 202 | _BITS_VALUE_TYPE[113] = ['113', 'Reserved for private use', 'LL', 11, 'n'] 203 | _BITS_VALUE_TYPE[114] = ['114', 'Reserved for national use', 'LLL', 999, 'ans'] 204 | _BITS_VALUE_TYPE[115] = ['115', 'Reserved for national use', 'LLL', 999, 'ans'] 205 | _BITS_VALUE_TYPE[116] = ['116', 'Reserved for national use', 'LLL', 999, 'ans'] 206 | _BITS_VALUE_TYPE[117] = ['117', 'Reserved for national use', 'LLL', 999, 'ans'] 207 | _BITS_VALUE_TYPE[118] = ['118', 'Reserved for national use', 'LLL', 999, 'ans'] 208 | _BITS_VALUE_TYPE[119] = ['119', 'Reserved for national use', 'LLL', 999, 'ans'] 209 | _BITS_VALUE_TYPE[120] = ['120', 'Reserved for private use', 'LLL', 999, 'ans'] 210 | _BITS_VALUE_TYPE[121] = ['121', 'Reserved for private use', 'LLL', 999, 'ans'] 211 | _BITS_VALUE_TYPE[122] = ['122', 'Reserved for national use', 'LLL', 999, 'ans'] 212 | _BITS_VALUE_TYPE[123] = ['123', 'Reserved for private use', 'LLL', 999, 'ans'] 213 | _BITS_VALUE_TYPE[124] = ['124', 'Info Text', 'LLL', 255, 'ans'] 214 | _BITS_VALUE_TYPE[125] = ['125', 'Network management information', 'LL', 50, 'ans'] 215 | _BITS_VALUE_TYPE[126] = ['126', 'Issuer trace id', 'LL', 6, 'ans'] 216 | _BITS_VALUE_TYPE[127] = ['127', 'Reserved for private use', 'LLL', 999, 'ans'] 217 | _BITS_VALUE_TYPE[128] = ['128', 'Message authentication code (MAC) field', 'B', 16, 'b'] 218 | 219 | 220 | 221 | ################################################################################################ 222 | # Default constructor of the ISO8583 Object 223 | def __init__(self, iso="", debug=False): 224 | """Default Constructor of ISO8583 Package. 225 | It inicialize a "brand new" ISO8583 package 226 | Example: To Enable debug you can use: 227 | pack = ISO8583(debug=True) 228 | @param: iso a String that represents the ASCII of the package. The same that you need to pass to setIsoContent() method. 229 | @param: debug (True or False) default False -> Used to print some debug infos. Only use if want that messages! 230 | """ 231 | # Bitmap internal representation 232 | self.BITMAP = [] 233 | # Values 234 | self.BITMAP_VALUES = [] 235 | # Bitmap ASCII representantion 236 | self.BITMAP_HEX = '' 237 | # MTI 238 | self.MESSAGE_TYPE_INDICATION = ''; 239 | # Debug ? 240 | self.DEBUG = debug 241 | 242 | self.__inicializeBitmap() 243 | self.__inicializeBitmapValues() 244 | 245 | if iso != "": 246 | self.setIsoContent(iso) 247 | 248 | ################################################################################################ 249 | 250 | ################################################################################################ 251 | # Return bit type 252 | def getBitType(self, bit): 253 | """Method that return the bit Type 254 | @param: bit -> Bit that will be searched and whose type will be returned 255 | @return: str that represents the type of the bit 256 | """ 257 | return self._BITS_VALUE_TYPE[bit][2] 258 | 259 | ################################################################################################ 260 | 261 | ################################################################################################ 262 | # Return bit limit 263 | def getBitLimit(self, bit): 264 | """Method that return the bit limit (Max size) 265 | @param: bit -> Bit that will be searched and whose limit will be returned 266 | @return: int that indicate the limit of the bit 267 | """ 268 | return self._BITS_VALUE_TYPE[bit][3] 269 | 270 | ################################################################################################ 271 | 272 | ################################################################################################ 273 | # Return bit value type 274 | def getBitValueType(self, bit): 275 | """Method that return the bit value type 276 | @param: bit -> Bit that will be searched and whose value type will be returned 277 | @return: str that indicate the valuye type of the bit 278 | """ 279 | return self._BITS_VALUE_TYPE[bit][4] 280 | 281 | ################################################################################################ 282 | 283 | ################################################################################################ 284 | # Return large bit name 285 | def getLargeBitName(self, bit): 286 | """Method that return the large bit name 287 | @param: bit -> Bit that will be searched and whose name will be returned 288 | @return: str that represents the name of the bit 289 | """ 290 | return self._BITS_VALUE_TYPE[bit][1] 291 | 292 | ################################################################################################ 293 | 294 | 295 | ################################################################################################ 296 | # Set the MTI 297 | def setTransationType(self, type): 298 | """Method that set Transation Type (MTI) 299 | @param: type -> MTI to be setted 300 | @raise: ValueToLarge Exception 301 | """ 302 | 303 | type = "%s" % type 304 | if len(type) > 4: 305 | type = type[0:3] 306 | raise ValueToLarge('Error: value up to size! MTI limit size = 4') 307 | 308 | typeT = ""; 309 | if len(type) < 4: 310 | for cont in range(len(type), 4): 311 | typeT += "0" 312 | 313 | self.MESSAGE_TYPE_INDICATION = "%s%s" % (typeT, type) 314 | 315 | ################################################################################################ 316 | 317 | ################################################################################################ 318 | # setMTI too 319 | def setMTI(self, type): 320 | """Method that set Transation Type (MTI) 321 | In fact, is an alias to "setTransationType" method 322 | @param: type -> MTI to be setted 323 | """ 324 | self.setTransationType(type) 325 | 326 | ################################################################################################ 327 | 328 | ################################################################################################ 329 | # Method that put "zeros" inside bitmap 330 | def __inicializeBitmap(self): 331 | """Method that inicialize/reset a internal bitmap representation 332 | It's a internal method, so don't call! 333 | """ 334 | 335 | if self.DEBUG == True: 336 | print('Init bitmap') 337 | 338 | if len(self.BITMAP) == 16: 339 | for cont in range(0, 16): 340 | self.BITMAP[cont] = self._BIT_DEFAULT_VALUE 341 | else: 342 | for cont in range(0, 16): 343 | self.BITMAP.append(self._BIT_DEFAULT_VALUE) 344 | 345 | ################################################################################################ 346 | 347 | ################################################################################################ 348 | # init with "0" the array of values 349 | def __inicializeBitmapValues(self): 350 | """Method that inicialize/reset a internal array used to save bits and values 351 | It's a internal method, so don't call! 352 | """ 353 | if self.DEBUG == True: 354 | print('Init bitmap_values') 355 | 356 | if len(self.BITMAP_VALUES) == 128: 357 | for cont in range(0, 129): 358 | self.BITMAP_VALUES[cont] = self._BIT_DEFAULT_VALUE 359 | else: 360 | for cont in range(0, 129): 361 | self.BITMAP_VALUES.append(self._BIT_DEFAULT_VALUE) 362 | 363 | ################################################################################################ 364 | 365 | ################################################################################################ 366 | # Set a value to a bit 367 | def setBit(self, bit, value): 368 | """Method used to set a bit with a value. 369 | It's one of the most important method to use when using this library 370 | @param: bit -> bit number that want to be setted 371 | @param: value -> the value of the bit 372 | @return: True/False default True -> To be used in the future! 373 | @raise: BitInexistent Exception, ValueToLarge Exception 374 | """ 375 | if self.DEBUG == True: 376 | print('Setting bit inside bitmap bit[%s] = %s') % (bit, value) 377 | 378 | if bit < 1 or bit > 128: 379 | raise BitInexistent("Bit number %s dosen't exist!" % bit) 380 | 381 | # caculate the position insede bitmap 382 | pos = 1 383 | 384 | if self.getBitType(bit) == 'LL': 385 | self.__setBitTypeLL(bit, value) 386 | 387 | if self.getBitType(bit) == 'LLL': 388 | self.__setBitTypeLLL(bit, value) 389 | 390 | if self.getBitType(bit) == 'N': 391 | self.__setBitTypeN(bit, value) 392 | 393 | if self.getBitType(bit) == 'A': 394 | self.__setBitTypeA(bit, value) 395 | 396 | if self.getBitType(bit) == 'ANS' or self.getBitType(bit) == 'B': 397 | self.__setBitTypeANS(bit, value) 398 | 399 | if self.getBitType(bit) == 'B': 400 | self.__setBitTypeB(bit, value) 401 | 402 | 403 | 404 | # Continuation bit? 405 | if bit > 64: 406 | self.BITMAP[0] = self.BITMAP[0] | self._TMP[2] # need to set bit 1 of first "bit" in bitmap 407 | 408 | if (bit % 8) == 0: 409 | pos = (bit / 8) - 1 410 | else: 411 | pos = (bit / 8) 412 | 413 | # need to check if the value can be there .. AN , N ... etc ... and the size 414 | 415 | self.BITMAP[pos] = self.BITMAP[pos] | self._TMP[(bit % 8) + 1] 416 | 417 | return True 418 | 419 | ################################################################################################ 420 | 421 | ################################################################################################ 422 | # print bitmap 423 | def showBitmap(self): 424 | """Method that print the bitmap in ASCII form 425 | Hint: Try to use getBitmap method and format your own print :) 426 | """ 427 | 428 | self.__buildBitmap() 429 | 430 | # printing 431 | print(self.BITMAP_HEX) 432 | 433 | ################################################################################################ 434 | 435 | ################################################################################################ 436 | # Build a bitmap 437 | def __buildBitmap(self): 438 | """Method that build the bitmap ASCII 439 | It's a internal method, so don't call! 440 | """ 441 | 442 | self.BITMAP_HEX = '' 443 | 444 | for c in range(0, 16): 445 | if (self.BITMAP[0] & self._BIT_POSITION_1) != self._BIT_POSITION_1: 446 | # Only has the first bitmap 447 | if self.DEBUG == True: 448 | print('%d Bitmap = %d(Decimal) = %s (hexa) ' % (c, self.BITMAP[c], hex(self.BITMAP[c]))) 449 | 450 | tm = hex(self.BITMAP[c])[2:] 451 | if len(tm) != 2: 452 | tm = '0' + tm 453 | self.BITMAP_HEX += tm 454 | if c == 7: 455 | break 456 | else: # second bitmap 457 | if self.DEBUG == True: 458 | print('%d Bitmap = %d(Decimal) = %s (hexa) ' % (c, self.BITMAP[c], hex(self.BITMAP[c]))) 459 | 460 | tm = hex(self.BITMAP[c])[2:] 461 | if len(tm) != 2: 462 | tm = '0' + tm 463 | self.BITMAP_HEX += tm 464 | 465 | ################################################################################################ 466 | 467 | ################################################################################################ 468 | # Get a bitmap from str 469 | def __getBitmapFromStr(self, bitmap): 470 | """Method that receive a bitmap str and transfor it to ISO8583 object readable. 471 | @param: bitmap -> bitmap str to be readable 472 | It's a internal method, so don't call! 473 | """ 474 | # Need to check if the size is correct etc... 475 | cont = 0 476 | 477 | if self.BITMAP_HEX != '': 478 | self.BITMAP_HEX = '' 479 | 480 | for x in range(0, 32, 2): 481 | if (int(bitmap[0:2], 16) & self._BIT_POSITION_1) != self._BIT_POSITION_1: # Only 1 bitmap 482 | if self.DEBUG == True: 483 | print('Token[%d] %s converted to int is = %s' % (x, bitmap[x:x + 2], int(bitmap[x:x + 2], 16))) 484 | 485 | self.BITMAP_HEX += bitmap[x:x + 2] 486 | self.BITMAP[cont] = int(bitmap[x:x + 2], 16) 487 | if x == 14: 488 | break 489 | else: # Second bitmap 490 | if self.DEBUG == True: 491 | print('Token[%d] %s converted to int is = %s' % (x, bitmap[x:x + 2], int(bitmap[x:x + 2], 16))) 492 | 493 | self.BITMAP_HEX += bitmap[x:x + 2] 494 | self.BITMAP[cont] = int(bitmap[x:x + 2], 16) 495 | cont += 1 496 | 497 | ################################################################################################ 498 | 499 | ################################################################################################ 500 | # print bit array that is present in the bitmap 501 | def showBitsFromBitmapStr(self, bitmap): 502 | """Method that receive a bitmap str, process it, and print a array with bits this bitmap string represents. 503 | Usualy is used to debug things. 504 | @param: bitmap -> bitmap str to be analized and translated to "bits" 505 | """ 506 | bits = self.__inicializeBitsFromBitmapStr(bitmap) 507 | print('Bits inside %s = %s' % (bitmap, bits)) 508 | 509 | ################################################################################################ 510 | 511 | ################################################################################################ 512 | # inicialize a bitmap using ASCII str 513 | def __inicializeBitsFromBitmapStr(self, bitmap): 514 | """Method that receive a bitmap str, process it, and prepare ISO8583 object to understand and "see" the bits and values inside the ISO ASCII package. 515 | It's a internal method, so don't call! 516 | @param: bitmap -> bitmap str to be analized and translated to "bits" 517 | """ 518 | bits = [] 519 | for c in range(0, 16): 520 | for d in range(1, 9): 521 | if self.DEBUG == True: 522 | print('Value (%d)-> %s & %s = %s' % ( 523 | d, self.BITMAP[c], self._TMP[d], (self.BITMAP[c] & self._TMP[d]))) 524 | if (self.BITMAP[c] & self._TMP[d]) == self._TMP[d]: 525 | if d == 1: # e o 8 bit 526 | if self.DEBUG == True: 527 | print('Bit %s is present !!!' % ((c + 1) * 8)) 528 | bits.append((c + 1) * 8) 529 | self.BITMAP_VALUES[(c + 1) * 8] = 'X' 530 | else: 531 | if (c == 0) & (d == 2): # Continuation bit 532 | if self.DEBUG == True: 533 | print('Bit 1 is present !!!') 534 | 535 | bits.append(1) 536 | 537 | else: 538 | if self.DEBUG == True: 539 | print('Bit %s is present !!!' % (c * 8 + d - 1)) 540 | 541 | bits.append(c * 8 + d - 1) 542 | self.BITMAP_VALUES[c * 8 + d - 1] = 'X' 543 | 544 | bits.sort() 545 | 546 | return bits 547 | 548 | ################################################################################################ 549 | 550 | ################################################################################################ 551 | # return a array of bits, when processing the bitmap 552 | def __getBitsFromBitmap(self): 553 | """Method that process the bitmap and return a array with the bits presents inside it. 554 | It's a internal method, so don't call! 555 | """ 556 | bits = [] 557 | for c in range(0, 16): 558 | for d in range(1, 9): 559 | if self.DEBUG == True: 560 | print('Value (%d)-> %s & %s = %s' % ( 561 | d, self.BITMAP[c], self._TMP[d], (self.BITMAP[c] & self._TMP[d]))) 562 | if (self.BITMAP[c] & self._TMP[d]) == self._TMP[d]: 563 | if d == 1: # e o 8 bit 564 | if self.DEBUG == True: 565 | print('Bit %s is present !!!' % ((c + 1) * 8)) 566 | 567 | bits.append((c + 1) * 8) 568 | else: 569 | if (c == 0) & (d == 2): # Continuation bit 570 | if self.DEBUG == True: 571 | print('Bit 1 is present !!!') 572 | 573 | bits.append(1) 574 | 575 | else: 576 | if self.DEBUG == True: 577 | print('Bit %s is present !!!' % (c * 8 + d - 1)) 578 | 579 | bits.append(c * 8 + d - 1) 580 | 581 | bits.sort() 582 | 583 | return bits 584 | 585 | ################################################################################################ 586 | 587 | ################################################################################################ 588 | # Set of type LL 589 | def __setBitTypeLL(self, bit, value): 590 | """Method that set a bit with value in form LL 591 | It put the size in front of the value 592 | Example: pack.setBit(99,'123') -> Bit 99 is a LL type, so this bit, in ASCII form need to be 03123. To understand, 03 is the size of the information and 123 is the information/value 593 | @param: bit -> bit to be setted 594 | @param: value -> value to be setted 595 | @raise: ValueToLarge Exception 596 | It's a internal method, so don't call! 597 | """ 598 | 599 | value = "%s" % value 600 | 601 | if len(value) > 99: 602 | # value = value[0:99] 603 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 604 | bit, self.getBitType(bit), self.getBitLimit(bit))) 605 | if len(value) > self.getBitLimit(bit): 606 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 607 | bit, self.getBitType(bit), self.getBitLimit(bit))) 608 | 609 | size = "%s" % len(value) 610 | 611 | self.BITMAP_VALUES[bit] = "%s%s" % (size.zfill(2), value) 612 | 613 | ################################################################################################ 614 | 615 | ################################################################################################ 616 | # Set of type LLL 617 | def __setBitTypeLLL(self, bit, value): 618 | """Method that set a bit with value in form LLL 619 | It put the size in front of the value 620 | Example: pack.setBit(104,'12345ABCD67890') -> Bit 104 is a LLL type, so this bit, in ASCII form need to be 01412345ABCD67890. 621 | To understand, 014 is the size of the information and 12345ABCD67890 is the information/value 622 | @param: bit -> bit to be setted 623 | @param: value -> value to be setted 624 | @raise: ValueToLarge Exception 625 | It's a internal method, so don't call! 626 | """ 627 | 628 | value = "%s" % value 629 | 630 | if len(value) > 999: 631 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 632 | bit, self.getBitType(bit), self.getBitLimit(bit))) 633 | if len(value) > self.getBitLimit(bit): 634 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 635 | bit, self.getBitType(bit), self.getBitLimit(bit))) 636 | 637 | size = "%s" % len(value) 638 | 639 | self.BITMAP_VALUES[bit] = "%s%s" % (size.zfill(3), value) 640 | 641 | ################################################################################################ 642 | 643 | ################################################################################################ 644 | # Set of type N, 645 | def __setBitTypeN(self, bit, value): 646 | """Method that set a bit with value in form N 647 | It complete the size of the bit with a default value 648 | Example: pack.setBit(3,'30000') -> Bit 3 is a N type, so this bit, in ASCII form need to has size = 6 (ISO especification) so the value 30000 size = 5 need to receive more "1" number. 649 | In this case, will be "0" in the left. In the package, the bit will be sent like '030000' 650 | @param: bit -> bit to be setted 651 | @param: value -> value to be setted 652 | @raise: ValueToLarge Exception 653 | It's a internal method, so don't call! 654 | """ 655 | 656 | value = "%s" % value 657 | 658 | if len(value) > self.getBitLimit(bit): 659 | value = value[0:self.getBitLimit(bit)] 660 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 661 | bit, self.getBitType(bit), self.getBitLimit(bit))) 662 | 663 | self.BITMAP_VALUES[bit] = value.zfill(self.getBitLimit(bit)) 664 | 665 | ################################################################################################ 666 | 667 | ################################################################################################ 668 | # Set of type A 669 | def __setBitTypeA(self, bit, value): 670 | """Method that set a bit with value in form A 671 | It complete the size of the bit with a default value 672 | Example: pack.setBit(3,'30000') -> Bit 3 is a A type, so this bit, in ASCII form need to has size = 6 (ISO especification) so the value 30000 size = 5 need to receive more "1" number. 673 | In this case, will be "0" in the left. In the package, the bit will be sent like '030000' 674 | @param: bit -> bit to be setted 675 | @param: value -> value to be setted 676 | @raise: ValueToLarge Exception 677 | It's a internal method, so don't call! 678 | """ 679 | 680 | value = "%s" % value 681 | 682 | if len(value) > self.getBitLimit(bit): 683 | value = value[0:self.getBitLimit(bit)] 684 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 685 | bit, self.getBitType(bit), self.getBitLimit(bit))) 686 | 687 | self.BITMAP_VALUES[bit] = value.zfill(self.getBitLimit(bit)) 688 | 689 | ################################################################################################ 690 | 691 | ################################################################################################ 692 | # Set of type B 693 | def __setBitTypeB(self, bit, value): 694 | """Method that set a bit with value in form B 695 | It complete the size of the bit with a default value 696 | Example: pack.setBit(3,'30000') -> Bit 3 is a B type, so this bit, in ASCII form need to has size = 6 (ISO especification) so the value 30000 size = 5 need to receive more "1" number. 697 | In this case, will be "0" in the left. In the package, the bit will be sent like '030000' 698 | @param: bit -> bit to be setted 699 | @param: value -> value to be setted 700 | @raise: ValueToLarge Exception 701 | It's a internal method, so don't call! 702 | """ 703 | 704 | value = "%s" % value 705 | 706 | if len(value) > self.getBitLimit(bit): 707 | value = value[0:self.getBitLimit(bit)] 708 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 709 | bit, self.getBitType(bit), self.getBitLimit(bit))) 710 | 711 | self.BITMAP_VALUES[bit] = value.zfill(self.getBitLimit(bit)) 712 | 713 | ################################################################################################ 714 | 715 | ################################################################################################ 716 | # Set of type ANS 717 | def __setBitTypeANS(self, bit, value): 718 | """Method that set a bit with value in form ANS 719 | It complete the size of the bit with a default value 720 | Example: pack.setBit(3,'30000') -> Bit 3 is a ANS type, so this bit, in ASCII form need to has size = 6 (ISO especification) so the value 30000 size = 5 need to receive more "1" number. 721 | In this case, will be "0" in the left. In the package, the bit will be sent like '030000' 722 | @param: bit -> bit to be setted 723 | @param: value -> value to be setted 724 | @raise: ValueToLarge Exception 725 | It's a internal method, so don't call! 726 | """ 727 | 728 | value = "%s" % value 729 | 730 | if len(value) > self.getBitLimit(bit): 731 | value = value[0:self.getBitLimit(bit)] 732 | raise ValueToLarge('Error: value up to size! Bit[%s] of type %s limit size = %s' % ( 733 | bit, self.getBitType(bit), self.getBitLimit(bit))) 734 | 735 | self.BITMAP_VALUES[bit] = value.zfill(self.getBitLimit(bit)) 736 | 737 | ################################################################################################ 738 | 739 | ################################################################################################ 740 | # print os bits insede iso 741 | def showIsoBits(self): 742 | """Method that show in detail a list of bits , values and types inside the object 743 | Example: output to 744 | (...) 745 | iso.setBit(2,2) 746 | iso.setBit(4,4) 747 | (...) 748 | iso.showIsoBits() 749 | (...) 750 | Bit[2] of type LL has limit 19 = 012 751 | Bit[4] of type N has limit 12 = 000000000004 752 | (...) 753 | """ 754 | 755 | for cont in range(0, 129): 756 | if self.BITMAP_VALUES[cont] != self._BIT_DEFAULT_VALUE: 757 | print("Bit[%s] of type %s has limit %s = %s" % ( 758 | cont, self.getBitType(cont), self.getBitLimit(cont), self.BITMAP_VALUES[cont])) 759 | 760 | ################################################################################################ 761 | 762 | ################################################################################################ 763 | # print Raw iso 764 | def showRawIso(self): 765 | """Method that print ISO8583 ASCII complete representation 766 | Example: 767 | iso = ISO8583() 768 | iso.setMTI('0800') 769 | iso.setBit(2,2) 770 | iso.setBit(4,4) 771 | iso.setBit(12,12) 772 | iso.setBit(17,17) 773 | iso.setBit(99,99) 774 | iso.showRawIso() 775 | output (print) -> 0800d010800000000000000000002000000001200000000000400001200170299 776 | Hint: Try to use getRawIso method and format your own print :) 777 | """ 778 | 779 | resp = self.getRawIso() 780 | print(resp) 781 | 782 | ################################################################################################ 783 | 784 | ################################################################################################ 785 | # Return raw iso 786 | def getRawIso(self): 787 | """Method that return ISO8583 ASCII complete representation 788 | Example: 789 | iso = ISO8583() 790 | iso.setMTI('0800') 791 | iso.setBit(2,2) 792 | iso.setBit(4,4) 793 | iso.setBit(12,12) 794 | iso.setBit(17,17) 795 | iso.setBit(99,99) 796 | str = iso.getRawIso() 797 | print ('This is the ASCII package %s' % str) 798 | output (print) -> This is the ASCII package 0800d010800000000000000000002000000001200000000000400001200170299 799 | 800 | @return: str with complete ASCII ISO8583 801 | @raise: InvalidMTI Exception 802 | """ 803 | 804 | self.__buildBitmap() 805 | 806 | if self.MESSAGE_TYPE_INDICATION == '': 807 | raise InvalidMTI('Check MTI! Do you set it?') 808 | 809 | resp = ""; 810 | 811 | resp += self.MESSAGE_TYPE_INDICATION 812 | resp += self.BITMAP_HEX 813 | 814 | for cont in range(0, 129): 815 | if self.BITMAP_VALUES[cont] != self._BIT_DEFAULT_VALUE: 816 | resp = "%s%s" % (resp, self.BITMAP_VALUES[cont]) 817 | 818 | return resp 819 | 820 | ################################################################################################ 821 | 822 | ################################################################################################ 823 | # Redefine a bit 824 | def redefineBit(self, bit, smallStr, largeStr, bitType, size, valueType): 825 | """Method that redefine a bit structure in global scope! 826 | Can be used to personalize ISO8583 structure to another specification (ISO8583 1987 for example!) 827 | Hint: If you have a lot of "ValueToLarge Exception" maybe the especification that you are using is different of mine. So you will need to use this method :) 828 | @param: bit -> bit to be redefined 829 | @param: smallStr -> a small String representantion of the bit, used to build "user friendly prints", example "2" for bit 2 830 | @param: largeStr -> a large String representantion of the bit, used to build "user friendly prints" and to be used to inform the "main use of the bit", 831 | example "Primary account number (PAN)" for bit 2 832 | @param: bitType -> type the bit, used to build the values, example "LL" for bit 2. Need to be one of (B, N, AN, ANS, LL, LLL) 833 | @param: size -> limit size the bit, used to build/complete the values, example "19" for bit 2. 834 | @param: valueType -> value type the bit, used to "validate" the values, example "n" for bit 2. This mean that in bit 2 we need to have only numeric values. 835 | Need to be one of (a, an, n, ansb, b) 836 | @raise: BitInexistent Exception, InvalidValueType Exception 837 | 838 | """ 839 | 840 | if self.DEBUG == True: 841 | print('Trying to redefine the bit with (self,%s,%s,%s,%s,%s,%s)' % ( 842 | bit, smallStr, largeStr, bitType, size, valueType)) 843 | 844 | # validating bit position 845 | if bit == 1 or bit == 64 or bit < 0 or bit > 128: 846 | raise BitInexistent("Error %d cannot be changed because has a invalid number!" % bit) 847 | 848 | # need to validate if the type and size is compatible! example slimit = 100 and type = LL 849 | 850 | if bitType == "B" or bitType == "N" or bitType == "AN" or bitType == "ANS" or bitType == "LL" or bitType == "LLL": 851 | if valueType == "a" or valueType == "n" or valueType == "ansb" or valueType == "ans" or valueType == "b" or valueType == "an": 852 | self._BITS_VALUE_TYPE[bit] = [smallStr, largeStr, bitType, size, valueType] 853 | if self.DEBUG == True: 854 | print('Bit %d redefined!' % bit) 855 | 856 | else: 857 | raise InvalidValueType( 858 | "Error bit %d cannot be changed because %s is not a valid valueType (a, an, n ansb, b)!" % ( 859 | bit, valueType)) 860 | # return 861 | else: 862 | raise InvalidBitType( 863 | "Error bit %d cannot be changed because %s is not a valid bitType (Hex, N, AN, ANS, LL, LLL)!" % ( 864 | bit, bitType)) 865 | # return 866 | 867 | ################################################################################################ 868 | 869 | ################################################################################################ 870 | # a partir de um trem de string, pega o MTI 871 | def __setMTIFromStr(self, iso): 872 | """Method that get the first 4 characters to be the MTI. 873 | It's a internal method, so don't call! 874 | """ 875 | 876 | self.MESSAGE_TYPE_INDICATION = iso[0:4] 877 | 878 | if self.DEBUG == True: 879 | print('MTI found was %s' % self.MESSAGE_TYPE_INDICATION) 880 | 881 | ################################################################################################ 882 | 883 | ################################################################################################ 884 | # return the MTI 885 | def getMTI(self): 886 | """Method that return the MTI of the package 887 | @return: str -> with the MTI 888 | """ 889 | 890 | # Need to validate if the MTI was setted ...etc ... 891 | return self.MESSAGE_TYPE_INDICATION 892 | 893 | ################################################################################################ 894 | 895 | ################################################################################################ 896 | # Return the bitmap 897 | def getBitmap(self): 898 | """Method that return the ASCII Bitmap of the package 899 | @return: str -> with the ASCII Bitmap 900 | """ 901 | if self.BITMAP_HEX == '': 902 | self.__buildBitmap() 903 | 904 | return self.BITMAP_HEX 905 | 906 | ################################################################################################ 907 | 908 | ################################################################################################ 909 | # return the Varray of values 910 | def getValuesArray(self): 911 | """Method that return an internal array of the package 912 | @return: array -> with all bits, presents or not in the bitmap 913 | """ 914 | return self.BITMAP_VALUES 915 | 916 | ################################################################################################ 917 | 918 | ################################################################################################ 919 | # Receive a str and interpret it to bits and values 920 | def __getBitFromStr(self, strWithoutMtiBitmap): 921 | """Method that receive a string (ASCII) without MTI and Bitmaps (first and second), understand it and remove the bits values 922 | @param: str -> with all bits presents whithout MTI and bitmap 923 | It's a internal method, so don't call! 924 | """ 925 | 926 | if self.DEBUG == True: 927 | print('This is the input string <%s>' % strWithoutMtiBitmap) 928 | 929 | offset = 0; 930 | # jump bit 1 because it was alread defined in the "__inicializeBitsFromBitmapStr" 931 | for cont in range(2, 129): 932 | if self.BITMAP_VALUES[cont] != self._BIT_DEFAULT_VALUE: 933 | if self.DEBUG == True: 934 | print('String = %s offset = %s bit = %s' % (strWithoutMtiBitmap[offset:], offset, cont)) 935 | 936 | if self.getBitType(cont) == 'LL': 937 | valueSize = int(strWithoutMtiBitmap[offset:offset + 2]) 938 | if self.DEBUG == True: 939 | print('Size of the message in LL = %s' % valueSize) 940 | 941 | if valueSize > self.getBitLimit(cont): 942 | print('This bit is larger thant the specification.') 943 | # raise ValueToLarge("This bit is larger than the especification!") 944 | 945 | self.BITMAP_VALUES[cont] = strWithoutMtiBitmap[offset:offset + 2] + strWithoutMtiBitmap[ 946 | offset + 2:offset + 2 + valueSize] 947 | 948 | if self.DEBUG == True: 949 | print('\tSetting bit %s value %s' % (cont, self.BITMAP_VALUES[cont])) 950 | 951 | # fix for AppZone - their responses don't comply with specifications 952 | if cont == 33: 953 | offset += valueSize + 2 # replace with 17 if it fails 954 | else: 955 | offset += valueSize + 2 956 | 957 | if self.getBitType(cont) == 'LLL': 958 | valueSize = int(strWithoutMtiBitmap[offset:offset + 3]) 959 | if self.DEBUG == True: 960 | print('Size of the message in LLL = %s' % valueSize) 961 | 962 | if valueSize > self.getBitLimit(cont): 963 | raise ValueToLarge("This bit is larger than the especification!") 964 | self.BITMAP_VALUES[cont] = strWithoutMtiBitmap[offset:offset + 3] + strWithoutMtiBitmap[ 965 | offset + 3:offset + 3 + valueSize] 966 | 967 | if self.DEBUG == True: 968 | print('\tSetting bit %s value %s' % (cont, self.BITMAP_VALUES[cont])) 969 | 970 | offset += valueSize + 3 971 | 972 | # if self.getBitType(cont) == 'LLLL': 973 | # valueSize = int(strWithoutMtiBitmap[offset:offset +4]) 974 | # if valueSize > self.getBitLimit(cont): 975 | # raise ValueToLarge("This bit is larger than the especification!") 976 | # self.BITMAP_VALUES[cont] = '(' + strWithoutMtiBitmap[offset:offset+4] + ')' + strWithoutMtiBitmap[offset+4:offset+4+valueSize] 977 | # offset += valueSize + 4 978 | 979 | if self.getBitType(cont) == 'N' or self.getBitType(cont) == 'A' or self.getBitType( 980 | cont) == 'ANS' or self.getBitType(cont) == 'B' or self.getBitType(cont) == 'AN': 981 | self.BITMAP_VALUES[cont] = strWithoutMtiBitmap[offset:self.getBitLimit(cont) + offset] 982 | 983 | if self.DEBUG == True: 984 | print('\tSetting bit %s value %s' % (cont, self.BITMAP_VALUES[cont])) 985 | 986 | offset += self.getBitLimit(cont) 987 | 988 | ################################################################################################ 989 | 990 | ################################################################################################ 991 | # Parse a ASCII iso to object 992 | def setIsoContent(self, iso): 993 | """Method that receive a complete ISO8583 string (ASCII) understand it and remove the bits values 994 | Example: 995 | iso = '0210B238000102C080040000000000000002100000000000001700010814465469421614465701081100301000000N399915444303500019991544986020 Value not allowed009000095492' 996 | i2 = ISO8583() 997 | # in this case, we need to redefine a bit because default bit 42 is LL and in this especification is "N" 998 | # the rest remain, so we use "get" :) 999 | i2.redefineBit(42, '42', i2.getLargeBitName(42), 'N', i2.getBitLimit(42), i2.getBitValueType(42) ) 1000 | i2.setIsoContent(iso2) 1001 | print ('Bitmap = %s' %i2.getBitmap()) 1002 | print ('MTI = %s' %i2.getMTI() ) 1003 | 1004 | print ('This ISO has bits:') 1005 | v3 = i2.getBitsAndValues() 1006 | for v in v3: 1007 | print ('Bit %s of type %s with value = %s' % (v['bit'],v['type'],v['value'])) 1008 | 1009 | @param: str -> complete ISO8583 string 1010 | @raise: InvalidIso8583 Exception 1011 | """ 1012 | if len(iso) < 20: 1013 | raise InvalidIso8583('This is not a valid iso!!') 1014 | if self.DEBUG == True: 1015 | print('ASCII to process <%s>' % iso) 1016 | 1017 | self.__setMTIFromStr(iso) 1018 | isoT = iso[4:] 1019 | self.__getBitmapFromStr(isoT) 1020 | self.__inicializeBitsFromBitmapStr(self.BITMAP_HEX) 1021 | if self.DEBUG == True: 1022 | print('This is the array of bits (before) %s ' % self.BITMAP_VALUES) 1023 | 1024 | self.__getBitFromStr(iso[4 + len(self.BITMAP_HEX):]) 1025 | if self.DEBUG == True: 1026 | print('This is the array of bits (after) %s ' % self.BITMAP_VALUES) 1027 | 1028 | ################################################################################################ 1029 | 1030 | ################################################################################################ 1031 | # Method that compare 2 isos 1032 | def __cmp__(self, obj2): 1033 | """Method that compare two objects in "==", "!=" and other things 1034 | Example: 1035 | p1 = ISO8583() 1036 | p1.setMTI('0800') 1037 | p1.setBit(2,2) 1038 | p1.setBit(4,4) 1039 | p1.setBit(12,12) 1040 | p1.setBit(17,17) 1041 | p1.setBit(99,99) 1042 | 1043 | #get the rawIso and save in the iso variable 1044 | iso = p1.getRawIso() 1045 | 1046 | p2 = ISO8583() 1047 | p2.setIsoContent(iso) 1048 | 1049 | print ('Is equivalent?') 1050 | if p1 == p1: 1051 | print ('Yes :)') 1052 | else: 1053 | print ('Noooooooooo :(') 1054 | 1055 | @param: obj2 -> object that will be compared 1056 | @return: <0 if is not equal, 0 if is equal 1057 | """ 1058 | ret = -1 # By default is different 1059 | if (self.getMTI() == obj2.getMTI()) and (self.getBitmap() == obj2.getBitmap()) and ( 1060 | self.getValuesArray() == obj2.getValuesArray()): 1061 | ret = 0 1062 | 1063 | return ret 1064 | 1065 | ################################################################################################ 1066 | 1067 | ################################################################################################ 1068 | # Method that return a array with bits and values inside the iso package 1069 | def getBitsAndValues(self): 1070 | """Method that return an array of bits, values, types etc. 1071 | Each array value is a dictionary with: {'bit':X ,'type': Y, 'value': Z} Where: 1072 | bit: is the bit number 1073 | type: is the bit type 1074 | value: is the bit value inside this object 1075 | so the Generic array returned is: [ (...),{'bit':X,'type': Y, 'value': Z}, (...)] 1076 | 1077 | Example: 1078 | p1 = ISO8583() 1079 | p1.setMTI('0800') 1080 | p1.setBit(2,2) 1081 | p1.setBit(4,4) 1082 | p1.setBit(12,12) 1083 | p1.setBit(17,17) 1084 | p1.setBit(99,99) 1085 | 1086 | v1 = p1.getBitsAndValues() 1087 | for v in v1: 1088 | print ('Bit %s of type %s with value = %s' % (v['bit'],v['type'],v['value'])) 1089 | 1090 | @return: array of values. 1091 | """ 1092 | ret = [] 1093 | for cont in range(2, 129): 1094 | if self.BITMAP_VALUES[cont] != self._BIT_DEFAULT_VALUE: 1095 | _TMP = {} 1096 | _TMP['bit'] = "%d" % cont 1097 | _TMP['type'] = self.getBitType(cont) 1098 | _TMP['value'] = self.BITMAP_VALUES[cont] 1099 | ret.append(_TMP) 1100 | return ret 1101 | 1102 | ################################################################################################ 1103 | 1104 | ################################################################################################ 1105 | # Method that return a array with bits and values inside the iso package 1106 | def getBit(self, bit): 1107 | """Return the value of the bit 1108 | @param: bit -> the number of the bit that you want the value 1109 | @raise: BitInexistent Exception, BitNotSet Exception 1110 | """ 1111 | 1112 | if bit < 1 or bit > 128: 1113 | raise BitInexistent("Bit number %s dosen't exist!" % bit) 1114 | 1115 | # Is that bit set? 1116 | isThere = False 1117 | arr = self.__getBitsFromBitmap() 1118 | 1119 | if self.DEBUG == True: 1120 | print('This is the array of bits inside the bitmap %s' % arr) 1121 | 1122 | for v in arr: 1123 | if v == bit: 1124 | value = self.BITMAP_VALUES[bit] 1125 | isThere = True 1126 | break 1127 | 1128 | if isThere: 1129 | return value 1130 | else: 1131 | raise BitNotSet("Bit number %s was not set!" % bit) 1132 | 1133 | ################################################################################################ 1134 | 1135 | ################################################################################################ 1136 | # Method that return ISO8583 to TCPIP network form, with the size in the beginning. 1137 | def getNetworkISO(self, bigEndian=True): 1138 | """Method that return ISO8583 ASCII package with the size in the beginning 1139 | By default, it return the package with size represented with big-endian. 1140 | Is the same that: 1141 | import struct 1142 | (...) 1143 | iso = ISO8583() 1144 | iso.setBit(3,'300000') 1145 | (...) 1146 | ascii = iso.getRawIso() 1147 | # Example: big-endian 1148 | # To little-endian, replace '!h' with ' the same that <%s>' % (iso.getNetworkISO(),netIso)) 1154 | 1155 | @param: bigEndian (True|False) -> if you want that the size be represented in this way. 1156 | @return: size + ASCII ISO8583 package ready to go to the network! 1157 | @raise: InvalidMTI Exception 1158 | """ 1159 | 1160 | netIso = "" 1161 | asciiIso = self.getRawIso() 1162 | 1163 | if bigEndian: 1164 | netIso = struct.pack('!h', len(asciiIso)) 1165 | if self.DEBUG == True: 1166 | print('Pack Big-endian') 1167 | else: 1168 | netIso = struct.pack(' str that represents size + ASCII ISO8583 package 1206 | @param: bigEndian (True|False) -> Codification of the size. 1207 | @raise: InvalidIso8583 Exception 1208 | """ 1209 | 1210 | if len(iso) < 24: 1211 | raise InvalidIso8583('This is not a valid iso!!Invalid Size') 1212 | 1213 | size = iso[0:2] 1214 | if bigEndian: 1215 | size = struct.unpack('!h', size) 1216 | if self.DEBUG == True: 1217 | print('Unpack Big-endian') 1218 | else: 1219 | size = struct.unpack('. 17 | 18 | """ 19 | 20 | """ Class used do inform errors. 21 | """ 22 | #Exception used to indicate that the value that setting in the bit is large than the iso limit to that bit! 23 | class ValueToLarge(Exception): 24 | """Exeption that indicate that a value that want to set inside the bit is large than the "ISO" limit. 25 | This can happen when you have a different specification of mine. 26 | If this is the case, you should use "ISO8583.redefineBit()" method and redefine the limit. 27 | """ 28 | def __init__(self, value): 29 | self.str = value 30 | def __str__(self): 31 | return repr(self.str) 32 | 33 | 34 | #Exception to indicate that bit dosen't Exist! 35 | class BitInexistent(Exception): 36 | """Exeption that indicate that a bit that you try to manage dosen't exist! 37 | Try to check your "setBit". Remember that ISO8583 1993 has only bits from 1 to 128! 38 | """ 39 | def __init__(self, value): 40 | self.str = value 41 | def __str__(self): 42 | return repr(self.str) 43 | 44 | #Execption to indicate that value type is not valid 45 | class InvalidValueType(Exception): 46 | """Exeption that indicate that a value that you try to insert is out of especification. 47 | For example: You try to insert a value "ABC" in a bit of type "N" (Number) , this is invalid! 48 | This can happen when you have a different specification of mine. 49 | If this is the case, you should use "ISO8583.redefineBit()" method and redefine the type. 50 | """ 51 | def __init__(self, value): 52 | self.str = value 53 | def __str__(self): 54 | return repr(self.str) 55 | 56 | #Execption to indicate that bit type is not valid 57 | class InvalidBitType(Exception): 58 | """Exception that indicate that the type that you try to set is invalid. 59 | For example: You try to set type "X", that dosen't exist. 60 | Valid type are: B, N, A, AN, ANS, LL, LLL 61 | """ 62 | def __init__(self, value): 63 | self.str = value 64 | def __str__(self): 65 | return repr(self.str) 66 | 67 | #Exception that indicate a invalid iso, maybe invalid size etc... 68 | class InvalidIso8583(Exception): 69 | """Exception that indicate a invalid ASCII message, for example, without a piece... Error size etc. 70 | """ 71 | def __init__(self, value): 72 | self.str = value 73 | def __str__(self): 74 | return repr(self.str) 75 | 76 | #Exception that indicate a invalid MTI, maybe it is not set 77 | class InvalidMTI(Exception): 78 | """Exception that indicate a invalid MTI 79 | """ 80 | def __init__(self, value): 81 | self.str = value 82 | def __str__(self): 83 | return repr(self.str) 84 | 85 | #Exception that indicate that bit is not there. 86 | class BitNotSet(Exception): 87 | """Exception that indicate that you try to access a bit not present in the bitmap. 88 | """ 89 | def __init__(self, value): 90 | self.str = value 91 | def __str__(self): 92 | return repr(self.str) -------------------------------------------------------------------------------- /ISO8583/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | INSTALL 2 | LICENCE 3 | README 4 | TODO 5 | setup.py 6 | ISO8583\ISO8583.py 7 | ISO8583\ISOErrors.py 8 | ISO8583\__init__.py 9 | doc\ISO8583.ISO8583.html 10 | doc\ISO8583.ISOErrors.html 11 | doc\ISO8583.html 12 | doc\index.html 13 | examples\echoClient.py 14 | examples\echoServer.py 15 | examples\example1.py 16 | examples\example2.py 17 | examples\example3.py 18 | examples\example4.py 19 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include INSTALL 2 | include LICENCE 3 | include TODO 4 | include doc/* 5 | include examples/* 6 | prune .bzr 7 | prune examples/*UT* 8 | prune examples/*test* -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | (C) Copyright 2009 Igor V. Custodio 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program. If not, see . 15 | 16 | ======================================================================== 17 | 18 | *) To install information, read INSTALL DOC 19 | 20 | 21 | *) To read the documentation use pyDoc. 22 | 23 | *) To generate HTML documentation use: 24 | 1) Go to doc dir 25 | 2) Use the command: pydoc -w PATH_TO_ISO8583_UNCOMPRESSED_DIR 26 | 3) That's it! 27 | 28 | 29 | ======================================================================== -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seedstars/python-iso8583/1aedc35eea5975218023a3917ce52d815f4762f6/TODO -------------------------------------------------------------------------------- /doc/ISO8583.ISO8583.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Python: module ISO8583.ISO8583 4 | 5 | 6 | 7 | 8 |
 
9 |  
ISO8583.ISO8583 (version 1.2)
index
c:\python25\lib\site-packages\iso8583\iso8583.py
12 |

(C) Copyright 2009 Igor V. Custodio
13 |  
14 | This program is free software: you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation, either version 3 of the License, or
17 | any later version.
18 |  
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 | GNU General Public License for more details.
23 |  
24 | You should have received a copy of the GNU General Public License
25 | along with this program.  If not, see <http://www.gnu.org/licenses/>.

26 |

27 | 28 | 29 | 31 | 32 | 33 |
 
30 | Modules
       
struct
34 |

35 | 36 | 37 | 39 | 40 | 41 |
 
38 | Classes
       
42 |
ISO8583 43 |
44 |

45 | 46 | 47 | 49 | 50 | 51 | 84 | 85 |
 
48 | class ISO8583
   Main Class to work with ISO8583 packages.
52 | Used to create, change, send, receive, parse or work with ISO8593 Package version 1993.
53 | It's 100% Python :)
54 | Enjoy it!
55 | Thanks to: Vulcanno IT Solutions <http://www.vulcanno.com.br>
56 | Licence: GPL Version 3
57 | More information: http://code.google.com/p/iso8583py/
58 |  
59 | Example:
60 |         from ISO8583.ISO8583 import ISO8583
61 |         from ISO8583.ISOErrors import *
62 |         
63 |         iso = ISO8583()
64 |         try:
65 |                 iso.setMTI('0800')
66 |                 iso.setBit(2,2)
67 |                 iso.setBit(4,4)
68 |                 iso.setBit(12,12)
69 |                 iso.setBit(21,21)
70 |                 iso.setBit(17,17)
71 |                 iso.setBit(49,986)
72 |                 iso.setBit(99,99)
73 |         except ValueToLarge, e:
74 |                         print ('Value too large :( %s' % e)
75 |         except InvalidMTI, i:
76 |                         print ('This MTI is wrong :( %s' % i)
77 |                         
78 |         print ('The Message Type Indication is = %s' %iso.getMTI()) 
79 |         
80 |         print ('The Bitmap is = %s' %iso.getBitmap()) 
81 |         iso.showIsoBits();
82 |         print ('This is the ISO8583 complete package %s' % iso.getRawIso())
83 |         print ('This is the ISO8583 complete package to sent over the TCPIP network %s' % iso.getNetworkISO())
 
 Methods defined here:
86 |
__cmp__(self, obj2)
Method that compare two objects in "==", "!=" and other things
87 | Example:
88 |         p1 = ISO8583()
89 |         p1.setMTI('0800')
90 |         p1.setBit(2,2)
91 |         p1.setBit(4,4)
92 |         p1.setBit(12,12)
93 |         p1.setBit(17,17)
94 |         p1.setBit(99,99)
95 |  
96 |         #get the rawIso and save in the iso variable
97 |         iso = p1.getRawIso()
98 |  
99 |         p2 = ISO8583()
100 |         p2.setIsoContent(iso)
101 |  
102 |         print 'Is equivalent?'
103 |         if p1 == p1:
104 |                 print ('Yes :)')
105 |         else:
106 |                 print ('Noooooooooo :(')
107 |  
108 | @param: obj2 -> object that will be compared
109 | @return: <0 if is not equal, 0 if is equal
110 | 111 |
__init__(self, iso='', debug=False)
Default Constructor of ISO8583 Package.
112 | It inicialize a "brand new" ISO8583 package
113 | Example: To Enable debug you can use:
114 |         pack = ISO8583(debug=True)
115 | @param: iso a String that represents the ASCII of the package. The same that you need to pass to setIsoContent() method.
116 | @param: debug (True or False) default False -> Used to print some debug infos. Only use if want that messages!
117 | 118 |
getBit(self, bit)
Return the value of the bit
119 | @param: bit -> the number of the bit that you want the value
120 | @raise: BitInexistent Exception, BitNotSet Exception
121 | 122 |
getBitLimit(self, bit)
Method that return the bit limit (Max size)
123 | @param: bit -> Bit that will be searched and whose limit will be returned
124 | @return: int that indicate the limit of the bit
125 | 126 |
getBitType(self, bit)
Method that return the bit Type
127 | @param: bit -> Bit that will be searched and whose type will be returned
128 | @return: str that represents the type of the bit
129 | 130 |
getBitValueType(self, bit)
Method that return the bit value type 
131 | @param: bit -> Bit that will be searched and whose value type will be returned
132 | @return: str that indicate the valuye type of the bit
133 | 134 |
getBitmap(self)
Method that return the ASCII Bitmap of the package
135 | @return: str -> with the ASCII Bitmap
136 | 137 |
getBitsAndValues(self)
Method that return an array of bits, values, types etc.
138 |         Each array value is a dictionary with: {'bit':X ,'type': Y, 'value': Z} Where:
139 |                 bit: is the bit number
140 |                 type: is the bit type
141 |                 value: is the bit value inside this object
142 |         so the Generic array returned is:  [ (...),{'bit':X,'type': Y, 'value': Z}, (...)] 
143 |         
144 | Example:
145 |         p1 = ISO8583()
146 |         p1.setMTI('0800')
147 |         p1.setBit(2,2)
148 |         p1.setBit(4,4)
149 |         p1.setBit(12,12)
150 |         p1.setBit(17,17)
151 |         p1.setBit(99,99)
152 |         
153 |         v1 = p1.getBitsAndValues()
154 |         for v in v1:
155 |                 print ('Bit %s of type %s with value = %s' % (v['bit'],v['type'],v['value']))
156 |  
157 | @return: array of values.
158 | 159 |
getLargeBitName(self, bit)
Method that return the large bit name
160 | @param: bit -> Bit that will be searched and whose name will be returned
161 | @return: str that represents the name of the bit
162 | 163 |
getMTI(self)
Method that return the MTI of the package
164 | @return: str -> with the MTI
165 | 166 |
getNetworkISO(self, bigEndian=True)
Method that return ISO8583 ASCII package with the size in the beginning
167 | By default, it return the package with size represented with big-endian.
168 | Is the same that:
169 |         import struct
170 |         (...)
171 |         iso = ISO8583()
172 |         iso.setBit(3,'300000')
173 |         (...)
174 |         ascii = iso.getRawIso()
175 |         # Example: big-endian
176 |         # To little-endian, replace '!h' with '<h'
177 |         netIso = struct.pack('!h',len(iso)) 
178 |         netIso += ascii
179 |         # Example: big-endian
180 |         # To little-endian, replace 'iso.getNetworkISO()' with 'iso.getNetworkISO(False)'
181 |         print ('This <%s> the same that <%s>' % (iso.getNetworkISO(),netIso))
182 |  
183 | @param: bigEndian (True|False) -> if you want that the size be represented in this way. 
184 | @return: size + ASCII ISO8583 package ready to go to the network!
185 | @raise: InvalidMTI Exception
186 | 187 |
getRawIso(self)
Method that return ISO8583 ASCII complete representation
188 | Example: 
189 | iso = ISO8583()
190 | iso.setMTI('0800')
191 | iso.setBit(2,2)
192 | iso.setBit(4,4)
193 | iso.setBit(12,12)
194 | iso.setBit(17,17)
195 | iso.setBit(99,99)
196 | str = iso.getRawIso()
197 | print ('This is the ASCII package %s' % str) 
198 | output (print) -> This is the ASCII package 0800d010800000000000000000002000000001200000000000400001200170299
199 |  
200 | @return: str with complete ASCII ISO8583
201 | @raise: InvalidMTI Exception
202 | 203 |
getValuesArray(self)
Method that return an internal array of the package
204 | @return: array -> with all bits, presents or not in the bitmap
205 | 206 |
redefineBit(self, bit, smallStr, largeStr, bitType, size, valueType)
Method that redefine a bit structure in global scope! 
207 | Can be used to personalize ISO8583 structure to another specification (ISO8583 1987 for example!)
208 | Hint: If you have a lot of "ValueToLarge Exception" maybe the especification that you are using is different of mine. So you will need to use this method :)
209 | @param: bit -> bit to be redefined
210 | @param: smallStr -> a small String representantion of the bit, used to build "user friendly prints", example "2" for bit 2
211 | @param: largeStr -> a large String representantion of the bit, used to build "user friendly prints" and to be used to inform the "main use of the bit", 
212 |         example "Primary account number (PAN)" for bit 2
213 | @param: bitType -> type the bit, used to build the values, example "LL" for bit 2. Need to be one of (B, N, AN, ANS, LL, LLL)   
214 | @param: size -> limit size the bit, used to build/complete the values, example "19" for bit 2.  
215 | @param: valueType -> value type the bit, used to "validate" the values, example "n" for bit 2. This mean that in bit 2 we need to have only numeric values.
216 |         Need to be one of (a, an, n, ansb, b)
217 | @raise: BitInexistent Exception, InvalidValueType Exception
218 | 219 |
setBit(self, bit, value)
Method used to set a bit with a value.
220 | It's one of the most important method to use when using this library
221 | @param: bit -> bit number that want to be setted
222 | @param: value -> the value of the bit
223 | @return: True/False default True -> To be used in the future!
224 | @raise: BitInexistent Exception, ValueToLarge Exception
225 | 226 |
setIsoContent(self, iso)
Method that receive a complete ISO8583 string (ASCII) understand it and remove the bits values
227 | Example:
228 |         iso = '0210B238000102C080040000000000000002100000000000001700010814465469421614465701081100301000000N399915444303500019991544986020   Value not allowed009000095492'
229 |         i2 = ISO8583()
230 |         # in this case, we need to redefine a bit because default bit 42 is LL and in this especification is "N"
231 |         # the rest remain, so we use "get" :)
232 |         i2.redefineBit(42, '42', i2.getLargeBitName(42), 'N', i2.getBitLimit(42), i2.getBitValueType(42) )
233 |         i2.setIsoContent(iso2)
234 |         print 'Bitmap = %s' %i2.getBitmap() 
235 |         print 'MTI = %s' %i2.getMTI() 
236 |  
237 |         print 'This ISO has bits:'
238 |         v3 = i2.getBitsAndValues()
239 |         for v in v3:
240 |                 print ('Bit %s of type %s with value = %s' % (v['bit'],v['type'],v['value']))
241 |                 
242 | @param: str -> complete ISO8583 string
243 | @raise: InvalidIso8583 Exception
244 | 245 |
setMTI(self, type)
Method that set Transation Type (MTI) 
246 | In fact, is an alias to "setTransationType" method
247 | @param: type -> MTI to be setted
248 | 249 |
setNetworkISO(self, iso, bigEndian=True)
Method that receive sie + ASCII ISO8583 package and transfor it in the ISO8583 object.
250 | By default, it recieve the package with size represented with big-endian.
251 | Is the same that:
252 | import struct
253 | (...)
254 | iso = ISO8583()
255 | iso.setBit(3,'300000')
256 | (...)
257 | # Example: big-endian
258 | # To little-endian, replace 'iso.getNetworkISO()' with 'iso.getNetworkISO(False)'
259 | netIso = iso.getNetworkISO()
260 | newIso = ISO8583()
261 | # Example: big-endian
262 | # To little-endian, replace 'newIso.setNetworkISO()' with 'newIso.setNetworkISO(False)'
263 | newIso.setNetworkISO(netIso)
264 | #Is the same that:
265 | #size = netIso[0:2]
266 | ## To little-endian, replace '!h' with '<h'
267 | #size = struct.unpack('!h',size )
268 | #newIso.setIsoContent(netIso[2:size])
269 | arr = newIso.getBitsAndValues()
270 | for v in arr:
271 |         print ('Bit %s Type %s Value = %s' % (v['bit'],v['type'],v['value']))
272 |  
273 | @param: iso -> str that represents size + ASCII ISO8583 package
274 | @param: bigEndian (True|False) -> Codification of the size.
275 | @raise: InvalidIso8583 Exception
276 | 277 |
setTransationType(self, type)
Method that set Transation Type (MTI)
278 | @param: type -> MTI to be setted
279 | @raise: ValueToLarge Exception
280 | 281 |
showBitmap(self)
Method that print the bitmap in ASCII form
282 | Hint: Try to use getBitmap method and format your own print :)
283 | 284 |
showBitsFromBitmapStr(self, bitmap)
Method that receive a bitmap str, process it, and print a array with bits this bitmap string represents.
285 | Usualy is used to debug things.
286 | @param: bitmap -> bitmap str to be analized and translated to "bits"
287 | 288 |
showIsoBits(self)
Method that show in detail a list of bits , values and types inside the object
289 | Example: output to
290 |         (...)
291 |         iso.setBit(2,2)
292 |         iso.setBit(4,4)
293 |         (...)
294 |         iso.showIsoBits()
295 |         (...)
296 |         Bit[2] of type LL has limit 19 = 012
297 |         Bit[4] of type N has limit 12 = 000000000004
298 |         (...)
299 | 300 |
showRawIso(self)
Method that print ISO8583 ASCII complete representation
301 | Example: 
302 | iso = ISO8583()
303 | iso.setMTI('0800')
304 | iso.setBit(2,2)
305 | iso.setBit(4,4)
306 | iso.setBit(12,12)
307 | iso.setBit(17,17)
308 | iso.setBit(99,99)
309 | iso.showRawIso()
310 | output (print) -> 0800d010800000000000000000002000000001200000000000400001200170299
311 | Hint: Try to use getRawIso method and format your own print :)
312 | 313 |

314 | 315 | 316 | 318 | 319 | 320 |
 
317 | Data
       __author__ = 'Igor Vitorio Custodio <igorvc@vulcanno.com.br>'
321 | __licence__ = 'GPL V3'
322 | __version__ = '1.2'

323 | 324 | 325 | 327 | 328 | 329 |
 
326 | Author
       Igor Vitorio Custodio <igorvc@vulcanno.com.br>
330 | -------------------------------------------------------------------------------- /doc/ISO8583.ISOErrors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Python: module ISO8583.ISOErrors 4 | 5 | 6 | 7 | 8 |
 
9 |  
ISO8583.ISOErrors
index
c:\python25\lib\site-packages\iso8583\isoerrors.py
12 |

(C) Copyright 2009 Igor V. Custodio
13 |  
14 | This program is free software: you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation, either version 3 of the License, or
17 | any later version.
18 |  
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 | GNU General Public License for more details.
23 |  
24 | You should have received a copy of the GNU General Public License
25 | along with this program.  If not, see <http://www.gnu.org/licenses/>.

26 |

27 | 28 | 29 | 31 | 32 | 33 |
 
30 | Classes
       
34 |
exceptions.Exception(exceptions.BaseException) 35 |
36 |
37 |
BitInexistent 38 |
BitNotSet 39 |
InvalidBitType 40 |
InvalidIso8583 41 |
InvalidMTI 42 |
InvalidValueType 43 |
ValueToLarge 44 |
45 |
46 |
47 |

48 | 49 | 50 | 52 | 53 | 54 | 56 | 57 |
 
51 | class BitInexistent(exceptions.Exception)
   Exeption that indicate that a bit that you try to manage dosen't exist!
55 | Try to check your "setBit". Remember that ISO8583 1993 has only bits from 1 to 128!
 
 
Method resolution order:
58 |
BitInexistent
59 |
exceptions.Exception
60 |
exceptions.BaseException
61 |
__builtin__.object
62 |
63 |
64 | Methods defined here:
65 |
__init__(self, value)
66 | 67 |
__str__(self)
68 | 69 |
70 | Data descriptors defined here:
71 |
__weakref__
72 |
list of weak references to the object (if defined)
73 |
74 |
75 | Data and other attributes inherited from exceptions.Exception:
76 |
__new__ = <built-in method __new__ of type object at 0x000000001E25A4C0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
77 | 78 |
79 | Methods inherited from exceptions.BaseException:
80 |
__delattr__(...)
x.__delattr__('name') <==> del x.name
81 | 82 |
__getattribute__(...)
x.__getattribute__('name') <==> x.name
83 | 84 |
__getitem__(...)
x.__getitem__(y) <==> x[y]
85 | 86 |
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
87 |  
88 | Use of negative indices is not supported.
89 | 90 |
__reduce__(...)
91 | 92 |
__repr__(...)
x.__repr__() <==> repr(x)
93 | 94 |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
95 | 96 |
__setstate__(...)
97 | 98 |
99 | Data descriptors inherited from exceptions.BaseException:
100 |
__dict__
101 |
102 |
args
103 |
104 |
message
105 |
exception message
106 |
107 |

108 | 109 | 110 | 112 | 113 | 114 | 115 | 116 |
 
111 | class BitNotSet(exceptions.Exception)
   Exception that indicate that you try to access a bit not present in the bitmap.
 
 
Method resolution order:
117 |
BitNotSet
118 |
exceptions.Exception
119 |
exceptions.BaseException
120 |
__builtin__.object
121 |
122 |
123 | Methods defined here:
124 |
__init__(self, value)
125 | 126 |
__str__(self)
127 | 128 |
129 | Data descriptors defined here:
130 |
__weakref__
131 |
list of weak references to the object (if defined)
132 |
133 |
134 | Data and other attributes inherited from exceptions.Exception:
135 |
__new__ = <built-in method __new__ of type object at 0x000000001E25A4C0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
136 | 137 |
138 | Methods inherited from exceptions.BaseException:
139 |
__delattr__(...)
x.__delattr__('name') <==> del x.name
140 | 141 |
__getattribute__(...)
x.__getattribute__('name') <==> x.name
142 | 143 |
__getitem__(...)
x.__getitem__(y) <==> x[y]
144 | 145 |
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
146 |  
147 | Use of negative indices is not supported.
148 | 149 |
__reduce__(...)
150 | 151 |
__repr__(...)
x.__repr__() <==> repr(x)
152 | 153 |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
154 | 155 |
__setstate__(...)
156 | 157 |
158 | Data descriptors inherited from exceptions.BaseException:
159 |
__dict__
160 |
161 |
args
162 |
163 |
message
164 |
exception message
165 |
166 |

167 | 168 | 169 | 171 | 172 | 173 | 176 | 177 |
 
170 | class InvalidBitType(exceptions.Exception)
   Exception that indicate that the type that you try to set is invalid.
174 | For example: You try to set type "X", that dosen't exist.
175 | Valid type are: B, N, A, AN, ANS, LL, LLL
 
 
Method resolution order:
178 |
InvalidBitType
179 |
exceptions.Exception
180 |
exceptions.BaseException
181 |
__builtin__.object
182 |
183 |
184 | Methods defined here:
185 |
__init__(self, value)
186 | 187 |
__str__(self)
188 | 189 |
190 | Data descriptors defined here:
191 |
__weakref__
192 |
list of weak references to the object (if defined)
193 |
194 |
195 | Data and other attributes inherited from exceptions.Exception:
196 |
__new__ = <built-in method __new__ of type object at 0x000000001E25A4C0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
197 | 198 |
199 | Methods inherited from exceptions.BaseException:
200 |
__delattr__(...)
x.__delattr__('name') <==> del x.name
201 | 202 |
__getattribute__(...)
x.__getattribute__('name') <==> x.name
203 | 204 |
__getitem__(...)
x.__getitem__(y) <==> x[y]
205 | 206 |
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
207 |  
208 | Use of negative indices is not supported.
209 | 210 |
__reduce__(...)
211 | 212 |
__repr__(...)
x.__repr__() <==> repr(x)
213 | 214 |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
215 | 216 |
__setstate__(...)
217 | 218 |
219 | Data descriptors inherited from exceptions.BaseException:
220 |
__dict__
221 |
222 |
args
223 |
224 |
message
225 |
exception message
226 |
227 |

228 | 229 | 230 | 232 | 233 | 234 | 235 | 236 |
 
231 | class InvalidIso8583(exceptions.Exception)
   Exception that indicate a invalid ASCII message, for example, without a piece... Error size etc.
 
 
Method resolution order:
237 |
InvalidIso8583
238 |
exceptions.Exception
239 |
exceptions.BaseException
240 |
__builtin__.object
241 |
242 |
243 | Methods defined here:
244 |
__init__(self, value)
245 | 246 |
__str__(self)
247 | 248 |
249 | Data descriptors defined here:
250 |
__weakref__
251 |
list of weak references to the object (if defined)
252 |
253 |
254 | Data and other attributes inherited from exceptions.Exception:
255 |
__new__ = <built-in method __new__ of type object at 0x000000001E25A4C0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
256 | 257 |
258 | Methods inherited from exceptions.BaseException:
259 |
__delattr__(...)
x.__delattr__('name') <==> del x.name
260 | 261 |
__getattribute__(...)
x.__getattribute__('name') <==> x.name
262 | 263 |
__getitem__(...)
x.__getitem__(y) <==> x[y]
264 | 265 |
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
266 |  
267 | Use of negative indices is not supported.
268 | 269 |
__reduce__(...)
270 | 271 |
__repr__(...)
x.__repr__() <==> repr(x)
272 | 273 |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
274 | 275 |
__setstate__(...)
276 | 277 |
278 | Data descriptors inherited from exceptions.BaseException:
279 |
__dict__
280 |
281 |
args
282 |
283 |
message
284 |
exception message
285 |
286 |

287 | 288 | 289 | 291 | 292 | 293 | 294 | 295 |
 
290 | class InvalidMTI(exceptions.Exception)
   Exception that indicate a invalid MTI
 
 
Method resolution order:
296 |
InvalidMTI
297 |
exceptions.Exception
298 |
exceptions.BaseException
299 |
__builtin__.object
300 |
301 |
302 | Methods defined here:
303 |
__init__(self, value)
304 | 305 |
__str__(self)
306 | 307 |
308 | Data descriptors defined here:
309 |
__weakref__
310 |
list of weak references to the object (if defined)
311 |
312 |
313 | Data and other attributes inherited from exceptions.Exception:
314 |
__new__ = <built-in method __new__ of type object at 0x000000001E25A4C0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
315 | 316 |
317 | Methods inherited from exceptions.BaseException:
318 |
__delattr__(...)
x.__delattr__('name') <==> del x.name
319 | 320 |
__getattribute__(...)
x.__getattribute__('name') <==> x.name
321 | 322 |
__getitem__(...)
x.__getitem__(y) <==> x[y]
323 | 324 |
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
325 |  
326 | Use of negative indices is not supported.
327 | 328 |
__reduce__(...)
329 | 330 |
__repr__(...)
x.__repr__() <==> repr(x)
331 | 332 |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
333 | 334 |
__setstate__(...)
335 | 336 |
337 | Data descriptors inherited from exceptions.BaseException:
338 |
__dict__
339 |
340 |
args
341 |
342 |
message
343 |
exception message
344 |
345 |

346 | 347 | 348 | 350 | 351 | 352 | 356 | 357 |
 
349 | class InvalidValueType(exceptions.Exception)
   Exeption that indicate that a value that you try to insert is out of especification.
353 | For example: You try to insert a value "ABC" in a bit of type "N" (Number) , this is invalid!
354 | This can happen when you have a different specification of mine.
355 | If this is the case, you should use "ISO8583.redefineBit()" method and redefine the type.
 
 
Method resolution order:
358 |
InvalidValueType
359 |
exceptions.Exception
360 |
exceptions.BaseException
361 |
__builtin__.object
362 |
363 |
364 | Methods defined here:
365 |
__init__(self, value)
366 | 367 |
__str__(self)
368 | 369 |
370 | Data descriptors defined here:
371 |
__weakref__
372 |
list of weak references to the object (if defined)
373 |
374 |
375 | Data and other attributes inherited from exceptions.Exception:
376 |
__new__ = <built-in method __new__ of type object at 0x000000001E25A4C0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
377 | 378 |
379 | Methods inherited from exceptions.BaseException:
380 |
__delattr__(...)
x.__delattr__('name') <==> del x.name
381 | 382 |
__getattribute__(...)
x.__getattribute__('name') <==> x.name
383 | 384 |
__getitem__(...)
x.__getitem__(y) <==> x[y]
385 | 386 |
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
387 |  
388 | Use of negative indices is not supported.
389 | 390 |
__reduce__(...)
391 | 392 |
__repr__(...)
x.__repr__() <==> repr(x)
393 | 394 |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
395 | 396 |
__setstate__(...)
397 | 398 |
399 | Data descriptors inherited from exceptions.BaseException:
400 |
__dict__
401 |
402 |
args
403 |
404 |
message
405 |
exception message
406 |
407 |

408 | 409 | 410 | 412 | 413 | 414 | 417 | 418 |
 
411 | class ValueToLarge(exceptions.Exception)
   Exeption that indicate that a value that want to set inside the bit is large than the "ISO" limit.
415 | This can happen when you have a different specification of mine.
416 | If this is the case, you should use "ISO8583.redefineBit()" method and redefine the limit.
 
 
Method resolution order:
419 |
ValueToLarge
420 |
exceptions.Exception
421 |
exceptions.BaseException
422 |
__builtin__.object
423 |
424 |
425 | Methods defined here:
426 |
__init__(self, value)
427 | 428 |
__str__(self)
429 | 430 |
431 | Data descriptors defined here:
432 |
__weakref__
433 |
list of weak references to the object (if defined)
434 |
435 |
436 | Data and other attributes inherited from exceptions.Exception:
437 |
__new__ = <built-in method __new__ of type object at 0x000000001E25A4C0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
438 | 439 |
440 | Methods inherited from exceptions.BaseException:
441 |
__delattr__(...)
x.__delattr__('name') <==> del x.name
442 | 443 |
__getattribute__(...)
x.__getattribute__('name') <==> x.name
444 | 445 |
__getitem__(...)
x.__getitem__(y) <==> x[y]
446 | 447 |
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
448 |  
449 | Use of negative indices is not supported.
450 | 451 |
__reduce__(...)
452 | 453 |
__repr__(...)
x.__repr__() <==> repr(x)
454 | 455 |
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
456 | 457 |
__setstate__(...)
458 | 459 |
460 | Data descriptors inherited from exceptions.BaseException:
461 |
__dict__
462 |
463 |
args
464 |
465 |
message
466 |
exception message
467 |
468 |

469 | -------------------------------------------------------------------------------- /doc/ISO8583.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Python: package ISO8583 4 | 5 | 6 | 7 | 8 |
 
9 |  
ISO8583
index
c:\python25\lib\site-packages\iso8583\__init__.py
12 |

(C) Copyright 2009 Igor V. Custodio
13 |  
14 | This program is free software: you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation, either version 3 of the License, or
17 | any later version.
18 |  
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 | GNU General Public License for more details.
23 |  
24 | You should have received a copy of the GNU General Public License
25 | along with this program.  If not, see <http://www.gnu.org/licenses/>.

26 |

27 | 28 | 29 | 31 | 32 | 33 |
 
30 | Package Contents
       
ISO8583
34 |
ISOErrors
35 |
36 | -------------------------------------------------------------------------------- /examples/echoClient.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ 19 | 20 | 21 | from ISO8583.ISO8583 import ISO8583 22 | from ISO8583.ISOErrors import * 23 | import socket 24 | import sys 25 | import time 26 | 27 | 28 | # Configure the client 29 | serverIP = "192.168.0.103" 30 | serverPort = 8583 31 | numberEcho = 5 32 | timeBetweenEcho = 5 # in seconds 33 | 34 | bigEndian = True 35 | #bigEndian = False 36 | 37 | s = None 38 | for res in socket.getaddrinfo(serverIP, serverPort, socket.AF_UNSPEC, socket.SOCK_STREAM): 39 | af, socktype, proto, canonname, sa = res 40 | try: 41 | s = socket.socket(af, socktype, proto) 42 | except socket.error, msg: 43 | s = None 44 | continue 45 | try: 46 | s.connect(sa) 47 | except socket.error, msg: 48 | s.close() 49 | s = None 50 | continue 51 | break 52 | if s is None: 53 | print ('Could not connect :(') 54 | sys.exit(1) 55 | 56 | 57 | 58 | for req in range(0,numberEcho): 59 | iso = ISO8583() 60 | iso.setMTI('0800') 61 | iso.setBit(3,'300000') 62 | iso.setBit(24,'045') 63 | iso.setBit(41,'11111111') 64 | iso.setBit(42,'222222222222222') 65 | iso.setBit(63,'This is a Test Message') 66 | if bigEndian: 67 | try: 68 | message = iso.getNetworkISO() 69 | s.send(message) 70 | print ('Sending ... %s' % message) 71 | ans = s.recv(2048) 72 | print ("\nInput ASCII |%s|" % ans) 73 | isoAns = ISO8583() 74 | isoAns.setNetworkISO(ans) 75 | v1 = isoAns.getBitsAndValues() 76 | for v in v1: 77 | print ('Bit %s of type %s with value = %s' % (v['bit'],v['type'],v['value'])) 78 | 79 | if isoAns.getMTI() == '0810': 80 | print ("\tThat's great !!! The server understand my message !!!") 81 | else: 82 | print ("The server dosen't understand my message!") 83 | 84 | except InvalidIso8583, ii: 85 | print ii 86 | break 87 | 88 | 89 | time.sleep(timeBetweenEcho) 90 | 91 | else: 92 | try: 93 | message = iso.getNetworkISO(False) 94 | s.send(message) 95 | print ('Sending ... %s' % message) 96 | ans = s.recv(2048) 97 | print ("\nInput ASCII |%s|" % ans) 98 | isoAns = ISO8583() 99 | isoAns.setNetworkISO(ans,False) 100 | v1 = isoAns.getBitsAndValues() 101 | for v in v1: 102 | print ('Bit %s of type %s with value = %s' % (v['bit'],v['type'],v['value'])) 103 | 104 | if isoAns.getMTI() == '0810': 105 | print ("\tThat's great !!! The server understand my message !!!") 106 | else: 107 | print ("The server dosen't understand my message!") 108 | 109 | except InvalidIso8583, ii: 110 | print ii 111 | break 112 | 113 | time.sleep(timeBetweenEcho) 114 | 115 | 116 | 117 | print ('Closing...') 118 | s.close() 119 | -------------------------------------------------------------------------------- /examples/echoServer.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ 19 | 20 | 21 | from ISO8583.ISO8583 import ISO8583 22 | from ISO8583.ISOErrors import * 23 | from socket import * 24 | 25 | # Configure the server 26 | serverIP = "192.168.0.103" 27 | serverPort = 8583 28 | maxConn = 5 29 | bigEndian = True 30 | #bigEndian = False 31 | 32 | 33 | # Create a TCP socket 34 | s = socket(AF_INET, SOCK_STREAM) 35 | # bind it to the server port 36 | s.bind((serverIP, serverPort)) 37 | # Configure it to accept up to N simultaneous Clients waiting... 38 | s.listen(maxConn) 39 | 40 | 41 | # Run forever 42 | while 1: 43 | #wait new Client Connection 44 | connection, address = s.accept() 45 | while 1: 46 | # receive message 47 | isoStr = connection.recv(2048) 48 | if isoStr: 49 | print ("\nInput ASCII |%s|" % isoStr) 50 | pack = ISO8583() 51 | #parse the iso 52 | try: 53 | if bigEndian: 54 | pack.setNetworkISO(isoStr) 55 | else: 56 | pack.setNetworkISO(isoStr,False) 57 | 58 | v1 = pack.getBitsAndValues() 59 | for v in v1: 60 | print ('Bit %s of type %s with value = %s' % (v['bit'],v['type'],v['value'])) 61 | 62 | if pack.getMTI() == '0800': 63 | print ("\tThat's great !!! The client send a correct message !!!") 64 | else: 65 | print ("The client dosen't send the correct message!") 66 | break 67 | 68 | 69 | except InvalidIso8583, ii: 70 | print ii 71 | break 72 | except: 73 | print ('Something happened!!!!') 74 | break 75 | 76 | #send answer 77 | pack.setMTI('0810') 78 | 79 | if bigEndian: 80 | ans = pack.getNetworkISO() 81 | else: 82 | ans = pack.getNetworkISO(False) 83 | 84 | print ('Sending answer %s' % ans) 85 | connection.send(ans) 86 | 87 | else: 88 | break 89 | # close socket 90 | connection.close() 91 | print ("Closed...") -------------------------------------------------------------------------------- /examples/example1.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ 19 | 20 | from ISO8583.ISO8583 import ISO8583 21 | from ISO8583.ISOErrors import * 22 | import traceback 23 | 24 | #Clean the shell 25 | import os 26 | os.system(['clear','cls'][os.name == 'nt']) 27 | 28 | # get new object 29 | p = ISO8583() 30 | #some string describing the transation type 31 | transation = "200" 32 | print ('Setting transation type to %s' % transation) 33 | p.setTransationType(transation) 34 | # Is the same that: 35 | #p.setMTI(transation) 36 | 37 | #Some tests and 38 | print ('Setting bits') 39 | 40 | p.setBit(3,"100000") 41 | p.setBit(4,1200) 42 | p.setBit(7,"1207231505") 43 | p.setBit(11,12) 44 | p.setBit(12,"231505") 45 | p.setBit(13,1207) 46 | p.setBit(32,"01020000000") 47 | p.setBit(40,"002") 48 | p.setBit(41,"98765432") 49 | p.setBit(42,"303500098765432") 50 | p.setBit(49,986) 51 | p.setBit(62,"PP16814995840013560000") 52 | p.setBit(63,"00000105") 53 | try: 54 | p.setBit(126,"00000000000000105") 55 | except ValueToLarge: 56 | print ('\t\tSomething happening!!!! The Exception! So, bit 126 is not set!!!!') 57 | #if want more information ... 58 | #traceback.print_exc() 59 | 60 | #show hex bitmap 61 | print ('Bitmap in HEX') 62 | p.showBitmap() 63 | 64 | #Show bits 65 | print ('Bits with values') 66 | p.showIsoBits() 67 | 68 | # Show raw ASCII ISO 69 | print ('The package is -> ') 70 | p.showRawIso() 71 | 72 | # Getting bits... 73 | print ('\n\n\n------------------------------------------\n') 74 | 75 | print ('Getting bits') 76 | try: 77 | print ('Bit 7 is there? %s' % p.getBit(7)) 78 | print ('Bit 32 is there? %s' % p.getBit(32)) 79 | except: 80 | print ('Something is bad...') 81 | 82 | # Testing exceptions... 83 | try: 84 | print ('Bit 45 is there? %s' % p.getBit(45)) 85 | except: 86 | print ("No, this bit is not there :)") 87 | 88 | try: 89 | print ('Bit 27 is there? %s' % p.getBit(27)) 90 | except BitNotSet, bns: 91 | print bns 92 | 93 | 94 | #More exceptions... 95 | print ('\n\n\n------------------------------------------\n') 96 | print ('Exceptions....') 97 | 98 | iso = ISO8583() 99 | try: 100 | iso.setMTI('0800') 101 | iso.setBit(2,2) 102 | iso.setBit(4,4) 103 | iso.setBit(12,12) 104 | iso.setBit(21,21) 105 | iso.setBit(17,17) 106 | iso.setBit(49,9861) # this bit is wrong ... 107 | iso.setBit(99,99) 108 | except ValueToLarge, e: 109 | print ('Value too large :( %s' % e) 110 | except InvalidMTI, i: 111 | print ('This MTI is wrong :( %s' % i) 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /examples/example2.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ 19 | 20 | 21 | from ISO8583.ISO8583 import ISO8583 22 | from ISO8583.ISOErrors import * 23 | 24 | import traceback 25 | 26 | import os 27 | os.system(['clear','cls'][os.name == 'nt']) 28 | 29 | # Testing some funcionalities 30 | p2 = ISO8583() 31 | p2.setMTI('0800') 32 | p2.setBit(2,2) 33 | p2.setBit(4,4) 34 | p2.setBit(12,12) 35 | p2.setBit(17,17) 36 | p2.setBit(99,99) 37 | 38 | print ('The MTI is = %s' %p2.getMTI()) 39 | print ('The Bitmap is = %s' %p2.getBitmap()) 40 | 41 | #Showing bits... 42 | p2.showIsoBits(); 43 | 44 | #Save the ASCII ISO value without size 45 | iso = p2.getRawIso() 46 | 47 | print ('\n\n\n------------------------------------------\n') 48 | print ('This is the ISO <%s> that will be interpreted' % iso) 49 | 50 | # New ISO 51 | i = ISO8583() 52 | # Set the ASCII 53 | i.setIsoContent(iso) 54 | 55 | # Showing that everything is ok 56 | print ('The MTI is = %s' %i.getMTI()) 57 | print ('The Bitmap is = %s' %i.getBitmap()) 58 | print ('Show bits inside the package') 59 | i.showIsoBits() 60 | 61 | # Using == to compare ISOS's 62 | print ('Compare ISOs ...') 63 | if i == p2: 64 | print ('They are equivalent!') 65 | 66 | else: 67 | print ('The are differente') 68 | 69 | # More example... 70 | print ('\n\n\n------------------------------------------\n') 71 | 72 | i3=ISO8583() 73 | i3.setMTI('0800') 74 | i3.setBit(3,'300000') 75 | i3.setBit(24,'045') 76 | i3.setBit(41,'11111111') 77 | i3.setBit(42,'222222222222222') 78 | i3.setBit(63,'123testing') 79 | 80 | i3.showIsoBits() 81 | 82 | print ('This is the pack %s' %i3.getRawIso()) 83 | 84 | 85 | -------------------------------------------------------------------------------- /examples/example3.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ 19 | 20 | from ISO8583.ISO8583 import ISO8583 21 | from ISO8583.ISOErrors import * 22 | 23 | import traceback 24 | 25 | import os 26 | os.system(['clear','cls'][os.name == 'nt']) 27 | 28 | #Enable Debug Information 29 | # It's print a lot of information ... So only use if you are developping the library! 30 | p2 = ISO8583(debug=True) 31 | p2.setMTI('0800') 32 | p2.setBit(2,2) 33 | p2.setBit(4,4) 34 | p2.setBit(12,12) 35 | p2.setBit(21,21) 36 | p2.setBit(17,17) 37 | p2.setBit(49,986) 38 | p2.setBit(99,99) 39 | print ('MTI = %s' %p2.getMTI()) 40 | print ('Bitmap = %s' %p2.getBitmap()) 41 | p2.showIsoBits(); 42 | 43 | 44 | iso = p2.getRawIso() 45 | #Show debug information of the parsing function 46 | print ('\n\n\n------------------------------------------\n') 47 | print ('Parsing ... <%s> ' % iso) 48 | 49 | 50 | i = ISO8583() 51 | i.setIsoContent(iso) 52 | #Show information ... to compare 53 | print ('MTI = %s' %i.getMTI()) 54 | print ('Bitmap = %s' %i.getBitmap()) 55 | print ('Here we have bits') 56 | i.showIsoBits() 57 | 58 | 59 | print ('This is the bits and values (1)') 60 | v1 = p2.getBitsAndValues() 61 | print ('\n%s\n' %v1) 62 | 63 | print ('This is the bits and values (2)') 64 | v2 = i.getBitsAndValues() 65 | print ('\n%s\n' %v2) 66 | 67 | print ('One way of printing the information ...!') 68 | for v in v1: 69 | print ('Bit %s of type %s has value = %s' % (v['bit'],v['type'],v['value'])) 70 | 71 | 72 | print ('Another way...') 73 | for v in range(0,len(v2)): 74 | print ('Bit %s of type %s has value = %s' % (v2[v]['bit'],v2[v]['type'],v2[v]['value'])) 75 | 76 | 77 | -------------------------------------------------------------------------------- /examples/example4.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | (C) Copyright 2009 Igor V. Custodio 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | """ 19 | 20 | from ISO8583.ISO8583 import ISO8583 21 | from ISO8583.ISOErrors import * 22 | 23 | import traceback 24 | 25 | import os 26 | os.system(['clear','cls'][os.name == 'nt']) 27 | 28 | 29 | ''' 30 | 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 0123456789012345 31 | ----------------------------------------------- ---------------- 32 | 00 30 32 31 30 42 32 33 38 30 30 30 31 30 32 43 30 0210B238000102C0 33 | 01 38 30 30 34 30 30 30 30 30 30 30 30 30 30 30 30 8004000000000000 34 | 02 30 30 30 32 31 30 30 30 30 30 30 30 30 30 30 30 0002100000000000 35 | 03 30 30 31 37 30 30 30 31 30 38 31 34 34 36 35 34 0017000108144654 36 | 04 36 39 34 32 31 36 31 34 34 36 35 37 30 31 30 38 6942161446570108 37 | 05 31 31 30 30 33 30 31 30 30 30 30 30 30 4e 33 39 1100301000000N39 38 | 06 39 39 31 35 34 34 34 33 30 33 35 30 30 30 31 39 9915444303500019 39 | 07 39 39 31 35 34 34 39 38 36 30 32 30 20 56 61 6c 991544986020 Val 40 | 08 6f 72 20 6e 61 6f 20 70 65 72 6d 69 74 69 21 21 ue not allowed!! 41 | 09 30 30 39 30 30 30 30 39 35 34 39 32 009000095492 42 | 43 | ''' 44 | #i2 = ISO8583(debug=True) 45 | i2 = ISO8583() 46 | 47 | iso2 = '0210B238000102C080040000000000000002100000000000001700010814465469421614465701081100301000000N399915444303500019991544986020 Value not allowed!!009000095492' 48 | print ('\n\n\n------------------------------------------\n') 49 | print ('This is the ISO <%s> parse it!' % iso2) 50 | 51 | i2.setIsoContent(iso2) 52 | print ('Bitmap = %s' %i2.getBitmap()) 53 | print ('MTI = %s' %i2.getMTI()) 54 | 55 | print ('Bits') 56 | v3 = i2.getBitsAndValues() 57 | for v in v3: 58 | print ('(1) Bit %s of type %s and value = %s' % (v['bit'],v['type'],v['value'])) 59 | 60 | 61 | # in this case, we need to redefine a bit because default bit 42 is A and in this especification is "N" 62 | # the rest remain, so we use get's to copy original values :) 63 | i2.redefineBit(42, '42', i2.getLargeBitName(42), 'N', i2.getBitLimit(42), i2.getBitValueType(42) ) 64 | print ('\nBit 42 redefined...\n') 65 | 66 | i3 = ISO8583(iso=iso2) 67 | print ('Bitmap = %s' %i3.getBitmap()) 68 | print ('MTI = %s' %i3.getMTI()) 69 | 70 | print ('Bits inside') 71 | v4 = i3.getBitsAndValues() 72 | for v in v4: 73 | print ('(2) Bit %s of type %s and value = %s' % (v['bit'],v['type'],v['value'])) 74 | 75 | 76 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from distutils.core import setup 4 | 5 | setup(name='ISO8583-Module', 6 | version='1.3', 7 | description='ISO8583 LIBRARY', 8 | author='Igor V. Custodio', 9 | author_email='igorvc@vulcanno.com.br', 10 | url='http://www.vulcanno.com.br/python', 11 | download_url='http://code.google.com/p/iso8583py/downloads/list', 12 | packages=['ISO8583'], 13 | classifiers=[ 14 | 'Development Status :: 5 - Production/Stable', 15 | 'Environment :: Console', 16 | 'Intended Audience :: Financial and Insurance Industry', 17 | 'Intended Audience :: Telecommunications Industry', 18 | 'Intended Audience :: Developers', 19 | 'License :: OSI Approved :: GNU General Public License (GPL)', 20 | 'Operating System :: OS Independent', 21 | 'Operating System :: Microsoft', 22 | 'Operating System :: POSIX :: Linux', 23 | 'Operating System :: Unix', 24 | 'Operating System :: MacOS', 25 | 'Programming Language :: Python', 26 | 'Topic :: Office/Business :: Financial', 27 | 'Topic :: Office/Business :: Financial :: Point-Of-Sale', 28 | 'Topic :: Communications', 29 | 'Natural Language :: Arabic', 30 | 'Natural Language :: Bulgarian', 31 | 'Natural Language :: Catalan', 32 | 'Natural Language :: Chinese (Simplified)', 33 | 'Natural Language :: Chinese (Traditional)', 34 | 'Natural Language :: Czech', 35 | 'Natural Language :: Danish', 36 | 'Natural Language :: Dutch', 37 | 'Natural Language :: English', 38 | 'Natural Language :: Esperanto', 39 | 'Natural Language :: Finnish', 40 | 'Natural Language :: French', 41 | 'Natural Language :: German', 42 | 'Natural Language :: Greek', 43 | 'Natural Language :: Hebrew', 44 | 'Natural Language :: Hungarian', 45 | 'Natural Language :: Indonesian', 46 | 'Natural Language :: Italian', 47 | 'Natural Language :: Japanese', 48 | 'Natural Language :: Korean', 49 | 'Natural Language :: Latvian', 50 | 'Natural Language :: Marathi', 51 | 'Natural Language :: Persian', 52 | 'Natural Language :: Polish', 53 | 'Natural Language :: Portuguese', 54 | 'Natural Language :: Portuguese (Brazilian)', 55 | 'Natural Language :: Romanian', 56 | 'Natural Language :: Russian', 57 | 'Natural Language :: Slovak', 58 | 'Natural Language :: Spanish', 59 | 'Natural Language :: Swedish', 60 | 'Natural Language :: Telugu', 61 | 'Natural Language :: Thai', 62 | 'Natural Language :: Turkish', 63 | 'Natural Language :: Ukranian', 64 | 'Natural Language :: Vietnamese ', 65 | 'Programming Language :: Python :: 2.5', 66 | 'Programming Language :: Python :: 2.6', 67 | 'Programming Language :: Python :: 2.7', 68 | 'Programming Language :: Python :: 3', 69 | 'Programming Language :: Python :: 3.0', 70 | 'Programming Language :: Python :: 3.1', 71 | 'Programming Language :: Python :: 3.2' 72 | 73 | ] 74 | ) 75 | 76 | --------------------------------------------------------------------------------