From fed0227968a5263b03701cd584182ecb1ae3fdf3 Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Sat, 30 Sep 2023 17:49:56 +0200 Subject: [PATCH] Preparing check process, head tags in article --- src/var/lib/tyto/program/args.py | 6 +++--- src/var/lib/tyto/program/check.py | 29 +++++++++++++++++++++++------ src/var/lib/tyto/program/tools.py | 11 ++++++++++- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index 39b9730..d699101 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -49,12 +49,12 @@ def get_action(): # Target arguments # #------------------# def get_target(): - global target, multiple + global target, targets try: target = sys.argv[2] except: target = "" - multiple = False - if target == "all": multiple = True + targets = False + if target == "all": targets = True #================================# diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 37e91ec..d996bc3 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -55,7 +55,7 @@ def ready(): #-------------------------------------------# def manage(action, target): # target is "all" - if args.multiple: + if args.targets: multiple_targets return @@ -76,17 +76,27 @@ def is_article(target): sys.exit(post.error) - head_contents() + validators() if post.error != 0: - if args.multiple: + if args.targets: return # Let other articles pass sys.exit(post.error) print("pass", post.error, args.multiple) + +# +# +# +def validators(): + targets = args.targets + post.error == 0 and ol_tags() or tools.exit(targets, post.error) + + + #===========================================# -# # Create a loop to get all .tyto articles # +# Create a loop to get all .tyto articles # #-------------------------------------------# def multiple_targets(): ready() @@ -95,7 +105,7 @@ def multiple_targets(): #=======================# # check header contents # #-----------------------# -def head_contents(): +def ol_tags(): for ln, line in enumerate(post.head_contents.rsplit("\n"), 1): if not line or line.isspace() or line.startswith("#"): continue @@ -123,7 +133,7 @@ def head_contents(): if not is_ol_tag(post.about[0], post.about[1]): return if not is_ol_tag(post.date[0], post.date[1]): return if not is_ol_tag(post.author[0], post.author[1]): return - if not is_ol_tag(post.tags[0], post.tags[1]): return + if not is_ol_tag(post.tags[0], post.tags[1]): return #===========================================# @@ -157,3 +167,10 @@ def is_ol_tag(tag, value): return False return True + + +# +# +# +def valid_date(): + diff --git a/src/var/lib/tyto/program/tools.py b/src/var/lib/tyto/program/tools.py index 4d78b39..59e66da 100644 --- a/src/var/lib/tyto/program/tools.py +++ b/src/var/lib/tyto/program/tools.py @@ -33,10 +33,19 @@ #-------------------------- from hashlib import blake2b -import os, configparser, datetime, time +import sys, os, configparser, datetime, time import debug, domain +# +# +# +def exit(targets, error): + if targets: return + + sys.exit(error) + + #==============================# # Set and return date and time # # With local options from lang #