Compare commits
2 commits
a9fa15d643
...
528115691a
Author | SHA1 | Date | |
---|---|---|---|
528115691a | |||
86380766ac |
3 changed files with 11 additions and 11 deletions
|
@ -17,25 +17,25 @@ from sshare.plugin import Plugin
|
|||
class Logger:
|
||||
def __init__(self, *args, **kwargs):
|
||||
if kwargs.get("preload_command_line") == True:
|
||||
self.loggers = [ Plugin.internal("command_line") ]
|
||||
self._loggers = [ Plugin.internal("command_line") ]
|
||||
else:
|
||||
self.loggers = []
|
||||
self._loggers = []
|
||||
self.add(*args)
|
||||
|
||||
def add(self, *args, **kwargs):
|
||||
for logger in args:
|
||||
self.loggers.append()
|
||||
self._loggers.append()
|
||||
|
||||
def info(self, message):
|
||||
for logger in self.loggers:
|
||||
for logger in self._loggers:
|
||||
logger.info(message)
|
||||
|
||||
def warn(self, message):
|
||||
for logger in self.loggers:
|
||||
for logger in self._loggers:
|
||||
logger.warn(message)
|
||||
|
||||
def error(self, message):
|
||||
for logger in self.loggers:
|
||||
for logger in self._loggers:
|
||||
logger.error(message)
|
||||
|
||||
def fatal(self, message, error_code=1):
|
||||
|
|
|
@ -150,7 +150,7 @@ def main():
|
|||
if isinstance(plugin.activate, dict):
|
||||
criteria = plugin.activate[plugin_type]
|
||||
for criterion in criteria:
|
||||
logger.error(f" {plugin.args[criterion].pretty()}")
|
||||
logger.error(f" {plugin.args[criterion]}")
|
||||
error = True
|
||||
if error:
|
||||
sys.exit(1)
|
||||
|
|
|
@ -39,10 +39,7 @@ class Argument:
|
|||
self.choices = choices
|
||||
self.help = help
|
||||
|
||||
def is_valid(self):
|
||||
return (self.short != None and self.short != "") or (self.long != None and self.long != "")
|
||||
|
||||
def pretty(self):
|
||||
def __str__(self):
|
||||
if self.short and self.long:
|
||||
pretty = f"-{self.short}, --{self.long}"
|
||||
elif self.long:
|
||||
|
@ -51,6 +48,9 @@ class Argument:
|
|||
pretty = f"-{self.short}"
|
||||
return pretty + f" {self.help}"
|
||||
|
||||
def is_valid(self):
|
||||
return (self.short != None and self.short != "") or (self.long != None and self.long != "")
|
||||
|
||||
def bind(self, plugin, argument):
|
||||
self.plugin = plugin
|
||||
self.metavar = argument
|
||||
|
|
Loading…
Reference in a new issue