aboutsummaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorHenryk Plötz <henryk@ploetzli.ch>2010-03-03 00:06:20 +0100
committerHenryk Plötz <henryk@ploetzli.ch>2010-03-03 00:06:20 +0100
commitbc07262d8043a189dd8f19df904c233b1358c230 (patch)
tree775b28696885edb4a37e3b71ca205f0dad7f244a /utils.py
parent47485362af6218e8385c39285c5e7c91916d7385 (diff)
API CHANGE: Move CommandLineArgumentHelper to readers module to allow proper import order.
(CommandLineArgumentHelper references the readers module, which references the utils module, so having CLAH in utils would create a circular reference.)
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py38
1 files changed, 1 insertions, 37 deletions
diff --git a/utils.py b/utils.py
index df93196..57883a2 100644
--- a/utils.py
+++ b/utils.py
@@ -1,40 +1,4 @@
-import string, binascii, sys, re, getopt, readers
-
-class CommandLineArgumentHelper:
- OPTIONS = "r:l"
- LONG_OPTIONS = ["reader=", "list-readers"]
- exit_now = False
- reader = None
-
- def connect(self):
- "Open the connection to a card"
-
- if self.reader is None:
- self.reader = 0
-
- return readers.connect_to(self.reader)
-
- def getopt(self, argv, opts="", long_opts=[]):
- "Wrapper around getopt.gnu_getopt. Handles common arguments, returns everything else."
- (options, arguments) = getopt.gnu_getopt(sys.argv[1:], self.OPTIONS+opts, self.LONG_OPTIONS+long_opts)
-
- unrecognized = []
-
- for (option, value) in options:
- if option in ("-r","--reader"):
- self.reader = value
- elif option in ("-l","--list-readers"):
- for i, (name, obj) in enumerate(readers.list_readers()):
- print "%i: %s" % (i,name)
- self.exit_now = True
- else:
- unrecognized.append( (option, value) )
-
- if self.exit_now:
- sys.exit()
-
- return unrecognized, arguments
-
+import string, binascii, sys, re
def represent_binary_fancy(len, value, mask = 0):
result = []