You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
619 B
24 lines
619 B
import re |
|
import sys |
|
from pathlib import Path |
|
|
|
MOIN_PATH = '/var/www/moin/wikis' |
|
MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' |
|
|
|
module_name = '{{ cookiecutter.directory_name }}' |
|
|
|
if not re.match(MODULE_REGEX, module_name): |
|
print('ERROR: %s is not a valid Python module name!' % module_name) |
|
sys.exit(1) |
|
|
|
try: |
|
import {{ cookiecutter.directory_name }} |
|
print('ERROR: %s is an existing Python module!' % module_name) |
|
sys.exit(2) |
|
except ModuleNotFoundError: |
|
pass |
|
|
|
wiki_path = Path(MOIN_PATH) / module_name |
|
if wiki_path.exists(): |
|
print('ERROR: wiki %s already exists!' % module_name) |
|
sys.exit(3)
|
|
|