From 7a1eca5aa0913d5ce4a926b6cb393f3ef244e369 Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Mon, 25 Sep 2023 14:55:51 +0200 Subject: [PATCH] Preparing articles databases --- CHANGELOG.md | 13 ++- README.md | 11 +- src/usr/bin/tyto | 4 +- .../program/__pycache__/check.cpython-311.pyc | Bin 744 -> 845 bytes .../program/__pycache__/debug.cpython-311.pyc | Bin 2888 -> 3132 bytes .../__pycache__/domain.cpython-311.pyc | Bin 20329 -> 20519 bytes .../program/__pycache__/post.cpython-311.pyc | Bin 0 -> 3926 bytes .../program/__pycache__/tyto.cpython-311.pyc | Bin 1846 -> 2203 bytes src/var/lib/tyto/program/check.py | 9 +- src/var/lib/tyto/program/debug.py | 4 + src/var/lib/tyto/program/domain.py | 6 ++ src/var/lib/tyto/program/post.py | 101 ++++++++++++++++++ src/var/lib/tyto/program/tyto.py | 57 ++++++++++ .../__pycache__/logs_fr.cpython-311.pyc | Bin 2539 -> 2718 bytes src/var/lib/tyto/translations/logs_fr.py | 22 ++-- 15 files changed, 200 insertions(+), 27 deletions(-) create mode 100644 src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc diff --git a/CHANGELOG.md b/CHANGELOG.md index 0be154d..66e73bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,14 @@ Tyto - Littérateur - Changelog: - License: - Documentation: - -## [1.9.1] -- Auto update configuration domain -- Better managing configuration domain values -- Better checking if valid domain + +## [1.9.5] +- Preparing post database + +## [1.9.4] +- Added start/strop action to activate (or deactivate) domain +- Directories creation for user working domain +- better log management for user diff --git a/README.md b/README.md index 3350f57..ac7fcac 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,9 @@ This program can ve tested but not at all usable. Lots of work to do... tyto ``` -# Working on -- Managing domain(s) -- - needs more checks to be validated -- english logs translation file (French only, for now) +## ToDo next (working on) +- check action +- user is in articles/ directory +- target post exists and compatible +- create template post database -# Next -- Create all directories for valid domain diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 46ed4a8..c1cb731 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Version: 1.9.4 -# Updated: 2023-09-25 1695630197 +# Version: 1.9.5 +# Updated: 2023-09-25 1695637945 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn diff --git a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc index 159ce74abb937591da62a0077f332f1da649e41f..5bb30def165453d0f863ad80404ff731455ae867 100644 GIT binary patch delta 514 zcmaFCdX|lMIWI340}wo_6imG|kynz@WTLtnFGC7r4oehE3R4S16zjwwCB}afOEsAa zbS5r{s;^;Ozy{KR4pLZ_F)}c$24V=v7cSw4u^AY$IAH7=MpSi-3?;%aIiNbQYe4*E zK)f0*!N`!p5X_*->NnYwk%xm-ucWdhUz2-s9HXu@M`~V5ad~D*#x0hD{Nj>ZT$#o3 ziA5!u$vLT$yBMV=uV!?r7Xcci1H{GgK%#-+DHBJF{zWF?D@?){m;$DjPN`fVyfke| z_Exhkwg*&BFrF~EC?0S{JmAL-CXROfCjANO7n!84FiBltGMig6r+!7*MR~I;@@7At zGO=G_lDxC#WGfysHl;vbg&PYwpw$kLBJe5&*@;ydL z_FJq4MVWaelfN@M)e8Z2>Hu+ZIFM*yc*@D&BY%-o>I$dS2L?uFySpr$EuJ08Q_ZGW zFJ)W8yP{-6;0~6HEVfrzY%j3bK4oIR!X$Z-N%{(t^aUpAyG-mI923-Ls9j`Iyuze- z0fs(<1)1Ff%eTesE)CVB~J#0>K*$(iaG!4+3nAN*@?739x+t4lQ0# diff --git a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc index 26bdfeac818e80738a3d0b3e728a7d3603ce4527..b9fb11ddfa92196b7fdd7758ffe4cde2dfc4a23f 100644 GIT binary patch delta 741 zcmZwEyG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NMLo5I*Q p!tDp@%?Zq#snZ?kO(E*puWVd=%i^8mk&w9lt1yQKXS(x+_#3kj9Kiqp delta 1000 zcmZ9KOH30{6oxzPOlha~g%qT`31Au%5eq>A0ZE{Wba*PLsVOZT%$UNEJA?5RzzFVi z;aTWPB}N`GCdFCk#w{B|+>eRuH0(6Ga^*SGSkxx-^}pwzJNMlG-i_zn{!`Ak;q{6( z{9QjCl)tub`|j|f1Bdkdcms*S8Zh`r{)}zh7I6&iXRsWLxL{A{gKlTJSb^gxK3Wf? zoZb9#^KvtE`6`Sr&NG~+3=MXKP!6YDwL(40UgL_3|JTa8j|)v`4I9tguem@qO{gK% z62g%1bc%;b5)#Im=crvciBdIoz1xm}WqHUyLiGYT%UFw4SNVRcmI zHAR=13b|-FL`ktK0tLew2#v58JrSB9IZ3!kxJ0-N4XriMS`rb7q&?Cg8*p<`L?WXMeI8%-%vDNV+U-&+Fv zx!tzHv{=OPSJx}_H7~(O@DtYm-~sT1`_)r8j0gvFOaT*~)vU!?CwSuZ;wH@?Jcjo8 zM0p(5FK&?);lJq^ne1aPP@QLKSdVv1S!Z2>1y)9|BI_VUL9sT%5+Oja^0fl9j?lWL zbQf5RK!?RBG)5cEH@*oyQYlvh6H)`W3b&=orY-XB5v*%Md7A=WB_+eUsM<)VgZEMu Ww*#M~Reupz{LNNCrJ)YJ<9-9BALE4p diff --git a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6b4965862e2e017123d836b28fab09bc74953183 GIT binary patch literal 3926 zcmb6b?@t@ab!PU5z1ZfLfdEZ{!;gTa#ug1+!X>&YI7jbvIutdO=#VPQcnz2u?Cvfh zL3U!UmX1S2pz5L^U65RX`j-n^N4zy9KK)gdVDe`t!VHX!s*+A#|$A@9cld4WVE;uxALws;B~eKJLimYHIV zmYrgamYd>4l0j3v$N;p7EI_-+0Te`hA9?vB%6vSGOMB494wZrW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k5e z3jLbUUqA#1E$wT9L2afJ19)#?Z{c8qe!1S!tuME}%=>Pg8Y#GqEjTJnQKTaLmm%K2 z4Ol&13qL+Su0<+zBF32`f#<{DjcosVx8={5{>JQ291I?asym>$1IKyNkRu~Sa@M^Y z-W%F)+P|y1M>O}ye$j}WVRVqd*!~YqNX?2Vz_S*|_aVZx0M7j&hXi$+~04OjR+RKNt6ZMe69%Am6qe_TLkf#G2P1CQeQp8x;= literal 0 HcmV?d00001 diff --git a/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc index ae863330c5e783551379eeefdcc04d7482d11496..d3a454d4496051dc702c359de9009d7e939f0773 100644 GIT binary patch delta 462 zcmdnSH(QWzIWI340}wo_6il7YH<3?*(Qcx;IZqT%3U3r|3STgTCjZ8y*{t=6+Kdbg z(JubJj-Gz8TzQGPsS37ST+wcxKCZD`nJEgk3S6Z{nII}92`E#NSd^Yx0%Q~yCCBGv z=4FFab45G*`-Qmrg#^cPm1LIWfQ(2?$}a_~18Pew0r7M4lM{2|p`4P$^kR^j(vtd& z{2~yuIIkcx8ANB6q~<0T09imoJzSl=W4SUCi!*?HsMgei{A3W9D>~dW0452y1twcu zl2`&Z5A1fX@>HPP6+n8z!%_9v0F5G~DLBLtz*hY)5CVU`B| n4`PfWEEgCAK5#Gy+X1;;I{YjR+#iw{8F+*nI6$yS6{r~i=zoCG delta 103 zcmbO&xQ&l*IWI340}x!a6igN3naC%>Xf{#ZoF$k+lXqj*Y*uDJO`gg2?6W6-WH;ne z1*&5N;^K(OIvkejd})k)EDc;ALYO&(SsM61h%kz articles/", domain.articles_dir, True, 2, True) + + # Target URI is from legacy directory + if target.startswith("./") or target.startswith("../"): + debug.out(20, "./, ../", target, True, 2, True) + + # Article exists + global uri + + uri = os.path.join(domain.articles_dir, target) + os.path.exists(uri) or debug.out(5, "False", uri, True, 2, True) + + # Article is a Tyto format and not empty (exit on errors) + is_tyto_format() + + # + global uri_id, cf_uri + + # Set post ID from URI + uri_id = tools.get_filesum(uri, False) + + # Set post configuration file database + cf_uri = os.path.join(domain.db_dir, uri_id + ".ini") + + # Load Database + db = cf_load() # True or False + if db: cf_valid() + else: tools.create_file(cf_uri, tyto.ini_article) + + + + +#=======================================# +# Load post database # +# return True, or False if unused (yet) # +#---------------------------------------# +def cf_load(): + if not os.path.exists(cf_uri): + return False + + global cf + + cf = configparser.ConfigParser() + cf.read(cf_uri) + + return True + + +#====================================================# +# Check if post database configuration file is valid # +#----------------------------------------------------# +def cf_valid(): + global chk_hash, wip_hash, www_hash + + chk_hash = cf.get("CHECK", "hash") + wip_hash = cf.get("WIP", "hash") + www_hash = cf.get("WWW", "hash") + + 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 a767c37..b62a86b 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -55,6 +55,8 @@ git_url = "https://git.a-lec.org/echolib/tyto-litterateur" #===========================# # Templates #================================================== +#===========================# +#===========================# # Domain configuration file # #---------------------------# ini_domain = """[DOMAIN] @@ -173,8 +175,63 @@ conf = root = """ +# Domains list ini file ini_domains_list = """[DOMAINS] """ # Domain keys that can be empty opt_domain_keys = ("legals_url", "terms_url", "statuses_url") + +#=============================# +# articles configuration file # +#-----------------------------# +ini_article = """[DOMAIN] +name = + +[FILE] +id = +uri = +db = +target = +src_link = + + +[CONTENTS] +title = +about = +date = +local_date = +tags = +authors = +snpic = +sitemap = + +[CHECK] +hash = +date = +epoch = + +[WIP] +hash = +date = +epoch = +static = +uri = +web = + +[WWW] +hash = +date = +epoch = +static = +uri = +web = + +[STATS] +lines = +""" + +#===================# +# Artcicle contents #========================================================== +#===================# +post_sep = "-----" diff --git a/src/var/lib/tyto/translations/__pycache__/logs_fr.cpython-311.pyc b/src/var/lib/tyto/translations/__pycache__/logs_fr.cpython-311.pyc index 02ca1b0013cf896f0221ed2870da3a1f4458b193..2332974cefedc20d1f91a40bfe2da37508b7dee3 100644 GIT binary patch delta 321 zcmaDYJWrHwIWI340}wo_6ik)lpU5Y{xM-q!nxI6KM2cjTWQtUjREl(zbPC7Bc`_nV z$|=fGDk&;aswt{bYAI^L44Ud2_sw7otr7|i@>Iyn&r?Xw&n-wS$xO;gEfoQp8hm(V zL1Iy2Nor}4LT+MSVQFGsNvSAM!nLRfB$kqxSFDhu?wVI}cvVSi6^~<4NoI0RszO<2 zO6uk?ru!_6>XXgbuUe!Q6~!kdro@*PW!~ZeaSHN_OX7=D3vThkc^RpRDYy9G+|=BH zlFH4T99)cCdO!;qfw=hAWLZvU2O-r4_8WrQ4IDQFwLpXph|mOysWxzd2(}x7$_?Bg c7K~7D;JG2F(ZG8{P`-h0at~)Tiw@8{0JE%SasU7T delta 142 zcmbOy`dXN8IWI340}wp55KPVCo5&}@IBBAKnjlA%M2bX|WQt^zREkuTbc*!Ec`_`) z44TRt&&^=myqoDh3#0Pn+3Z(0uj1ff}$0qOLbk^ZlYGA*?r_sQ1gHIhq gXo3hekeE^f7l>fH!Kcu`4PtRmw&#jw(E#cN0LmmLy8r+H diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index f5d50b3..2af3159 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -47,15 +47,19 @@ domain_srv = "URI du serveur" # logs for debug #--------------- # Errors -err_arg = "Argument invalide" -err_hole = "Dossier courant invalide" -err_date = "Format de date invalide" -err_lang = "Format de langue invalide" -err_dir = "Dossier non compatible" -err_no_dir = "Dossier inexistant" -err_cd = "Dossier non créé" -err_no_file = "Fichier manquant" -err_cr_file = "Fichier non créé" +err_arg = "Argument invalide" +err_hole = "Dossier courant invalide" +err_date = "Format de date invalide" +err_lang = "Format de langue invalide" +err_dir = "Dossier non compatible" +err_no_dir = "Dossier inexistant" +err_cd = "Dossier non créé" +err_no_file = "Fichier manquant" +err_cr_file = "Fichier non créé" +err_bad_uri = "URI non compatible" +err_post_sep = "Séparateur manquant" +err_post_head = "Erreur dans l'Entête" +err_post_empty = "Article vide" # Warnings warn_no_dom = "Domaine non configuré"