Read perseus network collection folder format
    
    >>> network_table, networks = read_networks(folder)
    
    :param folder: Path to network collection
    :returns: Network table and dictionary with 'name', 'edge_table', and 'node_table' keys.
963837
def read_networks(folder):
    
    network_table = read_perseus(path.join(folder, "networks.txt"))
    networks = {}
    for name, guid in network_table[['Name', 'GUID']].values:
        networks[guid] = {
                'name': name,
                'guid': guid,
                'node_table': read_perseus(path.join(folder, "{}_nodes.txt".format(guid))),
                'edge_table': read_perseus(path.join(folder, "{}_edges.txt".format(guid)))
                }
    return network_table, networks
37094
def folders(self):
        ''''''
        if self._folders is None :
            self.__init()
        if self._folders is not None and isinstance(self._folders, list):
            if len(self._folders) == 0:
                self._loadFolders()
        return self._folders
1054444
def _parse_networks(service_list: dict) -> list:
        
        # Initialising empty list
        networks = []

        for n_values in service_list['networks'].values():
            for n_key, n_value in n_values.items():
                if 'name' in n_key:
                    networks.append(n_value)
        return networks
581367
def data_nodes(self):
        

        return {k: v for k, v in self.nodes.items() if v['type'] == 'data'}
658241
def folder2ver(folder):
    """"""
    ver = folder.split('EnergyPlus')[-1]
    ver = ver[1:]
    splitapp = ver.split('-')
    ver = '.'.join(splitapp)
    return ver
1358345
def list_networks(self, retrieve_all=True, **_params):
        """"""
        # Pass filters in "params" argument to do_request
        return self.list('networks', self.networks_path, retrieve_all,
                         **_params)
250212
def _parse_networks(networks):
    '''
    
    '''
    networks = salt.utils.args.split_input(networks or [])
    if not networks:
        networks = {}
    else:
        # We don't want to recurse the repack, as the values of the kwargs
        # being passed when connecting to the network will not be dictlists.
        networks = salt.utils.data.repack_dictlist(networks)
        if not networks:
            raise CommandExecutionError(
                'Invalid network configuration (see documentation)'
            )
        for net_name, net_conf in six.iteritems(networks):
            if net_conf is None:
                networks[net_name] = {}
            else:
                networks[net_name] = salt.utils.data.repack_dictlist(net_conf)
                if not networks[net_name]:
                    raise CommandExecutionError(
                        'Invalid configuration for network \'{0}\' '
                        '(see documentation)'.format(net_name)
                    )
                for key in ('links', 'aliases'):
                    try:
                        networks[net_name][key] = salt.utils.args.split_input(
                            networks[net_name][key]
                        )
                    except KeyError:
                        continue

        # Iterate over the networks again now, looking for
        # incorrectly-formatted arguments
        errors = []
        for net_name, net_conf in six.iteritems(networks):
            if net_conf is not None:
                for key, val in six.iteritems(net_conf):
                    if val is None:
                        errors.append(
                            'Config option \'{0}\' for network \'{1}\' is '
                            'missing a value'.format(key, net_name)
                        )
        if errors:
            raise CommandExecutionError(
                'Invalid network configuration', info=errors)

    if networks:
        try:
            all_networks = [
                x['Name'] for x in __salt__['docker.networks']()
                if 'Name' in x
            ]
        except CommandExecutionError as exc:
            raise CommandExecutionError(
                'Failed to get list of existing networks: {0}.'.format(exc)
            )
        else:
            missing_networks = [
                x for x in sorted(networks) if x not in all_networks]
            if missing_networks:
                raise CommandExecutionError(
                    'The following networks are not present: {0}'.format(
                        ', '.join(missing_networks)
                    )
                )

    return networks
