-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
synchroniser for 'part of' relations
- Loading branch information
1 parent
c9f4d68
commit 566c16c
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
Submodule texts
updated
from 066238 to 52ce48
This file contains 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
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() |