pynmrstar 3.3.5__cp38-cp38-musllinux_1_2_i686.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pynmrstar might be problematic. Click here for more details.

@@ -0,0 +1,43 @@
1
+ """ Exceptions defined by PyNMR-STAR. """
2
+
3
+
4
+ class ParsingError(ValueError):
5
+ """ Indicates that something went wrong when parsing NMR-STAR data.
6
+ A line number on which the exception occurred will be provided if
7
+ possible. """
8
+
9
+ def __init__(self, message, line_number: int = None):
10
+ Exception.__init__(self)
11
+ self.message = message
12
+ self.line_number = line_number
13
+
14
+ def __repr__(self) -> str:
15
+ if self.line_number is not None:
16
+ return f'ParsingError("{self.message}") on line {self.line_number}'
17
+ else:
18
+ return f'ParsingError("{self.message}")'
19
+
20
+ def __str__(self) -> str:
21
+ if self.line_number is not None:
22
+ return f"{self.message} Error detected on line {self.line_number}."
23
+ else:
24
+ return self.message
25
+
26
+
27
+ class InvalidStateError(ValueError):
28
+ """ Indicates that the data as exists in the PyNMRSTAR objects is not
29
+ consistent with the NMR-STAR format or dictionary. This often means that
30
+ internal PyNMRSTAR attributes were modified directly rather than using the
31
+ appropriate getters/setters, since the library attempts to prevent actions
32
+ which would lead to such states. """
33
+
34
+ def __init__(self, message):
35
+ Exception.__init__(self)
36
+ self.message = message
37
+
38
+ def __repr__(self) -> str:
39
+ return f'InvalidStateError("{self.message}")'
40
+
41
+ def __str__(self) -> str:
42
+ return self.message
43
+