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-2013 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  This file is part of the U{BMRB library<https://gna.org/projects/bmrblib>}. 
 26   
 27  For example, see http://www.bmrb.wisc.edu/dictionary/3.1html_frame/frame_SaveFramePage.html#method 
 28  """ 
 29   
 30  # relax module imports. 
 31  from bmrblib.base_classes import BaseSaveframe, TagCategory, TagCategoryFree 
 32   
 33   
34 -class MethodSaveframe(BaseSaveframe):
35 """The method saveframe class.""" 36 37 # Class variables. 38 sf_label = 'method' 39
40 - def add_tag_categories(self):
41 """Create the tag categories.""" 42 43 # The tag category objects. 44 self.tag_categories.append(Method(self)) 45 self.tag_categories.append(MethodCitation(self)) 46 self.tag_categories.append(MethodFile(self)) 47 self.tag_categories.append(MethodParam(self))
48 49 50
51 -class Method(TagCategoryFree):
52 """Base class for the Method tag category.""" 53
54 - def __init__(self, sf):
55 """Setup the Method tag category. 56 57 @param sf: The saveframe object. 58 @type sf: saveframe instance 59 """ 60 61 # Initialise the baseclass. 62 super(Method, self).__init__(sf) 63 64 # Add the tag info. 65 self.add(key='MethodID', tag_name='ID', var_name='count_str') 66 self.add(key='Details', tag_name='Details', var_name='details')
67 68 69
70 -class MethodCitation(TagCategory):
71 """Base class for the MethodCitation tag category.""" 72
73 - def __init__(self, sf):
74 """Setup the MethodCitation tag category. 75 76 @param sf: The saveframe object. 77 @type sf: saveframe instance 78 """ 79 80 # Initialise the baseclass. 81 super(MethodCitation, self).__init__(sf) 82 83 # Add the tag info. 84 self.add(key='CitationID', tag_name='Citation_ID', var_name='cite_ids') 85 self.add(key='MethodID', tag_name='Method_ID', var_name='count_str')
86 87
88 - def is_empty(self):
89 """Check if the citation tag category is empty. 90 91 @return: The state of emptiness. 92 @rtype: bool 93 """ 94 95 # No citation IDs. 96 if not hasattr(self.sf, 'cite_ids') or not len(self.sf.cite_ids): 97 return True 98 99 # Not empty. 100 return False
101 102
103 -class MethodFile(TagCategory):
104 """Base class for the MethodFile tag category.""" 105
106 - def __init__(self, sf):
107 """Setup the MethodFile tag category. 108 109 @param sf: The saveframe object. 110 @type sf: saveframe instance 111 """ 112 113 # Initialise the baseclass. 114 super(MethodFile, self).__init__(sf) 115 116 # Add the tag info. 117 self.add(key='Name', tag_name='Name', var_name='file_name', missing=False) 118 self.add(key='TextFormat', tag_name='Text_format', var_name='text_format') 119 self.add(key='Text', tag_name='Text', var_name='file_text', missing=False) 120 self.add(key='MethodID', tag_name='Method_ID', var_name='count_str')
121 122 123
124 -class MethodParam(TagCategory):
125 """Base class for the MethodParam tag category.""" 126
127 - def __init__(self, sf):
128 """Setup the MethodParam tag category. 129 130 @param sf: The saveframe object. 131 @type sf: saveframe instance 132 """ 133 134 # Initialise the baseclass. 135 super(MethodParam, self).__init__(sf) 136 137 # Add the tag info. 138 self.add(key='FileName', tag_name='File_name', var_name='param_file_name') 139 self.add(key='TextFormat', tag_name='Text_format', var_name='text_format') 140 self.add(key='Text', tag_name='Text', var_name='param_file_text') 141 self.add(key='MethodID', tag_name='Method_ID', var_name='count_str')
142