From 086f890f3e602c2a2fa5de8124d512856b7f9ed6 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Wed, 15 May 2019 21:24:44 -0400 Subject: bin/news: Add write. --- bin/news | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bin') diff --git a/bin/news b/bin/news index 9d52bd9..8240c06 100644 --- a/bin/news +++ b/bin/news @@ -7,6 +7,7 @@ import datetime import os +import os.path import re import subprocess as subp import sys @@ -35,6 +36,16 @@ def read(f): return c +def write(p, c): + d = os.path.dirname(p) + + if not os.path.exists(d): + os.makedirs(d) + + with open(p, 'w') as f: + f.write(c) + + def slug(p): m = re.search(r'([a-zA-Z\-]+)\.md', p) -- cgit v1.2.3