Browse Source

adding a toolbox

master
manetta 5 years ago
parent
commit
6f7dc06d13
  1. 23
      toolbox/change-category-to-tag.py
  2. 14
      toolbox/change-image-url.py

23
toolbox/change-category-to-tag.py

@ -0,0 +1,23 @@
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()

14
toolbox/change-image-url.py

@ -0,0 +1,14 @@
import os
folder = 'content/'
filenames = os.listdir(folder)
for filename in filenames:
if '.md' in filename:
print('---'+filename+'---')
text = open(folder+filename, 'r').read()
text = text.replace('/images/', 'images/')
print(text)
outfile = open(folder+filename, 'w')
outfile.write(text)
outfile.close()
Loading…
Cancel
Save