def rm_source(identnr):
"""removes source with input identnr
:param identnr:
"""
source = get_sources(ident=str(identnr))
if source:
source_name = source[0][1]
else:
return False
path = CACHE_DIR + str(identnr) + "_" + source_name.replace(".", "") + '.json'
all_sources = _get_all_sources_as_list()
new = [x for x in all_sources if x[0] != identnr]
with open(SOURCE_FLE_NAME, 'w+') as csvfile:
sourcewriter = csv.writer(csvfile, delimiter=DELIMITER, quoting=csv.QUOTE_ALL)
for row in new:
sourcewriter.writerow(row)
if os.remove(path):
return True
else:
return False
评论列表
文章目录