|
From: <fri...@us...> - 2008-12-24 10:20:02
|
Revision: 9640
http://zaf.svn.sourceforge.net/zaf/?rev=9640&view=rev
Author: friedelwolff
Date: 2008-12-24 10:19:57 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
Move validation and member initialisation from the .add_... methods to each class' constructor
Modified Paths:
--------------
trunk/dict/zu/hunspell/hunspell_format.py
Modified: trunk/dict/zu/hunspell/hunspell_format.py
===================================================================
--- trunk/dict/zu/hunspell/hunspell_format.py 2008-12-24 07:15:56 UTC (rev 9639)
+++ trunk/dict/zu/hunspell/hunspell_format.py 2008-12-24 10:19:57 UTC (rev 9640)
@@ -82,9 +82,7 @@
def add_group(self, **kwargs):
"""Adds a new group to the file"""
- assert "flag" in kwargs
- new_group = AffixGroup()
- new_group.__dict__.update(kwargs)
+ new_group = AffixGroup(**kwargs)
self.groups.append(new_group)
return new_group
@@ -101,12 +99,15 @@
rules = []
"""A list with all the affixes in this group"""
- def __init__(self):
+ def __init__(self, **kwargs):
self.suffix = True
self.flag = ""
self.cross_product = True
self.rules = []
+ assert "flag" in kwargs
+ self.__dict__.update(kwargs)
+
def hunspell(self, options):
"""Output this affix class for the hunspell affix file"""
option = self.suffix and "SFX" or "PFX"
@@ -133,11 +134,7 @@
def add_rule(self, **kwargs):
"""Inserts a new rule in this affix class"""
- new_rule = Affix()
- new_rule.__dict__.update(kwargs)
- assert "group" not in kwargs
- assert "suffix" not in kwargs
- assert "prefix" not in kwargs
+ new_rule = Affix(**kwargs)
new_rule.group = self
self.rules.append(new_rule)
return new_rule
@@ -162,7 +159,7 @@
morphology = ""
"""Extra information about morphology"""
- def __init__(self):
+ def __init__(self, **kwargs):
self.group = None
self.strip = ""
self.affix = ""
@@ -172,6 +169,11 @@
self.circumfix = False
self.morphology = ""
+ assert "group" not in kwargs
+ assert "suffix" not in kwargs
+ assert "prefix" not in kwargs
+ self.__dict__.update(kwargs)
+
def _sort_key(self):
"""Return a key suitable for sorting"""
return (self.affix, self.strip, self.condition, self.morphology)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|