コード例 #1
0
  def get_row_validators(self, row):
    """Parses the row validators from the XSD.

    XSD is either user-specified or inferred from the HEAD row.

    Args:
      row: The parsed row from the TSV file.

    Returns:
      row_validators_list:
         A list of subclass of cell_validators.BaseCellValidator.
        (eg. [[string_validator, decimal_validator],[string_validator]]).
    """
    dsrf_xsd_file = self.dsrf_xsd_file
    if not dsrf_xsd_file:
      # User did not specify one, read from the library.
      profile_name, profile_version = row[2:4]
      self.logger.info(
          'Detected profile and version from HEAD: %s (%s)' %
          (profile_name, profile_version))
      try:
        dsrf_xsd_file = constants.get_xsd_file(profile_name, profile_version)
      except ValueError as e:
        self.logger.error(str(e))
        sys.stderr.write(str(e))
        sys.exit(-1)

    self.logger.info('XSD file location: %s' % dsrf_xsd_file)

    schema_parser = dsrf_schema_parser.DsrfSchemaParser(
        self.avs_xsd_file, dsrf_xsd_file)
    return schema_parser.parse_xsd_file(self.logger)
コード例 #2
0
  def parse_xsd(self, block):
    self.parse_profile_info_from_head(block)
    if not self.dsrf_xsd_file_name:
      # User did not provided an XSD to validate with.
      self.dsrf_xsd_file_name = constants.get_xsd_file(
          self.profile_name, self.profile_version)

    xsd_parser = xsd_profile_parser.XSDProfileParser(self.dsrf_xsd_file_name)
    self.block_processor.node = xsd_parser.parse_profile_from_xsd(
        self.profile_name)
コード例 #3
0
 def get_avs_location_from_root(self, root):
   """Inspects the root tag of the profile XSD to find the AVS xsd version."""
   for child in root:
     if child.tag == constants.XSD_TAG_PREFIX + 'import':
       if child.attrib.get('namespace') == constants.AVS_XSD_NAMESPACE:
         schema_location = child.attrib['schemaLocation']
         unused_directory, avs_version = path.split(
             path.split(schema_location)[0])
         return constants.get_xsd_file('avs', avs_version)
   raise error.XsdParsingFailure(
       self.dsrf_xsd_file_name,
       'No AVS import found (namespace = %s).' % constants.AVS_XSD_NAMESPACE)
コード例 #4
0
ファイル: dsrf_schema_parser.py プロジェクト: ddexnet/dsrf
 def get_avs_location_from_root(self, root):
   """Inspects the root tag of the profile XSD to find the AVS xsd version."""
   for child in root:
     if child.tag == constants.XSD_TAG_PREFIX + 'import':
       if child.attrib.get('namespace') == constants.AVS_XSD_NAMESPACE:
         schema_location = child.attrib['schemaLocation']
         unused_directory, avs_version = path.split(
             path.split(schema_location)[0])
         return constants.get_xsd_file('avs', avs_version)
   raise error.XsdParsingFailure(
       self.dsrf_xsd_file_name,
       'No AVS import found (namespace = %s).' % constants.AVS_XSD_NAMESPACE)