def parse_GDS(filepath):
    """Parse GDS SOFT file.

    Args:
        filepath (:obj:`str`): Path to GDS SOFT file.

    Returns:
        :obj:`GEOparse.GDS`: A GDS object.

    """
    dataset_lines = []
    subsets = {}
    database = None
    dataset_name = None
    with utils.smart_open(filepath) as soft:
        groupper = groupby(soft, lambda x: x.startswith("^"))
        for is_new_entry, group in groupper:
            if is_new_entry:
                entry_type, entry_name = __parse_entry(next(group))
                logger.debug("%s: %s" % (entry_type.upper(), entry_name))
                if entry_type == "SUBSET":
                    is_data, data_group = next(groupper)
                    message = ("The key is not False, probably there is an "
                               "error in the SOFT file")
                    assert not is_data, message
                    subset_metadata = parse_metadata(data_group)
                    subsets[entry_name] = GDSSubset(name=entry_name,
                                                    metadata=subset_metadata)
                elif entry_type == "DATABASE":

                    is_data, data_group = next(groupper)
                    message = ("The key is not False, probably there is an "
                               "error in the SOFT file")
                    assert not is_data, message
                    database_metadata = parse_metadata(data_group)
                    database = GEODatabase(name=entry_name,
                                           metadata=database_metadata)
                elif entry_type == "DATASET":
                    is_data, data_group = next(groupper)
                    dataset_name = entry_name
                    for line in data_group:
                        dataset_lines.append(line.rstrip())
                else:
                    logger.error("Cannot recognize type %s" % entry_type)

    metadata = parse_metadata(dataset_lines)
    columns = parse_GDS_columns(dataset_lines, subsets)
    table = parse_table_data(dataset_lines)
    return GDS(name=dataset_name, metadata=metadata, columns=columns,
               table=table, subsets=subsets, database=database)
def parse_GDS ( filepath ) : dataset_lines = [ ] subsets = { } database = None dataset_name = None with utils . smart_open ( filepath ) as soft : groupper = groupby ( soft , lambda x : x . startswith ( "^" ) ) for is_new_entry , group in groupper : if is_new_entry : entry_type , entry_name = __parse_entry ( next ( group ) ) logger . debug ( "%s: %s" % ( entry_type . upper ( ) , entry_name ) ) if entry_type == "SUBSET" : is_data , data_group = next ( groupper ) message = ( "The key is not False, probably there is an " "error in the SOFT file" ) assert not is_data , message subset_metadata = parse_metadata ( data_group ) subsets [ entry_name ] = GDSSubset ( name = entry_name , metadata = subset_metadata ) elif entry_type == "DATABASE" : is_data , data_group = next ( groupper ) message = ( "The key is not False, probably there is an " "error in the SOFT file" ) assert not is_data , message database_metadata = parse_metadata ( data_group ) database = GEODatabase ( name = entry_name , metadata = database_metadata ) elif entry_type == "DATASET" : is_data , data_group = next ( groupper ) dataset_name = entry_name for line in data_group : dataset_lines . append ( line . rstrip ( ) ) else : logger . error ( "Cannot recognize type %s" % entry_type ) metadata = parse_metadata ( dataset_lines ) columns = parse_GDS_columns ( dataset_lines , subsets ) table = parse_table_data ( dataset_lines ) return GDS ( name = dataset_name , metadata = metadata , columns = columns , table = table , subsets = subsets , database = database )
Parse GDS SOFT file.

    Args:
        filepath (:obj:`str`): Path to GDS SOFT file.

    Returns:
        :obj:`GEOparse.GDS`: A GDS object.