mirror of https://gitlab.com/bashrc2/epicyon
Removing tag from file
parent
a19e61c90d
commit
7b96e12e2b
9
utils.py
9
utils.py
|
@ -361,10 +361,15 @@ def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilena
|
||||||
if not os.path.isfile(tagIndexFilename):
|
if not os.path.isfile(tagIndexFilename):
|
||||||
continue
|
continue
|
||||||
# remove postId from the tag index file
|
# remove postId from the tag index file
|
||||||
|
lines=None
|
||||||
with open(tagIndexFilename, "r") as f:
|
with open(tagIndexFilename, "r") as f:
|
||||||
lines=f.readlines()
|
lines=f.readlines()
|
||||||
newlines=lines.replace(postId+'\n','')
|
if lines:
|
||||||
if newlines!=lines:
|
newlines=''
|
||||||
|
for l in lines:
|
||||||
|
if postId in l:
|
||||||
|
continue
|
||||||
|
newlines+=l
|
||||||
if not newlines.strip():
|
if not newlines.strip():
|
||||||
# if there are no lines then remove the hashtag file
|
# if there are no lines then remove the hashtag file
|
||||||
os.remove(tagIndexFilename)
|
os.remove(tagIndexFilename)
|
||||||
|
|
Loading…
Reference in New Issue