You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
Python
49 lines
1.0 KiB
Python
2 years ago
|
import frontmatter, os, sys, getopt
|
||
|
from io import BytesIO
|
||
|
|
||
|
|
||
|
|
||
|
def main(argv):
|
||
|
folder = ''
|
||
|
try:
|
||
|
opts, args = getopt.getopt(argv,"hf:",["folder="])
|
||
|
except getopt.GetoptError:
|
||
|
print('template.py -f <folder>')
|
||
|
sys.exit(2)
|
||
|
for opt, arg in opts:
|
||
|
if opt == '-h':
|
||
|
print('template.py -f <folder>')
|
||
|
sys.exit()
|
||
|
elif opt in ("-f", "--folder"):
|
||
|
folder = arg
|
||
|
|
||
|
try:
|
||
|
os.makedirs(folder)
|
||
|
except OSError:
|
||
|
pass
|
||
|
|
||
|
|
||
|
|
||
|
with open(f"{folder}/contents.md", "w") as file:
|
||
|
|
||
|
metadata = {
|
||
|
'folder': folder,
|
||
|
'title': '',
|
||
|
'post_width': 75,
|
||
|
'post_height': 75,
|
||
|
'page_width': 210,
|
||
|
'page_height': 297,
|
||
|
'background': 'white',
|
||
|
'margin': 5,
|
||
|
'unit': 'mm',
|
||
|
'contents': ''
|
||
|
}
|
||
|
|
||
|
page = frontmatter.Post('', **metadata)
|
||
|
file.write(frontmatter.dumps(page))
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main(sys.argv[1:])
|