mirror of https://github.com/Hoffelhas/autodoist
check_header function updated
parent
619489a1d0
commit
e1c0060afb
54
autodoist.py
54
autodoist.py
|
@ -612,34 +612,40 @@ def check_header(api, model):
|
||||||
header_all_in_level = False
|
header_all_in_level = False
|
||||||
unheader_all_in_level = False
|
unheader_all_in_level = False
|
||||||
regex_a = '(^[*]{2}\s*)(.*)'
|
regex_a = '(^[*]{2}\s*)(.*)'
|
||||||
regex_b = '(^!\*\s*)(.*)'
|
regex_b = '(^\-\*\s*)(.*)'
|
||||||
|
|
||||||
if isinstance(model, Task):
|
try:
|
||||||
ra = re.search(regex_a, model.content)
|
if isinstance(model, Task):
|
||||||
rb = re.search(regex_b, model.content)
|
ra = re.search(regex_a, model.content)
|
||||||
prefix_a = ra[0]
|
rb = re.search(regex_b, model.content)
|
||||||
prefix_b = rb[0]
|
|
||||||
|
|
||||||
if prefix_a:
|
if ra:
|
||||||
header_all_in_level = True
|
header_all_in_level = True
|
||||||
api.update_task(task_id=model.id, content=ra[2])
|
api.update_task(task_id=model.id, content=ra[2])
|
||||||
if prefix_b:
|
if rb:
|
||||||
unheader_all_in_level = True
|
unheader_all_in_level = True
|
||||||
api.update_task(task_id=model.id, content=ra[2])
|
api.update_task(task_id=model.id, content=rb[2])
|
||||||
|
else:
|
||||||
|
ra = re.search(regex_a, model.name)
|
||||||
|
rb = re.search(regex_b, model.name)
|
||||||
|
|
||||||
# api.update_section(section_id="7025", name="Supermarket")
|
if isinstance(model, Section):
|
||||||
# api.update_project(project_id="2203306141", name="Things To Buy")
|
if ra:
|
||||||
|
header_all_in_level = True
|
||||||
|
api.update_section(section_id=model.id, name=ra[2])
|
||||||
|
if rb:
|
||||||
|
unheader_all_in_level = True
|
||||||
|
api.update_section(section_id=model.id, name=rb[2])
|
||||||
|
|
||||||
# elif isinstance(model, Section) or isinstance(model, Project):
|
elif isinstance(model, Project):
|
||||||
# if name[:3] == '** ':
|
if ra:
|
||||||
# header_all_in_level = True
|
header_all_in_level = True
|
||||||
# level.update(name=name[3:])
|
api.update_project(project_id=model.id, name=ra[2])
|
||||||
# if name[:3] == '!* ' or name[:3] == '_* ':
|
if rb:
|
||||||
# unheader_all_in_level = True
|
unheader_all_in_level = True
|
||||||
# level.update(name=name[3:])
|
api.update_project(project_id=model.id, name=rb[2])
|
||||||
|
except:
|
||||||
else:
|
logging.debug('check_header: no right model found')
|
||||||
pass
|
|
||||||
|
|
||||||
return header_all_in_level, unheader_all_in_level
|
return header_all_in_level, unheader_all_in_level
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue