From 0259f32e880041e3fbfd7bfba2698723c71700c8 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 18 Feb 2023 16:36:30 -0600 Subject: fix flake8 issues, still need to fix 80+ col lines --- src/pyssg/builder.py | 1 - src/pyssg/configuration.py | 6 ++---- src/pyssg/database.py | 4 ++-- src/pyssg/database_entry.py | 1 - src/pyssg/md_parser.py | 5 ++--- src/pyssg/page.py | 5 ++--- src/pyssg/per_level_formatter.py | 1 + src/pyssg/pyssg.py | 1 - src/pyssg/yaml_parser.py | 3 +-- 9 files changed, 10 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/pyssg/builder.py b/src/pyssg/builder.py index c70994d..f09bf08 100644 --- a/src/pyssg/builder.py +++ b/src/pyssg/builder.py @@ -1,6 +1,5 @@ import os import sys -import pprint from copy import deepcopy from operator import itemgetter from logging import Logger, getLogger diff --git a/src/pyssg/configuration.py b/src/pyssg/configuration.py index b68930c..7b292d5 100644 --- a/src/pyssg/configuration.py +++ b/src/pyssg/configuration.py @@ -1,6 +1,5 @@ import sys from importlib.metadata import version -from importlib.resources import path as rpath from datetime import datetime, timezone from logging import Logger, getLogger @@ -67,8 +66,7 @@ def get_static_config() -> dict[str, dict]: log.debug('reading and setting static config') config: dict = get_parsed_yaml('static_config.yaml', 'pyssg.plt')[0] # do I really need a lambda function... - time = lambda x : datetime.now(tz=timezone.utc).strftime(config['fmt'][x]) config['info']['version'] = VERSION - config['info']['rss_run_date'] = time('rss_date') - config['info']['sitemap_run_date'] = time('sitemap_date') + config['info']['rss_run_date'] = datetime.now(tz=timezone.utc).strftime(config['fmt']['rss_date']) + config['info']['sitemap_run_date'] = datetime.now(tz=timezone.utc).strftime(config['fmt']['sitemap_date']) return config diff --git a/src/pyssg/database.py b/src/pyssg/database.py index 40065ef..5d7d71d 100644 --- a/src/pyssg/database.py +++ b/src/pyssg/database.py @@ -36,7 +36,7 @@ class Database: sys.exit(1) def update(self, file_name: str, - remove: str='') -> None: + remove: str = '') -> None: log.debug('updating entry for file "%s"', file_name) f: str = file_name tags: list[str] = [] @@ -55,7 +55,7 @@ class Database: # three cases, 1) entry didn't exist, # 2) entry has been mod and, # 3) entry hasn't been mod - #1) + # 1) if f not in self.e: log.debug('entry "%s" didn\'t exist, adding with defaults', f) self.e[f] = DatabaseEntry([f, time, 0.0, checksum, tags]) diff --git a/src/pyssg/database_entry.py b/src/pyssg/database_entry.py index 1674a7c..5c3e659 100644 --- a/src/pyssg/database_entry.py +++ b/src/pyssg/database_entry.py @@ -1,4 +1,3 @@ -from typing import Union from logging import Logger, getLogger log: Logger = getLogger(__name__) diff --git a/src/pyssg/md_parser.py b/src/pyssg/md_parser.py index 07c62f8..3119db7 100644 --- a/src/pyssg/md_parser.py +++ b/src/pyssg/md_parser.py @@ -1,6 +1,5 @@ import os from operator import itemgetter -from markdown import Markdown from logging import Logger, getLogger from markdown import Markdown @@ -71,8 +70,8 @@ class MDParser: self.db.e[f].ctimestamp, self.db.e[f].mtimestamp, content, - self.md.toc, # type: ignore - self.md.toc_tokens, # type: ignore + self.md.toc, # type: ignore + self.md.toc_tokens, # type: ignore self.md.Meta, # type: ignore self.config, self.dir_config) diff --git a/src/pyssg/page.py b/src/pyssg/page.py index 19c92f9..6b8916d 100644 --- a/src/pyssg/page.py +++ b/src/pyssg/page.py @@ -1,4 +1,3 @@ -import os import sys from datetime import datetime, timezone from logging import Logger, getLogger @@ -75,7 +74,7 @@ class Page: log.warning('no mdatetime found, can\'t return a formatted string') return '' if format in self.config['fmt']: - return self.mdatetime.strftime(self.config['fmt'][format]) # type: ignore + return self.mdatetime.strftime(self.config['fmt'][format]) # type: ignore else: log.warning('format "%s" not found in config["fmt"], returning empty string', format) return '' @@ -160,4 +159,4 @@ class Page: self.og[k] = v else: - log.debug('no tags to parse') \ No newline at end of file + log.debug('no tags to parse') diff --git a/src/pyssg/per_level_formatter.py b/src/pyssg/per_level_formatter.py index 394471e..e3b6977 100644 --- a/src/pyssg/per_level_formatter.py +++ b/src/pyssg/per_level_formatter.py @@ -1,5 +1,6 @@ from logging import Formatter, LogRecord, DEBUG, INFO, WARNING, ERROR, CRITICAL + # only reason for this class is to get info formatting as normal text # and everything else with more info and with colors class PerLevelFormatter(Formatter): diff --git a/src/pyssg/pyssg.py b/src/pyssg/pyssg.py index e9cf28c..678000b 100644 --- a/src/pyssg/pyssg.py +++ b/src/pyssg/pyssg.py @@ -101,7 +101,6 @@ def main() -> None: log.info('finished initialization') sys.exit(0) - if args['build']: log.info('building the html files') for config in config_all: diff --git a/src/pyssg/yaml_parser.py b/src/pyssg/yaml_parser.py index 3109cbc..fb19a23 100644 --- a/src/pyssg/yaml_parser.py +++ b/src/pyssg/yaml_parser.py @@ -1,7 +1,6 @@ import yaml from yaml import SafeLoader from yaml.nodes import SequenceNode -from io import TextIOWrapper from importlib.resources import path as rpath from logging import Logger, getLogger @@ -22,7 +21,7 @@ def __read_raw_yaml(path: str) -> list[dict]: return all_docs -def get_parsed_yaml(resource: str, package: str='') -> list[dict]: +def get_parsed_yaml(resource: str, package: str = '') -> list[dict]: if package == '': log.debug('parsing yaml; reading "%s"', resource) return __read_raw_yaml(resource) -- cgit v1.2.3-70-g09d2