Skip to content

Commit

Permalink
Revert "Now it should just work"
Browse files Browse the repository at this point in the history
This reverts commit 3aef621.
  • Loading branch information
tpwo committed Nov 7, 2023
1 parent 3aef621 commit 19c643c
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/pyzet/zettel.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,31 @@ def get(path: Path) -> Zettel:
"""Gets zettel from a full path."""
if path.is_dir():
raise ValueError

title_line, tags_line = _get_first_and_last_line(path)

if title_line == '':
raise ValueError

if tags_line.startswith(4 * ' '):
tags = get_tags(tags_line.strip())
else:
tags = tuple()

id_ = path.parent.name

zettel = Zettel(
id=id_,
title=get_markdown_title(title_line, id_),
path=path,
tags=tags,
)
logging.debug(f'zettel.get: {zettel}')
return zettel
title_line, tags_line = _get_first_and_last_line(path)
title = get_markdown_title(title_line.strip(), path.name)
tags = get_tags(tags_line.strip()) if tags_line.startswith(4 * ' ') else ()
logging.debug(f"get_zettel: '{path.name}' with title '{title}'")
return Zettel(title=title, id=id_, tags=tags, path=path)

# title_line, tags_line = _get_first_and_last_line(path)
# if title_line == '':
# raise ValueError

# if tags_line.startswith(4 * ' '):
# tags = get_tags(tags_line.strip())
# else:
# tags = tuple()

# id_ = path.parent.name

# return Zettel(
# id=id_,
# title=get_markdown_title(title_line, id_),
# path=path,
# tags=tags,
# )


def get_zettel_repr(zet: Zettel, args: Namespace) -> str:
Expand Down

0 comments on commit 19c643c

Please sign in to comment.