Skip to content

Commit 45a48b5

Browse files
committed
Add minimal pyscript
1 parent 4ebf501 commit 45a48b5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/projspec/proj/pyscript.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import toml
2+
3+
from projspec.proj import ProjectSpec
4+
from projspec.utils import AttrDict
5+
6+
7+
class PyScriptSpec(ProjectSpec):
8+
def match(self) -> bool:
9+
basenames = [_.rsplit("/", 1)[0] for _ in self.root.filelist]
10+
return "pyscript.toml" in basenames or "pyscript.json" in basenames
11+
12+
def parse(self) -> None:
13+
try:
14+
with self.root.fs.open(f"{self.root.url}/pyscript.toml") as f:
15+
meta = toml.load(f)
16+
except FileNotFoundError:
17+
with self.root.fs.open(f"{self.root.url}/pyscript.json") as f:
18+
meta = toml.load(f)
19+
cont = AttrDict()
20+
if "packages" in meta:
21+
cont["environment"] = AttrDict(default=meta["packages"])
22+
self._contents = cont
23+
24+
# perhaps a local deployment can be a reasonable artifact
25+
# https://github.com/pyscript/pyscript-cli
26+
self._artifacts = AttrDict()

0 commit comments

Comments
 (0)