Skip to content

Commit efef855

Browse files
committed
more packge scaffolding
1 parent e43702c commit efef855

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

quarto/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
# Version of the quarto package
44
__version__ = "0.1.0"
55

6+
from quarto.quarto import path
67
from quarto.render import render
78
from quarto.metadata import metadata

quarto/metadata.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11

22
import sys
3+
import json
4+
import subprocess
5+
6+
from quarto.quarto import find_quarto
37

48
def metadata(input):
5-
print("render", file = sys.stdout)
9+
args = ["metadata", input, "--json"]
10+
metadata_json = subprocess.check_output([find_quarto()] + args)
11+
return json.loads(metadata_json)
12+
13+

quarto/quarto.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
import os
3+
import sys
4+
import shutil
5+
import subprocess
6+
7+
def path():
8+
path_env = os.getenv("QUARTO_PATH")
9+
if path_env is None:
10+
return shutil.which("quarto")
11+
else:
12+
return path_env
13+
14+
15+
def find_quarto():
16+
quarto = path()
17+
if quarto is None:
18+
raise FileNotFoundError('Unable to find quarto command line tools.')
19+
return quarto

quarto/render.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11

22
import sys
3+
import subprocess
4+
5+
from quarto.quarto import find_quarto
36

47
def render(input):
5-
print("render", file = sys.stdout)
8+
args = ["render", input]
9+
process = subprocess.Popen([find_quarto()] + args)
10+
process.wait()
11+
12+

0 commit comments

Comments
 (0)