@@ -83,9 +83,16 @@ def __init__(
8383 self .artifacts = AttrDict ()
8484 # read and respect .gitignore? for exclude directories?
8585 self .excludes = excludes or default_excludes
86- self ._pyproject = None
87- self ._scanned_files = None
86+ self ._reset ()
8887 self .resolve (walk = walk , types = types , xtypes = xtypes )
88+
89+ def _reset (self ):
90+ """Prepare this project for parsing with new specs"""
91+ # cached properties
92+ self .__dict__ .pop ("basenames" , None )
93+ self .__dict__ .pop ("filelist" , None )
94+ self .__dict__ .pop ("pyproject" , None )
95+ self ._scanned_files = None
8996 # clear cached files
9097 self ._scanned_files = None
9198
@@ -368,12 +375,22 @@ def from_dict(dic):
368375 proj .fs , proj .url = fsspec .url_to_fs (proj .path , ** proj .storage_options )
369376 return proj
370377
371- def create (self , name : str ):
372- """Make this project conform to the given project spec type."""
378+ def create (self , name : str ) -> list [str ]:
379+ """Make this project conform to the given project spec type.
380+
381+ Returns a list of files that were created.
382+ """
373383 cls = get_cls (name )
374384 # causes reparse and makes a new instance
375385 # could rerun resolve or only parse for give type and add, instead.
376- return cls .create (self .path )
386+ allfiles = self .fs .find (self .url , detail = False )
387+ cls .create (self .url )
388+ allfiles2 = self .fs .find (self .url , detasil = False )
389+ self ._reset ()
390+ spec = cls (self )
391+ spec .parse ()
392+ self .specs [camel_to_snake (cls .__name__ )] = spec
393+ return sorted (set (allfiles2 ) - set (allfiles ))
377394
378395 def make (self , qname : str , ** kwargs ) -> None :
379396 """Make an artifact of the given type
@@ -467,7 +484,7 @@ def _create(path: str) -> None:
467484 raise NotImplementedError ("Subclass must implement this" )
468485
469486 @classmethod
470- def create (cls , path : str ) -> Project :
487+ def create (cls , path : str ):
471488 """Make the target directory compliant with this project type, if not already"""
472489 # TODO: implement remote??
473490 # TODO: implement dry-run?
@@ -476,8 +493,6 @@ def create(cls, path: str) -> Project:
476493 os .makedirs (path , exist_ok = True )
477494 if not cls .snake_name () in Project (path ):
478495 cls ._create (path )
479- # perhaps should return ProjSpec, but it needs to be added to a project
480- return Project (path )
481496
482497 def parse (self ) -> None :
483498 raise ParseFailed
0 commit comments