#!/usr/bin/env python# -*- coding: utf-8 -*-## This file is part of the `pypath` python module## Copyright 2014-2023# EMBL, EMBL-EBI, Uniklinik RWTH Aachen, Heidelberg University## Authors: see the file `README.rst`# Contact: Dénes Türei (turei.denes@gmail.com)## Distributed under the GPLv3 License.# See accompanying file LICENSE.txt or copy at# https://www.gnu.org/licenses/gpl-3.0.html## Website: https://pypath.omnipathdb.org/#importbs4importpypath.resources.urlsasurlsimportpypath.share.curlascurl
[docs]defgraphviz_attrs():""" Downloads the list of graphviz attributes from graphviz.org. Returns 3 dicts of dicts: graph_attrs, vertex_attrs and edge_attrs. """url=urls.urls['graphviz']['url']c=curl.Curl(url)html=c.resultsoup=bs4.BeautifulSoup(html,'lxml')vertex_attrs={}edge_attrs={}graph_attrs={}fortblinsoup.find_all('table'):iftbl.find('tr').text.strip().startswith('Name'):forrintbl.find_all('tr'):r=r.find_all('td')ifr:usedby=r[1].textthis_attr={'type':r[2].text.strip(),'default':r[3].text.strip(),'min':r[4].text.strip(),'notes':r[5].text.strip()}attr_name=r[0].text.strip()if'N'inusedby:vertex_attrs[attr_name]=this_attrif'E'inusedby:edge_attrs[attr_name]=this_attrif'G'inusedby:graph_attrs[attr_name]=this_attrbreakreturngraph_attrs,vertex_attrs,edge_attrs