forked from albertlauncher/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkLog.py
More file actions
58 lines (47 loc) · 1.31 KB
/
Copy pathWorkLog.py
File metadata and controls
58 lines (47 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
""" Work Log Extension
Write every day note to user defined directory with your GUI editr.
"""
import os
from datetime import datetime
from subprocess import call
from albertv0 import iconLookup, Item, FuncAction
__iid__ = "PythonInterface/v0.1"
__prettyname__ = "Work Log"
__version__ = "0.1"
__trigger__ = "worklog"
__author__ = "alswl"
__dependencies__ = []
iconPath = iconLookup('gvim')
DIR_PATH = 'Desktop/md/work-log'
APP = "gvim"
def handleQuery(query):
if not query.isTriggered:
return
results = []
results.append(
Item(
id="worklog",
icon=iconPath,
text="Work log",
subtext="open today work log",
completion='worklog',
actions=[
FuncAction("Write", open_markdown),
]
)
)
return results
def open_markdown():
now = datetime.now()
dir_name = "" + now.strftime('%Y-%m')
dir_path = os.path.join(os.environ.get('HOME'), DIR_PATH, dir_name)
file_name = now.strftime('%Y-%m-%d' + '.md')
file_path = os.path.join(dir_path, file_name)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
os.chdir(dir_path)
call(APP + " " + file_path, shell=True)
def test_open_markdown():
open_markdown()
if __name__ == '__main__':
test_open_markdown()