2018-05-04 13:53:29 +02:00
|
|
|
#!/usr/bin/env python3
|
2017-04-25 15:22:04 +02:00
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"Hepler to create a new webpage associated with a module."
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
def createModuleFolder(modulename):
|
|
|
|
path_module = os.path.join('modules', modulename)
|
|
|
|
os.mkdir(path_module)
|
2018-04-17 16:06:32 +02:00
|
|
|
|
2017-04-25 15:22:04 +02:00
|
|
|
# create html template
|
|
|
|
with open('templates/base_template.html', 'r') as templateFile:
|
|
|
|
template = templateFile.read()
|
|
|
|
template = template.replace('MODULENAME', modulename)
|
2018-04-17 16:06:32 +02:00
|
|
|
|
2017-04-25 15:22:04 +02:00
|
|
|
os.mkdir(os.path.join(path_module, 'templates'))
|
|
|
|
with open(os.path.join(os.path.join(path_module, 'templates'), modulename+'.html'), 'w') as toWriteTemplate:
|
|
|
|
toWriteTemplate.write(template)
|
|
|
|
|
|
|
|
# create html header template
|
|
|
|
with open('templates/header_base_template.html', 'r') as header_templateFile:
|
|
|
|
header = header_templateFile.read()
|
|
|
|
header = header.replace('MODULENAME', modulename)
|
2018-04-17 16:06:32 +02:00
|
|
|
|
2017-04-25 15:22:04 +02:00
|
|
|
with open(os.path.join(os.path.join(path_module, 'templates'), 'header_{}.html'.format(modulename) ), 'w') as toWriteHeader:
|
|
|
|
toWriteHeader.write(header)
|
|
|
|
|
|
|
|
|
|
|
|
#create flask template
|
|
|
|
with open('Flask_base_template.py', 'r') as flaskFile:
|
|
|
|
flask = flaskFile.read()
|
|
|
|
flask = flask.replace('MODULENAME', modulename)
|
|
|
|
|
|
|
|
with open(os.path.join(path_module, 'Flask_{}.py'.format(modulename)), 'w') as toWriteFlask:
|
|
|
|
toWriteFlask.write(flask)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2018-05-09 13:03:46 +02:00
|
|
|
rep1 = input('New module name: ')
|
2017-04-25 15:22:04 +02:00
|
|
|
createModuleFolder(rep1)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|