From fc529b167234b9720557cdbca1fa7fa6949b7295 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 00:57:46 +0200 Subject: [PATCH 01/20] Mark serve_file as a stub in the function docstring. --- __init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/__init__.py b/__init__.py index 6b257d4..a76e4f2 100644 --- a/__init__.py +++ b/__init__.py @@ -66,6 +66,9 @@ def serve_error(code, message=None): return flask.make_response((flask.render_template(os.path.join(templatehelper.config['template'], template), code=code, message=message, templatehelper=templatehelper, pathprefix=pathprefix, path=''), code, None)) def serve_file(path): + """ + Left as just a stub as it is unlikely to be called anytime soon. + """ return flask.send_file(os.path.join('..', 'public', path)) return app From 194a9fe5fe92b39253d8610037bb1187817f7853 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 00:58:55 +0200 Subject: [PATCH 02/20] Explicitely specify the "public" directory as this is needed by FastCGI. --- templates/nomike.com/directory.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/nomike.com/directory.html b/templates/nomike.com/directory.html index 71a8dd4..755514d 100644 --- a/templates/nomike.com/directory.html +++ b/templates/nomike.com/directory.html @@ -1,15 +1,15 @@ {# scms Copyright (C) 2020 - nomike This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. This is free software, and you are welcome to redistribute it under certain conditions -#} {% extends templatehelper.os.path.join(templatehelper.config['template'], 'base.html') - -%} {% block title %}/{{ path }}{% endblock %}\ {% block menu %} {% if not templatehelper.os.path.exists(templatehelper.os.path.join('public', path, '.scmsnonavigation')): -%} + -%} {% block title %}/{{ path }}{% endblock %}\ {% block menu %} {% if not templatehelper.os.path.exists(templatehelper.os.path.join(path, '.scmsnonavigation')): -%} {% endif -%} {% endblock -%} {% block content -%} {% if templatehelper.os.path.isfile(templatehelper.os.path.join(pathprefix, path,'index.md')) -%} {{ templatehelper.markdown.markdown(templatehelper.readfile(templatehelper.os.path.join(pathprefix,path,'index.md')),extensions=['fenced_code','toc','tables']) From 5ab8b135aff969bc3accd325220333d4df211b15 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 01:01:04 +0200 Subject: [PATCH 03/20] Adapt scms.fcgi.example for FastCGI usage. --- scms.fcgi.example | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scms.fcgi.example b/scms.fcgi.example index af4021a..a5d9de0 100644 --- a/scms.fcgi.example +++ b/scms.fcgi.example @@ -1,11 +1,8 @@ #!/home/user/venv/bin/python import sys -sys.path.append('..') +sys.path.append('.') sys.path.append('../scms') from flup.server.fcgi import WSGIServer -from scms import app - -if __name__ == '__main__': - WSGIServer(app).run() +from scms import app as application From 577df786dfec0645b519ce3b0e71dc6db5ce6c4f Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 01:05:45 +0200 Subject: [PATCH 04/20] Add license header to scms.fcgi.example. --- scms.fcgi.example | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scms.fcgi.example b/scms.fcgi.example index a5d9de0..c4c0c08 100644 --- a/scms.fcgi.example +++ b/scms.fcgi.example @@ -1,4 +1,10 @@ #!/home/user/venv/bin/python + +# scms Copyright (C) 2020 - nomike +# This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. +# This is free software, and you are welcome to redistribute it +# under certain conditions; type `show c' for details. + import sys sys.path.append('.') From f652bd70876318a7ae9c3da79db79f32d75aa994 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 01:06:44 +0200 Subject: [PATCH 05/20] Explicitely specify the "public" directory as this is needed by FastCGI. --- templates/nomike.com/base.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/nomike.com/base.html b/templates/nomike.com/base.html index eaafc20..c7b4c14 100644 --- a/templates/nomike.com/base.html +++ b/templates/nomike.com/base.html @@ -1,4 +1,4 @@ -{% if not templatehelper.os.path.exists(templatehelper.os.path.join('public', path, '.scmsnotemplate')): -%} +{% if not templatehelper.os.path.exists(templatehelper.os.path.join(path, '.scmsnotemplate')): -%} @@ -35,11 +35,11 @@ {% endblock %} {% block menu %}{% endblock %}
- {% endif -%} {% block content -%}{% endblock -%} {% if not templatehelper.os.path.exists(templatehelper.os.path.join('public', path, '.scmsnotemplate')): -%} + {% endif -%} {% block content -%}{% endblock -%} {% if not templatehelper.os.path.exists(templatehelper.os.path.join(path, '.scmsnotemplate')): -%}

 

From 0d2fdbda5201d2d11d8538251b5d27579136a8d0 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 01:08:35 +0200 Subject: [PATCH 06/20] Make it more obvious that the shebang in scsm.fcgi.example needs to be adapted. --- scms.fcgi.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scms.fcgi.example b/scms.fcgi.example index c4c0c08..84f1669 100644 --- a/scms.fcgi.example +++ b/scms.fcgi.example @@ -1,4 +1,4 @@ -#!/home/user/venv/bin/python +#!/home//venv/bin/python # scms Copyright (C) 2020 - nomike # This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. From 356bb48e875029d20f3ff66021cb2f762558fc4e Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 01:13:08 +0200 Subject: [PATCH 07/20] Code linting. --- templatehelper.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/templatehelper.py b/templatehelper.py index 17a3ba5..fe53ab6 100644 --- a/templatehelper.py +++ b/templatehelper.py @@ -5,33 +5,34 @@ Example: {% for parentpath, parentname in templatehelper.getparents(path) %} - {{ parentname }} + + {{ parentname }} + {% endfor %} """ +import fnmatch +import json +import mimetypes import os -import re + import regex -import mimetypes -import fnmatch -from datetime import datetime, tzinfo, timezone import yaml -import markdown -import urllib -import json config = None with open("../config.yaml") as file: config = yaml.load(file, Loader=yaml.SafeLoader) -# paths sent by flask are relative to the "public" directory. This prefix should be added to get paths relative to the pages root directory. +# paths sent by flask are relative to the "public" directory. This prefix should be added to get +# paths relative to the pages root directory. #TODO: This is a redundant specification and should be avoided. pathprefix = '' # List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml # If you want additional mimetypes to be covered, add them to this list. -# The types map to FontAwesome identifiers. Check out https://fontawesome.com/icons?d=gallery for a list of available images. +# The types map to FontAwesome identifiers. Check out https://fontawesome.com/icons?d=gallery +# for a list of available images. mimetype_fas_mapping = { # Media 'image': 'fa-file-image', @@ -62,11 +63,12 @@ def listdir(path): List all child-elements of the specified path. Hidden files and, files ending in ".scmsfasicon" and files ending with a "~" are ignored. - You can also ignore additional files by creating a file called ".scmsignore" in the current folder. + You can also ignore additional files by creating a file called ".scmsignore" in the current + folder. All files listed in there will not be listed. - If a file named "index" is present, it is supposed to be rendered as the main content of the page - and thus it will be ommited from the list as well. + If a file named "index" is present, it is supposed to be rendered as the main content of the + page and thus it will be ommited from the list as well. """ ignorelist = ['index', 'index.md', '*.scmsfasicon', '*.scmstarget'] if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')): @@ -88,11 +90,12 @@ def listchildren(path): List all child-elements of the specified path. Hidden files and, files ending in ".scmsfasicon" and files ending with a "~" are ignored. - You can also ignore additional files by creating a file called ".scmsignore" in the current folder. + You can also ignore additional files by creating a file called ".scmsignore" in the current + folder. All files listed in there will not be listed. - If a file named "index" is present, it is supposed to be rendered as the main content of the page - and thus it will be ommited from the list as well. + If a file named "index" is present, it is supposed to be rendered as the main content of the + page and thus it will be ommited from the list as well. """ ignorelist = ['index', 'index.md', '*.scmsfasicon', '*.scmstarget'] if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')): @@ -118,7 +121,8 @@ def getparents(path): Return a list of tupels with all parent elements. Tupels have the format (path, basename) - path: the full path relative to the "public" folder, leading to the parent, including the basename + path: the full path relative to the "public" folder, leading to the parent, including the + basename basename: only the basename of the parent """ pathelements = path.split(os.path.sep)[:-1] From f6097c2c07bebe85ce0a93b3df44409b597eb656 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 01:59:51 +0200 Subject: [PATCH 08/20] Code linting. --- __init__.py | 40 ++++++++++++++++++++++++++++++++-------- templatehelper.py | 12 ++++++++++-- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/__init__.py b/__init__.py index a76e4f2..b6aa2e8 100644 --- a/__init__.py +++ b/__init__.py @@ -20,8 +20,12 @@ def create_app(): """ Factory for creating a Flask application. """ - app = Flask(__name__, instance_relative_config=True, static_folder='templates/{}/static'.format(templatehelper.config['template'])) - # paths sent by flask are relative to the "public" directory. This prefix should be added to get paths relative to the pages root directory. + app = Flask( + __name__, + instance_relative_config=True, + static_folder='templates/{}/static'.format(templatehelper.config['template'])) + # paths sent by flask are relative to the "public" directory. This prefix should be added to + # get paths relative to the pages root directory. pathprefix = '' @app.route('/') @@ -36,8 +40,10 @@ def serve_directory_or_file(path): if os.path.isdir(fullpath): return serve_directory(path) else: - # If a specified path exists, dreamhost seems to serve the file directly without invoking this Flask application. - # As nonexistent paths are taken care of above, this else-branch is not expected to ever be called. It is left in as a + # If a specified path exists, dreamhost seems to serve the file directly without + # invoking this Flask application. + # As nonexistent paths are taken care of above, this else-branch is not expected to + # ever be called. It is left in as a # stub though, in case this ever changes. return serve_file(path) @@ -49,7 +55,11 @@ def serve_directory(path): # Ensure paths always end with a "/" return flask.redirect('/' + path + '/') else: - return flask.render_template(os.path.join(templatehelper.config['template'], 'directory.html'), pathprefix = pathprefix, path = path, templatehelper = templatehelper) + return flask.render_template( + os.path.join(templatehelper.config['template'], 'directory.html'), + pathprefix = pathprefix, + path = path, + templatehelper = templatehelper) @app.route('/') def serve_root(): @@ -59,11 +69,25 @@ def serve_root(): return serve_directory_or_file(os.path.curdir) def serve_error(code, message=None): - if os.path.exists(os.path.join(__name__, 'templates', templatehelper.config['template'], '%d.html' % (code))): + if os.path.exists( + os.path.join( + __name__, + 'templates', + templatehelper.config['template'], + '%d.html' % (code))): template = '%d.html' % (code) else: template = 'error.html' - return flask.make_response((flask.render_template(os.path.join(templatehelper.config['template'], template), code=code, message=message, templatehelper=templatehelper, pathprefix=pathprefix, path=''), code, None)) + return flask.make_response(( + flask.render_template( + os.path.join(templatehelper.config['template'], template), + code=code, + message=message, + templatehelper=templatehelper, + pathprefix=pathprefix, + path=''), + code, + None)) def serve_file(path): """ @@ -74,4 +98,4 @@ def serve_file(path): return app # Create an instance of the scms application. -app = create_app() \ No newline at end of file +app = create_app() diff --git a/templatehelper.py b/templatehelper.py index fe53ab6..b1e06ef 100644 --- a/templatehelper.py +++ b/templatehelper.py @@ -74,7 +74,11 @@ def listdir(path): if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')): with open(os.path.join(pathprefix, path, '.scmsignore')) as file: ignorelist.extend([line.strip('\n') for line in file.readlines()]) - dirlist = [os.path.basename(f) for f in os.listdir(os.path.join(pathprefix, path)) if regex.match('^(?!\\.).*(? Date: Wed, 18 Sep 2024 02:07:52 +0200 Subject: [PATCH 09/20] Ignore .venv from git. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1e12e92..6b5820e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__/ *~ # C extensions *.so +.venv From cc4715b1f7263bc0019cff708fdcc6c33c48cd69 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:08:05 +0200 Subject: [PATCH 10/20] Add requirements.txt vor venvs. --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4834a59 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +pyyaml From 4bde051c07bb89fbbab3f72e66196778a516f81e Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:08:16 +0200 Subject: [PATCH 11/20] Code linting. --- __init__.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/__init__.py b/__init__.py index b6aa2e8..11b42d6 100644 --- a/__init__.py +++ b/__init__.py @@ -8,13 +8,14 @@ """ import os -from flask import Flask -import flask +import urllib.parse from io import StringIO -import re + +import flask +from flask import Flask + from . import templatehelper -import urllib.parse -import yaml + def create_app(): """ @@ -23,11 +24,11 @@ def create_app(): app = Flask( __name__, instance_relative_config=True, - static_folder='templates/{}/static'.format(templatehelper.config['template'])) + static_folder=f"templates/{templatehelper.config['template']}/static") # paths sent by flask are relative to the "public" directory. This prefix should be added to # get paths relative to the pages root directory. pathprefix = '' - + @app.route('/') def serve_directory_or_file(path): """ @@ -39,13 +40,13 @@ def serve_directory_or_file(path): return serve_error(404, "File not found...") if os.path.isdir(fullpath): return serve_directory(path) - else: - # If a specified path exists, dreamhost seems to serve the file directly without - # invoking this Flask application. - # As nonexistent paths are taken care of above, this else-branch is not expected to - # ever be called. It is left in as a - # stub though, in case this ever changes. - return serve_file(path) + + # If a specified path exists, dreamhost seems to serve the file directly without + # invoking this Flask application. + # As nonexistent paths are taken care of above, this else-branch is not expected to + # ever be called. It is left in as a + # stub though, in case this ever changes. + return serve_file(path) def serve_directory(path): """ @@ -54,13 +55,12 @@ def serve_directory(path): if not path.endswith('/') and len(path) > 1: # Ensure paths always end with a "/" return flask.redirect('/' + path + '/') - else: - return flask.render_template( - os.path.join(templatehelper.config['template'], 'directory.html'), - pathprefix = pathprefix, - path = path, - templatehelper = templatehelper) - + return flask.render_template( + os.path.join(templatehelper.config['template'], 'directory.html'), + pathprefix = pathprefix, + path = path, + templatehelper = templatehelper) + @app.route('/') def serve_root(): """ @@ -74,8 +74,8 @@ def serve_error(code, message=None): __name__, 'templates', templatehelper.config['template'], - '%d.html' % (code))): - template = '%d.html' % (code) + f'{code}.html')): + template = f'{code}.html' else: template = 'error.html' return flask.make_response(( From f5074276c21ff3978b11135a5ef058828b5491cc Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:12:58 +0200 Subject: [PATCH 12/20] Code linting. --- __init__.py | 8 ++++---- templatehelper.py | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/__init__.py b/__init__.py index 11b42d6..c35d81c 100644 --- a/__init__.py +++ b/__init__.py @@ -24,7 +24,7 @@ def create_app(): app = Flask( __name__, instance_relative_config=True, - static_folder=f"templates/{templatehelper.config['template']}/static") + static_folder=f"templates/{templatehelper.CONFIG['template']}/static") # paths sent by flask are relative to the "public" directory. This prefix should be added to # get paths relative to the pages root directory. pathprefix = '' @@ -56,7 +56,7 @@ def serve_directory(path): # Ensure paths always end with a "/" return flask.redirect('/' + path + '/') return flask.render_template( - os.path.join(templatehelper.config['template'], 'directory.html'), + os.path.join(templatehelper.CONFIG['template'], 'directory.html'), pathprefix = pathprefix, path = path, templatehelper = templatehelper) @@ -73,14 +73,14 @@ def serve_error(code, message=None): os.path.join( __name__, 'templates', - templatehelper.config['template'], + templatehelper.CONFIG['template'], f'{code}.html')): template = f'{code}.html' else: template = 'error.html' return flask.make_response(( flask.render_template( - os.path.join(templatehelper.config['template'], template), + os.path.join(templatehelper.CONFIG['template'], template), code=code, message=message, templatehelper=templatehelper, diff --git a/templatehelper.py b/templatehelper.py index b1e06ef..4d2a8a7 100644 --- a/templatehelper.py +++ b/templatehelper.py @@ -19,15 +19,15 @@ import regex import yaml -config = None -with open("../config.yaml") as file: - config = yaml.load(file, Loader=yaml.SafeLoader) +CONFIG = None +with open("../config.yaml", encoding='utf-8') as file: + CONFIG = yaml.load(file, Loader=yaml.SafeLoader) # paths sent by flask are relative to the "public" directory. This prefix should be added to get # paths relative to the pages root directory. #TODO: This is a redundant specification and should be avoided. -pathprefix = '' +PATHPREFIX = '' # List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml # If you want additional mimetypes to be covered, add them to this list. @@ -71,12 +71,12 @@ def listdir(path): page and thus it will be ommited from the list as well. """ ignorelist = ['index', 'index.md', '*.scmsfasicon', '*.scmstarget'] - if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')): - with open(os.path.join(pathprefix, path, '.scmsignore')) as file: + if os.path.exists(os.path.join(PATHPREFIX, path, '.scmsignore')): + with open(os.path.join(PATHPREFIX, path, '.scmsignore'), encoding='utf-8') as file: ignorelist.extend([line.strip('\n') for line in file.readlines()]) dirlist = [ os.path.basename(f) - for f in os.listdir(os.path.join(pathprefix, path)) + for f in os.listdir(os.path.join(PATHPREFIX, path)) if regex.match('^(?!\\.).*(? Date: Wed, 18 Sep 2024 02:14:48 +0200 Subject: [PATCH 13/20] Code linting. --- templatehelper.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/templatehelper.py b/templatehelper.py index 4d2a8a7..c8e0fcc 100644 --- a/templatehelper.py +++ b/templatehelper.py @@ -111,7 +111,7 @@ def listchildren(path): if regex.match('^(?!\\.).*(? Date: Wed, 18 Sep 2024 02:19:36 +0200 Subject: [PATCH 14/20] Code linting. --- templatehelper.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/templatehelper.py b/templatehelper.py index c8e0fcc..c2c4260 100644 --- a/templatehelper.py +++ b/templatehelper.py @@ -72,18 +72,18 @@ def listdir(path): """ ignorelist = ['index', 'index.md', '*.scmsfasicon', '*.scmstarget'] if os.path.exists(os.path.join(PATHPREFIX, path, '.scmsignore')): - with open(os.path.join(PATHPREFIX, path, '.scmsignore'), encoding='utf-8') as file: - ignorelist.extend([line.strip('\n') for line in file.readlines()]) + with open(os.path.join(PATHPREFIX, path, '.scmsignore'), encoding='utf-8') as scsmignore: + ignorelist.extend([line.strip('\n') for line in scsmignore.readlines()]) dirlist = [ os.path.basename(f) for f in os.listdir(os.path.join(PATHPREFIX, path)) if regex.match('^(?!\\.).*(? Date: Wed, 18 Sep 2024 02:30:45 +0200 Subject: [PATCH 15/20] Code linting. --- __init__.py | 15 ++++++++------- templatehelper.py | 18 +++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/__init__.py b/__init__.py index c35d81c..99fd715 100644 --- a/__init__.py +++ b/__init__.py @@ -17,11 +17,11 @@ from . import templatehelper -def create_app(): +def create_application(): """ Factory for creating a Flask application. """ - app = Flask( + application = Flask( __name__, instance_relative_config=True, static_folder=f"templates/{templatehelper.CONFIG['template']}/static") @@ -29,7 +29,7 @@ def create_app(): # get paths relative to the pages root directory. pathprefix = '' - @app.route('/') + @application.route('/') def serve_directory_or_file(path): """ Main handler for all paths @@ -61,10 +61,11 @@ def serve_directory(path): path = path, templatehelper = templatehelper) - @app.route('/') + @application.route('/') def serve_root(): """ - `@app.route('/')` doesn't match '/' and thus this convenience function is needed. + `@application.route('/')` doesn't match '/' and thus this convenience function + is needed. """ return serve_directory_or_file(os.path.curdir) @@ -95,7 +96,7 @@ def serve_file(path): """ return flask.send_file(os.path.join('..', 'public', path)) - return app + return application # Create an instance of the scms application. -app = create_app() +app = create_application() diff --git a/templatehelper.py b/templatehelper.py index c2c4260..32031d3 100644 --- a/templatehelper.py +++ b/templatehelper.py @@ -26,7 +26,6 @@ # paths sent by flask are relative to the "public" directory. This prefix should be added to get # paths relative to the pages root directory. -#TODO: This is a redundant specification and should be avoided. PATHPREFIX = '' # List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml @@ -136,6 +135,7 @@ def getparents(path): pathelements = path.split(os.path.sep)[:-1] parents = [] i = 0 + # pylint: disable=consider-using-enumerate for i in range(0, len(pathelements)): parents.append(('/' + '/'.join(pathelements[:i+1]), pathelements[i])) return parents @@ -178,18 +178,22 @@ def getfastype(path): return 'fa-file' def getlastmodifiedfile(path): + """ + Recursively search for the newest file in the specified directory. + """ + path = os.path.join('..', path) assert os.path.isdir(path) newest = {"file": path, "timestamp": os.path.getmtime(path)} for root, dirs, files in os.walk(path): - for path in dirs: - timestamp = os.path.getmtime(os.path.join(root, path)) + for directory in dirs: + timestamp = os.path.getmtime(os.path.join(root, directory)) if timestamp > newest['timestamp']: - newest['file'] = os.path.join(root, path) + newest['file'] = os.path.join(root, directory) newest['timestamp'] = timestamp - for path in files: - timestamp = os.path.getmtime(os.path.join(root, path)) + for directory in files: + timestamp = os.path.getmtime(os.path.join(root, directory)) if timestamp > newest['timestamp']: - newest['file'] = os.path.join(root, path) + newest['file'] = os.path.join(root, directory) newest['timestamp'] = timestamp return newest From fea583153bec1fbf64fba0d5f8643cbc614af60f Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:31:01 +0200 Subject: [PATCH 16/20] Add regex to requirements.txt. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 4834a59..a73b78c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ flask pyyaml +regex From 6607aa0baa26a4353c9ecc38223aedebabb7f685 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:32:22 +0200 Subject: [PATCH 17/20] Install requirements for linting. --- .github/workflows/pylint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 383e65c..e44f0a7 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -18,6 +18,7 @@ jobs: run: | python -m pip install --upgrade pip pip install pylint + pip install -r requirements.txt - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') From 5d1a15e9b4a9e4ae90aa9f5475cd383b398cb535 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:34:14 +0200 Subject: [PATCH 18/20] Drop suppoer for python 3.8. Add support for python 3.11 and 3.12. --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index e44f0a7..dac5ae8 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 5f9f4bdf3c270bd0309fc88b20a3a91dab5ee2a4 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:37:18 +0200 Subject: [PATCH 19/20] Add support for python 3.13. --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index dac5ae8..5228720 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 17a59b60b98da323920a4a0b19c99168e5c5af43 Mon Sep 17 00:00:00 2001 From: nomike Date: Wed, 18 Sep 2024 02:38:43 +0200 Subject: [PATCH 20/20] Specify the rc2 version in pylint workflow for pythonm 3.13.0. --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 5228720..633ac00 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13.0-rc.2"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }}