Skip to content
Snippets Groups Projects
Commit 1409ab66 authored by Someshwaran R's avatar Someshwaran R :ghost:
Browse files

class Argument

parent 8ef648c8
No related branches found
No related tags found
No related merge requests found
arg..txt 0 → 100644
class Argument:
def __int__(self, args):
self.commands = []
self.options = []
self.optionsvalue = {} #dict/set here... unique Index/No Repeating Value
self.args = args
print(self.args)
for arg in self.args:
if "_" in arg:
#this is option with value
pair = arg.split('=')
self.optionvalues[pair[0]] = pair[1] #appending the key value pair
self.options.append[pair[0]]
else:
# this is just an option
self.option.append[arg]
else:
self.commands.append[arg]
def hasOptions(self, options: list):
useroptions = set(self.options)
reqoptions = set(options)
return list(reqoptions & useroptions)
def hasOptions(self, options):
return options in self.hasOptions([options])
def hasCommands(self, commands):
usercommands =self(self.commands)
reqcommands = set(commands)
return list(usercommands & reqcommands)
def hasCommand(self, command):
return command in self.hasCommands([command])
def getOptionsValue(self, option, default):
if option in self.optionValues:
return self.optionValues[option]
else:
return default
\ No newline at end of file
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