brukerapi 0.1.9__py3-none-any.whl → 0.2.0__py3-none-any.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.
brukerapi/exceptions.py CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  class UnknownAcqSchemeException(Exception):
4
2
  def __init__(self, *args):
5
3
  if args:
@@ -9,9 +7,8 @@ class UnknownAcqSchemeException(Exception):
9
7
 
10
8
  def __str__(self):
11
9
  if self.message:
12
- return 'Unknown acquisition scheme, {}'.format(self.message)
13
- else:
14
- return 'Unknown acquisition scheme'
10
+ return f"Unknown acquisition scheme, {self.message}"
11
+ return "Unknown acquisition scheme"
15
12
 
16
13
 
17
14
  class UnsuportedDatasetType(Exception):
@@ -23,9 +20,8 @@ class UnsuportedDatasetType(Exception):
23
20
 
24
21
  def __str__(self):
25
22
  if self.message:
26
- return 'Dataset type: {} is not supported'.format(self.message)
27
- else:
28
- return 'Dataset type is not supported'
23
+ return f"Dataset type: {self.message} is not supported"
24
+ return "Dataset type is not supported"
29
25
 
30
26
 
31
27
  class InvalidJcampdxFile(Exception):
@@ -37,9 +33,8 @@ class InvalidJcampdxFile(Exception):
37
33
 
38
34
  def __str__(self):
39
35
  if self.message:
40
- return '{} is not valid JCAMP-DX file'.format(self.message)
41
- else:
42
- return 'Invalid JCAMP-DX file'
36
+ return f"{self.message} is not valid JCAMP-DX file"
37
+ return "Invalid JCAMP-DX file"
43
38
 
44
39
 
45
40
  class ParameterNotFound(Exception):
@@ -48,13 +43,14 @@ class ParameterNotFound(Exception):
48
43
  self.key = args[0]
49
44
  self.path = args[1]
50
45
  else:
46
+ self.key = None
47
+ self.path = None
51
48
  self.message = None
52
49
 
53
50
  def __str__(self):
54
51
  if self.key and self.path:
55
- return '{} not found in {}'.format(self.key, self.path)
56
- else:
57
- return 'Parameter not found'
52
+ return f"{self.key} not found in {self.path}"
53
+ return "Parameter not found"
58
54
 
59
55
 
60
56
  class JcampdxVersionError(Exception):
@@ -66,9 +62,8 @@ class JcampdxVersionError(Exception):
66
62
 
67
63
  def __str__(self):
68
64
  if self.message:
69
- return '"{}" is not a valid JCAMP-DX version, supported versions are {}'.format(self.message, SUPPORTED_VERSIONS)
70
- else:
71
- return 'Not a valid JCAMP-DX version'
65
+ return f'"{self.message}" is not a valid JCAMP-DX version'
66
+ return "Not a valid JCAMP-DX version"
72
67
 
73
68
 
74
69
  class JcampdxFileError(Exception):
@@ -80,9 +75,8 @@ class JcampdxFileError(Exception):
80
75
 
81
76
  def __str__(self):
82
77
  if self.message:
83
- return 'Not a valid JCAMP-DX file {} '.format(self.message)
84
- else:
85
- return 'Not a valid JCAMP-DX file'
78
+ return f"Not a valid JCAMP-DX file {self.message} "
79
+ return "Not a valid JCAMP-DX file"
86
80
 
87
81
 
88
82
  class JcampdxInvalidLine(Exception):
@@ -94,9 +88,8 @@ class JcampdxInvalidLine(Exception):
94
88
 
95
89
  def __str__(self):
96
90
  if self.message:
97
- return 'Not a valid JCAMP-DX data line {} '.format(self.message)
98
- else:
99
- return 'Not a valid JCAMP-DX data line'
91
+ return f"Not a valid JCAMP-DX data line {self.message} "
92
+ return "Not a valid JCAMP-DX data line"
100
93
 
101
94
 
102
95
  class DatasetTypeMissmatch(Exception):
@@ -109,8 +102,7 @@ class DatasetTypeMissmatch(Exception):
109
102
  def __str__(self):
110
103
  if self.message:
111
104
  return self.message
112
- else:
113
- return 'DatasetTypeMissmatch'
105
+ return "DatasetTypeMissmatch"
114
106
 
115
107
 
116
108
  class IncompleteDataset(Exception):
@@ -123,8 +115,7 @@ class IncompleteDataset(Exception):
123
115
  def __str__(self):
124
116
  if self.message:
125
117
  return self.message
126
- else:
127
- return 'DatasetTypeMissmatch'
118
+ return "DatasetTypeMissmatch"
128
119
 
129
120
 
130
121
  class ConditionNotMet(Exception):
@@ -136,9 +127,8 @@ class ConditionNotMet(Exception):
136
127
 
137
128
  def __str__(self):
138
129
  if self.message:
139
- return '{}'.format(self.message)
140
- else:
141
- return 'Not a valid JCAMP-DX version'
130
+ return f"{self.message}"
131
+ return "Not a valid JCAMP-DX version"
142
132
 
143
133
 
144
134
  class SequenceNotMet(Exception):
@@ -150,9 +140,8 @@ class SequenceNotMet(Exception):
150
140
 
151
141
  def __str__(self):
152
142
  if self.message:
153
- return 'Message {}'.format(self.message)
154
- else:
155
- return 'Not a valid JCAMP-DX version'
143
+ return f"Message {self.message}"
144
+ return "Not a valid JCAMP-DX version"
156
145
 
157
146
 
158
147
  class PvVersionNotMet(Exception):
@@ -164,9 +153,8 @@ class PvVersionNotMet(Exception):
164
153
 
165
154
  def __str__(self):
166
155
  if self.message:
167
- return 'Message {}'.format(self.message)
168
- else:
169
- return 'Not a valid ParaVision version'
156
+ return f"Message {self.message}"
157
+ return "Not a valid ParaVision version"
170
158
 
171
159
 
172
160
  class FilterEvalFalse(Exception):
@@ -178,9 +166,8 @@ class FilterEvalFalse(Exception):
178
166
 
179
167
  def __str__(self):
180
168
  if self.message:
181
- return '{}'.format(self.message)
182
- else:
183
- return 'FilterEvalFalse'
169
+ return f"{self.message}"
170
+ return "FilterEvalFalse"
184
171
 
185
172
 
186
173
  class NotADatasetDir(Exception):
@@ -192,9 +179,9 @@ class NotADatasetDir(Exception):
192
179
 
193
180
  def __str__(self):
194
181
  if self.message:
195
- return '{}'.format(self.message)
196
- else:
197
- return 'NotADatasetDir {}'.format(self.message)
182
+ return f"{self.message}"
183
+ return f"NotADatasetDir {self.message}"
184
+
198
185
 
199
186
  class ScanNotFound(Exception):
200
187
  def __init__(self, *args):
@@ -205,9 +192,8 @@ class ScanNotFound(Exception):
205
192
 
206
193
  def __str__(self):
207
194
  if self.message:
208
- return '{}'.format(self.message)
209
- else:
210
- return 'Scan: {} not found'.format(self.message)
195
+ return f"{self.message}"
196
+ return f"Scan: {self.message} not found"
211
197
 
212
198
 
213
199
  class RecoNotFound(Exception):
@@ -219,9 +205,8 @@ class RecoNotFound(Exception):
219
205
 
220
206
  def __str__(self):
221
207
  if self.message:
222
- return '{}'.format(self.message)
223
- else:
224
- return 'Reco: {} not found'.format(self.message)
208
+ return f"{self.message}"
209
+ return f"Reco: {self.message} not found"
225
210
 
226
211
 
227
212
  class ParametersNotLoaded(Exception):
@@ -233,9 +218,8 @@ class ParametersNotLoaded(Exception):
233
218
 
234
219
  def __str__(self):
235
220
  if self.message:
236
- return '{}'.format(self.message)
237
- else:
238
- return 'ParametersNotLoaded'
221
+ return f"{self.message}"
222
+ return "ParametersNotLoaded"
239
223
 
240
224
 
241
225
  class SchemeNotLoaded(Exception):
@@ -247,9 +231,8 @@ class SchemeNotLoaded(Exception):
247
231
 
248
232
  def __str__(self):
249
233
  if self.message:
250
- return '{}'.format(self.message)
251
- else:
252
- return 'SchemeNotLoaded'
234
+ return f"{self.message}"
235
+ return "SchemeNotLoaded"
253
236
 
254
237
 
255
238
  class DataNotLoaded(Exception):
@@ -261,9 +244,8 @@ class DataNotLoaded(Exception):
261
244
 
262
245
  def __str__(self):
263
246
  if self.message:
264
- return '{}'.format(self.message)
265
- else:
266
- return 'DataNotLoaded'
247
+ return f"{self.message}"
248
+ return "DataNotLoaded"
267
249
 
268
250
 
269
251
  class TrajNotLoaded(Exception):
@@ -275,9 +257,8 @@ class TrajNotLoaded(Exception):
275
257
 
276
258
  def __str__(self):
277
259
  if self.message:
278
- return '{}'.format(self.message)
279
- else:
280
- return 'TrajNotLoaded'
260
+ return f"{self.message}"
261
+ return "TrajNotLoaded"
281
262
 
282
263
 
283
264
  class NotStudyFolder(Exception):
@@ -289,9 +270,8 @@ class NotStudyFolder(Exception):
289
270
 
290
271
  def __str__(self):
291
272
  if self.message:
292
- return '{}'.format(self.message)
293
- else:
294
- return 'Not a Bruker study folder.'
273
+ return f"{self.message}"
274
+ return "Not a Bruker study folder."
295
275
 
296
276
 
297
277
  class NotExperimentFolder(Exception):
@@ -303,9 +283,8 @@ class NotExperimentFolder(Exception):
303
283
 
304
284
  def __str__(self):
305
285
  if self.message:
306
- return '{}'.format(self.message)
307
- else:
308
- return 'Not a Bruker experiment folder.'
286
+ return f"{self.message}"
287
+ return "Not a Bruker experiment folder."
309
288
 
310
289
 
311
290
  class NotProcessingFolder(Exception):
@@ -317,9 +296,8 @@ class NotProcessingFolder(Exception):
317
296
 
318
297
  def __str__(self):
319
298
  if self.message:
320
- return '{}'.format(self.message)
321
- else:
322
- return 'Not a Bruker processing folder.'
299
+ return f"{self.message}"
300
+ return "Not a Bruker processing folder."
323
301
 
324
302
 
325
303
  class PropertyConditionNotMet(Exception):
@@ -331,9 +309,8 @@ class PropertyConditionNotMet(Exception):
331
309
 
332
310
  def __str__(self):
333
311
  if self.message:
334
- return '{}'.format(self.message)
335
- else:
336
- return 'Not a Bruker processing folder.'
312
+ return f"{self.message}"
313
+ return "Not a Bruker processing folder."
337
314
 
338
315
 
339
316
  class FidSchemaUndefined(Exception):
@@ -344,13 +321,13 @@ class FidSchemaUndefined(Exception):
344
321
  self.message = None
345
322
 
346
323
  def __str__(self):
347
- common = 'Schema was not identified for this dataset. This issue might occur in case of a pulse sequence. ' \
348
- 'Please, contact authors to include the new sequence into the API configuration.'
324
+ common = (
325
+ "Schema was not identified for this dataset. This issue might occur in case of a pulse sequence. "
326
+ "Please, contact authors to include the new sequence into the API configuration."
327
+ )
349
328
  if self.message:
350
- return common + '\n The name of ' \
351
- 'pulse sequence used to measure this dataset is {}'.format(self.message)
352
- else:
353
- return common
329
+ return common + f"\n The name of pulse sequence used to measure this dataset is {self.message}"
330
+ return common
354
331
 
355
332
 
356
333
  class MissingProperty(Exception):
@@ -362,9 +339,5 @@ class MissingProperty(Exception):
362
339
 
363
340
  def __str__(self):
364
341
  if self.message:
365
- return "Dataset is missing the {} property. We can offer some help, please contact us via " \
366
- "https://github.com/isi-nmr/brukerapi-python".format(self.message)
367
- else:
368
- return "Dataset is missing one of the required properties. We can offer some help, please contact us via " \
369
- "https://github.com/isi-nmr/brukerapi-python"
370
-
342
+ return f"Dataset is missing the {self.message} property. We can offer some help, please contact us via https://github.com/isi-nmr/brukerapi-python"
343
+ return "Dataset is missing one of the required properties. We can offer some help, please contact us via https://github.com/isi-nmr/brukerapi-python"