(self)
| 168 | super(PackAPI, self).__init__(**values) |
| 169 | |
| 170 | def validate(self): |
| 171 | # We wrap default validate() implementation and throw a more user-friendly exception in |
| 172 | # case pack version doesn't follow a valid semver format and other errors |
| 173 | try: |
| 174 | super(PackAPI, self).validate() |
| 175 | except jsonschema.ValidationError as e: |
| 176 | msg = six.text_type(e) |
| 177 | |
| 178 | # Invalid version |
| 179 | if "Failed validating 'pattern' in schema['properties']['version']" in msg: |
| 180 | new_msg = ( |
| 181 | 'Pack version "%s" doesn\'t follow a valid semver format. Valid ' |
| 182 | "versions and formats include: 0.1.0, 0.2.1, 1.1.0, etc." |
| 183 | % (self.version) |
| 184 | ) |
| 185 | new_msg += "\n\n" + msg |
| 186 | raise jsonschema.ValidationError(new_msg) |
| 187 | |
| 188 | # Invalid ref / name |
| 189 | if "Failed validating 'pattern' in schema['properties']['ref']" in msg: |
| 190 | new_msg = ( |
| 191 | "Pack ref / name can only contain valid word characters (a-z, 0-9 and " |
| 192 | "_), dashes are not allowed." |
| 193 | ) |
| 194 | new_msg += "\n\n" + msg |
| 195 | raise jsonschema.ValidationError(new_msg) |
| 196 | |
| 197 | raise e |
| 198 | |
| 199 | @classmethod |
| 200 | def to_model(cls, pack): |
no outgoing calls
no test coverage detected