Fix all pylint warnings

This commit is contained in:
Ivan R. 2022-12-15 22:34:06 +05:00
parent be72f4f693
commit 3d63e3d4b9
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C

View file

@ -1,4 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""
Histd: how I spent this day.
A simple but useful personal diary CLI utility.
"""
from datetime import date from datetime import date
import os import os
import subprocess import subprocess
@ -6,6 +12,10 @@ import sys
def main(): def main():
"""
Main function, run first.
Prepares environment and parses commands.
"""
base_dir = get_base_dir() base_dir = get_base_dir()
today = date.today() today = date.today()
@ -76,17 +86,17 @@ def merge(base_dir: str):
This function concatenates all files and prefixes each with the filename. This function concatenates all files and prefixes each with the filename.
The result will be printed to stdout. The result will be printed to stdout.
""" """
def read_files(path: str) -> str: def read_files(path: str) -> str:
""" """
Recursive function to read all files in a directory Recursive function to read all files in a directory
""" """
strings = [] strings = []
contents = os.listdir(path) contents = os.listdir(path)
for entry in contents: for entry in contents:
entry_path = os.path.join(path, entry) entry_path = os.path.join(path, entry)
# It's a directory # It's a directory
if os.path.isdir(entry_path): if os.path.isdir(entry_path):
# Read all files in this directory # Read all files in this directory
@ -94,10 +104,10 @@ def merge(base_dir: str):
strings.append(res) strings.append(res)
# It's a file # It's a file
else: else:
with open(entry_path, 'r') as note: with open(entry_path, 'r', encoding='utf-8') as note:
strings.append(f'## {entry_path}') strings.append(f'## {entry_path}')
strings.append(note.read()) strings.append(note.read())
return '\n\n'.join(strings) return '\n\n'.join(strings)
res = read_files(base_dir) res = read_files(base_dir)