36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import os, logging
|
|
DEBUG = os.environ.get('DEBUG')
|
|
logging.basicConfig(
|
|
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
|
|
level=logging.DEBUG if DEBUG else logging.INFO)
|
|
|
|
NOTES_DIR = '/home/tanner/notes-git/notes'
|
|
|
|
def collect_daily_notes():
|
|
daily_notes_path = os.path.join(NOTES_DIR, 'Daily Notes')
|
|
if not os.path.isdir(daily_notes_path):
|
|
logging.error(f"Directory not found: {daily_notes_path}")
|
|
return []
|
|
|
|
try:
|
|
all_files = os.listdir(daily_notes_path)
|
|
md_files = [f for f in all_files if os.path.isfile(os.path.join(daily_notes_path, f)) and f.endswith('.md')]
|
|
|
|
# Sort in reverse alphabetical order
|
|
md_files.sort(reverse=True)
|
|
|
|
# Transform to the desired format
|
|
formatted_notes = [f"![[{f[:-3]}]]" for f in md_files]
|
|
|
|
logging.debug(f"Formatted notes: {formatted_notes}")
|
|
return formatted_notes
|
|
except OSError as e:
|
|
logging.error(f"Error accessing directory {daily_notes_path}: {e}")
|
|
return []
|
|
|
|
def main():
|
|
collect_daily_notes()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|