Package bmrblib :: Package experimental_details :: Module method
[hide private]
[frames] | no frames]

Source Code for Module bmrblib.experimental_details.method

  1  ############################################################################# 
  2  #                                                                           # 
  3  # The BMRB library.                                                         # 
  4  #                                                                           # 
  5  # Copyright (C) 2009-2010 Edward d'Auvergne                                 # 
  6  #                                                                           # 
  7  # This program is free software: you can redistribute it and/or modify      # 
  8  # it under the terms of the GNU General Public License as published by      # 
  9  # the Free Software Foundation, either version 3 of the License, or         # 
 10  # (at your option) any later version.                                       # 
 11  #                                                                           # 
 12  # This program is distributed in the hope that it will be useful,           # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of            # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             # 
 15  # GNU General Public License for more details.                              # 
 16  #                                                                           # 
 17  # You should have received a copy of the GNU General Public License         # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.     # 
 19  #                                                                           # 
 20  ############################################################################# 
 21   
 22  # Module docstring. 
 23  """The method saveframe category. 
 24   
 25  For example, see http://www.bmrb.wisc.edu/dictionary/3.1html_frame/frame_SaveFramePage.html#method 
 26  """ 
 27   
 28  # relax module imports. 
 29  from bmrblib.base_classes import BaseSaveframe, TagCategory, TagCategoryFree 
 30   
 31   
32 -class MethodSaveframe(BaseSaveframe):
33 """The method saveframe class.""" 34 35 # Class variables. 36 sf_label = 'method' 37
38 - def add_tag_categories(self):
39 """Create the tag categories.""" 40 41 # The tag category objects. 42 self.tag_categories.append(Method(self)) 43 self.tag_categories.append(MethodCitation(self)) 44 self.tag_categories.append(MethodFile(self)) 45 self.tag_categories.append(MethodParam(self))
46 47 48
49 -class Method(TagCategoryFree):
50 """Base class for the Method tag category.""" 51
52 - def __init__(self, sf):
53 """Setup the Method tag category. 54 55 @param sf: The saveframe object. 56 @type sf: saveframe instance 57 """ 58 59 # Initialise the baseclass. 60 super(Method, self).__init__(sf) 61 62 # Add the tag info. 63 self.add(key='MethodID', tag_name='ID', var_name='count_str') 64 self.add(key='Details', tag_name='Details', var_name='details')
65 66 67
68 -class MethodCitation(TagCategory):
69 """Base class for the MethodCitation tag category.""" 70
71 - def __init__(self, sf):
72 """Setup the MethodCitation tag category. 73 74 @param sf: The saveframe object. 75 @type sf: saveframe instance 76 """ 77 78 # Initialise the baseclass. 79 super(MethodCitation, self).__init__(sf) 80 81 # Add the tag info. 82 self.add(key='CitationID', tag_name='Citation_ID', var_name='cite_ids') 83 self.add(key='MethodID', tag_name='Method_ID', var_name='count_str')
84 85
86 - def is_empty(self):
87 """Check if the citation tag category is empty. 88 89 @return: The state of emptiness. 90 @rtype: bool 91 """ 92 93 # No citation IDs. 94 if not hasattr(self.sf, 'cite_ids') or not len(self.sf.cite_ids): 95 return True 96 97 # Not empty. 98 return False
99 100
101 -class MethodFile(TagCategory):
102 """Base class for the MethodFile tag category.""" 103
104 - def __init__(self, sf):
105 """Setup the MethodFile tag category. 106 107 @param sf: The saveframe object. 108 @type sf: saveframe instance 109 """ 110 111 # Initialise the baseclass. 112 super(MethodFile, self).__init__(sf) 113 114 # Add the tag info. 115 self.add(key='Name', tag_name='Name', var_name='file_name', missing=False) 116 self.add(key='TextFormat', tag_name='Text_format', var_name='text_format') 117 self.add(key='Text', tag_name='Text', var_name='file_text', missing=False) 118 self.add(key='MethodID', tag_name='Method_ID', var_name='count_str')
119 120 121
122 -class MethodParam(TagCategory):
123 """Base class for the MethodParam tag category.""" 124
125 - def __init__(self, sf):
126 """Setup the MethodParam tag category. 127 128 @param sf: The saveframe object. 129 @type sf: saveframe instance 130 """ 131 132 # Initialise the baseclass. 133 super(MethodParam, self).__init__(sf) 134 135 # Add the tag info. 136 self.add(key='FileName', tag_name='File_name', var_name='param_file_name') 137 self.add(key='TextFormat', tag_name='Text_format', var_name='text_format') 138 self.add(key='Text', tag_name='Text', var_name='param_file_text') 139 self.add(key='MethodID', tag_name='Method_ID', var_name='count_str')
140