Skip to content
Snippets Groups Projects
Commit 1eaacb65 authored by jacques Grelet's avatar jacques Grelet
Browse files

add multiple key arg

parent 58ca8a6f
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,15 @@ class Roscop:
def __str__(self):
return 'Class Roscop, file: %s, size = %d' % (self.file, len(self.hash))
def __getattr__(self, name):
'''
overload r.key
'''
return self.hash[name]
def __repr__(self):
return super().__repr__()
def disp(self, theKey):
print("%s :" % theKey)
print(self.hash[theKey])
......@@ -49,19 +58,26 @@ if __name__ == "__main__":
# display extra logging info
# see: https://stackoverflow.com/questions/14097061/easier-way-to-enable-verbose-logging
# https://docs.python.org/2/howto/argparse.html
parser = argparse.ArgumentParser(
description='This class Roscop parse a csv file describing physical parameter codification')
parser.add_argument("-d", "--debug", help="display debug informations",
action="store_true")
parser.add_argument("-k", "--key", nargs='+',
help="display dictionary for key(s), example -k TEMP [PSAL ...]")
parser.add_argument("file", type=str, help="the csv file to parse")
args = parser.parse_args()
if args.debug:
logging.basicConfig(level=logging.DEBUG)
key = args.key
# Read the csv file and create an instance of Roscop class
r = Roscop(args.file)
#r = Roscop("code_roscop.csv")
# r = Roscop("code_roscop.csv")
r.read()
print(r)
# r.disp('TEMP')
r.disp('BATH')
for k in key:
r.disp(k)
# print(r.TEMP)
# print(r[key])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment