summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2019-05-15 21:24:44 -0400
committerrsiddharth <s@ricketyspace.net>2019-05-15 21:24:44 -0400
commit086f890f3e602c2a2fa5de8124d512856b7f9ed6 (patch)
tree6ba058b4355a688d6a61ddd0ba172cb42c12b38b /bin
parent97f0b45c17199e2b7213217cbad8cea1461182fe (diff)
bin/news: Add write.
Diffstat (limited to 'bin')
-rw-r--r--bin/news11
1 files changed, 11 insertions, 0 deletions
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)