delettion

This commit is contained in:
gauthiier
2019-12-26 11:42:35 +01:00
parent 45393ec97d
commit f159ac9454
8 changed files with 152 additions and 307 deletions
+37
View File
@@ -8,6 +8,7 @@ sel_dump = os.path.join(config.selection, "tm-selection-dump.js")
LL = Lock()
# TAGS
def update(tag, newtag, newdesc):
with LL:
d = load_selection()
@@ -65,6 +66,30 @@ def new(tag, desc):
return True
# URL
def delete_url(tag, url):
with LL:
d = load_selection()
if tag not in list(d.keys()):
return False
for m in d[tag]['lists']:
if m['url'] == url:
d[tag]['lists'].remove(m)
break
write_selection(d)
sd = load_selection_dump()
if not tag in list(sd.keys()):
logging.warning("possible inconsistency between sel and sel_dump...")
else:
for m in sd[tag]['lists']:
if recursive_delete(m, sd[tag]['lists'], url):
break
write_selection_dump(sd)
return True
def load_selection():
with open(sel, encoding='utf-8') as f:
@@ -122,6 +147,18 @@ def recursive_find(msg, li, url):
return msg # <-- parent thread
return None
def recursive_delete(msg, parent_list, url):
if msg['url'] == url:
parent_list.remove(msg)
return True
d = False
if 'follow-up' in list(msg.keys()):
for m in msg['follow-up']:
d = d | recursive_delete(m, msg['follow-up'], url)
return d
def find(li, url):
d = os.path.join(config.archives, li)
File diff suppressed because one or more lines are too long
+6 -10
View File
@@ -1,19 +1,15 @@
{
"end2end": {
"lists": [],
"desc": "..."
},
"net.art": {
"desc": "...",
"lists": [
{
"list": "crumb",
"url": "https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1310&L=new-media-curating&F=&S=&P=2942"
},
{
"list": "crumb",
"url": "https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1207&L=new-media-curating&F=&S=&P=1869"
}
]
},
"end2end": {
"desc": "...",
"lists": []
],
"desc": "..."
}
}