From 6a9ef0ed6734f17519c23c1fe61afddb97d54a53 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Tue, 7 Feb 2023 15:16:55 +0100 Subject: [PATCH] check, with edit option: ask to check if changes --- src/var/lib/tyto/program/check.py | 16 +++++++++++++++- src/var/lib/tyto/program/html.py | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index c67376a..0d1282e 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -38,13 +38,27 @@ def manage_check(target, option): # Manage option #-------------- if option == 'Edit': + curr_hash = tyto.get_filesum(db.uri_file, True) tyto.edit_file(db.uri_file) - return + new_hash = tyto.get_filesum(db.uri_file, True) + if curr_hash != new_hash: + ask = '' + try: + ask = input('-> Check your changes ? ') + except KeyboardInterrupt: + print('') + logs.out("255", '', True) + if not ask in ['y', 'Y']: + logs.out("255", '', True) + else: + option = 'Force' + elif option == 'Show': article_raw = open(db.uri_file).read() for line in article_raw.rsplit('\n'): print(line) return + # Just read the DB from command elif option == 'DB': if db.db_exists: diff --git a/src/var/lib/tyto/program/html.py b/src/var/lib/tyto/program/html.py index 48c9573..fb7488f 100644 --- a/src/var/lib/tyto/program/html.py +++ b/src/var/lib/tyto/program/html.py @@ -194,8 +194,8 @@ def create_main_page(target, article_bottom): def create_html_infos_section(process): # Need to reload the DB to get last time updated exec(open(db.post_db).read(), globals()) - global post_pub + global post_pub if process == 'wip': date_raw = date_wip #