diff --git a/compile_md.py b/compile_md.py index 8ce6711..085ff2c 100644 --- a/compile_md.py +++ b/compile_md.py @@ -14,17 +14,17 @@ import logging from functools import reduce # Other -import cmd_args +from cmd_args import settings import load_moods import utils -def compile_note_YAML(): +def compile_note_yaml(): """Returns string with YAML metadata for each note. It looks like this: --- tags: --- """ - return f"---\ntags: {cmd_args.settings.TAGS} \n---\n\n" + return f"---\ntags: {settings.TAGS} \n---\n\n" def compile_entry_contents(entry): """Return a string that is a parsed entry from Daylio CSV as a string. @@ -37,11 +37,11 @@ def compile_entry_contents(entry): """ # compose the title with optional mood colouring this_entry_title = get_colour(entry.mood) + entry.mood + " - " + entry.time - final_output = cmd_args.settings.HEADER_LEVEL*'#' + " " + this_entry_title + final_output = settings.HEADER_LEVEL*'#' + " " + this_entry_title # compose the mood-tag and the activity-tags into one paragraph final_output += "\nI felt #" - final_output += utils.slugify(entry.mood, cmd_args.settings.ACTIVITIES_AS_TAGS) + final_output += utils.slugify(entry.mood, settings.ACTIVITIES_AS_TAGS) if len(entry.activities) > 0 and entry.activities[0] != "": final_output += " with the following: " ## first append # to each activity, then mush them together into one string @@ -61,7 +61,7 @@ def get_colour(mood_to_check): """Prepend appropriate colour for the mood passed in mood_to_check""" prepended_colour = "" mood_colour=["🟣","🟢","🔵","🟠","🔴"] # 0 - best, 4 - worst mood group - if cmd_args.settings.colour: + if settings.colour: for i, (_, this_group) in enumerate(load_moods.available_moods.items()): if mood_to_check in this_group: prepended_colour = f"{mood_colour[i]} " diff --git a/main.py b/main.py index baa79a9..9139ad0 100644 --- a/main.py +++ b/main.py @@ -42,7 +42,7 @@ ) for day, entries in days.items(): - note_contents = compile_md.compile_note_YAML() + note_contents = compile_md.compile_note_yaml() for current_entry in entries: note_contents += compile_md.compile_entry_contents(current_entry) current_note = write_md.Note(day, note_contents) diff --git a/parse_csv.py b/parse_csv.py index 841355a..79552a7 100644 --- a/parse_csv.py +++ b/parse_csv.py @@ -1,9 +1,9 @@ """Creates structured data from Daylio .CSV""" import csv import utils -import cmd_args +from cmd_args import settings -delimiter = f" {cmd_args.settings.csv_delimiter} " +delimiter = f" {settings.csv_delimiter} " class Entry: """Journal entry made at a given moment in time, and describing a particular emotional state""" @@ -16,7 +16,7 @@ def __init__(self, parsed_line, prop_inside_delimiter = delimiter): for index, _ in enumerate(self.activities): self.activities[index] = utils.slugify( self.activities[index], - cmd_args.settings.ACTIVITIES_AS_TAGS + settings.ACTIVITIES_AS_TAGS ) self.title = self.slice_quotes(parsed_line[6]) self.note = self.slice_quotes(parsed_line[7]) diff --git a/test_main.py b/test_main.py index ee68110..dab9af8 100644 --- a/test_main.py +++ b/test_main.py @@ -1,12 +1,8 @@ """Test cases for main.py""" import unittest -import os # Custom import parse_csv -import write_md -import compile_md import utils -import cmd_args class TestScript(unittest.TestCase): def setUp(self): diff --git a/write_md.py b/write_md.py index 2aa2970..2a3f930 100644 --- a/write_md.py +++ b/write_md.py @@ -2,14 +2,14 @@ import hashlib import os # Custom -import cmd_args +from cmd_args import settings class Note: """Note is a file encompassing every entry made on a given date""" def __init__(self, day, contents): self.day = day self.contents = contents - self.path = f"{os.path.join(cmd_args.settings.destination, cmd_args.settings.prefix)}{day}{cmd_args.settings.suffix}.md" + self.path = f"{os.path.join(settings.destination, settings.prefix)}{day}{settings.suffix}.md" self.control_sum = hashlib.sha256() temp_contents = self.contents # we need a temporary contents var to be consumed for byte_block in iter(lambda: temp_contents[:4096].encode('utf-8'), b""):