forked from varia/varia.website
many many many Varia's websites, work in progress: https://many.vvvvvvaria.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
544 B
24 lines
544 B
4 years ago
|
import os
|
||
|
|
||
|
folder = 'announcement/'
|
||
|
filenames = os.listdir(folder)
|
||
|
for filename in filenames:
|
||
|
print('---'+filename+'---')
|
||
|
out = []
|
||
|
f = open(folder+filename, 'r')
|
||
|
lines = f.readlines()
|
||
|
for line in lines:
|
||
|
tmpline = line.lower()
|
||
|
if 'category:' in tmpline:
|
||
|
category = tmpline.replace('category:', '').strip()
|
||
|
continue
|
||
|
elif 'tags' in tmpline:
|
||
|
line = line + ', {}'.format(category)
|
||
|
out.append(line)
|
||
|
|
||
|
outstring = '\n'.join(out)
|
||
|
print(outstring)
|
||
|
outfile = open(folder+filename, 'w')
|
||
|
#outfile.write(outstring)
|
||
|
outfile.close()
|