3 # Taskboard to Markdown
4 # This program is to pass information from taskboard JSON file [https://github.com/klaudiosinani/taskbook] to markdown [https://commonmark.org/]
6 # This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
7 # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
8 # You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
16 # Import JSON taskboard file
17 with
open(tbfile
) as f
:
20 j
= json
.loads(contents
)
22 # Export Hash as List of tasks
29 ## A task could has several boards
30 sboards
= [t
['boards'] for t
in tasks
]
36 # So the boards is the sorted boards along all tasks
37 boards
= sorted(list(set(boards
)))
40 ## Just incompleted tasks
41 msg
= "# Versions \n\n"
44 msg
= msg
+ "\n## " + b
[1:] + " \n\n"
46 tasksinb
= [t
for t
in tasks
if b
in t
['boards'] and t
['_isTask'] == True and t
['isComplete'] == False]
47 notesinb
= [t
for t
in tasks
if b
in t
['boards'] and t
['_isTask'] == False]
51 msg
= msg
+ "### Notes \n\n"
54 msg
= msg
+ "- [#{_id}] {description}\n".format(_id
= n
['_id'], description
=n
['description'])
61 msg
= msg
+ "### Tasks \n\n"
64 msg
= msg
+ "- [#{_id}] {description} \n".format(_id
= t
['_id'], description
= t
['description'])
70 # Parse program arguments
71 parser
= argparse
.ArgumentParser(description
="Convert tarkboard JSON file to markdown")
72 parser
.add_argument("json", type=str, help="JSON file to convert")
73 args
= parser
.parse_args()
76 if os
.path
.exists(args
.json
):
79 print("Error. No JSON file to convert provided")