summaryrefslogtreecommitdiff
path: root/scripts/migrate-chunks
diff options
context:
space:
mode:
authorFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2014-08-11 09:08:02 +0000
committerFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2014-08-11 09:08:02 +0000
commit0a90d74ed73795a81d950a8cd986195252f3ab5c (patch)
treeed53c4c4393683a5012aa5fd3fdc1980a7f0cd1e /scripts/migrate-chunks
parentbdec7cfa3a8a4f80496796bc640dbf64c9a61dad (diff)
downloaddefinitions-0a90d74ed73795a81d950a8cd986195252f3ab5c.tar.gz
Fix error and add comments
Diffstat (limited to 'scripts/migrate-chunks')
-rwxr-xr-xscripts/migrate-chunks18
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/migrate-chunks b/scripts/migrate-chunks
index e9351037..aba56306 100755
--- a/scripts/migrate-chunks
+++ b/scripts/migrate-chunks
@@ -108,7 +108,7 @@ def move_morphs(morphs, kind):
loader.save_to_file(chunk['morph'], new_chunk)
print "Downloading %s from %s and placing in %s" %(name, repo, chunk['morph'])
except urllib2.HTTPError as err:
- # If there si no morphology in the repository we assume that the morphology
+ # If there is no morphology in the repository we assume that the morphology
# system will be autodetected, so we don't have to create a new one
# unless we shut down the autodetecting system (fallback system).
if err.code == 404:
@@ -116,15 +116,23 @@ def move_morphs(morphs, kind):
except morphlib.morphloader.InvalidFieldError as err:
print "ERROR: %s in chunk %s" % (err, chunk_morph)
if "comments" in err:
- fixed_chunk = str(chunk_morph).replace("comments", "description")
+ # This error is caused because there are old morphologies which
+ # contain the field "comments" instead of "description".
+ # Replacing "comments" field by "description" will allow the morphology
+ # to pass parse_morphology_text check and ready to be written to a file.
+ fixed_chunk = str(chunk_morph).replace("comments: ", "description:")
m_fixed_chunk = loader.load_from_string(chunk['morph'],fixed_chunk)
loader.save_to_file(chunk['morph'], m_fixed_chunk)
print "Downloading %s from %s and placing in %s" %(name, repo, chunk['morph'])
except morphlib.morphloader.MorphologyNotYamlError as err:
print "ERROR: %s in chunk %s" % (err, chunk_morph)
- new_chunk = json.loads(chunk_morph)
- print "%s" % new_chunk
- sys.exit(0)
+ # This error is caused because there are old morphologies written
+ # in JSON which contain '\t' characters. When try to load this
+ # kind of morphologies load_from_string fails when parse_morphology_text.
+ # Removing this characters will make load_from_string to load the morphology
+ # and translate it into a correct yaml format.
+ fix_chunk = chunk_morph.replace('\t','')
+ new_chunk = loader.load_from_string(fix_chunk)
loader.save_to_file(chunk['morph'], new_chunk)
print "Downloading %s from %s and placing in %s" %(name, repo, chunk['morph'])