710522
def profile_network(filename):
    
    log = logging.getLogger(filename)
    logfile = os.path.join(LOGS, filename + '.log')
    os.makedirs(os.path.dirname(logfile), exist_ok=True)
    handler = logging.FileHandler(logfile)
    handler.setFormatter(formatter)
    log.addHandler(handler)
    log.setLevel(logging.INFO)

    try:
        with open(os.path.join(NETWORKS, filename + '.json')) as f:

            network, state = load_json_network(json.load(f))

            log.info('Profiling %s...', filename)
            log.info('PyPhi configuration:\n%s',
                     pyphi.config.get_config_string())

            start = time()
            pr = cProfile.Profile()
            pr.enable()

            results = tuple(pyphi.compute.complexes(network, state))

            pr.disable()
            end = time()

            pstatsfile = os.path.join(PSTATS, filename + '.pstats')
            os.makedirs(os.path.dirname(pstatsfile), exist_ok=True)
            pr.dump_stats(pstatsfile)

            log.info('Finished in %i seconds.', end - start)

            resultfile = os.path.join(RESULTS, filename + '-results.pkl')
            os.makedirs(os.path.dirname(resultfile), exist_ok=True)
            with open(resultfile, 'wb') as f:
                pickle.dump(results, f)
    except Exception as e:
        log.error(e)
        raise e
123968
def all_network_files():
    """"""
    # TODO: list explicitly since some are missing?
    network_types = [
        'AND-circle',
        'MAJ-specialized',
        'MAJ-complete',
        'iit-3.0-modular'
    ]
    network_sizes = range(5, 8)
    network_files = []
    for n in network_sizes:
        for t in network_types:
            network_files.append('{}-{}'.format(n, t))
    return network_files
441065
def read_dir(path, folder):
    
    full_path = os.path.join(path, folder)
    fnames = glob(f"{full_path}/*.*")
    directories = glob(f"{full_path}/*/")
    if any(fnames):
        return [os.path.relpath(f,path) for f in fnames]
    elif any(directories):
        raise FileNotFoundError("{} has subdirectories but contains no files. Is your directory structure is correct?".format(full_path))
    else:
        raise FileNotFoundError("{} folder doesn't exist or is empty".format(full_path))
734189
def parse(self, data):
        
        # initialize graph and list of aggregated nodes
        graph = self._init_graph()
        if len(data) != 0:
            if "links" not in data[0]:
                raise ParserError('Parse error, "links" key not found')
        # loop over topology section and create networkx graph
        # this data structure does not contain cost information, so we set it as 1
        for node in data:
            for link in node['links']:
                cost = (link['txRate'] + link['rxRate']) / 2.0
                graph.add_edge(node['name'],
                               link['name'],
                               weight=cost,
                               tx_rate=link['txRate'],
                               rx_rate=link['rxRate'])
        return graph
792239
def collect_results(working_folder):
    
    results = {} 
    working_folder = Path(working_folder)
    output_folders = working_folder/'output_folders'

    for rec_name in os.listdir(output_folders):
        if not os.path.isdir(output_folders / rec_name):
            continue
        # print(rec_name)
        results[rec_name] = {}
        for sorter_name in os.listdir(output_folders / rec_name):
            # print('  ', sorter_name)
            output_folder = output_folders / rec_name / sorter_name
            #~ print(output_folder)
            if not os.path.isdir(output_folder):
                continue
            SorterClass = sorter_dict[sorter_name]
            results[rec_name][sorter_name] = SorterClass.get_result_from_folder(output_folder)

    return results
331993
def read(self) -> None:
        
        for folder in self.folders.values():
            for file_ in folder.values():
                file_.read()
1078521
def list_networks(full_ids=False):
    
    networks = docker_fabric().networks()
    _format_output_table(networks, NETWORK_COLUMNS, full_ids)
805677
def get_routes(iface):
    '''
    
    '''

    filename = os.path.join(_DEB_NETWORK_UP_DIR, 'route-{0}'.format(iface))
    results = _read_file(filename)

    filename = os.path.join(_DEB_NETWORK_DOWN_DIR, 'route-{0}'.format(iface))
    results += _read_file(filename)

    return results
899166
def _get_subnet_explicit_route_table(subnet_id, vpc_id, conn=None, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    if not conn:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if conn:
        vpc_route_tables = conn.get_all_route_tables(filters={'vpc_id': vpc_id})
        for vpc_route_table in vpc_route_tables:
            for rt_association in vpc_route_table.associations:
                if rt_association.subnet_id == subnet_id and not rt_association.main:
                    return rt_association.id
    return None
1089200
public static String[] scanFolderAsArray(String folder) {
        List<String> list = scanFolder(folder);
        String[] arrays = new String[list.size()];
        int i = 0;
        for (String item : list) {
            arrays[i++] = item;
        }
        return arrays;
    }