<commit_before>"""
    This a nice simple reference implementation when creating new smartcard
    programs using the LL-Smartcard API
"""
# Navtive
import logging
import optparse

# LL Smartcard 
from llsmartcard.card import VisaCard

def process_card(connection, options):
    """
        Implement your function here
    """

    # Open card
    card = VisaCard(connection)
    
    # Select 
    card.select_visa_applet()
    card.read_visa()
    

if __name__ == "__main__":

    # Import our command line parser
    from llsmartcard import parser
    opts = optparse.OptionParser()

    # Add any options we want here
    opts.add_option("-s", "--sample", action="store_true",
        dest="sample", default=False,<commit_msg>Updated VISA example<commit_after>"""
    This a nice simple reference implementation when creating new smartcard
    programs using the LL-Smartcard API
"""
# Navtive
import logging
import sys
import optparse

# LL Smartcard 
from llsmartcard.card import VisaCard


# Service code decoder
service_first = {
    '1': 'International interchange OK',
    '2': 'International interchange, use IC (chip) where feasible',
    '5': 'National interchange only except under bilateral agreement',
    '6': 'National interchange only except under bilateral agreement, use IC (chip) where feasible',
    '7': 'No interchange except under bilateral agreement (closed loop)',
    '9': 'Test'
}
service_second = {
    '0': 'Normal',
    '2': 'Contact issuer via online means',
    '4': 'Contact issuer via online means except under bilateral agreement'
}
service_third = {
    '0': 'No restrictions, PIN required',
    '1': 'No restrictions',
    '2': 'Goods and services only (no cash)',
    '3': 'ATM only, PIN required',
    '4': 'Cash only',
    '5': 'Goods and services only (no cash), PIN required',
    '6': 'No restrictions, use PIN where feasible',
    '7': 'Goods and services only (no cash), use PIN where feasible'
}


def process_card(connection, options):
    """
        Implement your function here
    """

    # Open card
    card = VisaCard(connection)
    
    # Select 
    card.select_visa_applet()
#     card.dump_records()
    
#     for sfi in range(0x00,32):
#         for rec in range(0x00,17):
#             (data, sw1, sw2) = card.apdu_read_record(rec, (sfi << 3) | 4)
#             if (sw1, sw2) == (0x6e,0x0):
#                 for cla in range (0x01, 0xff+1):
#                     (data, sw1, sw2) = card.apdu_read_record(rec, (sfi << 3) | 4, cla=cla)
#                     if (sw1, sw2) == (0x90,0x0):
#                         sys.exit(0)
    cc_info = card.read_visa()
    
    if cc_info is not None:
            print "Bank card info: "
            print " * Name: %s %s"%(cc_info['first_name'],cc_info['last_name'])
            print " * Account #: %s"%(cc_info['account_number'])
            print " * Expiration: %s/%s"%(cc_info['exp_month'], cc_info['exp_year'])
            print " * Service: %s"%(service_first[cc_info['service_first']])
            print "            %s"%(service_second[cc_info['service_second']])
            print "            %s"%(service_third[cc_info['service_third']])
    

if __name__ == "__main__":

    # Import our command line parser
    from llsmartcard import parser
    opts = optparse.OptionParser()

    # Add any options we want here
    opts.add_option("-s", "--sample", action="store_true",
        dest="sample", default=False,
{'fraction_non_alphanumeric': 0.12510936132983377, 'fraction_numerical': 0.015748031496062992, 'mean_word_length': 2.819599109131403, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4485998', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1046, 'n_words': 320}