Package pyxb :: Module exceptions_
[hide private]
[frames] | no frames]

Source Code for Module pyxb.exceptions_

  1  # Copyright 2009, Peter A. Bigot 
  2  # 
  3  # Licensed under the Apache License, Version 2.0 (the "License"); you may 
  4  # not use this file except in compliance with the License. You may obtain a 
  5  # copy of the License at: 
  6  # 
  7  #            http://www.apache.org/licenses/LICENSE-2.0 
  8  # 
  9  # Unless required by applicable law or agreed to in writing, software 
 10  # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 11  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 12  # License for the specific language governing permissions and limitations 
 13  # under the License. 
 14   
 15  """Extensions of standard exceptions for PyXB events. 
 16   
 17  Yeah, I'd love this module to be named exceptions.py, but it can't 
 18  because the standard library has one of those, and we need to 
 19  reference it below. 
 20  """ 
 21   
 22  import exceptions 
 23   
24 -class PyXBException (exceptions.Exception):
25 """Base class for exceptions that indicate a problem that the user should fix.""" 26 pass
27
28 -class SchemaValidationError (PyXBException):
29 """Raised when the XML hierarchy does not appear to be valid for an XML schema.""" 30 pass
31
32 -class NamespaceError (PyXBException):
33 """Violation of some rule relevant to XML Namespaces"""
34 - def __init__ (self, namespace, *args, **kw):
35 PyXBException.__init__(self, *args, **kw) 36 self.__namespace = namespace
37
38 - def namespace (self): return self.__namespace
39
40 -class NamespaceArchiveError (PyXBException):
41 """Problem related to namespace archives""" 42 pass
43
44 -class SchemaUniquenessError (PyXBException):
45 """Raised when somebody tries to create a schema component using a 46 schema that has already been used in that namespace. Import and 47 include processing would have avoided this, so somebody asked for 48 it specifically."""
49 - def __init__ (self, namespace, schema_location, existing_schema, *args, **kw):
50 # Prior to 2.5, exceptions did not inherit from object, and 51 # super could not be used. 52 #super(SchemaUniquenessError, self).__init__(*args, **kw) 53 PyXBException.__init__(self, *args, **kw) 54 self.__namespace = namespace 55 self.__schemaLocation = schema_location 56 self.__existingSchema = existing_schema
57
58 - def namespace (self): return self.__namespace
59 - def schemaLocation (self): return self.__schemaLocation
60 - def existingSchema (self): return self.__existingSchema
61
62 -class BindingGenerationError (PyXBException):
63 """Raised when something goes wrong generating the binding classes""" 64 pass
65
66 -class NamespaceUniquenessError (NamespaceError):
67 """Raised when an attempt is made to record multiple objects of the same name in the same namespace category.""" 68 pass
69
70 -class BadTypeValueError (PyXBException):
71 """Raised when a value in an XML attribute does not conform to the simple type.""" 72 pass
73
74 -class NotInNamespaceError (PyXBException):
75 '''Raised when a name is referenced that is not defined in the appropriate namespace.''' 76 __namespace = None 77 __ncName = None
78
79 -class BadPropertyError (PyXBException):
80 """Raised when a schema component property is accessed on a component instance that does not define that property.""" 81 pass
82
83 -class BadDocumentError (PyXBException):
84 """Raised when processing document content and an error is encountered.""" 85 pass
86
87 -class StructuralBadDocumentError (BadDocumentError):
88 """Raised when processing document and the content model is not satisfied."""
89
90 -class AbstractElementError (StructuralBadDocumentError):
91 """Raised when attempting to construct an element that is abstract.""" 92 pass
93
94 -class UnrecognizedContentError (StructuralBadDocumentError):
95 """Raised when processing document and an element does not match the content model."""
96
97 -class UnrecognizedElementError (UnrecognizedContentError):
98 """Raised when creating an instance from a document with an unrecognized root element."""
99
100 -class ExtraContentError (StructuralBadDocumentError):
101 """Raised when processing document and there is more material in an element content than expected."""
102
103 -class ContentInNilElementError (ExtraContentError):
104 """Raised when an element that is marked to be nil has content.""" 105 pass
106
107 -class MissingContentError (StructuralBadDocumentError):
108 """Raised when processing document and expected content is not present. See also UnrecognizedContentError."""
109
110 -class NotAnElementError (UnrecognizedContentError):
111 """Raised when processing document and a tag that is a type but not an element is encountered."""
112
113 -class UnrecognizedAttributeError (BadDocumentError):
114 """Raised when an attribute is found that is not sanctioned by the content model."""
115
116 -class ValidationError (PyXBException):
117 """Raised when something in the infoset fails to satisfy a content model or attribute requirement.""" 118 pass
119
120 -class AttributeValidationError (ValidationError):
121 """Raised when an attribute requirement is not satisfied.""" 122 pass
123
124 -class ProhibitedAttributeError (AttributeValidationError):
125 """Raised when an attribute that is prohibited is provided in an element."""
126
127 -class MissingAttributeError (AttributeValidationError):
128 """Raised when an attribute that is required is missing in an element."""
129
130 -class AttributeChangeError (BadDocumentError):
131 """Raised when an attribute with a fixed value constraint is set to a different value."""
132
133 -class AbstractInstantiationError (PyXBException):
134 """Raised when somebody tries to instantiate an abstract complex type."""
135
136 -class DOMGenerationError (PyXBException):
137 """Raised when converting binding to DOM and something goes wrong.""" 138 pass
139
140 -class NoNillableSupportError (PyXBException):
141 """Raised when checking _isNil on a type that does not support nillable.""" 142 pass
143
144 -class BindingValidationError (ValidationError):
145 """Raised when the content of a binding object is not consistent with its content model""" 146 pass
147
148 -class UnexpectedNonElementContentError (ValidationError):
149 """Raised when an element is given non-element content but may not contain such.""" 150 pass
151
152 -class NoContentModel (BindingValidationError):
153 """Raised when an operation is attempted that requires a content 154 model, but the complex type has empty or simple content.""" 155 pass
156
157 -class BindingError (PyXBException):
158 """Raised when the bindings are mis-used.""" 159 pass
160
161 -class NotSimpleContentError (BindingError):
162 """Raised when an operation that requires simple content is 163 invoked on a complex type that does not have simple content.""" 164 pass
165
166 -class NotComplexContentError (BindingError):
167 """Raised when an operation is attempted that requires a content 168 model, but the complex type has empty or simple content.""" 169 pass
170
171 -class PyXBError (exceptions.Exception):
172 """Base class for exceptions that indicate a problem that the user probably can't fix.""" 173 pass
174
175 -class UsageError (PyXBError):
176 """Raised when the code detects arguments to a public 177 operation."""
178
179 -class LogicError (PyXBError):
180 """Raised when the code detects an implementation problem."""
181
182 -class IncompleteImplementationError (LogicError):
183 """Raised when a code branch is taken that has not yet been implemented."""
184