In [1]:
%matplotlib inline
%load_ext autoreload
%autoreload
from mdt import *

#import mdt.mdt_parse as mp
#import mdt.mdt_stat as ms
#import importlib as imp
#imp.reload(mp)

Parser

Markdown


In [4]:
dta = mp.parse_md_files("../mdt/mdt_demo.md")
dta.head()
#dta


Out[4]:
Filename ID T1 T2 T3 TXT
0 mdt_demo 0.0.0 None None None # T1
1 mdt_demo 0.1.0 None ## T1-1 None # T2
2 mdt_demo 1.0.0 You can use additional markups None None * [] Task2
3 mdt_demo 1.0.0 You can use additional markups None None * [v] Task2 #tag1:1 #tag2:1.5 #tag1
4 mdt_demo 1.0.0 You can use additional markups None None * [v] #tag2:2 [v] #tag2:3.5

TaskPaper


In [5]:
mp.P_T1 = r"^(.*):$"
mp.C_TITLE = ":"
dta = mp.parse_md_files("../mdt/mdt_demo*.taskpaper")
dta


Out[5]:
Filename ID T1 T2 T3 TXT
0 mdt_demo1 1.0.0 Prj1 None None - Task1
1 mdt_demo1 1.0.0 Prj1 None None - Task2 @done(2017-01-02)
2 mdt_demo1 2.0.0 Prj2 None None - Task3 @p(1) @done(2017-01-02)
3 mdt_demo1 2.0.0 Prj2 None None - Task4 @p(3) @p(2)
0 mdt_demo2 1.0.0 Prj1 None None - Task5
1 mdt_demo2 1.0.0 Prj1 None None - Task6 @done(2017-01-09)
2 mdt_demo2 2.0.0 Prj2 None None - Task7 @p(1) @done(2017-01-10)
3 mdt_demo2 2.0.0 Prj2 None None - Task8 @p(3) @p(2)

Stats


In [6]:
reload(ms)
dta.apply(ms.stat_journal,axis=1)


Out[6]:
done p
0 NaN NaN
1 2017-01-02 NaN
2 2017-01-02 1.0
3 NaN 5.0
0 NaN NaN
1 2017-01-09 NaN
2 2017-01-10 1.0
3 NaN 5.0

In [7]:
reload(ms)
ms.add_stat(dta, "done,p")


Out[7]:
Filename ID T1 T2 T3 TXT done p
0 mdt_demo1 1.0.0 Prj1 None None - Task1 NaN NaN
1 mdt_demo1 1.0.0 Prj1 None None - Task2 @done(2017-01-02) 2017-01-02 NaN
2 mdt_demo1 2.0.0 Prj2 None None - Task3 @p(1) @done(2017-01-02) 2017-01-02 1.0
3 mdt_demo1 2.0.0 Prj2 None None - Task4 @p(3) @p(2) NaN 5.0
0 mdt_demo2 1.0.0 Prj1 None None - Task5 NaN NaN
1 mdt_demo2 1.0.0 Prj1 None None - Task6 @done(2017-01-09) 2017-01-09 NaN
2 mdt_demo2 2.0.0 Prj2 None None - Task7 @p(1) @done(2017-01-10) 2017-01-10 1.0
3 mdt_demo2 2.0.0 Prj2 None None - Task8 @p(3) @p(2) NaN 5.0

Visualization

Bokeh


In [8]:
from bokeh.io import push_notebook, show, output_notebook
from bokeh.layouts import row
from bokeh.plotting import figure
output_notebook()


Loading BokehJS ...

ggolpt


In [9]:
# from ggplot import *
# diamonds.head()


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-9-bac39ed5f483> in <module>()
----> 1 from ggplot import *
      2 diamonds.head()

ImportError: No module named ggplot

In [ ]:
# p = ggplot(aes(x='date', y='beef'), data=meat)
# p + geom_point() + geom_line() + stat_smooth(color='blue')

Dropbox I/O


In [10]:
auth_token = "bdOpEz-TVPwAAAAAAAAzs3AZSPeNDDDyZiaioA4gMK2LMoazNL5x5XrJgjawNJw4"
dbx = dropbox.Dropbox(auth_token)
dbx.users_get_current_account()
dbx.files_list_folder("")
#dbx.files_upload('!!!', "/Hello2", )


