PlainTasks 是款很有名的任務管理插件,具體的介紹在這裡

我最近的工作作務,是開發一款插件,能實現 JSON 文件到 todo 類文件的轉換。

JSON 的格式是這樣的

   1:  {
   2:     "project2":[
   3:        {
   4:           "finish_time":"",
   5:           "status":0,
   6:           "name":"marking a  sublime demo"
   7:        },
   8:        {
   9:           "finish_time":"",
  10:           "status":0,
  11:           "name":"testing"
  12:        },
  13:        {
  14:           "finish_time":"",
  15:           "status":0,
  16:           "name":"programing"
  17:        }
  18:     ],
  19:     "project1":[
  20:        {
  21:           "finish_time":"",
  22:           "status":0,
  23:           "name":"writing a  blog"
  24:        },
  25:        {
  26:           "finish_time":"",
  27:           "status":0,
  28:           "name":"reading a book"
  29:        },
  30:        {
  31:           "finish_time":"",
  32:           "status":0,
  33:           "name":"go to home"
  34:        }
  35:     ]
  36:  }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

以下是部分代碼片斷,很喜歡 python 的語法,但我不夠深入,希望高手指正下

   1:   def conver_todo_json(self):
   2:          file_name = self.window.active_view().file_name()
   3:          if not ".todo" in file_name:
   4:              return
   5:   
   6:          rom = '^\s*☐\s*(.*)$'
   7:          rdm = '\s*\✔\s*(.+?)\s*@done?([\(\)\d\w,\.:\-/ ]*)\s*'
   8:          rpm = '([^\b\(]*?)(?=\:)'
   9:   
  10:          json_data = {}
  11:          json_file = re.sub("\.todo", '.json', file_name)
  12:          project = 'other'
  13:   
  14:          with open(file_name, "r+", encoding="utf-8") as f:
  15:              for line in f:
  16:                  prj = re.match(rpm, line)
  17:                  if prj:
  18:                      project = prj.groups()[0]
  19:                      json_data[project] = []
  20:                  task_open = re.match(rom, line)
  21:                  if task_open:
  22:                      task_item = {"name": task_open.groups()[0] ,"status":0,"finish_time":""}
  23:                      json_data[project].append(task_item)
  24:                  task_done = re.match(rdm, line)
  25:                  if task_done:
  26:                      task_item = {"name":task_done.groups()[0],"status":1,"finish_time":task_done.groups()[1] }
  27:                      json_data[project].append(task_item)
  28:   
  29:          with open(json_file, "w+", encoding="utf-8") as f:
  30:              json.dump(json_data, f)
  31:   
  32:          self.window.open_file(json_file)

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

具體的詳細信息在這裡

開發PlainTasks與JSON的插件的更多相关文章

  1. Visual Studio 跨平台開發實戰(4) - Xamarin Android 基本控制項介紹 (转帖)

    前言 不同於iOS, Xamarin 在Visual Studio中針對Android, 可以直接設計使用者介面. 在本篇教學文章中, 筆者會針對Android的專案目錄結構以及基本控制項進行介紹, ...

  2. ASP.NET MVC 開發心得分享 (21):Routing 觀念與技巧

    ASP.NET MVC 預設在 Global.asax 所定義的 RegisterRoutes 方法中可以輕易的定義你希望擁有的網址格式,嚴格上來講這並非 ASP.NET MVC 的專利,而是從 AS ...

  3. Delphi APP 開發入門(九)拍照與分享

    Delphi APP 開發入門(九)拍照與分享 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數:30 ...

  4. Delphi APP 開發入門(七)通知與雲端推播

    Delphi APP 開發入門(七)通知與雲端推播 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數: ...

  5. 各式 Web 前端開發工具整理

    程式碼編寫工具 (Coding Tools) 工作流程/建置/組合 (Workflow/Builds/Assemblers) lumbar brunch grunt lineman yeoman Ta ...

  6. Delphi APP 開發入門(十)REST Client 開發

    Delphi APP 開發入門(十)REST Client 開發 分享: Share on facebookShare on twitterShare on google_plusone_share ...

  7. 騰訊RTX的API開發,給RTX開個天窗

    好多人可能沒聽說RTX這個軟件,在此我簡單說明一下,這個軟件是騰訊為企業開發的一個內部聊天軟件,服務端不是在騰訊那邊,而是需要企業自己安裝到自己公司內部的服務器上,以供企業內部員工交流使用,功能和QQ ...

  8. RTX的api開發實例

    RTX的api開發實例 最近接觸了RTX的接口開發部份,RTX其实有很多玩法,除了可以用自帶的客戶端發消息之外還可以用PHP調用API的方式來做一些事情,下邊整理了一下分享給大家 值得提醒的是这些接口 ...

  9. Bear 實驗室: 什麼是Git flow ? 如何在SourceTree使用Git flow管理開發!

      http://www.takobear.tw/12/post/2014/02/bear-git-flow-sourcetreegit-flow.html     Bear 實驗室: 什麼是Git ...

随机推荐

  1. Docker + .NET Core(一)

    原文:Docker + .NET Core(一) 前言: 环境:centos7.5 64 位 正文: 拉取 microsoft/dotnet, 安装完毕后执行 docker images 可以看到本地 ...

  2. Java入门程序

    JavaC.exe 编译器,编译.java文件 Java.exe 解释器,执行class文件 编译命令  javac HelloWorld.java 编译后 会产生同名的.class文件 javac编 ...

  3. 集装箱set相关算法

     set_union 算法set_union可构造S1.S2的并集.此集合内含S1或S2内的每个元素. S1.S2及其并集都是以排序区间表示.返回值是一个迭代器.指向输出区间的尾端. 因为S1和S ...

  4. 再议指针---------函数回调(qsort函数原理)

    我们是否能写一个这种函数: 能够对不论什么类型数据排序 不论什么人在使用该函数不须要改动该函数代码(即:用户能够不必看到函数源 码,仅仅会调用即可) 思考: 用户须要排序的数据的类型千变万化,可能是i ...

  5. Data analysis system

    A data analysis system, particularly, a system capable of efficiently analyzing big data is provided ...

  6. VS2015编译环境下CUDA安装配置

    CUDA下载 CUDA是NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题,CUDA只支持NVIDIA自家的显卡,过旧的版本型号也不被支持. 下载地址:https://devel ...

  7. 取消Jquery mobile自动省略的文本

    在使用jquery moblie做移动客户端app时,listview控件下的列表文本不能完全显示,只能显示一行,超过字数jquery mobile会自动用省略号代替.很是纠结啊. 最后在一个岛国网站 ...

  8. Linux性能测试 free命令

    命 令: free功能说明:显示内存状态.语 法: free [-bkmotV][-s <间隔秒数>]补充说明:free指令会显示内存的使用情况,包括实体内存,虚拟的交换文件内存,共享内存 ...

  9. leetcode先刷_Pascal&#39;s Triangle II

    三角相对简答题.第一个问题是太简单.我不沾了,我一定会写.其实没什么的第二个问题,与这个问题计算路径有点像一个三角形,假定输入是n,然后从第一行计数到第一n行,保存在数据线上的时间到,由于只有相关的事 ...

  10. qt翻译--QWaitCondition

    QWaitCondition Class Reference[QtCore module] 该类提供一个情况变量来同步线程. #include <QWaitCondition> 注意:该类 ...