From 453ccd6457f592f6eaa05e785aee04ad9c3ebf32 Mon Sep 17 00:00:00 2001 From: nodiscc Date: Wed, 25 Oct 2023 12:08:29 +0000 Subject: [PATCH] processors/awesome_lint: allow skipping last update checks for specific items by `source_code_url` (#124) - `last_updated_skip` - ref. https://github.com/awesome-selfhosted/awesome-selfhosted-data/issues/72 --- CHANGELOG.md | 3 +++ hecat/processors/awesome_lint.py | 12 +++++++++++- tests/.hecat.awesome_lint.yml | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0fb8df..099f60b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). #### [v1.2.1](https://github.com/nodiscc/hecat/releases/tag/1.2.1) - UNRELEASED +**Added:** +- processors/awesome_lint: allow skipping last update checks for specific items by `source_code_url` + **Fixed:** - processors/awesome_lint: don't log last update date check errors twice diff --git a/hecat/processors/awesome_lint.py b/hecat/processors/awesome_lint.py index b6ff858..4fe2c97 100644 --- a/hecat/processors/awesome_lint.py +++ b/hecat/processors/awesome_lint.py @@ -15,6 +15,12 @@ licenses_files: # (optional, default ['licenses.yml']) path to files containing lists of licenses - licenses.yml - licenses-nonfree.yml + last_updated_skip: # (optional, default []) list of items (source_code_url) for which the last update date check should not produce errors/warnings + - https://github.com/tomershvueli/homepage # simple/no maintenance required https://github.com/awesome-selfhosted/awesome-selfhosted-data/pull/242 + - https://github.com/abrenaut/posio # simple/no maintenance required + - https://github.com/knrdl/bicimon # simple/no maintenance required + - https://github.com/Kshitij-Banerjee/Cubiks-2048 # simple/no maintenance required + source_directory: path to directory where data can be found. Directory structure: ├── software @@ -170,7 +176,9 @@ def check_last_updated(software, step, errors): if 'updated_at' in software: last_update_time = datetime.strptime(software['updated_at'], "%Y-%m-%d") time_since_last_update = last_update_time - datetime.now() - if last_update_time < datetime.now() - timedelta(days=step['module_options']['last_updated_error_days']): + if software['source_code_url'] in step['module_options']['last_updated_skip']: + logging.info('%s: skipping last update time check as per configuration (last_updated_skip) (%s)', software['name'], time_since_last_update) + elif last_update_time < datetime.now() - timedelta(days=step['module_options']['last_updated_error_days']): message = '{}: last updated {} ago, older than {} days'.format(software['name'], time_since_last_update, step['module_options']['last_updated_error_days']) log_exception(message, errors, severity=logging.error) elif last_update_time < datetime.now() - timedelta(days=step['module_options']['last_updated_warn_days']): @@ -192,6 +200,8 @@ def awesome_lint(step): step['module_options']['last_updated_error_days'] = 3650 if 'licenses_files' not in step['module_options']: step['module_options']['licenses_files'] = ['/licenses.yml'] + if 'last_updated_skip' not in step['module_options']: + step['module_options']['last_updated_skip'] = [] licenses_list = [] for filename in step['module_options']['licenses_files']: licenses_list = licenses_list + load_yaml_data(step['module_options']['source_directory'] + '/' + filename) diff --git a/tests/.hecat.awesome_lint.yml b/tests/.hecat.awesome_lint.yml index 41269ed..a5b15eb 100644 --- a/tests/.hecat.awesome_lint.yml +++ b/tests/.hecat.awesome_lint.yml @@ -10,3 +10,8 @@ steps: licenses_files: - licenses.yml - licenses-nonfree.yml + last_updated_skip: # (optional, default []) list of items (source_code_url) for which the last update date check should not produce errors/warnings + - https://github.com/tomershvueli/homepage # simple/no maintenance required https://github.com/awesome-selfhosted/awesome-selfhosted-data/pull/242 + - https://github.com/abrenaut/posio # simple/no maintenance required + - https://github.com/knrdl/bicimon # simple/no maintenance required + - https://github.com/Kshitij-Banerjee/Cubiks-2048 # simple/no maintenance required