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. 【OpenGL】Shader实例分析(六)- 卡牌特效

    转发请保持地址:http://blog.csdn.net/stalendp/article/details/30989295 本文将介绍怎么通过alpha通道来隐藏信息.并实现卡牌特效. 执行效果例如 ...

  2. 高并发场景之RabbitMQ

    高并发场景之RabbitMQ 上次我们介绍了在单机.集群下高并发场景可以选择的一些方案,传送门:高并发场景之一般解决方案 但是也发现了一些问题,比如集群下使用ConcurrentQueue或加锁都不能 ...

  3. for, for..in, in, for...of的区别

    for是ES5里做数组循环里最常用的 for (var i = 0; i < array.length; i++) { // todo } for...in是ES5里用来遍历对象属性用的 var ...

  4. 微软 2018 年第一笔收购:文件存储公司 Avere Systems

    微软 2018 年第一笔收购:文件存储公司 Avere Systems 2018 年 1 月 4 日, 9:47 上午 · Picturepan2 微软今天宣布收购文件存储公司 Avere Syste ...

  5. phpcms视图查询数据

    {pc:get sql="SELECT * FROM phpcms WHERE id in ($id) ORDER BY listorder ASC LIMIT 0, 1--"re ...

  6. Android 在子线程中更新UI的几种方法

    第一种: new Handler(context.getMainLooper()).post(new Runnable() { @Override public void run() { // 在这里 ...

  7. wpf控件开发基础(3) -属性系统(2)

    原文:wpf控件开发基础(3) -属性系统(2) 上篇说明了属性存在的一系列问题. 属性默认值,可以保证属性的有效性. 属性验证有效性,可以对输入的属性进行校验 属性强制回调, 即不管属性有无发生变化 ...

  8. hibernate validator 专题

    JSR-303 原生支持的限制有如下几种 : 限制 说明 @Null 限制只能为 null @NotNull 限制必须不为 null @AssertFalse 限制必须为 false @AssertT ...

  9. 微信公众平台消息接口开发(31)微信浏览器HTTP_USER_AGENT判断

    微信公众平台开发 微信公众平台开发者 微信公众平台开发模式 微信浏览器 HTTP_USER_AGENT作者:方倍工作室 原文:http://www.cnblogs.com/txw1958/archiv ...

  10. MySQL SYS CPU高的案例分析(二)

    原文:MySQL SYS CPU高的案例分析(二) 后面又做了补充测试,增加了每秒context switch的监控,以及SQL执行时各步骤消耗时间的监控. [测试现象一] 启用1000个并发线程的压 ...