diff options
Diffstat (limited to 'morphlib/blobs.py')
-rw-r--r-- | morphlib/blobs.py | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/morphlib/blobs.py b/morphlib/blobs.py deleted file mode 100644 index 1c8686b0..00000000 --- a/morphlib/blobs.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright (C) 2012 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - -class Blob(object): - - @staticmethod - def create_blob(morph): - if morph.kind == 'stratum': - return Stratum(morph) - elif morph.kind == 'chunk': - return Chunk(morph) - elif morph.kind == 'system': - return System(morph) - else: - raise TypeError('Morphology %s has an unknown type: %s' % - (morph.filename, morph.kind)) - - def __init__(self, morph): - self.parents = [] - self.morph = morph - self.dependencies = [] - self.dependents = [] - - def add_parent(self, parent): - if not parent in self.parents: - self.parents.append(parent) - - def remove_parent(self, parent): - if parent in self.parents: - self.parents.remove(parent) - - def add_dependency(self, other): - if not other in self.dependencies: - self.dependencies.append(other) - if not self in other.dependents: - other.dependents.append(self) - - def remove_dependency(self, other): - self.dependencies.remove(other) - other.dependents.remove(self) - - def depends_on(self, other): - return other in self.dependencies - - @property - def chunks(self): - if self.morph.chunks: - return self.morph.chunks - else: - return { self.morph.name: ['.'] } - - def __eq__(self, other): - return self.morph == other.morph - - def __hash__(self): - return hash(self.morph) - - def __str__(self): # pragma: no cover - return str(self.morph) - - -class Chunk(Blob): - - pass - - -class Stratum(Blob): - - pass - - -class System(Blob): - - pass |