Created
October 24, 2010 06:04
-
-
Save yono/643185 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import commands | |
import os | |
import re | |
import sys | |
dirnum= sys.argv[1] | |
os.chdir('memo%s' % (dirnum)) | |
files = commands.getoutput('ls -1').splitlines() | |
num = 1 | |
for afile in files: | |
afile_read = open(afile).read().splitlines() | |
first = True | |
memo = [] | |
for line in afile_read: | |
if first: | |
memo.append(re.sub('^', '* ', line)) | |
first = False | |
if line.startswith('・') or line.startswith(' *'): | |
memo.append(line.replace('・','- ').replace(' *','- ')) | |
elif line.startswith(' o'): | |
memo.append(line.replace(' o',' -')) | |
elif line.startswith(' +'): | |
memo.append(line.replace(' +',' -')) | |
else: | |
memo.append(line) | |
print afile, '%s-%d.org' % (dirnum, num) | |
newfile = open('%s-%d.org' % (dirnum, num), 'w') | |
newfile.write('\n'.join(memo)) | |
num += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment