Skip to content

Commit

Permalink
REFACTOR : Use lookup directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
crdoconnor committed Dec 25, 2023
1 parent 6c460ce commit 9983314
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions orji/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, text):
if len(split) == 1:
self.filepath = split[0]
self.ref = None
self.parsed_ref = []
elif len(split) == 2:
self.filepath = split[0]
self.ref = split[1]
Expand Down
4 changes: 4 additions & 0 deletions orji/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def at(self, lookup):
else:
return Note(matching_notes[0], temp_dir=self._temp_dir)

@property
def children(self):
return [Note(node, temp_dir=self._temp_dir) for node in self._node.children]

def __iter__(self):
for node in self._node.children:
yield Note(node, temp_dir=self._temp_dir)
15 changes: 1 addition & 14 deletions orji/output.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from .note import Note
from pathlib import Path
import click
from .template import Template
import orgmunge
from .tempdir import TempDir
from .lookup import Lookup

Expand All @@ -24,21 +22,10 @@
)
def output(orglookup, jinjafile, latexmode, pymodule):
lookup = Lookup(orglookup)
orgfile = lookup.filepath
indexlookup = lookup.ref
temp_dir = TempDir()
temp_dir.create()
org_text = Path(orgfile).read_text()
template_text = Path(jinjafile).read_text()
munge_parsed = orgmunge.Org(
org_text,
from_file=False,
todos={"todo_states": {"todo": "TODO"}, "done_states": {"done": "DONE"}},
)
notes = Note(munge_parsed.root, temp_dir=temp_dir)

if indexlookup is not None:
notes = notes.from_indexlookup(indexlookup)
notes = lookup.load(temp_dir)

output_text = Template(
template_text, jinjafile, latexmode=latexmode, pymodule_filename=pymodule
Expand Down

0 comments on commit 9983314

Please sign in to comment.