Holger Frey
7 years ago
2 changed files with 26 additions and 1 deletions
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
{ |
||||
"new_wiki": "", |
||||
"wiki_name": "{{ cookiecutter.new_wiki|title|replace(' ', '')|replace('Wiki', '') }}", |
||||
"wiki_name": "{{ cookiecutter.new_wiki|title|replace(' ', '') }}", |
||||
"directory_name": "{{ cookiecutter.wiki_name|lower }}", |
||||
"url": "https://{{cookiecutter.directory_name}}.cpi.imtek.uni-freiburg.de/" |
||||
} |
||||
|
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
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(1) |
Loading…
Reference in new issue