MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / remove_must_read

Function remove_must_read

scripts/add_must_read.py:207–237  ·  view source on GitHub ↗

Remove entities from must-read list

(profile, entity_type, entities)

Source from the content-addressed store, hash-verified

205
206def remove_must_read(profile, entity_type, entities):
207 """Remove entities from must-read list"""
208 must_read = profile.get('must_read', {})
209 current_list = must_read.get(entity_type, [])
210 removed, not_found = [], []
211 for entity in entities:
212 if entity in current_list:
213 current_list.remove(entity)
214 removed.append(entity)
215 else:
216 not_found.append(entity)
217
218 updated = profile.copy()
219 updated['must_read'] = must_read
220 updated['version'] = f"0.{int(profile.get('version', '0.1').split('.')[1]) + 1}"
221 updated['updated_at'] = datetime.now().isoformat()
222
223 type_labels = {'authors': '作者', 'institutions': '机构', 'keywords': '关键词'}
224 label = type_labels.get(entity_type, entity_type)
225
226 if removed:
227 msg = f"[OK] 已删除 {label}:" + ", ".join(removed)
228 if current_list:
229 msg += f"\n\n当前必读{label}清单:\n" + "\n".join(f" - {e}" for e in current_list)
230 else:
231 msg += f"\n当前必读{label}清单为空"
232 elif not_found:
233 msg = f"[提示] {', '.join(not_found)} 不在必读{label}清单中"
234 else:
235 msg = "[错误] 未删除任何内容"
236 return (len(removed) > 0, msg, updated if removed else None)
237
238
239def list_must_read(profile):
240 """List current must-read items"""

Callers 1

mainFunction · 0.70

Calls 2

getMethod · 0.80
nowMethod · 0.80

Tested by

no test coverage detected