osp-blog.www
clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

combine_tags.py
text/x-python

Download raw (642 bytes)

from pathlib import Path
import re

pathlist = Path("/home/colm/git/OSP/osp.tools.osp-blog/content").glob('**/*.md')
for path in pathlist:
    path_in_str = str(path)
    data = open(path_in_str, 'r+')
    c = data.read()
    t0 = re.findall(r'Tags: [a-zA-Z]*\nTags:.*\n', c)
    if len(t0) == 0 :
        continue
    else :
        t0 = ''.join(t0)
        t0 = t0.split(':')
        t1 = t0[1].split( )
        t1 = t1[0]
        newtags = t0[0] + ': ' + t1 + ',' + t0[2]
    t2 = re.findall(r'Tags: [a-zA-Z]*\nTags:.*\n', c)
    t3 = re.sub(r'Tags: [a-zA-Z]*\nTags:.*\n', newtags, c)
    f = open(path, 'w')
    f.write(t3)
    f.close()