Out[10]:
ListFolderResult(entries=[FileMetadata(name=u'20170101.taskpaper', id=u'id:DKtWu_T6HIQAAAAAAAIykQ', client_modified=datetime.datetime(2017, 2, 2, 19, 25, 4), server_modified=datetime.datetime(2017, 2, 6, 19, 21, 54), rev=u'353e8a877', size=1994, path_lower=u'/20170101.taskpaper', path_display=u'/20170101.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'13a0b5cdedba8acb27c4c9bf140030c0ac2aded3d3adf36b524f31294c5a345f'), FileMetadata(name=u'20170108.taskpaper', id=u'id:DKtWu_T6HIQAAAAAAAI7kg', client_modified=datetime.datetime(2017, 2, 2, 19, 24, 58), server_modified=datetime.datetime(2017, 2, 6, 19, 21, 54), rev=u'453e8a877', size=2224, path_lower=u'/20170108.taskpaper', path_display=u'/20170108.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'621a8d34e7e59579c522da33a1a1999ae8354607070b11a30cf13bed7b22be34'), FileMetadata(name=u'20170115.taskpaper', id=u'id:DKtWu_T6HIQAAAAAAAJGrA', client_modified=datetime.datetime(2017, 2, 2, 19, 24, 52), server_modified=datetime.datetime(2017, 2, 6, 19, 21, 54), rev=u'553e8a877', size=2567, path_lower=u'/20170115.taskpaper', path_display=u'/20170115.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'6709deef182f69a8ebe7aab542ea3a97d0d6f5d3d926bd61db05aa901cec343a'), FileMetadata(name=u'20170122.taskpaper', id=u'id:DKtWu_T6HIQAAAAAAAJb5A', client_modified=datetime.datetime(2017, 2, 2, 19, 24, 46), server_modified=datetime.datetime(2017, 2, 6, 19, 21, 54), rev=u'653e8a877', size=1952, path_lower=u'/20170122.taskpaper', path_display=u'/20170122.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'3786b85dd0b09a46fd7dc7e3e11cfd10ff5a75362054b354f1c948ac5c279017'), FileMetadata(name=u'20170129.taskpaper', id=u'id:DKtWu_T6HIQAAAAAAAJfxQ', client_modified=datetime.datetime(2017, 2, 7, 0, 55, 51), server_modified=datetime.datetime(2017, 2, 7, 0, 55, 54), rev=u'1353e8a877', size=2283, path_lower=u'/20170129.taskpaper', path_display=u'/20170129.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'c05ff879428a1120fb755322c171f1e6fa5819ba8736a6291b87f178431108a2'), FileMetadata(name=u'20170205.taskpaper', id=u'id:DKtWu_T6HIQAAAAAAAJg5A', client_modified=datetime.datetime(2017, 2, 14, 4, 40, 12), server_modified=datetime.datetime(2017, 2, 14, 4, 45, 48), rev=u'9d53e8a877', size=4135, path_lower=u'/20170205.taskpaper', path_display=u'/20170205.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'd43fc5a29dfc036b0fd54a766dfd30d6ae4c17313e772304538da6777a6feb03'), FileMetadata(name=u'20170212.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAIA', client_modified=datetime.datetime(2017, 2, 19, 15, 21, 25), server_modified=datetime.datetime(2017, 2, 19, 15, 21, 25), rev=u'ba53e8a877', size=1253, path_lower=u'/20170212.taskpaper', path_display=u'/20170212.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'721f3d10473c70fe980e01492688243d97744c729811076cdd829ebb90ce9d98'), FileMetadata(name=u'20170219.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAQg', client_modified=datetime.datetime(2017, 2, 26, 8, 59, 53), server_modified=datetime.datetime(2017, 3, 5, 17, 47, 47), rev=u'15253e8a877', size=2358, path_lower=u'/20170219.taskpaper', path_display=u'/20170219.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'c21451d51fd8acb9f2a19e6e3af489819c900705c60996a6ab8618b2b23ee026'), FileMetadata(name=u'20170226.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAARg', client_modified=datetime.datetime(2017, 3, 5, 17, 48, 33), server_modified=datetime.datetime(2017, 3, 5, 17, 48, 34), rev=u'15553e8a877', size=2139, path_lower=u'/20170226.taskpaper', path_display=u'/20170226.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'7692f9491167788ae5d61b21fcf932463c80083c84bb0d6fbd8c8c356bab6fb3'), FileMetadata(name=u'20170305.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAdg', client_modified=datetime.datetime(2017, 3, 13, 15, 8, 8), server_modified=datetime.datetime(2017, 3, 13, 15, 8, 8), rev=u'17753e8a877', size=1826, path_lower=u'/20170305.taskpaper', path_display=u'/20170305.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'14072d485ec3babbfe0fd0303985d11a49fbee5f3c8d759727734fdbe30ad37a'), FileMetadata(name=u'20170312.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAdw', client_modified=datetime.datetime(2017, 3, 19, 7, 7, 33), server_modified=datetime.datetime(2017, 3, 19, 7, 7, 34), rev=u'18a53e8a877', size=465, path_lower=u'/20170312.taskpaper', path_display=u'/20170312.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'a294d2c2aea902234f1f03e02db9eea8e90efb2ff8725160647c62174a66e81e'), FileMetadata(name=u'20170319.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAeQ', client_modified=datetime.datetime(2017, 3, 24, 18, 0, 10), server_modified=datetime.datetime(2017, 3, 24, 18, 0, 12), rev=u'19753e8a877', size=814, path_lower=u'/20170319.taskpaper', path_display=u'/20170319.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'db9f9d343b4dcdef89bc920097c631d644f5c944064999d27ed8cf697b796d96'), FileMetadata(name=u'20170326.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAeg', client_modified=datetime.datetime(2017, 4, 3, 6, 16, 29), server_modified=datetime.datetime(2017, 4, 3, 6, 16, 29), rev=u'1db53e8a877', size=1934, path_lower=u'/20170326.taskpaper', path_display=u'/20170326.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'319e0e84c46dede46abcb6deda7197cb26dd8cbd4b5de880e62520e01979e60a'), FileMetadata(name=u'20170402 @ SF.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAfA', client_modified=datetime.datetime(2017, 4, 10, 3, 59, 6), server_modified=datetime.datetime(2017, 4, 10, 3, 59, 6), rev=u'1f853e8a877', size=1668, path_lower=u'/20170402 @ sf.taskpaper', path_display=u'/20170402 @ SF.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'eaad4ce705d0456ce00bbd8b3f48816219a26d767f1b9c39b937a32b212d7300'), FileMetadata(name=u'20170409 Back in LA.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAfg', client_modified=datetime.datetime(2017, 4, 17, 15, 19, 48), server_modified=datetime.datetime(2017, 4, 17, 15, 19, 48), rev=u'20053e8a877', size=481, path_lower=u'/20170409 back in la.taskpaper', path_display=u'/20170409 Back in LA.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'48efceebed1565014149dfc7b81c806852f0eb94db68c6605832c5a2afb70c60'), FileMetadata(name=u'20170416.taskpaper', id=u'id:iELSCRdigeAAAAAAAAAAfw', client_modified=datetime.datetime(2017, 4, 17, 19, 17, 32), server_modified=datetime.datetime(2017, 4, 17, 19, 17, 36), rev=u'21a53e8a877', size=554, path_lower=u'/20170416.taskpaper', path_display=u'/20170416.taskpaper', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None, content_hash=u'ea765904a6915e08018dbe2848f08f450ee71900043ca8dc13c2670c7cf03b3e')], cursor=u'AAHujRWICttHua96pAyGaAIh54nsPgo6L1IFC8JRnOTGDaLecYMhinxWMCKxLPSMe6GrLjshpVBgC-_ZQn9EQE5vNTdQkSXNJ9Z2It_TUikHQ-_n4-RjvJqVtTX27X8ilXS6SEkVAMJWxp6IOttwfmkN', has_more=False)

In [12]:
root = ''
for entry in dbx.files_list_folder(root).entries:
    print(entry.name)
    md, res = dbx.files_download('/'+entry.name)


20170101.taskpaper
20170108.taskpaper
20170115.taskpaper
20170122.taskpaper
20170129.taskpaper
20170205.taskpaper
20170212.taskpaper
20170219.taskpaper
20170226.taskpaper
20170305.taskpaper
20170312.taskpaper
20170319.taskpaper
20170326.taskpaper
20170402 @ SF.taskpaper
20170409 Back in LA.taskpaper
20170416.taskpaper

In [13]:
res.content.decode().split("\n")
md.name


Out[13]:
u'20170416.taskpaper'

In [14]:
reload(mp)
auth_token = "bdOpEz-TVPwAAAAAAAAzs3AZSPeNDDDyZiaioA4gMK2LMoazNL5x5XrJgjawNJw4"
mp.import_from_dropbox(auth_token, 'tmp')
dt = mp.parse_md_files("./tmp/"+"*.taskpaper")


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-6e9cdf4dcb4e> in <module>()
      1 reload(mp)
      2 auth_token = "bdOpEz-TVPwAAAAAAAAzs3AZSPeNDDDyZiaioA4gMK2LMoazNL5x5XrJgjawNJw4"
----> 3 mp.import_from_dropbox(auth_token, 'tmp')
      4 dt = mp.parse_md_files("./tmp/"+"*.taskpaper")

AttributeError: 'module' object has no attribute 'import_from_dropbox'

Test


In [ ]:
"a b c".split(" ")

In [ ]:
reload(ms)
print(ms.P_TAG2)
text = ["abc @tag def", "a @tag(value!) c @tag2", "@done(2015-01-01)", "@p(1)"]
for t in text:
    print("## ", t)
    print(re.findall(ms.P_TAG, t))
    print(re.findall(ms.P_TAG2, t))

In [ ]:
import yaml
mc = open("mdt_config.yaml","r").read()
yaml.load(mc)

Deprecated


In [ ]: