summaryrefslogtreecommitdiff
path: root/morphlib/morphology.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-10-04 13:42:59 +0100
committerLars Wirzenius <liw@liw.fi>2011-10-04 13:42:59 +0100
commitc44c15f7190841497d565f43128b73abe6f9cbfc (patch)
treeb03041d251e2a1873d6420644aabe8218d95f39b /morphlib/morphology.py
parentc45e1325b9930c0008f9cfdbae2c527b3d62de6e (diff)
downloadmorph-c44c15f7190841497d565f43128b73abe6f9cbfc.tar.gz
Remove morphology validation.
The implementation was painful to write, more painful to maintain, and that clashed badly with the need to be able to make changes easily during an exploratory, experimental phase of development. Validation should come back later, when things stabilize.
Diffstat (limited to 'morphlib/morphology.py')
-rw-r--r--morphlib/morphology.py84
1 files changed, 1 insertions, 83 deletions
diff --git a/morphlib/morphology.py b/morphlib/morphology.py
index 903df472..359c8f3b 100644
--- a/morphlib/morphology.py
+++ b/morphlib/morphology.py
@@ -18,11 +18,6 @@ import json
import logging
-class SchemaError(Exception):
-
- pass
-
-
class Morphology(object):
'''Represent a morphology: description of how to build binaries.'''
@@ -36,86 +31,12 @@ class Morphology(object):
logging.debug('Loading morphology %s' % self._fp.name)
self._dict = json.load(self._fp)
- if 'name' not in self._dict:
- raise self._error('must contain "name"')
-
- if not self.name:
- raise self._error('"name" must not be empty')
-
- if 'kind' not in self._dict:
- raise self._error('must contain "kind"')
-
- if self.kind == 'chunk':
- self._validate_chunk()
- elif self.kind == 'stratum':
- self._validate_stratum()
+ if self.kind == 'stratum':
for source in self.sources.itervalues():
source['repo'] = self._join_with_baseurl(source['repo'])
- elif self.kind == 'system':
- pass
- else:
- raise self._error('kind must be chunk or stratum, not %s' %
- self.kind)
self.filename = self._fp.name
- def _validate_chunk(self):
- valid_toplevel_keys = ['name', 'kind', 'configure-commands',
- 'build-commands', 'test-commands',
- 'install-commands']
-
- cmdlists = [
- (self.configure_commands, 'configure-commands'),
- (self.build_commands, 'build-commands'),
- (self.test_commands, 'test-commands'),
- (self.install_commands, 'install-commands'),
- ]
- for value, name in cmdlists:
- if type(value) != list:
- raise self._error('"%s" must be a list' % name)
- for x in value:
- if type(x) != unicode:
- raise self._error('"%s" must contain strings' % name)
-
- for key in self._dict.keys():
- if key not in valid_toplevel_keys:
- raise self._error('unknown key "%s"' % key)
-
- def _validate_stratum(self):
- valid_toplevel_keys = ['name', 'kind', 'sources']
-
- if 'sources' not in self._dict:
- raise self._error('stratum must contain "sources"')
-
- if type(self.sources) != dict:
- raise self._error('"sources" must be a dict')
-
- if len(self.sources) == 0:
- raise self._error('"sources" must not be empty')
-
- for name, source in self.sources.iteritems():
- if type(source) != dict:
- raise self._error('"sources" must contain dicts')
- if 'repo' not in source:
- raise self._error('sources must have "repo"')
- if type(source['repo']) != unicode:
- raise self._error('"repo" must be a string')
- if not source['repo']:
- raise self._error('"repo" must be a non-empty string')
- if 'ref' not in source:
- raise self._error('sources must have "ref"')
- if type(source['ref']) != unicode:
- raise self._error('"ref" must be a string')
- if not source['ref']:
- raise self._error('"ref" must be a non-empty string')
- for key in source:
- if key not in ('repo', 'ref'):
- raise self._error('unknown key "%s" in sources' % key)
-
- for key in self._dict.keys():
- if key not in valid_toplevel_keys:
- raise self._error('unknown key "%s"' % key)
-
@property
def name(self):
return self._dict['name']
@@ -159,6 +80,3 @@ class Morphology(object):
else:
return url
- def _error(self, msg):
- return SchemaError('Morphology %s: %s' % (self._fp.name, msg))
-