forked from indymedia/epicyon
Read tag files line by line
This prevents the whole file needing to be read and so should improve performancemain
parent
073444c55a
commit
0e87344ee7
|
@ -5541,12 +5541,13 @@ def htmlHashTagSwarm(baseDir: str, actor: str) -> str:
|
||||||
if daysSinceEpochStr not in open(tagsFilename).read():
|
if daysSinceEpochStr not in open(tagsFilename).read():
|
||||||
continue
|
continue
|
||||||
with open(tagsFilename, 'r') as tagsFile:
|
with open(tagsFilename, 'r') as tagsFile:
|
||||||
|
line = tagsFile.readline()
|
||||||
|
lineCtr = 1
|
||||||
tagCtr = 0
|
tagCtr = 0
|
||||||
lines = tagsFile.readlines()
|
while line:
|
||||||
for l in lines:
|
if ' ' not in line:
|
||||||
if ' ' not in l:
|
|
||||||
continue
|
continue
|
||||||
postDaysSinceEpochStr = l.split(' ')[0]
|
postDaysSinceEpochStr = line.split(' ')[0]
|
||||||
if not postDaysSinceEpochStr.isdigit():
|
if not postDaysSinceEpochStr.isdigit():
|
||||||
continue
|
continue
|
||||||
postDaysSinceEpoch = int(postDaysSinceEpochStr)
|
postDaysSinceEpoch = int(postDaysSinceEpochStr)
|
||||||
|
@ -5558,6 +5559,13 @@ def htmlHashTagSwarm(baseDir: str, actor: str) -> str:
|
||||||
tagCtr += 1
|
tagCtr += 1
|
||||||
if tagCtr > 3:
|
if tagCtr > 3:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
line = tagsFile.readline()
|
||||||
|
lineCtr += 1
|
||||||
|
# don't read too many lines
|
||||||
|
if lineCtr > 4:
|
||||||
|
break
|
||||||
|
|
||||||
if tagCtr > 0:
|
if tagCtr > 0:
|
||||||
tagSwarmCtr.append(tagCtr)
|
tagSwarmCtr.append(tagCtr)
|
||||||
if not tagSwarm:
|
if not tagSwarm:
|
||||||
|
|
Loading…
Reference in New Issue