From 6910800c66f5733a66ed04d3d30c036ef36ce4f6 Mon Sep 17 00:00:00 2001 From: Francisco Redondo Marchena Date: Tue, 5 Aug 2014 14:29:57 +0000 Subject: WIP: play with clusters --- scripts/migrate-chunks | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) (limited to 'scripts/migrate-chunks') 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) -- cgit v1.2.1