aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2021-02-21 17:40:52 -0300
committerSilvio Rhatto <rhatto@riseup.net>2021-02-21 17:40:52 -0300
commit02c3d6eda63d77418046041a73c1c8a157a21467 (patch)
tree55cd31754148b9c881ceba33969930db4bd93c2a
parenta95760dc4b5a4c6985c8babfac05000c7307918f (diff)
downloadscripts-02c3d6eda63d77418046041a73c1c8a157a21467.tar.gz
scripts-02c3d6eda63d77418046041a73c1c8a157a21467.tar.bz2
Fix: anarchronofile: skip folders
-rwxr-xr-xanarchronofile14
1 files 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)