File tree Expand file tree Collapse file tree 6 files changed +24
-14
lines changed
Expand file tree Collapse file tree 6 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,10 @@ def clean(self):
7474 pass
7575
7676 def __repr__ (self ):
77- return f"{ type (self ).__name__ } , { self .state } "
77+ return f"{ type (self ).__name__ } , '{ ' ' .join (self .cmd )} ', { self .state } "
78+
79+ def _repr2 (self ):
80+ return f"{ ' ' .join (self .cmd )} , { self .state } "
7881
7982
8083class FileArtifact (BaseArtifact ):
Original file line number Diff line number Diff line change 22
33from projspec .artifact import BaseArtifact
44from projspec .proj .base import Project
5+ from projspec .utils import Enum
56
67
78@dataclass
89class BaseContent :
910 proj : Project = field (repr = False )
1011 artifacts : set [BaseArtifact ] = field (repr = False )
12+
13+ def _repr2 (self ):
14+ return {
15+ k : (v .name if isinstance (v , Enum ) else v )
16+ for k , v in self .__dict__ .items ()
17+ if not k .startswith ("_" ) and k not in ("proj" , "artifacts" )
18+ }
Original file line number Diff line number Diff line change 99class Command (BaseContent ):
1010 """The simplest runnable thing - we don't know what it does"""
1111
12- cmd : list [str ]
13- background : bool = False
14- interactive : bool = False
12+ cmd : list [str ] | str
13+
14+ def _repr2 (self ):
15+ return " " .join (self .cmd ) if isinstance (self .cmd , list ) else self .cmd
Original file line number Diff line number Diff line change 22from .conda_package import CondaRecipe , RattlerRecipe
33from .conda_project import CondaProject
44from .pixi import Pixi
5+ from .pyscript import PyScriptSpec
56from .python_code import PythonCode , PythonLibrary
67from .uv import UVProject
78
1213 "CondaProject" ,
1314 "RattlerRecipe" ,
1415 "Pixi" ,
16+ "PyScriptSpec" ,
1517 "PythonCode" ,
1618 "PythonLibrary" ,
1719 "UVProject" ,
Original file line number Diff line number Diff line change 66
77class PyScriptSpec (ProjectSpec ):
88 def match (self ) -> bool :
9- basenames = [_ .rsplit ("/" , 1 )[0 ] for _ in self .root .filelist ]
9+ basenames = [_ .rsplit ("/" , 1 )[- 1 ] for _ in self .root .filelist ]
1010 return "pyscript.toml" in basenames or "pyscript.json" in basenames
1111
1212 def parse (self ) -> None :
1313 try :
14- with self .root .fs .open (f"{ self .root .url } /pyscript.toml" ) as f :
14+ with self .root .fs .open (f"{ self .root .url } /pyscript.toml" , "rt" ) as f :
1515 meta = toml .load (f )
1616 except FileNotFoundError :
17- with self .root .fs .open (f"{ self .root .url } /pyscript.json" ) as f :
17+ with self .root .fs .open (f"{ self .root .url } /pyscript.json" , "rt" ) as f :
1818 meta = toml .load (f )
1919 cont = AttrDict ()
2020 if "packages" in meta :
Original file line number Diff line number Diff line change @@ -57,13 +57,7 @@ def to_dict(obj):
5757 if isinstance (obj , Iterable ):
5858 return [to_dict (_ ) for _ in obj ]
5959 if isinstance (obj , (BaseArtifact , BaseContent )):
60- return to_dict (
61- {
62- k : v
63- for k , v in obj .__dict__ .items ()
64- if k not in {"proj" , "artifacts" }
65- }
66- )
60+ return obj ._repr2 ()
6761 return str (obj )
6862
6963
@@ -134,6 +128,8 @@ def __contains__(self, item):
134128
135129
136130def _yaml_no_jinja (fileobj ):
131+ # TODO: rather than skip jinja stuff, we can copy conda code to parse it, but
132+ # templates can involve function calls and reference to env vars we don't have
137133 txt = fileobj .read ().decode ()
138134 lines = []
139135 for line in txt .splitlines ():
You can’t perform that action at this time.
0 commit comments