Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #46 from adelosa/feature/deprecate
Browse files Browse the repository at this point in the history
Deprecation of module -> move to cardutil
  • Loading branch information
adelosa committed Mar 9, 2020
2 parents 35d491f + 92fcbe8 commit c51d8f2
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -4,9 +4,9 @@ language: python

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "pypy"

# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
Expand All @@ -15,7 +15,7 @@ install:
- "pip install -r requirements.txt"

# command to run tests, e.g. python setup.py test
script:
script:
- python setup.py install
- coverage run --source=mciutil setup.py test

Expand Down
29 changes: 29 additions & 0 deletions README.rst
Expand Up @@ -17,6 +17,35 @@ Set of command line utilities to work with various MasterCard files.
* Free software: BSD license
* Documentation: https://mciutil.readthedocs.org.

Warning
-------

THIS PACKAGE HAS BEEN DEPRECATED AND WILL NOT BE UPDATED GOING FORWARD

This package was created when I first started learning python. I have learned a lot over the last 4 years
and I now see the error in my ways.

Some of the issues with this module that prompted me to rewrite it:

* memory efficiency - loads entire file into memory for processing. Very ineffient and not very scalable
* programming interface - mciutil did not consider the developer experience. You have to hack to use the logic elsewhere
* dependencies - Too many third party modules, with ones that required a compilation. New version is compile free
* bloat - I used a cookie cutter template when I started and it has stuff I don't like, value or use.
* just mastercard - The old module was for mastercard only but I think it makes sense to have a library for all card utils
* python 2 guff - mciutil works on py2 and 3. There is a lot of gunk in the code to make this work. We live in a py3 world now!

The replacement module is cardutil - see https://cardutil.readthedocs.io
It addresses all of the above issues.


why not just update mciutil?
****************************

Thats a good question. I think because the new codebase as developed from scratch rather than
via changes to the existing one (there is some borrowed code from mciutil).
If I just released a new version, anyone leaning on the internal API's would definetly be in trouble
as they are not the same.

Features
--------

Expand Down
4 changes: 4 additions & 0 deletions mciutil/__init__.py
Expand Up @@ -9,6 +9,10 @@
flip_message_encoding, b,
)

import warnings
warnings.warn("mciutil project is now deprecated. Please use python module cardutil instead. "
"See https://cardutil.readthedocs.io", DeprecationWarning)

__author__ = 'Anthony Delosa'
__email__ = 'adelosa@gmail.com'

Expand Down
4 changes: 1 addition & 3 deletions mciutil/cli/__init__.py
Expand Up @@ -2,6 +2,4 @@
"""
Command line interface
"""
__author__ = 'Anthony Delosa'
__email__ = 'adelosa@gmail.com'
__version__ = '0.4.1'

7 changes: 7 additions & 0 deletions mciutil/cli/common.py
Expand Up @@ -11,6 +11,13 @@
from pkg_resources import resource_filename

LOGGER = logging.getLogger(__name__)
# this module gets loaded by all the CLI programs so will emit message
# for all cli programs.
print("""!!! WARINING !!!
mciutil module has been deprecated
Please consider using module cardutil instead
see https://cardutil.readthedocs.io
""")


def update_cli_progress(current_val, end_val, bar_length=20):
Expand Down
3 changes: 3 additions & 0 deletions mciutil/mciutil.py
Expand Up @@ -579,6 +579,9 @@ def _get_icc_fields(field_data):

field_tag_display = binascii.b2a_hex(field_tag)
LOGGER.debug("field_tag_display=%s", field_tag_display)
# stop processing de55 if low values tag found
if field_tag_display == b('00'):
break
field_length_raw = field_data[field_pointer:field_pointer+1]
field_length = struct.unpack(">B", field_length_raw)[0]

Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -54,7 +54,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand Down
6 changes: 6 additions & 0 deletions tests/test_mciutil.py
Expand Up @@ -2,6 +2,7 @@

from __future__ import absolute_import
from unittest import TestCase
import binascii
import hexdump

# Public import
Expand Down Expand Up @@ -222,3 +223,8 @@ def test_get_de55_fields(self):
self.assertEqual(return_dict['TAG9F36'], b("04dd"))
self.assertNotEqual(return_dict.get("TAG82", False), False)
self.assertEqual(return_dict['TAG82'], b("2000"))

def test_get_de55_null_eof(self):
de55_data = binascii.unhexlify('9f26081c89a48c0c4c3a309f2701809f10120110a04001240000000000000000000000ff9f370401bd0f6d9f36020011950500000480009a031909069c01009f02060000000289985f2a020032820239009f1a0200329f03060000000000009f1e0837383636343738349f3303e0f0c89f3501009f090200009f34034203008407a0000000041010910aaf6f5977b4ca292500120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')
return_dict = _get_icc_fields(de55_data)
print(return_dict)
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py34, py35, py36, py37
envlist = py27, py35, py36, py37

[testenv]
setenv =
Expand Down

0 comments on commit c51d8f2

Please sign in to comment.