Created
June 25, 2019 07:24
-
-
Save takavfx/50f0eb123c0d0c82eed016fae20b2ac6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import datetime | |
import shutil | |
import traceback | |
from pathlib import Path | |
SCRIPTPATH = Path(os.path.dirname(os.path.abspath(__file__))) | |
now = datetime.datetime.now() | |
cur_year = str(now.year) | |
cur_month = str(now.month).zfill(2) | |
cur_day = str(now.day).zfill(2) | |
cur_date = '{}-{}-{}'.format(cur_year, cur_month, cur_day) | |
month_dirname = Path('{}-{}'.format(cur_year, cur_month)) | |
file_name = Path('{}.md'.format(cur_date)) | |
file_dir = SCRIPTPATH / Path(cur_year) / month_dirname | |
file_path = file_dir / file_name | |
if not file_dir.exists(): | |
try: | |
os.makedirs(file_dir) | |
except: | |
print(traceback.format_exc()) | |
quit() | |
if file_path.exists(): | |
quit() | |
shutil.copy(SCRIPTPATH / 'template.md', file_name) | |
print("## Today's daily report {} is create at {}".format(file_name, file_path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment