mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-12 17:54:29 +00:00
aha fix black formatting include, generate core by cloning into tmp directory
This commit is contained in:
parent
d03e4107a4
commit
0c51f00596
3 changed files with 27 additions and 12 deletions
|
@ -117,7 +117,11 @@ class GitRepo:
|
|||
path (:class:`pathlib.Path`): A directory to clone to -
|
||||
if ``None``, use :attr:`~.Config.git_dir` / :attr:`.NamespaceRepo.name`
|
||||
"""
|
||||
self._temp_directory = path
|
||||
if path is None:
|
||||
self._base_directory = Config().git_dir
|
||||
else:
|
||||
self._base_directory = Path(path)
|
||||
self._temp_directory = None
|
||||
self.namespace = namespace
|
||||
self._commit = commit
|
||||
|
||||
|
@ -135,8 +139,7 @@ class GitRepo:
|
|||
Temporary directory where this repository will be cloned to
|
||||
"""
|
||||
if self._temp_directory is None:
|
||||
git_dir = Config().git_dir
|
||||
self._temp_directory = git_dir / self.namespace.name
|
||||
self._temp_directory = self._base_directory / self.namespace.name
|
||||
if not self._temp_directory.exists():
|
||||
self._temp_directory.mkdir(parents=True)
|
||||
|
||||
|
|
|
@ -101,5 +101,5 @@ warn_unreachable = true
|
|||
target-version = ['py38', 'py39', 'py310', 'py311']
|
||||
enable-unstable-feature = ["string_processing"]
|
||||
preview = true
|
||||
include = "nwb_linkml/.*\\.py$|nwb_schema_language/.*\\.py$"
|
||||
include = "nwb_linkml/.*\\.py$|nwb_schema_language/.*\\.py$|nwb_models/.*\\.py$"
|
||||
line-length = 100
|
|
@ -50,6 +50,18 @@ def generate_core_pydantic(yaml_path: Path, output_path: Path, dry_run: bool = F
|
|||
pfile.write(gen_pydantic)
|
||||
|
||||
|
||||
def make_tmp_dir(clear: bool = False) -> Path:
|
||||
# use a directory underneath this one as the temporary directory rather than
|
||||
# the default hidden one
|
||||
tmp_dir = Path(__file__).parent / "__tmp__"
|
||||
if tmp_dir.exists() and clear:
|
||||
for p in tmp_dir.iterdir():
|
||||
if p.is_dir() and not p.name == "git":
|
||||
shutil.rmtree(tmp_dir)
|
||||
tmp_dir.mkdir(exist_ok=True)
|
||||
return tmp_dir
|
||||
|
||||
|
||||
def generate_versions(
|
||||
yaml_path: Path,
|
||||
pydantic_path: Path,
|
||||
|
@ -64,12 +76,7 @@ def generate_versions(
|
|||
# repo.clone(force=True)
|
||||
repo.clone()
|
||||
|
||||
# use a directory underneath this one as the temporary directory rather than
|
||||
# the default hidden one
|
||||
tmp_dir = Path(__file__).parent / "__tmp__"
|
||||
if tmp_dir.exists():
|
||||
shutil.rmtree(tmp_dir)
|
||||
tmp_dir.mkdir()
|
||||
tmp_dir = make_tmp_dir()
|
||||
|
||||
linkml_provider = LinkMLProvider(path=tmp_dir, verbose=False)
|
||||
pydantic_provider = PydanticProvider(path=tmp_dir, verbose=False)
|
||||
|
@ -227,10 +234,15 @@ def parser() -> ArgumentParser:
|
|||
|
||||
def main():
|
||||
args = parser().parse_args()
|
||||
|
||||
tmp_dir = make_tmp_dir(clear=True)
|
||||
git_dir = tmp_dir / "git"
|
||||
git_dir.mkdir(exist_ok=True)
|
||||
|
||||
if args.hdmf:
|
||||
repo = GitRepo(HDMF_COMMON_REPO)
|
||||
repo = GitRepo(HDMF_COMMON_REPO, path=git_dir)
|
||||
else:
|
||||
repo = GitRepo(NWB_CORE_REPO)
|
||||
repo = GitRepo(NWB_CORE_REPO, path=git_dir)
|
||||
|
||||
if not args.dry_run:
|
||||
args.yaml.mkdir(exist_ok=True)
|
||||
|
|
Loading…
Reference in a new issue