diff --git a/papis-marvin b/papis-marvin index 50c57e8..6d7545b 100755 --- a/papis-marvin +++ b/papis-marvin @@ -12,8 +12,6 @@ import papis.database import re import subprocess -# use argument passed to command as file or default file here - def format_entry(row) -> str: text = f"> {row['HighlightText']}" @@ -26,6 +24,17 @@ def format_entry(row) -> str: return text +_old_title = "" +def is_same_book(title): + global _old_title + + same = _old_title == title + _old_title = title + if same: + return True + return False + + def main(fpath, db): notes = {} with open(fpath) as f: @@ -34,15 +43,12 @@ def main(fpath, db): csv = csv.DictReader(f) title_strip_pattern = re.compile(r"([^\s\w]|_)+") - old_title = "" note_file = "" for row in csv: title_stripped = title_strip_pattern.sub("", row["Title"]) # switch to next book - if old_title != row["Title"]: - old_title = row["Title"] - + if not is_same_book(row["Title"]): documents = db.query( f"author:({row['Author']}) title:({title_stripped})" ) @@ -89,6 +95,7 @@ def main(fpath, db): if __name__ == "__main__": + # use argument passed to command as file or default file here fpath = ( sys.argv[1] if len(sys.argv) > 1