diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e5828..886fd5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ Tyto - Littérateur # CURRENTLY IN DEV ! +## [1.9.22] (Not Yet push) +- new bcode process (html prepared for wip) +- new post database management values +- new icode process (html prepared for wip) +- bcodes and icodes are FIRST processed in text article +- lots more + ## [1.9.21] - new indentation (3 spaces) - added 'raw:' marker diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index 01f12d5..d5f0e32 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Version: 1.9.21 -# Updated: 2023-10-08 1696756865 +# Version: 1.9.22 +# Updated: 2023-10-11 1697039459 # 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 b52b816..20bf5f1 100644 Binary files a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc differ 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 c751f53..c1b80bb 100644 Binary files a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc index 903c4dc..fa9f0df 100644 Binary files a/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/domain.cpython-311.pyc differ 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 f314b29..c310828 100644 Binary files a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc index 7e2b40b..6db0642 100644 Binary files a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc differ 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 e930bb7..5f6e52d 100644 Binary files a/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/tyto.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc new file mode 100644 index 0000000..7c9264f Binary files /dev/null and b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 5c83af6..024986d 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -32,10 +32,10 @@ # file program : #-------------------------- -import sys, os +import sys, os, re from dateutil.parser import parse -import args, domain, langs, debug, post, tools, tyto +import args, domain, langs, debug, post, tools, tyto, wip #=====================================# @@ -71,14 +71,12 @@ def manage(action, target): # Also used with multiple (loop) # #--------------------------------# def is_article(target): - valid(target) + valid(target) or tools.exit(targets, post.error) # When all is OK # Will create post database, but now, show some values - print("chk_date", chk_date) - print() - print("Final text_contents string") - for ln, line in enumerate(post.text_contents.rsplit("\n"), post.head_lines): + print("Final texts string") + for ln, line in enumerate(texts, post.head_lines + 1): print(">", ln, line) print() @@ -91,38 +89,48 @@ def is_article(target): # In error case, exit or return if targetS # #-------------------------------------------# def valid(target): + global targets targets = args.targets # Target is a tyto article format post.is_article(target) or tools.exit(targets, post.error) + if not post.do_chk: + post.error = debug.out(210, post.chk_date, post.uri, True, 0, False) + return False + + # Reset post database (Old values are prepared) + tools.create_file(post.cf_uri, post.ini_template) + post.cf_load() global css - css = domain.cf.get("WEBSITE", "css") + css = domain.css global headers, texts headers = post.head_contents.rsplit("\n") - texts = post.text_contents.rsplit("\n") - - # ============= - # Head contents - # ============= - - # One Line targs in head_contents - post.error == 0 and ol_tags() or tools.exit(targets, post.error) - #Multiple and optional Tags on 3 linges - post.error == 0 and ml_tags() or tools.exit(targets, post.error) - + texts = post.text_contents.rsplit("\n") + + # ============ + # Text article + # ============ + # Process bcodes and icodes first to protect their contents + post.error == 0 and bcodes() or tools.exit(targets, post.error) + post.error == 0 and icodes() or tools.exit(targets, post.error) + + # ============= + # Head contents + # ============= + # One Line targs in head_contents + post.error == 0 and ol_tags() or tools.exit(targets, post.error) + # Multiple and optional Tags on 3 linges + post.error == 0 and ml_tags() or tools.exit(targets, post.error) + # ============ # Text article # ============ - # Start Lines - # ----------- - # Paired tags. - post.error == 0 and sl_paired("bcodes") or tools.exit(targets, post.error) - post.error == 0 and sl_paired("quotes") or tools.exit(targets, post.error) - post.error == 0 and sl_paired("parags") or tools.exit(targets, post.error) # Single tags - post.error == 0 and titles() or tools.exit(targets, post.error) + post.error == 0 and sl_tags() or tools.exit(targets, post.error) + + return True #===========================================# @@ -144,14 +152,23 @@ def ol_tags(): sitemap = "True" for ln, line in enumerate(headers, 1): - if not line or line.isspace(): continue + # Optional one line markers if line.startswith("#"): post.stats_tyto_head_coms += 1 - continue + elif line.startswith(post.nositemap): + sitemap = "False" + elif line.startswith(post.logo[0]): + if not post.logo[1]: + post.logo = (post.logo[0], ol_tag_value(line, False)) + logo_ln = ln + if is_value2_file_exists(logo_ln, "logo:", post.logo[1]): + src_uri = "%s%s"%(domain.www_url, src_uri) + else: + return False # One Line tags (Must be set) # =========================== - if not post.title[1] and line.startswith(post.title[0]): + elif not post.title[1] and line.startswith(post.title[0]): post.title = (post.title[0], ol_tag_value(line, False)) elif not post.about[1] and line.startswith(post.about[0]): @@ -166,17 +183,7 @@ def ol_tags(): elif not post.tags[1] and line.startswith(post.tags[0]): post.tags = (post.tags[0], ol_tag_value(line, True)) - - # Optional tags - # ------------- - elif not post.logo[1] and line.startswith(post.logo[0]): - post.logo = (post.logo[0], ol_tag_value(line, False)) - logo_ln = ln - - elif line.startswith(post.nositemap): - sitemap = "False" - - + # Sets are done from loop # Check if tag value exists # ========================= @@ -188,14 +195,10 @@ def ol_tags(): if not is_ol_tag(post.tags[0], post.tags[1]): return False # Default domain logo for this post - src_uri = "%stemplate/%s"%(domain.www_url, domain.logo) - # logo is set with specific uri - if is_value2_file_exists(logo_ln, "logo:", post.logo[1]): - src_uri = "%s%s"%(domain.www_url, src_uri) - else: - return False - post.logo = (post.logo[0], src_uri) - post.cf.set("HEADERS", "logo", src_uri) + if not post.logo[1]: + src_uri = "%stemplate/%s"%(domain.www_url, domain.logo) + post.logo = (post.logo[0], src_uri) + post.cf_set("HEADERS", "logo", src_uri) return True @@ -255,8 +258,6 @@ def is_valid_date(date): # Tags are stric start line # #----------------------------# def ml_tags(): - #global value1 - c = 0 # Continue for next x lines, as tags are 3 lines values for ln, line in enumerate(headers): @@ -302,12 +303,12 @@ def ml_tag_values(ln, tag, stats): # value1 must not starts or contains:o elif value1.startswith("_"): - debug.out(56, "%s) '_...'"%(ln+1), post.uri, True, 2, False) + post.error = debug.out(56, "%s) '_...'"%(ln+1), post.uri, True, 2, False) return False # Specific for image: logo name is reserved elif tag == post.ml_tags[1] and value1 == "logo": - debug.out(56, "%s) 'logo'"%(ln+1), post.uri, True, 2, False) + post.error = debug.out(56, "%s) 'logo'"%(ln+1), post.uri, True, 2, False) return False # value2 @@ -350,24 +351,25 @@ def ml_tag_values(ln, tag, stats): if tag == post.ml_tags[0]: section = "LINKS" post.stats_text_links += post.text_contents.count(tyto_value) - html_value = '%s'%( - value2, css, "%%s", value3, value1 + html_value = tyto.a_link%( + value2, "%s link"%css, "%%s", value3, value1 ) # file: elif tag == post.ml_tags[2]: section = "FILES" post.stats_text_files += post.text_contents.count(tyto_value) - html_value = '%s'%( - value2, css, "%%s", value3, value1 + html_value = tyto.a_link%( + value2, "%s file"%css, "%%s", value3, value1 ) # image: elif tag == post.ml_tags[1]: section = "IMAGES" post.stats_text_images += post.text_contents.count(tyto_value) - html_value = '%s'%( - value2, "%%s", "%%s", value3, "%%s" + html_value = tyto.image_link%( + value2, "%%s image", "%%s", + value3, value3, "%%s" ) # raw: (content file converted to base64) @@ -386,18 +388,15 @@ def ml_tag_values(ln, tag, stats): post.stats_text_codes += post.text_contents.count(tyto_value) htmlbcode = ""%value3 with open(value2_uri, "r") as f: - for line in f.read().rsplit("\n"): + for ln, line in enumerate(f.read().rsplit("\n"), 1): line = tools.convert_html_signs(line) - line = '
  • %s
  • '%(domain.css, line) + line = tyto.code_line%(ln, line) htmlbcode = "%s\n%s"%(htmlbcode, line) - html_value = tyto.pre_bcode%( - domain.css, domain.css, domain.css, - htmlbcode - ) - print() - print(html_value) - print() + html_value = tyto.code_bcode%(css, htmlbcode) + #print() + #print(html_value) + #print() html_value = tools.b64_convert("encode", html_value) # abbr: @@ -405,11 +404,11 @@ def ml_tag_values(ln, tag, stats): section = "ABBRS" post.stats_text_abbrs += post.text_contents.count(tyto_value) html_value = '%s'%( - domain.css, value2, value3 + css, value2, value3 ) - post.cf.set(section, link_var, tyto_value) - post.cf.set(section, html_var, html_value) + post.cf_set(section, link_var, tyto_value) + post.cf_set(section, html_var, html_value) return True @@ -458,7 +457,7 @@ def is_value2_file_exists(ln, tag, val2): # Add file to [SOURCE_FILES] post database post.stats_total_files += 1 - post.cf.set("SOURCE_FILES", "file_%s"%post.stats_total_files, src_uri) + post.cf_set("SOURCE_FILES", "file_%s"%post.stats_total_files, src_uri) return True @@ -466,99 +465,181 @@ def is_value2_file_exists(ln, tag, val2): #=====================# # check text contents #======================================================== #=====================# -#========================================# -# First process ! # -# Used for bvodes, quotes, parags # -# Check if opened and closed tags match # -# Check if contents in tags are indented # -# Count tags for stats # -# Remove bcodes, quotes lines # -# - Create new post.text_contents # -# Return True/False # -#----------------------------------------# -def sl_paired(markers): +#=======================================# +# bcodes: first process ! # +# Check if opened and closed tags match # +# Count bcodes for stats # +# Remove bcodes lines # +# - Create new post "texts" contents # +# Return True/False # +#---------------------------------------# +def bcodes(): global texts + + markers = post.bcodes + index0 = index1 = -1 - new_text_contents = "" - opened = closed = in_tag = False - stats_opened = stats_closed = 0 - tags = () - - if markers == "bcodes" : tags = post.bcodes - elif markers == "quotes" : tags = post.quotes - elif markers == "parags" : tags = post.parags - - # loop lines in text_contents for ln, line in enumerate(texts, post.head_lines + 1): - - # Tag was closed, but not in_tag content line - if closed and in_tag: - in_tag = False - - # Tag is opened - if line.startswith(tags[0]): - # Tag was already opened - if opened: - post.error = \ - debug.out(53, "%s) %s ... %s"%( - ln+1, - tags[0], tags[1] - ), post.uri, True, 2, False) - return False - - # check next line if exists or is a closed tag - try: - next_line = post.contents.rsplit("\n")[ln] - if next_line.startswith(tags[1]): + if index0 >= 0 : + #print(">>>", ln, line) + bcode = "%s\n%s"%(bcode, line) + texts[ln - 1 - post.head_lines] = "" + + # Opened mark + if line.lstrip().startswith(markers[0]): + # Mark was opened yet + if index0 >= 0: + # at the same position + if line.index(markers[0][0]) == index0: post.error = \ - debug.out(55, "%s) '%s'"%(ln, tags[0]), post.uri, True, 2, False) - return False - except: - post.error = \ - debug.out(55, "%s) '%s'"%(ln, tags[0]), post.uri, True, 2, False) - return False - - opened = in_tag = True - closed = False - stats_opened += 1 - - # Tag is closed - if line.startswith(tags[1]): - # Tag was already closed - if closed: - post.error = \ - debug.out(53, "%s) %s ... %s"%( - ln+1, - tags[0], tags[1] - ), post.uri, True, 2, False) - return False - - closed = True - opened = False - stats_closed += 1 - - - if in_tag: - # Contents must be indented - if not line.startswith(tags): - if len(line) - len(line.lstrip()) < 3: - post.error = \ - debug.out(54, "%s) '\t'%s..."%( - ln+1, line[0:10] + debug.out(53, '%s...%s) "%s"'%( + tag_ln, ln, markers[1] ), post.uri, True, 2, False) return False - line = "" + continue + index0 = line.index(markers[0][0]) + tag_ln = ln + bcode = line + #print(">>>", ln, line) + texts[ln - 1 - post.head_lines] = "" - # Create new string, removing in_tag line if in bcodes or quotes - if markers in post.raw_contents: - if not new_text_contents: new_text_contents = line - else: new_text_contents = "%s\n%s"%(new_text_contents, line) + # Closed mark + if line.lstrip().startswith(markers[1]): + if index0 < 0: + post.error = \ + debug.out(53, '%s) "%s"...'%( + ln, markers[0] + ), post.uri, True, 2, False) + return False + index1 = line.index(markers[1][0]) + # at same position as opened + if index1 == index0: + index0 = index1 = -1 + tag_ln = "" + post.stats_bcodes += 1 + + # create ini values for this bcode + var_name = "bcode_%s"%post.stats_bcodes + val_raws = tools.b64_convert("encode", bcode) + var_html = "html_%s"%post.stats_bcodes + val_html = tools.b64_convert("encode", wip.bcode(bcode)) + post.cf_set("BCODES", var_name, val_raws) + post.cf_set("BCODES", var_html, val_html) + + # bcode not opened, but closed tag found + elif index0 < 0: + tag_ln = ln + + + # Check if markers match + # ---------------------- + if index1 >= 0 and index0 < 0: + post.error = \ + debug.out(53, '%s) "%s"...'%(tag_ln, markers[0]), post.uri, True,2, False) + return False + + if index0 >= 0 and index1 < 0: + post.error = \ + debug.out(53, '%s) ..."%s"'%(tag_ln, markers[1]), post.uri, True,2, False) + return False + + if index0 != index1: + post.error = \ + debug.out(53, '%s) "%s"..."%s"'%( + tag_ln, markers[0], markers[1] + ), post.uri, True,2, False) + return False + return True + + +# +# icodes (SAME LINE) +# Check if opened and closed markers match # +# +def icodes(): + global texts + + markers = post.icodes + for ln, line in enumerate(texts, post.head_lines + 1): + # Search for opened, closed markers + # markers cannot be at same position on line + m0 = line.find(markers[0]) + m1 = line.find(markers[1]) + if m0 == m1: + continue - texts = new_text_contents.rsplit("\n") + # Simple 3 cases errors + # --------------------- + # First marker is a closed one + if m1 < m0: + post.error = \ + debug.out(53, '%s) "%s"..."%s"'%( + ln, markers[1], markers[0] + ), post.uri, True,2, False) + return False + + # First marker but unused closed one + if m0 >= 0 and m1 == -1: + post.error = \ + debug.out(53, '%s) ..."%s"'%( + ln, markers[1] + ), post.uri, True,2, False) + return False + + # Last marker but unused opened one + elif m1 >= 0 and m0 == -1: + post.error = \ + debug.out(53, '%s) "%s"...'%( + ln, markers[0] + ), post.uri, True,2, False) + return False + + if post.words_markers[0][0] in line: + line = line.replace(post.words_markers[0][0], post.words_markers[0][4]) + line = line.replace(post.words_markers[0][1], post.words_markers[0][5]) + icodes = re.findall('%s(.*?)%s'%( + post.words_markers[0][4], post.words_markers[0][5] + ), line) - # Create post.stats - post.cf.set("STATS_TEXTS", markers, str(stats_opened)) + for icode in icodes: + post.stats_text_icodes += 1 + icnew = post.words_markers[0][4] + icode + post.words_markers[0][5] + line = line.replace(icnew, "") + + # Set HTML [ICODES] to post database + icode_var = "icode_%s"%post.stats_text_icodes + icleg = post.words_markers[0][0] + icode + post.words_markers[0][1] + html_var = "html_%s"%post.stats_text_icodes + html_val = icnew.replace(post.words_markers[0][4], + post.words_markers[0][2]%css) + html_val = html_val.replace(post.words_markers[0][5], + post.words_markers[0][3]) + post.cf_set("ICODES", icode_var, icleg) + post.cf_set("ICODES", html_var, html_val) + + line = line.replace(post.words_markers[1][0], post.words_markers[1][4]) + line = line.replace(post.words_markers[1][1], post.words_markers[1][5]) + icodes = re.findall('%s(.*?)%s'%( + post.words_markers[1][4], post.words_markers[1][5] + ), line) + for icode in icodes: + post.stats_text_icodes += 1 + icnew = post.words_markers[1][4] + icode + post.words_markers[1][5] + line = line.replace(icnew, "") + # Set HTML [ICODES] to post database + icode_var = "icode_%s"%post.stats_text_icodes + icleg = post.words_markers[1][0] + icode + post.words_markers[1][1] + html_var = "html_%s"%post.stats_text_icodes + html_val = icnew.replace(post.words_markers[1][4], + post.words_markers[1][2]%css) + html_val = html_val.replace(post.words_markers[1][5], + post.words_markers[1][3]) + post.cf_set("ICODES", icode_var, icleg) + post.cf_set("ICODES", html_var, html_val) + + texts[ln - 1 - post.head_lines] = line + return True @@ -568,7 +649,7 @@ def sl_paired(markers): # Add stat for _image:logo # # Return True/False # #----------------------------# -def titles(): +def sl_tags(): for ln, line in enumerate(texts, post.head_lines + 1): # legacy Tyto Titles if line.startswith(post.tyto_titles): @@ -587,13 +668,13 @@ def titles(): # Create html value for this title in database link_var = "title_%s"%post.stats_titles - post.cf.set("TITLES", link_var, line) + post.cf_set("TITLES", link_var, line) html_var = "html_%s"%post.stats_titles mark = line[0:2] title = line[3:] - html_val = post.html_titles[mark]%(domain.css, title) - post.cf.set("TITLES", html_var, html_val) + html_val = post.html_titles[mark]%(css, title) + post.cf_set("TITLES", html_var, html_val) # Count Tyto Comments elif line.lstrip().startswith("#"): @@ -606,9 +687,9 @@ def titles(): if line.lstrip().startswith(post.text_comments[0]): real_com = line.lstrip()[3:] link_var = "comm_%s"%post.stats_html_coms - post.cf.set("COMMENTS", link_var, line.lstrip()) + post.cf_set("COMMENTS", link_var, line.lstrip()) html_var = "html_%s"%post.stats_html_coms - post.cf.set("COMMENTS", html_var, ''%real_com) + post.cf_set("COMMENTS", html_var, ''%real_com) # Add stat + html for [IMAGES] when user wants to show logo in post @@ -617,12 +698,13 @@ def titles(): link_var = "image_%s"%(post.ml_tags_stats["image:"] + 1) link_val = "_image:logo" html_var = "html_%s"%(post.ml_tags_stats["image:"] + 1) - html_val = '%s'%( - post.logo[1], "%%s", "%%s", post.title[1], "%%s" + html_val = tyto.image_link%( + post.logo[1], "post_logo image", "%%s", + post.title[1], post.title[1], "%%s" ) - post.cf.set("IMAGES", link_var, link_val) - post.cf.set("IMAGES", html_var, html_val) - + post.cf_set("IMAGES", link_var, link_val) + post.cf_set("IMAGES", html_var, html_val) + return True @@ -632,56 +714,79 @@ def titles(): def cf_update_values(): post.date = ("date:", tools.local_date(post.date[1])) - post.cf.set("DOMAIN", "name", domain.name) + post.cf_set("DOMAIN", "name", domain.name) - post.cf.set("FILE", "id", post.uri_id) - post.cf.set("FILE", "uri", post.uri) - post.cf.set("FILE", "db", post.cf_uri) - post.cf.set("FILE", "target", post.wrk_target) + # [FILE] + post.cf_set("FILE", "id", post.uri_id) + post.cf_set("FILE", "uri", post.uri) + post.cf_set("FILE", "db", post.cf_uri) + post.cf_set("FILE", "target", post.wrk_target) - post.cf.set("HEADERS", "title", post.title[1]) - post.cf.set("HEADERS", "about", post.about[1]) - post.cf.set("HEADERS", "date", post.date[1]) - post.cf.set("HEADERS", "tags", post.tags[1]) - post.cf.set("HEADERS", "authors", post.author[1]) - post.cf.set("HEADERS", "sitemap", str(sitemap)) + # [HEADERS] + # --------- + post.cf_set("HEADERS", "title", post.title[1]) + post.cf_set("HEADERS", "about", post.about[1]) + post.cf_set("HEADERS", "date", post.date[1]) + post.cf_set("HEADERS", "tags", post.tags[1]) + post.cf_set("HEADERS", "authors", post.author[1]) + post.cf_set("HEADERS", "sitemap", str(sitemap)) - post.cf.set("CHECK", "hash", post.wrk_id) - post.cf.set("CHECK", "date", chk_date) - post.cf.set("CHECK", "static", str(domain.static)) + # [check] + # ------- + post.cf_set("CHECK", "hash", post.wrk_id) + post.cf_set("CHECK", "date", chk_date) + post.cf_set("CHECK", "static", str(domain.static)) + post.cf_set("CHECK", "errors", "False") - post.cf.set("WIP", "web", "%s%s"%(domain.wip_url, post.wrk_target)) - post.cf.set("WIP", "uri", "%s%s"%(domain.wip, post.wrk_target)) + # [WIP] + # ----- + post.cf_set("WIP", "hash", post.wip_hash) + post.cf_set("WIP", "date", post.wip_date) + post.cf_set("WIP", "web", "%s%s"%(domain.wip_url, post.wrk_target)) + post.cf_set("WIP", "uri", "%s%s"%(domain.wip, post.wrk_target)) - post.cf.set("WWW", "web", "%s%s"%(domain.www_url, post.wrk_target)) - post.cf.set("WWW", "uri", "%s%s"%(domain.www, post.wrk_target)) + # [WWW] + # ----- + post.cf_set("WWW", "hash", post.www_hash) + post.cf_set("WWW", "date", post.www_date) + post.cf_set("WWW", "web", "%s%s"%(domain.www_url, post.wrk_target)) + post.cf_set("WWW", "uri", "%s%s"%(domain.www, post.wrk_target)) + # [STATS_FILE] + # ------------ stats_tyto_all_coms = post.stats_tyto_text_coms + post.stats_tyto_head_coms - post.cf.set("STATS_FILE", "lines", str(post.lines)) - post.cf.set("STATS_FILE", "tyto_coms", str(stats_tyto_all_coms)) - post.cf.set("STATS_FILE", "files", str(post.stats_total_files)) + post.cf_set("STATS_FILE", "lines", str(post.lines)) + post.cf_set("STATS_FILE", "tyto_coms", str(stats_tyto_all_coms)) + post.cf_set("STATS_FILE", "files", str(post.stats_total_files)) - post.cf.set("STATS_HEADERS", "lines", str(post.head_lines)) - post.cf.set("STATS_HEADERS", "tyto_coms", str(post.stats_tyto_head_coms)) - post.cf.set("STATS_HEADERS", "links", str(post.ml_tags_stats["link:"])) - post.cf.set("STATS_HEADERS", "files", str(post.ml_tags_stats["file:"])) - post.cf.set("STATS_HEADERS", "images", str(post.ml_tags_stats["image:"])) - post.cf.set("STATS_HEADERS", "abbrs", str(post.ml_tags_stats["abbr:"])) - post.cf.set("STATS_HEADERS", "codes", str(post.ml_tags_stats["code:"])) - post.cf.set("STATS_HEADERS", "raws", str(post.ml_tags_stats["raw:"])) + # [STATS_HEADERS] + # --------------- + post.cf_set("STATS_HEADERS", "lines", str(post.head_lines)) + post.cf_set("STATS_HEADERS", "tyto_coms", str(post.stats_tyto_head_coms)) + post.cf_set("STATS_HEADERS", "links", str(post.ml_tags_stats["link:"])) + post.cf_set("STATS_HEADERS", "files", str(post.ml_tags_stats["file:"])) + post.cf_set("STATS_HEADERS", "images", str(post.ml_tags_stats["image:"])) + post.cf_set("STATS_HEADERS", "abbrs", str(post.ml_tags_stats["abbr:"])) + post.cf_set("STATS_HEADERS", "codes", str(post.ml_tags_stats["code:"])) + post.cf_set("STATS_HEADERS", "raws", str(post.ml_tags_stats["raw:"])) - post.cf.set("STATS_TEXTS", "lines", str(post.text_lines)) - post.cf.set("STATS_TEXTS", "tyto_coms", str(post.stats_tyto_text_coms)) - post.cf.set("STATS_TEXTS", "html_coms", str(post.stats_html_coms)) - post.cf.set("STATS_TEXTS", "titles", str(post.stats_titles)) - post.cf.set("STATS_TEXTS", "links", str(post.stats_text_links)) - post.cf.set("STATS_TEXTS", "files", str(post.stats_text_files)) - post.cf.set("STATS_TEXTS", "images", str(post.stats_text_images)) - post.cf.set("STATS_TEXTS", "abbrs", str(post.stats_text_abbrs)) - post.cf.set("STATS_TEXTS", "codes", str(post.stats_text_codes)) - post.cf.set("STATS_TEXTS", "raws", str(post.stats_text_raws)) + # [STATS_TEXTS] + # ------------- + post.cf_set("STATS_TEXTS", "lines", str(post.text_lines)) + post.cf_set("STATS_TEXTS", "tyto_coms", str(post.stats_tyto_text_coms)) + post.cf_set("STATS_TEXTS", "html_coms", str(post.stats_html_coms)) + post.cf_set("STATS_TEXTS", "titles", str(post.stats_titles)) + post.cf_set("STATS_TEXTS", "bcodes", str(post.stats_bcodes)) + post.cf_set("STATS_TEXTS", "bcodes_lines", str(post.stats_bcodes_lines)) + # Founds from header tags + post.cf_set("STATS_TEXTS", "links", str(post.stats_text_links)) + post.cf_set("STATS_TEXTS", "files", str(post.stats_text_files)) + post.cf_set("STATS_TEXTS", "images", str(post.stats_text_images)) + post.cf_set("STATS_TEXTS", "abbrs", str(post.stats_text_abbrs)) + post.cf_set("STATS_TEXTS", "icodes", str(post.stats_text_icodes)) + post.cf_set("STATS_TEXTS", "codes", str(post.stats_text_codes)) + post.cf_set("STATS_TEXTS", "raws", str(post.stats_text_raws)) - with open(post.cf_uri, "w") as f: - post.cf.write(f) - - + # Write new values in database + post.cf_write() + diff --git a/src/var/lib/tyto/program/debug.py b/src/var/lib/tyto/program/debug.py index 4aaf6d0..79af455 100644 --- a/src/var/lib/tyto/program/debug.py +++ b/src/var/lib/tyto/program/debug.py @@ -113,6 +113,7 @@ def out(nbr, var, val, show, color, stop): 207 : langs.logs.updated_file, 208 : langs.logs.website_lang, 209 : langs.logs.domain_on, + 210 : langs.logs.post_chk_yet, 255 : langs.logs.later, } diff --git a/src/var/lib/tyto/program/domain.py b/src/var/lib/tyto/program/domain.py index f7c98cb..cfc8333 100644 --- a/src/var/lib/tyto/program/domain.py +++ b/src/var/lib/tyto/program/domain.py @@ -178,7 +178,7 @@ def cf_create(): # Create section, set key if not exists # # Ask yser when default is a key form and not value # #---------------------------------------------------# -def cf_set_value(section, key, default): +def cf_set(section, key, default): global new_val try: new_val except: new_val = False @@ -223,270 +223,270 @@ def cf_update_values(write): # ======== global activated, title, date, about, mail, tags, license, license_url try: activated = cf.getboolean("DOMAIN", "activated") - except: activated = cf_set_value("DOMAIN", "activated", "no") + except: activated = cf_set("DOMAIN", "activated", "no") - cf_set_value("DOMAIN", "name", name) + cf_set("DOMAIN", "name", name) - title = cf_set_value("DOMAIN", "title", "title") - date = cf_set_value("DOMAIN", "date", "date") - about = cf_set_value("DOMAIN", "about", "about") - mail = cf_set_value("DOMAIN", "mail", "mail") - tags = cf_set_value("DOMAIN", "tags", "tags") - license = cf_set_value("DOMAIN", "lincese", "") + title = cf_set("DOMAIN", "title", "title") + date = cf_set("DOMAIN", "date", "date") + about = cf_set("DOMAIN", "about", "about") + mail = cf_set("DOMAIN", "mail", "mail") + tags = cf_set("DOMAIN", "tags", "tags") + license = cf_set("DOMAIN", "lincese", "") if not license: - license = cf_set_value("DOMAIN", "lincese", "gfdl-1.3") - license_url = cf_set_value("DOMAIN", "lincese_url", + license = cf_set("DOMAIN", "lincese", "gfdl-1.3") + license_url = cf_set("DOMAIN", "lincese_url", "https://www.gnu.org/licenses/fdl-1.3.txt") elif not license == "gfdl-1.3": - license_url = cf_set_value("DOMAIN", "lincese_url","") + license_url = cf_set("DOMAIN", "lincese_url","") # Optional global legals_url, terms_url, statuses_url - legals_url = cf_set_value("DOMAIN", "legals_url", "") - terms_url = cf_set_value("DOMAIN", "terms_url", "") - statuses_url = cf_set_value("DOMAIN", "statuses_url", "") + legals_url = cf_set("DOMAIN", "legals_url", "") + terms_url = cf_set("DOMAIN", "terms_url", "") + statuses_url = cf_set("DOMAIN", "statuses_url", "") # [SERVER] # ======== global srv, srv_name, wip, www - srv = cf_set_value("SERVER", "root", "server") + srv = cf_set("SERVER", "root", "server") if not tools.dir_exists(srv, False): - srv = cf_set_value("SERVER", "root", "server") + srv = cf_set("SERVER", "root", "server") srv_name = os.path.join(srv, name + "/") - cf_set_value("SERVER", "domain", srv_name) + cf_set("SERVER", "domain", srv_name) wip = os.path.join(srv_name, "wip/") - cf_set_value("SERVER", "wip", wip) + cf_set("SERVER", "wip", wip) www = os.path.join(srv_name, "www/") - cf_set_value("SERVER", "www", www) + cf_set("SERVER", "www", www) # [WIP_DIRS] # ========== global wip_tpl, wip_images, wip_files wip_tpl = os.path.join(wip, "template/") - cf_set_value("WIP_DIRS", "template", wip_tpl) + cf_set("WIP_DIRS", "template", wip_tpl) wip_images = os.path.join(wip, "images/") - cf_set_value("WIP_DIRS", "images", wip_images) + cf_set("WIP_DIRS", "images", wip_images) wip_files = os.path.join(wip, "files/") - cf_set_value("WIP_DIRS", "files", wip_files) + cf_set("WIP_DIRS", "files", wip_files) # [WWW_DIRS] # ========== global www_tpl, www_images, www_files www_tpl = os.path.join(www, "template/") - cf_set_value("WWW_DIRS", "template", www_tpl) + cf_set("WWW_DIRS", "template", www_tpl) www_images = os.path.join(www, "images/") - cf_set_value("WWW_DIRS", "images", www_images) + cf_set("WWW_DIRS", "images", www_images) www_files = os.path.join(www, "files/") - cf_set_value("WWW_DIRS", "files", www_files) + cf_set("WWW_DIRS", "files", www_files) # [WEBSITE] # ========= global wip_url, www_url, lang, css, sep, article_code, static - wip_url = cf_set_value("WEBSITE", "wip_url", "") + wip_url = cf_set("WEBSITE", "wip_url", "") if not wip_url: - wip_url = cf_set_value("WEBSITE", "wip_url", create_wip_url()) + wip_url = cf_set("WEBSITE", "wip_url", create_wip_url()) - www_url = cf_set_value("WEBSITE", "www_url", "") + www_url = cf_set("WEBSITE", "www_url", "") if not www_url: - www_url = cf_set_value("WEBSITE", "www_url", "https://%s/"%name) + www_url = cf_set("WEBSITE", "www_url", "https://%s/"%name) - lang = cf_set_value("WEBSITE", "lang", "") + lang = cf_set("WEBSITE", "lang", "") if not lang: - lang = cf_set_value("WEBSITE", "lang", langs.load_website_lang()) + lang = cf_set("WEBSITE", "lang", langs.load_website_lang()) elif not langs.translation_exists("website", lang, False): lang = langs.get_sys_lang() langs.load_website_lang() - css = cf_set_value("WEBSITE", "css", "") + css = cf_set("WEBSITE", "css", "") if not css: - css = cf_set_value("WEBSITE", "css", "tyto") + css = cf_set("WEBSITE", "css", "tyto") - sep = cf_set_value("WEBSITE", "separator", "") + sep = cf_set("WEBSITE", "separator", "") if not sep or len(sep) > 2: - sep = cf_set_value("WEBSITE", "separator", "|") + sep = cf_set("WEBSITE", "separator", "|") try: article_code = cf.getboolean("WEBSITE", "article_code") - except: article_code = cf_set_value("WEBSITE", "article_code", "yes") + except: article_code = cf_set("WEBSITE", "article_code", "yes") try: static = cf.getboolean("WEBSITE", "static") - except: static = cf_set_value("WEBSITE", "static", "no") + except: static = cf_set("WEBSITE", "static", "no") # [WEBSITE_MODULES] # ================= global navbar, sidebar_title, sidebar_items, rss_items, sitemaps try: navbar = cf.getboolean("WEBSITE_MODULES", "navbar") - except: navbar = cf_set_value("WEBSITE_MODULES", "navbar", "yes") + except: navbar = cf_set("WEBSITE_MODULES", "navbar", "yes") - sidebar_title = cf_set_value("WEBSITE_MODULES", "sidebar_title", "") + sidebar_title = cf_set("WEBSITE_MODULES", "sidebar_title", "") if not sidebar_title: - sidebar_title = cf_set_value("WEBSITE_MODULES", "sidebar_title", + sidebar_title = cf_set("WEBSITE_MODULES", "sidebar_title", langs.site.sidebar_title) - sidebar_items = cf_set_value("WEBSITE_MODULES", "sidebar_items", "") + sidebar_items = cf_set("WEBSITE_MODULES", "sidebar_items", "") if not sidebar_items or not sidebar_items.isdigit(): - sidebar_items = cf_set_value("WEBSITE_MODULES", "sidebar_items", "0") + sidebar_items = cf_set("WEBSITE_MODULES", "sidebar_items", "0") - rss_items = cf_set_value("WEBSITE_MODULES", "rss_items", "") + rss_items = cf_set("WEBSITE_MODULES", "rss_items", "") if not rss_items or not rss_items.isdigit(): - rss_items = cf_set_value("WEBSITE_MODULES", "rss_items", "0") + rss_items = cf_set("WEBSITE_MODULES", "rss_items", "0") try: sitemaps = cf.getboolean("WEBSITE_MODULES", "sitemaps") - except: sitemaps = cf_set_value("WEBSITE_MODULES", "sitemaps", "yes") + except: sitemaps = cf_set("WEBSITE_MODULES", "sitemaps", "yes") # TEMPLATE_FILENAMES # ================== global favicon, logo, styles, rss, stats - favicon = cf_set_value("TEMPLATE_FILENAMES", "favicon", "") + favicon = cf_set("TEMPLATE_FILENAMES", "favicon", "") if not favicon: - favicon = cf_set_value("TEMPLATE_FILENAMES", "favicon", "favicon.png") + favicon = cf_set("TEMPLATE_FILENAMES", "favicon", "favicon.png") - logo = cf_set_value("TEMPLATE_FILENAMES", "logo", "") + logo = cf_set("TEMPLATE_FILENAMES", "logo", "") if not logo: - logo = cf_set_value("TEMPLATE_FILENAMES", "logo", "logo.png") + logo = cf_set("TEMPLATE_FILENAMES", "logo", "logo.png") - styles = cf_set_value("TEMPLATE_FILENAMES", "styles", "") + styles = cf_set("TEMPLATE_FILENAMES", "styles", "") if not styles: - styles = cf_set_value("TEMPLATE_FILENAMES", "styles", "styles.css") + styles = cf_set("TEMPLATE_FILENAMES", "styles", "styles.css") - rss = cf_set_value("TEMPLATE_FILENAMES", "rss", "") + rss = cf_set("TEMPLATE_FILENAMES", "rss", "") if not rss: - rss = cf_set_value("TEMPLATE_FILENAMES", "rss", "rss.xml") + rss = cf_set("TEMPLATE_FILENAMES", "rss", "rss.xml") - stats = cf_set_value("TEMPLATE_FILENAMES", "stats", "") + stats = cf_set("TEMPLATE_FILENAMES", "stats", "") if not stats: - stats = cf_set_value("TEMPLATE_FILENAMES", "stats", "tyto_stats.ini") + stats = cf_set("TEMPLATE_FILENAMES", "stats", "tyto_stats.ini") # [USER_DIRS] # =========== - cf_set_value("USER_DIRS", "root", wrk_dir) - cf_set_value("USER_DIRS", "articles", wrk_articles) - cf_set_value("USER_DIRS", "images", wrk_images) - cf_set_value("USER_DIRS", "files", wrk_files) - cf_set_value("USER_DIRS", "template", wrk_tpl) - cf_set_value("USER_DIRS", "modules", wrk_mods) - cf_set_value("USER_DIRS", "database", wrk_db) + cf_set("USER_DIRS", "root", wrk_dir) + cf_set("USER_DIRS", "articles", wrk_articles) + cf_set("USER_DIRS", "images", wrk_images) + cf_set("USER_DIRS", "files", wrk_files) + cf_set("USER_DIRS", "template", wrk_tpl) + cf_set("USER_DIRS", "modules", wrk_mods) + cf_set("USER_DIRS", "database", wrk_db) # [USER_TEMPLATE_FILES] # ===================== global wrk_favicon, wrk_logo, wri_styles wrk_favicon = os.path.join(wrk_tpl, favicon) - cf_set_value("USER_TEMPLATE_FILES", "favicon", wrk_favicon) + cf_set("USER_TEMPLATE_FILES", "favicon", wrk_favicon) wrk_logo = os.path.join(wrk_tpl, logo) - cf_set_value("USER_TEMPLATE_FILES", "logo", wrk_logo) + cf_set("USER_TEMPLATE_FILES", "logo", wrk_logo) wrk_styles = os.path.join(wrk_tpl, styles) - cf_set_value("USER_TEMPLATE_FILES", "styles", wrk_styles) + cf_set("USER_TEMPLATE_FILES", "styles", wrk_styles) # [USER_MODULES_FILES] # ==================== global wrk_metas, wrk_header, wrk_navbar, wrk_sidebar, wrk_footer wrk_metas = os.path.join(wrk_mods, "tyto_metas.raw") - cf_set_value("USER_MODULES_FILES", "metas", wrk_metas) + cf_set("USER_MODULES_FILES", "metas", wrk_metas) wrk_header = os.path.join(wrk_mods, "tyto_header.raw") - cf_set_value("USER_MODULES_FILES", "header", wrk_header) + cf_set("USER_MODULES_FILES", "header", wrk_header) wrk_navbar = os.path.join(wrk_mods, "tyto_navbar.raw") - cf_set_value("USER_MODULES_FILES", "navbar", wrk_navbar) + cf_set("USER_MODULES_FILES", "navbar", wrk_navbar) wrk_sidebar = os.path.join(wrk_mods, "tyto_sidebar.raw") - cf_set_value("USER_MODULES_FILES", "sidebar", wrk_sidebar) + cf_set("USER_MODULES_FILES", "sidebar", wrk_sidebar) wrk_footer = os.path.join(wrk_mods, "tyto_footer.raw") - cf_set_value("USER_MODULES_FILES", "footer", wrk_footer) + cf_set("USER_MODULES_FILES", "footer", wrk_footer) # [WIP_FILES] # =========== global wip_favicon, wip_logo, wip_styles, wip_rss, wip_stats wip_favicon = os.path.join(wip_tpl, favicon) - cf_set_value("WIP_FILES", "favicon", wip_favicon) + cf_set("WIP_FILES", "favicon", wip_favicon) wip_logo = os.path.join(wip_tpl, logo) - cf_set_value("WIP_FILES", "logo", wip_logo) + cf_set("WIP_FILES", "logo", wip_logo) wip_styles = os.path.join(wip_tpl, styles) - cf_set_value("WIP_FILES", "styles", wip_styles) + cf_set("WIP_FILES", "styles", wip_styles) wip_rss = os.path.join(wip_tpl, rss) - cf_set_value("WIP_FILES", "rss", wip_rss) + cf_set("WIP_FILES", "rss", wip_rss) wip_stats = os.path.join(wip_tpl, stats) - cf_set_value("WIP_FILES", "stats", wip_stats) + cf_set("WIP_FILES", "stats", wip_stats) global wip_metas, wip_header, wip_navbar, wip_sidebar, wip_footer wip_metas = os.path.join(wip_tpl, "metas.html") - cf_set_value("WIP_FILES", "metas", wip_metas) + cf_set("WIP_FILES", "metas", wip_metas) wip_header = os.path.join(wip_tpl, "header.html") - cf_set_value("WIP_FILES", "header", wip_header) + cf_set("WIP_FILES", "header", wip_header) wip_navbar = os.path.join(wip_tpl, "navbar.html") - cf_set_value("WIP_FILES", "navbar", wip_navbar) + cf_set("WIP_FILES", "navbar", wip_navbar) wip_sidebar = os.path.join(wip_tpl, "sidebar.html") - cf_set_value("WIP_FILES", "sidebar", wip_sidebar) + cf_set("WIP_FILES", "sidebar", wip_sidebar) wip_footer = os.path.join(wip_tpl, "footer.html") - cf_set_value("WIP_FILES", "footer", wip_footer) + cf_set("WIP_FILES", "footer", wip_footer) # [WWW_FILES] # =========== global www_favicon, www_logo, www_styles, www_rss, www_stats www_favicon = os.path.join(www_tpl, favicon) - cf_set_value("WWW_FILES", "favicon", www_favicon) + cf_set("WWW_FILES", "favicon", www_favicon) www_logo = os.path.join(www_tpl, logo) - cf_set_value("WWW_FILES", "logo", www_logo) + cf_set("WWW_FILES", "logo", www_logo) www_styles = os.path.join(www_tpl, styles) - cf_set_value("WWW_FILES", "styles", www_styles) + cf_set("WWW_FILES", "styles", www_styles) www_rss = os.path.join(www_tpl, rss) - cf_set_value("WWW_FILES", "rss", www_rss) + cf_set("WWW_FILES", "rss", www_rss) www_stats = os.path.join(www_tpl, stats) - cf_set_value("WWW_FILES", "stats", www_stats) + cf_set("WWW_FILES", "stats", www_stats) global www_metas, www_header, www_navbar, www_sidebar, www_footer www_metas = os.path.join(www_tpl, "metas.html") - cf_set_value("WWW_FILES", "metas", www_metas) + cf_set("WWW_FILES", "metas", www_metas) www_header = os.path.join(www_tpl, "header.html") - cf_set_value("WWW_FILES", "header", www_header) + cf_set("WWW_FILES", "header", www_header) www_navbar = os.path.join(www_tpl, "navbar.html") - cf_set_value("WWW_FILES", "navbar", www_navbar) + cf_set("WWW_FILES", "navbar", www_navbar) www_sidebar = os.path.join(www_tpl, "sidebar.html") - cf_set_value("WWW_FILES", "sidebar", www_sidebar) + cf_set("WWW_FILES", "sidebar", www_sidebar) www_footer = os.path.join(www_tpl, "footer.html") - cf_set_value("WWW_FILES", "footer", www_footer) + cf_set("WWW_FILES", "footer", www_footer) # [TYTO] # ====== - cf_set_value("TYTO", "domain_hash", cf_id) - cf_set_value("TYTO", "domain_conf", cf_uri) - cf_set_value("TYTO", "domain_user", ult_cf_uri) + cf_set("TYTO", "domain_hash", cf_id) + cf_set("TYTO", "domain_conf", cf_uri) + cf_set("TYTO", "domain_user", ult_cf_uri) # ================================= # diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index b009313..1bf5fea 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -33,10 +33,11 @@ #-------------------------- import os, sys, configparser -import domain, debug, tools, tyto +import args, domain, debug, tools, tyto error = 0 +write = False # When updating database in cf_set(), cf_write() #============================================# @@ -57,7 +58,7 @@ def is_article(target): # Article exists global uri - uri = os.path.join(domain.wrk_articles, target) + uri = os.path.join(domain.user_dir, target) if not os.path.exists(uri): error = debug.out(5, "False", uri, True, 2, False) return False @@ -77,11 +78,10 @@ def is_article(target): # Set target from articles/ wrk_target = uri.rsplit(domain.wrk_articles)[1] - # Load Database - global db - db = False - db = cf_load() # True or False - + # Load Database, get and compare values + cf_load() + cf_datas() + compare_datas() return True @@ -131,19 +131,112 @@ def cf_load(): 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 +#================================# +# Return value from section, key # +#--------------------------------# +def cf_get(section, key, boolean): + if boolean: + try: return cf.getboolean(section, key) + except: return False - chk_hash = cf.get("CHECK", "hash") - wip_hash = cf.get("WIP", "hash") - www_hash = cf.get("WWW", "hash") + try: return cf.get(section, key) + except: return "" + + +#=============================================# +# Get and prepare new vars from post database # +#---------------------------------------------# +def cf_datas(): + # [CHECK] + # ------- + global chk_hash, chk_date, chk_static, chk_errors + chk_hash = cf_get("CHECK", "hash", False) + chk_date = cf_get("CHECK", "date", False) + chk_static = cf_get("CHECK", "static", True) + chk_errors = cf_get("CHECK", "errors", True) + + # [WIP] + # ----- + global wip_hash, wip_date, wip_uri, wip_static + wip_hash = cf_get("WIP", "hash", False) + wip_date = cf_get("WIP", "date", False) + wip_uri = cf_get("WIP", "uri", False) + wip_static = cf_get("WIP", "static", True) + + # [WIP] + # ----- + global www_hash, www_date, www_uri, www_static + www_hash = cf_get("WWW", "hash", False) + www_date = cf_get("WWW", "date", False) + www_uri = cf_get("WWW", "uri", False) + www_static = cf_get("WWW", "static", True) + + +#===============================# +# Do some datas comparisons # +# after post cf_datas() setup # +# Used to do processes (mainly) # +#-------------------------------# +def compare_datas(): + global do_chk, do_wip + + do_chk = False + + if chk_errors: + do_chk = True + do_wip = False + + if chk_static != domain.static: + do_chk = True + + if args.force: + do_chk = do_wip = True + + else: + do_chk = tools.compare_values(wrk_id, chk_hash) + do_wip = tools.compare_values(chk_hash, wip_hash) + + +#===============================# +# Set a value in post database # +# only if changed value # +# check for [section] in file # +# or create it with key and val # +# config file must be loaded # +#-------------------------------# +def cf_set(section, key, value): + global write + + try: cf + except: cf_load() + + if not cf.has_section(section): + cf.add_section(section) + + try: curval = cf.get(section, key) + except: curval = "" + + if not curval or curval != value: + cf.set(section, key, value) + write = True + + +#=====================# +# Write post database # +# if new value is set # +#---------------------# +def cf_write(): + global write + + if write: + with open(cf_uri, "w") as f: + cf.write(f) + + write = False #======# @@ -156,16 +249,16 @@ stats_tyto_text_coms = 0 stats_html_coms = 0 stats_titles = 0 stats_bcodes = 0 +stats_bcodes_lines = 0 stats_quotes = 0 stats_parags = 0 +stats_lists = 0 stats_links = 0 stats_images = 0 stats_files = 0 stats_raws = 0 stats_codes = 0 stats_abbrs = 0 -stats_codes = 0 -stats_raws = 0 stats_total_files = 0 @@ -175,27 +268,26 @@ stats_text_images = 0 stats_text_abbrs = 0 stats_text_codes = 0 stats_text_raws = 0 +stats_text_icodes = 0 # head_contents #============== - # Optional Tags nositemap = "! NoSitemap" # Article will not be included in sitemap # One Line needed -sep = "-----" # Splitter between header and article +sep = "-----" # Splitter between header and article texts # Will replace "Fals" with title value -title = ("title:", False) -about = ("about:", False) -date = ("date:", False) -tags = ("tags:", False) +title = ("title:", False) +about = ("about:", False) +date = ("date:", False) +tags = ("tags:", False) author = ("author:", False) -# optional -logo = ("logo:", False) +logo = ("logo:", False) # optional -# Multiple lines (3) +# Multiple lines (3) markers ml_tags = ("link:", "image:", "file:", "raw:", "code:", "abbr:") ml_tags_marks = { "link:" : "__", @@ -224,12 +316,7 @@ value2s_ext_uris = ("http", "ftp") bcodes = ("{{", "}}") quotes = ("[[", "]]") parags = ("((", "))") - -# markers with "protected" contents -raw_contents = ("bcodes", "quotes") - -# Comments -text_comments = (";;", "