]> gitweb.fluxo.info Git - scripts.git/commitdiff
Fix: anarchronofile: skip folders
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 21 Feb 2021 20:40:52 +0000 (17:40 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 21 Feb 2021 20:40:52 +0000 (17:40 -0300)
anarchronofile

index a21aa08ce52cc23027b6d4ca4c5aae47c1bc467c..26ee7e54823f9dd8c978cfbd5bc8c3c3f0259909 100755 (executable)
@@ -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)