1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

compatibility function call

This commit is contained in:
Kelly Brazil
2019-11-05 17:00:36 -06:00
parent 721b546659
commit 7f99677806
2 changed files with 19 additions and 1 deletions

View File

@ -68,12 +68,26 @@ def helptext(message):
Example: Example:
ls -al | jc --ls -p ls -al | jc --ls -p
''' '''
print(textwrap.dedent(helptext_string), file=sys.stderr) print(textwrap.dedent(helptext_string), file=sys.stderr)
def errormessage(message):
error_string = f'''
jc: {message}
'''
print(textwrap.dedent(error_string), file=sys.stderr)
def compatibility(mod_name, compatible):
if sys.platform not in compatible:
mod = mod_name.split('.')[-1]
errormessage(f'{mod} parser not compatible with your OS ({sys.platform}).\n Compatible platforms: {compatible}')
exit()
def main(): def main():
signal.signal(signal.SIGINT, ctrlc) signal.signal(signal.SIGINT, ctrlc)

View File

@ -79,6 +79,7 @@ $ lsblk | jc --lsblk -p
] ]
""" """
import string import string
import jc
def process(proc_data): def process(proc_data):
@ -129,6 +130,9 @@ def process(proc_data):
def parse(data, raw=False): def parse(data, raw=False):
jc.jc.compatibility(__name__,
['linux'])
raw_output = [] raw_output = []
linedata = data.splitlines() linedata = data.splitlines()
# Clear any blank lines # Clear any blank lines