mirror of
https://github.com/alvierahman90/gronk.git
synced 2024-11-21 23:09:52 +00:00
formatting
This commit is contained in:
parent
af5bef0125
commit
09334831f7
@ -1,39 +1,41 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
import editfrontmatter
|
import editfrontmatter
|
||||||
import frontmatter
|
import frontmatter
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
""" Get command line arguments """
|
""" Get command line arguments """
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('filename', type=pathlib.Path)
|
parser.add_argument('filename', type=pathlib.Path)
|
||||||
parser.add_argument('-w', '--write', action='store_true',
|
parser.add_argument('-w',
|
||||||
help='write to file instead of stdout')
|
'--write',
|
||||||
|
action='store_true',
|
||||||
|
help='write to file instead of stdout')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
""" Entry point for script """
|
""" Entry point for script """
|
||||||
template_str= "\n".join([
|
template_str = "\n".join([
|
||||||
"author: {{ author }}"
|
"author: {{ author }}"
|
||||||
"date: {{ date }}"
|
"date: {{ date }}"
|
||||||
"title: {{ title }}"
|
"title: {{ title }}"
|
||||||
"tags: {{ tags }}"
|
"tags: {{ tags }}"
|
||||||
"uuid: {{ uuid }}"
|
"uuid: {{ uuid }}"
|
||||||
])
|
])
|
||||||
|
|
||||||
with open(args.filename) as fp:
|
with open(args.filename) as fp:
|
||||||
fm_pre = frontmatter.load(fp)
|
fm_pre = frontmatter.load(fp)
|
||||||
|
|
||||||
processor = editfrontmatter.EditFrontMatter(file_path=args.filename, template_str=template_str)
|
processor = editfrontmatter.EditFrontMatter(file_path=args.filename,
|
||||||
|
template_str=template_str)
|
||||||
fm_data = fm_pre.metadata
|
fm_data = fm_pre.metadata
|
||||||
if 'uuid' not in fm_data.keys():
|
if 'uuid' not in fm_data.keys():
|
||||||
fm_data['uuid'] = str(uuid.uuid4())
|
fm_data['uuid'] = str(uuid.uuid4())
|
||||||
|
Loading…
Reference in New Issue
Block a user