From 5b4356d229b352bb1290c404a9586c7d0bac2072 Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Fri, 29 Sep 2023 18:26:12 +0200 Subject: [PATCH] Preparing articles values, multiple targets with 'all' --- CHANGELOG.md | 6 + src/usr/bin/tyto | 4 +- .../program/__pycache__/args.cpython-311.pyc | Bin 2488 -> 2603 bytes .../program/__pycache__/check.cpython-311.pyc | Bin 730 -> 1991 bytes .../__pycache__/domain.cpython-311.pyc | Bin 23498 -> 23487 bytes .../program/__pycache__/post.cpython-311.pyc | Bin 3668 -> 4010 bytes .../program/__pycache__/tyto.cpython-311.pyc | Bin 2572 -> 2577 bytes src/var/lib/tyto/program/args.py | 5 +- src/var/lib/tyto/program/check.py | 57 +++++++++- src/var/lib/tyto/program/post.py | 104 +++++++++++------- src/var/lib/tyto/program/tyto.py | 1 + 11 files changed, 131 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c500c3..117ad39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,16 @@ Tyto - Littérateur # CURRENTLY IN DEV ! +## [1.9.11] +- Preparing for multi-targets with "all" +- check if article is a .tyto format +- preparing values for articles + ## [1.9.10] - cleaner code - start/stop domain by user - User directories check/create when domain activated +- Check install configuration ## [1.9.9] - cleaner code with new check/update domain process diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index abf0518..099edab 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Version: 1.9.10 -# Updated: 2023-09-29 1695998917 +# Version: 1.9.11 +# Updated: 2023-09-29 1696004712 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn diff --git a/src/var/lib/tyto/program/__pycache__/args.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/args.cpython-311.pyc index 3515f88724397e108e28254ba4771ad268eaa3cd..17afd7ec8dccd01c0aec2d3826ba47346d03fed3 100644 GIT binary patch delta 305 zcmd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o$=ImM&9MTyj%=G@c5xvYSu>H)KHOsK;CqQ5|AJi6gy5%R92q+MpAgPJe!zU z3Udle2^&n3fuRb>F5#JcFI0E3t+?o9g)m8GhFZqS`2u20HH?!(!YqZjilTtZi^M>L zABcD{c~+Q;Ia5&xkaLSOC9^0sxg@`+vX}|TS5PS82dQ}qBkX~q#kD|Q1H)G~1}@>r dKf{z6*KU>#|H;J9!KnCw0ZyoFR*jm)2mst6G(7+S diff --git a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc index be29656677e727be0afa8b91907b258d392e2558..235c5b2075d2ace30b7756169a0db8b5b86fdb3f 100644 GIT binary patch literal 4010 zcmbUk?@t`Zb@u1&-Vg3D1h56>eEhsP+?C42RcfU&*fdcTl-d+4sL^R*4s+z-uCt4= z5!mMnwGuI`RPljtSGkcaKK0Gs?cN@6O4`}o zH*em&U-M?>&Ft5KfEPh|^SC8>t`VVs(S}{v3i9d}AWslRm`S6_a?MOKR-2t@Nw|Hx&`nF(kQJ` z<{Z9)?U~(W)iu0ShgF_|)N@BN8_{ID2cbE^#xaB0v*j@decUqm zpxtBRwLXxJIzI4NSV5LO@uWS>D-srOBki266ZBg%N81Hom0HEl9?uGT2GM)&L{Rb9 z(HW>}s$yDO6|WtYS}(F5EV-rXjL%aUUx!OSpwFGA%39;^bO>lJWaBmZ#S`Oe)P7us zJ0WwfPE3A0&P|R_5gS7Y%gfL>VWZjYb>WRFcNIH(25aMvz2_YPrA3Q74fG7qYW!AV z6~mtMjUCacU-l2Y8&-&xnocLx`1nyXrFmlUx5BYleDsL!3sV?X(rR*=9ScfDJ`l=lE5iqdQ}bds7onr*7PrtPZPFQQ^3io#k(e#S=3Bkd!S`ZX(0p5 zcaxeaBnin7lg+3mpH)DVpUZ$+Zjq!+F?m0wYO2|gQWI1xF_R(l3dm@gOjV_dl5UWo@m9wmIyrR6N^9}&*!Gufdw#;` z_?gZQ8th;RG294qz(|#G=I&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8^l@9E>^$0g+A zLU^;I=smZdUCsXf$=Z|LC&i|Y=iWbf^Sst{NpFHn(J6#*nXd3fPcvYpqq!(G0Tixx zt#)m-zUb7P{kpTiga{~FJ64>gwuLne;hlw@g}n*(6?#WEKHK=LIC%Ypq~tTZ5ZGYK zLn_mMo5TB$Nvq}c_`}1)daBX~h;tW6=-Kc$Bb&c@+4`r>zj3=0dqaCv^M!O@=&(q< z1u{}r=Y21uJ6Cs`cW-IF5#2ZPKa~aF$nj4`zytgWdo8}W*)!_qzH{@VO^)w;7-*oO ze53WUMPip^c?+ articles/", domain.cf_usr_articles, True, 2, True) + domain.user_dir.startswith(domain.wrk_articles) or \ + debug.out(2, "-> articles/", domain.wrk_articles, True, 2, True) + + global error # Target URI most be from legacy directory or not begins with if target.startswith(tyto.notarget): - debug.out(20, "./, ../", target, True, 2, True) + debug.out(20, "./, ../", target, True, 2, False) + error = 20 + return False # Article exists global uri uri = os.path.join(domain.wrk_articles, target) - os.path.exists(uri) or debug.out(5, "False", uri, True, 2, True) + if not os.path.exists(uri): + debug.out(5, "False", uri, True, 2, False) + error = 5 + return False # Article is a Tyto format and not empty (exit on errors) - is_tyto_format() + if not is_tyto_format(): + return False - # - global uri_id, cf_uri - - # Set post ID from URI - uri_id = tools.get_filesum(uri, False) + global uri_id, wrk_id, cf_uri, wrk_target + # Set post ID from... + uri_id = tools.get_filesum(uri, False) # ...URI + wrk_id = tools.get_filesum(uri, True) # ...CONTENTS # Set post configuration file database cf_uri = os.path.join(domain.wrk_db, uri_id + ".ini") + # Set target from articles/ + wrk_target = uri.rsplit(domain.wrk_articles)[1] + # Load Database db = cf_load() # True or False + return True + + +#=========================================# +# Article is in Tyto format and not empty # +# Return True or False # +#-----------------------------------------# +def is_tyto_format(): + global head_contents, text_contents, error + + separator = False + head_contents = text_contents = "" + + with open(uri, "r") as contents: + contents = contents.read() + for line in contents.rsplit("\n"): + if not line: + continue + + if line.startswith(tyto.post_sep): + separator = True + continue + + if separator: text_contents = "%s%s\n"%(text_contents, line) + else: head_contents = "%s%s\n"%(head_contents, line) + + if not separator: + debug.out(21, tyto.post_sep, uri, True, 2, False) + error = 21 + return False + + if not head_contents: + debug.out(22, "?", uri, True, 2, False) + error = 22 + return False + + if not text_contents: + debug.out(23, "?", uri, True, 2, False) + error = 23 + return False + + return True #=======================================# @@ -78,10 +132,12 @@ def is_article(target): # return True, or False if unused (yet) # #---------------------------------------# def cf_load(): + global cf + cf = False + if not os.path.exists(cf_uri): return False - global cf cf = configparser.ConfigParser() cf.read(cf_uri) @@ -100,29 +156,3 @@ def cf_valid(): print("post: chk_hash", chk_hash) - -#=========================================# -# Article is in Tyto format and not empty # -#-----------------------------------------# -def is_tyto_format(): - global uri, header_contents, writer_contents - - separator = False - head_contents = text_contents = "" - - with open(uri, "r") as contents: - contents = contents.read() - for line in contents.rsplit("\n"): - if not line: - continue - - if line.startswith(tyto.post_sep): - separator = True - continue - - if separator: text_contents = "%s%s\n"%(text_contents, line) - else: head_contents = "%s%s\n"%(head_contents, line) - - separator or debug.out(21, tyto.post_sep, uri, True, 2, True) - head_contents or debug.out(22, "?", uri, True, 2, True) - text_contents or debug.out(23, "?", uri, True, 2, True) diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 1bcc1c0..d06818f 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -40,6 +40,7 @@ targets = ( "domain", "domains", "title", "date", "about", "mail", "tags", "lang", "server", + "all", ) force_options = ("--force", "-F")