annotate cravat_convert/base_converter.py @ 26:9d8c12fa6888 draft default tip

Uploaded
author in_silico
date Wed, 18 Jul 2018 10:33:16 -0400
parents 442aaa50e7b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
1 class BaseConverter(object):
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
2 def __init__(self):
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
3 self.format_name = None
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
4 def check_format(self,*args,**kwargs):
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
5 err_msg = 'Converter for %s format has no method check_format' %\
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
6 self.format_name
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
7 raise NotImplementedError(err_msg)
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
8 def setup(self,*args,**kwargs):
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
9 err_msg = 'Converter for %s format has no method setup' %\
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
10 self.format_name
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
11 raise NotImplementedError(err_msg)
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
12 def convert_line(self,*args,**kwargs):
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
13 err_msg = 'Converter for %s format has no method convert_line' %\
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
14 self.format_name
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
15 raise NotImplementedError(err_msg)
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
16
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
17
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
18 class BadFormatError(Exception):
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
19 def __init__(self, message, errors=None):
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
20 super(BadFormatError, self).__init__(message)
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
21 # Support for custom error codes, if added later
442aaa50e7b3 Uploaded
in_silico
parents:
diff changeset
22 self.errors = errors