Skip to content

Commit

Permalink
synchroniser for 'part of' relations
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 18, 2013
1 parent c9f4d68 commit 566c16c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion topics/documents/wiki/texts
Submodule texts updated from 066238 to 52ce48
26 changes: 26 additions & 0 deletions topics/documents/wiki/updOf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/local/bin/python
# -*- coding: utf-8 -*-

import os

# * Abridge is a part of [[XBGF]]

for root, dirs, filenames in os.walk('texts'):
for f in filenames:
rd = open(os.path.join(root,f),'r')
lines = rd.readlines()
changed = False
for i in range(0,len(lines)):
if lines[i].startswith('* ') and lines[i].find('is a part of')>-1:
what = lines[i].split(' is a part of ')[0][2:]
expect = f.split('.')[0]
if what != expect:
print '%s claimed to be %s, fixed.' % (expect, what)
changed = True
lines[i] = '* %s is a part of %s' % (expect, lines[i].split(' is a part of ')[-1])
rd.close()
if changed:
rd = open(os.path.join(root,f),'w')
for line in lines:
rd.write(line)
rd.close()

0 comments on commit 566c16c

Please sign in to comment.