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

Snapshots | iceberg

Inside this repository

remove_linebreaks.py
text/x-python

Download raw (943 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'({[^}]*})', c)
    if len(t0) == 0 :
        continue
    else:
        t0 = t0[0]
        t1 = t0.replace('\n', ' ')
        t1 = t1[:1] + ': ' + t1[1:]
        print(t1)
        t2 = re.sub(r'({[^}]*})', t1, c)
        print(t2)
        f = open(path, 'w')
        f.write(t2)
        f.close()










    # 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()