Package jazzparser :: Package formalisms :: Module loader
[hide private]
[frames] | no frames]

Source Code for Module jazzparser.formalisms.loader

 1  """Dynamic loader for named formalisms. 
 2   
 3  Some basic tools for the process of loading a named formalism. 
 4  A formalism can be loaded by name and the object returned should contain  
 5  all the information you need to use the formalism (i.e. pointers to  
 6  classes and functions). 
 7   
 8  """ 
 9  """ 
10  ============================== License ======================================== 
11   Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding 
12    
13   This file is part of The Jazz Parser. 
14    
15   The Jazz Parser is free software: you can redistribute it and/or modify 
16   it under the terms of the GNU General Public License as published by 
17   the Free Software Foundation, either version 3 of the License, or 
18   (at your option) any later version. 
19    
20   The Jazz Parser is distributed in the hope that it will be useful, 
21   but WITHOUT ANY WARRANTY; without even the implied warranty of 
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
23   GNU General Public License for more details. 
24    
25   You should have received a copy of the GNU General Public License 
26   along with The Jazz Parser.  If not, see <http://www.gnu.org/licenses/>. 
27   
28  ============================ End license ====================================== 
29   
30  """ 
31  __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"  
32   
33  from jazzparser.utils.base import load_class 
34  from jazzparser.settings import DEFAULT_FORMALISM 
35   
36 -def get_formalism(name):
37 """ 38 Returns the Formalism structure for the formalism with the given 39 name. 40 """ 41 from . import FORMALISMS 42 if name not in FORMALISMS: 43 raise FormalismLoadError, "The formalism '%s' does not exist" % name 44 path = 'jazzparser.formalisms.%s.Formalism' % name 45 return load_class(path)
46
47 -def get_default_formalism():
48 return get_formalism(DEFAULT_FORMALISM)
49
50 -class FormalismLoadError(Exception):
51 pass
52