text: # #!/home/exec/anaconda3/bin/python
  # -*- coding: utf-8 -*-
  ​
  # curl --silent ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/3sn6.xml.gz | gunzip | python2 parse_sifts.py 1> 3sn6.tsv 2> /dev/null
  # Generated Thu Nov 20 17:12:58 2014 by generateDS.py version 2.13a.
  #
  # Command line options:
  #   ('-f', '')
  #   ('-o', 'sifts.py')
  #
  # Command line arguments:
  #   eFamily.xsd
  #
  # Command line:
  #   /usr/local/bin/generateDS.py -f -o "sifts.py" eFamily.xsd
  #
  # Current working directory (os.getcwd()):
  #   src
  #
  ​
  import sys
  import getopt
  import re as re_
  import base64
  import datetime as datetime_
  ​
  etree_ = None
  Verbose_import_ = False
  (
      XMLParser_import_none, XMLParser_import_lxml,
      XMLParser_import_elementtree
  ) = range(3)
  XMLParser_import_library = None
  try:
      # lxml
      from lxml import etree as etree_
      XMLParser_import_library = XMLParser_import_lxml
      if Verbose_import_:
          print("running with lxml.etree")
  except ImportError:
      try:
          # cElementTree from Python 2.5+
          import xml.etree.cElementTree as etree_
          XMLParser_import_library = XMLParser_import_elementtree
          if Verbose_import_:
              print("running with cElementTree on Python 2.5+")
      except ImportError:
          try:
              # ElementTree from Python 2.5+
              import xml.etree.ElementTree as etree_
              XMLParser_import_library = XMLParser_import_elementtree
              if Verbose_import_:
                  print("running with ElementTree on Python 2.5+")
          except ImportError:
              try:
                  # normal cElementTree install
                  import cElementTree as etree_
                  XMLParser_import_library = XMLParser_import_elementtree
                  if Verbose_import_:
                      print("running with cElementTree")
              except ImportError:
                  try:
                      # normal ElementTree install
                      import elementtree.ElementTree as etree_
                      XMLParser_import_library = XMLParser_import_elementtree
                      if Verbose_import_:
                          print("running with ElementTree")
                  except ImportError:
                      raise ImportError(
                          "Failed to import ElementTree from any known place")
  ​
  ​
  def parsexml_(*args, **kwargs):
      if (XMLParser_import_library == XMLParser_import_lxml and
              'parser' not in kwargs):
          # Use the lxml ElementTree compatible parser so that, e.g.,
          #   we ignore comments.
          kwargs['parser'] = etree_.ETCompatXMLParser()
      doc = etree_.parse(*args, **kwargs)
      return doc
  ​
  #
  # User methods
  #
  # Calls to the methods in these classes are generated by generateDS.py.
  # You can replace these methods by re-implementing the following class
  #   in a module named generatedssuper.py.
  ​
  try:
      from generatedssuper import GeneratedsSuper
  except ImportError as exp:
  ​
      class GeneratedsSuper(object):
          tzoff_pattern = re_.compile(r'(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$')
          class _FixedOffsetTZ(datetime_.tzinfo):
              def __init__(self, offset, name):
                  self.__offset = datetime_.timedelta(minutes=offset)
                  self.__name = name
              def utcoffset(self, dt):
                  return self.__offset
              def tzname(self, dt):
                  return self.__name
              def dst(self, dt):
                  return None
          def gds_format_string(self, input_data, input_name=''):
              return input_data
          def gds_validate_string(self, input_data, node, input_name=''):
              if not input_data:
                  return ''
              else:
                  return input_data
          def gds_format_base64(self, input_data, input_name=''):
              return base64.b64encode(input_data)
          def gds_validate_base64(self, input_data, node, input_name=''):
              return input_data
          def gds_format_integer(self, input_data, input_name=''):
              return '%d' % input_data
          def gds_validate_integer(self, input_data, node, input_name=''):
              return input_data
          def gds_format_integer_list(self, input_data, input_name=''):
              return '%s' % input_data
          def gds_validate_integer_list(self, input_data, node, input_name=''):
              values = input_data.split()
              for value in values:
                  try:
                      float(value)
                  except (TypeError, ValueError):
                      raise_parse_error(node, 'Requires sequence of integers')
              return input_data
          def gds_format_float(self, input_data, input_name=''):
              return ('%.15f' % input_data).rstrip('0')
          def gds_validate_float(self, input_data, node, input_name=''):
              return input_data
          def gds_format_float_list(self, input_data, input_name=''):
              return '%s' % input_data
          def gds_validate_float_list(self, input_data, node, input_name=''):
              values = input_data.split()
              for value in values:
                  try:
                      float(value)
                  except (TypeError, ValueError):
                      raise_parse_error(node, 'Requires sequence of floats')
              return input_data
          def gds_format_double(self, input_data, input_name=''):
              return '%e' % input_data
          def gds_validate_double(self, input_data, node, input_name=''):
              return input_data
          def gds_format_double_list(self, input_data, input_name=''):
              return '%s' % input_data
          def gds_validate_double_list(self, input_data, node, input_name=''):
              values = input_data.split()
              for value in values:
                  try:
                      float(value)
                  except (TypeError, ValueError):
                      raise_parse_error(node, 'Requires sequence of doubles')
              return input_data
          def gds_format_boolean(self, input_data, input_name=''):
              return ('%s' % input_data).lower()
          def gds_validate_boolean(self, input_data, node, input_name=''):
              return input_data
          def gds_format_boolean_list(self, input_data, input_name=''):
              return '%s' % input_data
          def gds_validate_boolean_list(self, input_data, node, input_name=''):
              values = input_data.split()
              for value in values:
                  if value not in ('true', '1', 'false', '0', ):
                      raise_parse_error(
                          node,
                          'Requires sequence of booleans '
                          '("true", "1", "false", "0")')
              return input_data
          def gds_validate_datetime(self, input_data, node, input_name=''):
              return input_data
          def gds_format_datetime(self, input_data, input_name=''):
              if input_data.microsecond == 0:
                  _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (
                      input_data.year,
                      input_data.month,
                      input_data.day,
                      input_data.hour,
                      input_data.minute,
                      input_data.second,
                  )
              else:
                  _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (
                      input_data.year,
                      input_data.month,
                      input_data.day,
                      input_data.hour,
                      input_data.minute,
                      input_data.second,
                      ('%f' % (float(input_data.microsecond) / 1000000))[2:],
                  )
              if input_data.tzinfo is not None:
                  tzoff = input_data.tzinfo.utcoffset(input_data)
                  if tzoff is not None:
                      total_seconds = tzoff.seconds + (86400 * tzoff.days)
                      if total_seconds == 0:
                          _svalue += 'Z'
                      else:
                          if total_seconds < 0:
                              _svalue += '-'
                              total_seconds *= -1
                          else:
                              _svalue += '+'
                          hours = total_seconds // 3600
                          minutes = (total_seconds - (hours * 3600)) // 60
                          _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
              return _svalue
          @classmethod
          def gds_parse_datetime(cls, input_data):
              tz = None
              if input_data[-1] == 'Z':
                  tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                  input_data = input_data[:-1]
              else:
                  results = GeneratedsSuper.tzoff_pattern.search(input_data)
                  if results is not None:
                      tzoff_parts = results.group(2).split(':')
                      tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
                      if results.group(1) == '-':
                          tzoff *= -1
                      tz = GeneratedsSuper._FixedOffsetTZ(
                          tzoff, results.group(0))
                      input_data = input_data[:-6]
              time_parts = input_data.split('.')
              if len(time_parts) > 1:
                  micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
                  input_data = '%s.%s' % (time_parts[0], micro_seconds, )
                  dt = datetime_.datetime.strptime(
                      input_data, '%Y-%m-%dT%H:%M:%S.%f')
              else:
                  dt = datetime_.datetime.strptime(
                      input_data, '%Y-%m-%dT%H:%M:%S')
              dt = dt.replace(tzinfo=tz)
              return dt
          def gds_validate_date(self, input_data, node, input_name=''):
              return input_data
          def gds_format_date(self, input_data, input_name=''):
              _svalue = '%04d-%02d-%02d' % (
                  input_data.year,
                  input_data.month,
                  input_data.day,
              )
              try:
                  if input_data.tzinfo is not None:
                      tzoff = input_data.tzinfo.utcoffset(input_data)
                      if tzoff is not None:
                          total_seconds = tzoff.seconds + (86400 * tzoff.days)
                          if total_seconds == 0:
                              _svalue += 'Z'
                          else:
                              if total_seconds < 0:
                                  _svalue += '-'
                                  total_seconds *= -1
                              else:
                                  _svalue += '+'
                              hours = total_seconds // 3600
                              minutes = (total_seconds - (hours * 3600)) // 60
                              _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
              except AttributeError:
                  pass
              return _svalue
          @classmethod
          def gds_parse_date(cls, input_data):
              tz = None
              if input_data[-1] == 'Z':
                  tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                  input_data = input_data[:-1]
              else:
                  results = GeneratedsSuper.tzoff_pattern.search(input_data)
                  if results is not None:
                      tzoff_parts = results.group(2).split(':')
                      tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
                      if results.group(1) == '-':
                          tzoff *= -1
                      tz = GeneratedsSuper._FixedOffsetTZ(
                          tzoff, results.group(0))
                      input_data = input_data[:-6]
              dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')
              dt = dt.replace(tzinfo=tz)
              return dt.date()
          def gds_validate_time(self, input_data, node, input_name=''):
              return input_data
          def gds_format_time(self, input_data, input_name=''):
              if input_data.microsecond == 0:
                  _svalue = '%02d:%02d:%02d' % (
                      input_data.hour,
                      input_data.minute,
                      input_data.second,
                  )
              else:
                  _svalue = '%02d:%02d:%02d.%s' % (
                      input_data.hour,
                      input_data.minute,
                      input_data.second,
                      ('%f' % (float(input_data.microsecond) / 1000000))[2:],
                  )
              if input_data.tzinfo is not None:
                  tzoff = input_data.tzinfo.utcoffset(input_data)
                  if tzoff is not None:
                      total_seconds = tzoff.seconds + (86400 * tzoff.days)
                      if total_seconds == 0:
                          _svalue += 'Z'
                      else:
                    ...
  