Skip to content

Commit

Permalink
Make site a required argument.
Browse files Browse the repository at this point in the history
Make sure source is a directory.
  • Loading branch information
yaph committed Nov 5, 2024
1 parent 2c87ddc commit 93acae2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions logya/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from logya.util import paths


def create(dir_site: str, name: str, site: str | None = None, **kwargs):
def create(dir_site: str, name: str, site: str, **kwargs):
target = paths(dir_site=dir_site).root.joinpath(name)
if target.exists():
sys.exit(f'Error: "{target}" already exists. Please remove it or specify another location.')
try:
source = resources.files(__name__).joinpath(f'sites/{site}')
except KeyError:
sys.exit(f'The site "{site}" is not installed.')

source = resources.files(__name__).joinpath(f'sites/{site}')
if source.is_dir():
shutil.copytree(source, target) # type: ignore
else:
shutil.copytree(source, target)
print(f'Site created in "{target}".')
sys.exit(f'The site "{site}" is not installed.')

print(f'Site created in "{target}".')

0 comments on commit 93acae2

Please sign in to comment.