PageRenderTime 26ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/make_autolinks.py

https://bitbucket.org/maghoff/radiosity
Python | 24 lines | 20 code | 2 blank | 2 comment | 0 complexity | 2b84b1931d0342c07e1c2970a4b8b67f MD5 | raw file
 1#!/usr/bin/env python
 2# -*- coding: utf-8 -*-
 3
 4import os, re
 5
 6r = re.compile('^((\d\d)-\d\d\d\d-\d\d-\d\d-.*).md$')
 7buf = ''
 8
 9for f in os.listdir(os.curdir):
10	m = r.match(f)
11	if m:
12		buf += '[%s]: %s.html\n' % (m.groups()[1], m.groups()[0])
13
14def should_write():
15	try:
16		f = open('autolinks.md', 'rb')
17		old = f.read()
18		f.close()
19		return old != buf
20	except:
21		return True
22
23if should_write():
24	open('autolinks.md', 'wb').write(buf)