diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-15 14:05:40 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-15 17:02:08 +0000 |
commit | 71aad66f7360c16eb9569c599ffb709df0a49db4 (patch) | |
tree | ddf142cd8ee916169fe4820c1ab895ffc52b32ac /morphlib/morphloader.py | |
parent | 2cc11a34cf32eeeba34ddd38dc901cc15bdffb64 (diff) | |
download | morph-71aad66f7360c16eb9569c599ffb709df0a49db4.tar.gz |
Rename method to MorphologyLoader.parse_morphology_text
The new name is more descriptive, since it turns out that the
method doesn't just parse strings, but also open file handles.
Suggested by Richard Maw.
Diffstat (limited to 'morphlib/morphloader.py')
-rw-r--r-- | morphlib/morphloader.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 5b2c1063..a8bf2440 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -146,9 +146,11 @@ class MorphologyLoader(object): }, } - def parse_from_string(self, string, whence): + def parse_morphology_text(self, text, whence): '''Parse a textual morphology. + The text may be a string, or an open file handle. + Return the new Morphology object, or raise an error indicating the problem. This method does minimal validation: a syntactically correct morphology is fine, even if none of the fields are @@ -161,7 +163,7 @@ class MorphologyLoader(object): ''' try: - obj = yaml.safe_load(string) + obj = yaml.safe_load(text) except yaml.error.YAMLError as e: logging.error('Could not load morphology as YAML:\n%s' % str(e)) raise MorphologySyntaxError(whence) @@ -178,7 +180,7 @@ class MorphologyLoader(object): ''' - m = self.parse_from_string(string, filename) + m = self.parse_morphology_text(text, filename) m.filename = filename self.validate(m) self.set_defaults(m) |