From 02c3d6eda63d77418046041a73c1c8a157a21467 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 21 Feb 2021 17:40:52 -0300 Subject: Fix: anarchronofile: skip folders --- anarchronofile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/anarchronofile b/anarchronofile index a21aa08..26ee7e5 100755 --- a/anarchronofile +++ b/anarchronofile @@ -24,16 +24,20 @@ import yaml import argparse from pprint import pprint -class Anarchronofile: +class AnarChronofile: def __init__(self, args): if not os.path.exists(args.file[0]): raise FileNotFoundError('File not found: ' + args.file[0]) - self.args = args - self.file = open(args.file[0], '+r') - self.yaml = yaml.load(self.file) + if os.path.isfile(args.file[0]): + self.args = args + self.file = open(args.file[0], '+r') + self.yaml = yaml.load(self.file) def run(self): + if getattr(self, 'args', None) is None: + return + print(self.args) print("---") print("") @@ -88,7 +92,7 @@ if __name__ == "__main__": args = cmdline() try: - parser = Anarchronofile(args) + parser = AnarChronofile(args) parser.run() except (FileNotFoundError, KeyboardInterrupt) as e: print(e) -- cgit v1.2.3