Compare commits
2 commits
070b0fea01
...
c133b7068f
Author | SHA1 | Date | |
---|---|---|---|
c133b7068f | |||
885bad2fa2 |
1 changed files with 24 additions and 7 deletions
|
@ -57,7 +57,7 @@ def parse_comments(task_id):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def parse_task(task, subtask):
|
def parse_task(task, subtask, additional_labels):
|
||||||
"""Print a task."""
|
"""Print a task."""
|
||||||
output = []
|
output = []
|
||||||
if subtask:
|
if subtask:
|
||||||
|
@ -65,9 +65,10 @@ def parse_task(task, subtask):
|
||||||
else:
|
else:
|
||||||
headline = f"** TODO {task.content}"
|
headline = f"** TODO {task.content}"
|
||||||
|
|
||||||
labels = task.labels
|
labels = [*additional_labels, *task.labels]
|
||||||
if len(labels) > 0:
|
if len(labels) > 0:
|
||||||
headline += " :" + ":".join(labels) + ":"
|
labels_string = " :" + ":".join(labels) + ":"
|
||||||
|
headline += labels_string.replace("-", "_")
|
||||||
|
|
||||||
output.append(headline)
|
output.append(headline)
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ def parse_task(task, subtask):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def parse_sections(project_id, tasks):
|
def parse_sections(project_id, tasks, additional_labels):
|
||||||
"""Print a section."""
|
"""Print a section."""
|
||||||
output = []
|
output = []
|
||||||
sections = api.get_sections(project_id=project_id)
|
sections = api.get_sections(project_id=project_id)
|
||||||
|
@ -119,6 +120,8 @@ def parse_sections(project_id, tasks):
|
||||||
for section in sections:
|
for section in sections:
|
||||||
output.append(f"* {section.name}")
|
output.append(f"* {section.name}")
|
||||||
output.append("")
|
output.append("")
|
||||||
|
section_slug = get_filename(section.name, False)
|
||||||
|
additional_labels.append(section_slug)
|
||||||
subtask = False
|
subtask = False
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
if task.section_id == section.id:
|
if task.section_id == section.id:
|
||||||
|
@ -127,7 +130,7 @@ def parse_sections(project_id, tasks):
|
||||||
subtask = True
|
subtask = True
|
||||||
if subtask and not task.parent_id:
|
if subtask and not task.parent_id:
|
||||||
subtask = False
|
subtask = False
|
||||||
output.extend(parse_task(task, subtask))
|
output.extend(parse_task(task, subtask, additional_labels))
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -135,6 +138,8 @@ def parse_sections(project_id, tasks):
|
||||||
def parse_project(project, parent_project_name=""):
|
def parse_project(project, parent_project_name=""):
|
||||||
"""Parse a project."""
|
"""Parse a project."""
|
||||||
filename = get_filename(project.name)
|
filename = get_filename(project.name)
|
||||||
|
project_slug = get_filename(project.name, False)
|
||||||
|
additional_lables = [f"@{project_slug}"]
|
||||||
content = []
|
content = []
|
||||||
|
|
||||||
output_dir = os.environ.get("OUTPUT_DIR", "./output")
|
output_dir = os.environ.get("OUTPUT_DIR", "./output")
|
||||||
|
@ -166,9 +171,10 @@ def parse_project(project, parent_project_name=""):
|
||||||
subtask = True
|
subtask = True
|
||||||
if subtask and not task.parent_id:
|
if subtask and not task.parent_id:
|
||||||
subtask = False
|
subtask = False
|
||||||
content.extend(parse_task(task, subtask))
|
|
||||||
|
|
||||||
content.extend(parse_sections(project.id, tasks))
|
content.extend(parse_task(task, subtask, additional_lables))
|
||||||
|
|
||||||
|
content.extend(parse_sections(project.id, tasks, additional_lables))
|
||||||
|
|
||||||
write_file(path, content)
|
write_file(path, content)
|
||||||
return parent_project_name
|
return parent_project_name
|
||||||
|
@ -199,6 +205,16 @@ def parse_projects():
|
||||||
parent_project_name = parse_project(project, parent_project_name)
|
parent_project_name = parse_project(project, parent_project_name)
|
||||||
|
|
||||||
|
|
||||||
|
def print_warning():
|
||||||
|
"""Print warning about missing recurrences."""
|
||||||
|
print(
|
||||||
|
"Please keep in mind that this script does not support recurring "
|
||||||
|
+ "items and will only schedule them for next occurence. "
|
||||||
|
+ "If a task is recurring then the description will include a note "
|
||||||
|
+ "'(recurring)'."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Run the program."""
|
"""Run the program."""
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
@ -207,6 +223,7 @@ def main():
|
||||||
create_output_dir()
|
create_output_dir()
|
||||||
parse_projects()
|
parse_projects()
|
||||||
print_stats()
|
print_stats()
|
||||||
|
print_warning()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue