summaryrefslogtreecommitdiff
path: root/scripts/migrate-chunks
diff options
context:
space:
mode:
authorFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2014-08-05 14:29:57 +0000
committerFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2014-08-05 14:29:57 +0000
commit6910800c66f5733a66ed04d3d30c036ef36ce4f6 (patch)
treeaca465e46df6f612c7ac7659b2f4484b1bffb2ba /scripts/migrate-chunks
parent756834554c563b74154f57b23f354bbc0e8569f3 (diff)
downloaddefinitions-6910800c66f5733a66ed04d3d30c036ef36ce4f6.tar.gz
WIP: play with clusters
Diffstat (limited to 'scripts/migrate-chunks')
-rwxr-xr-xscripts/migrate-chunks46
1 files changed, 39 insertions, 7 deletions
diff --git a/scripts/migrate-chunks b/scripts/migrate-chunks
index 08899e1a..28fad3c9 100755
--- a/scripts/migrate-chunks
+++ b/scripts/migrate-chunks
@@ -9,6 +9,7 @@ import urllib
import urllib2
import urlparse
import yaml
+import re
verbose = False
if '--verbose' in sys.argv or '-v' in sys.argv:
@@ -26,30 +27,61 @@ morphologies = { 'chunk': '', 'stratum': '', 'system' : '', 'cluster': '' }
for key in morphologies.iterkeys():
morphologies[key] = [m for m in morphs if m['kind'] == key]
- print 'There are: %d %s' %(len(morphologies[key]), key)
+ #print 'There are: %d %s' %(len(morphologies[key]), key)
# organise the definitions repo
definitions_repo = sb.get_git_directory_name(sb.root_repository_url)
def move_morphs(morphs, kind):
- print 'Moving %s into subdirectory' % kind
- subdir = os.path.join(definitions_repo, kind)
- subprocess.call(['mkdir', subdir])
+ if kind == 'cluster':
+ print 'Moving %s into subdirectory' % kind
+ subdir = os.path.join(definitions_repo, 'cluster')
+ subprocess.call(['mkdir','-p', subdir])
+ for morph in morphs:
+ print 'Initial: %s' % str(morph)
+ morph['systems'][0]['morph'] = str( 'systems/' + morph['systems'][0]['morph'] + '.morph')
+ new_morph = loader.parse_morphology_text(str(morph), morph.filename)
+ loader.save_to_file(morph.filename,new_morph)
+ new_location = os.path.join(subdir, morph.filename)
+ subprocess.call(['git', 'mv', morph.filename, new_location])
+ #morph.filename = new_location
+ #subprocess.call(['git', 'commit', '--quiet', '-m',
+ # 'Move %s into subdirectory' %kind])
+ if kind == 'system':
+ print 'Moving %s into subdirectory' % kind
+ subdir = os.path.join(definitions_repo, 'system')
+ subprocess.call(['mkdir','-p', subdir])
+ for morph in morphs:
+ print 'Initial: %s' % str(morph)
+ sys.exit(0)
+ morph['systems'][0]['morph'] = str( 'strata/' + morph['strata'][0]['morph'] + '.morph')
+ new_morph = loader.parse_morphology_text(str(morph), morph.filename)
+ loader.save_to_file(morph.filename,new_morph)
+ new_location = os.path.join(subdir, morph.filename)
+ subprocess.call(['git', 'mv', morph.filename, new_location])
+ #morph.filename = new_location
+ #subprocess.call(['git', 'commit', '--quiet', '-m',
+ # 'Move %s into subdirectory' %kind])
+ sys.exit(0)
for morph in morphs:
+ print '%s' %morph
+ str_morph = str(morph)
+ new_morph = loader.parse_morphology_text(str_morph, morph.filename)
new_location = os.path.join(subdir, morph.filename.replace('-' + kind,'',1))
+ loader.save_to_file(new_location,new_morph)
print '%s' % new_location
+ sys.exit(0)
#subprocess.call(['git', 'mv', morph.filename, new_location])
#morph.filename = new_location
#subprocess.call(['git', 'commit', '--quiet', '-m',
# 'Move %s into subdirectory' % kind]m
for key in morphologies.iterkeys():
- if key in ['cluster', 'system']:
+ if key == 'system'
move_morphs(morphologies[key], key)
-sys.exit(0)
#move_morphs(chunks, 'chunks')
#move_morphs(strata, 'strata')
-move_morphs(systems, 'systems')
+#move_morphs(systems, 'systems')
#move_morphs(clusters, 'clusters')
sys.exit(0)