py4cytoscape.styles.export_visual_styles
-
export_visual_styles
(filename=None, type='XML', styles=None, base_url='http://127.0.0.1:1234/v1', *, overwrite_file=False)[source] Save one or more visual styles to file.
- Parameters
filename (str) – Full path or path relative to current working directory, in addition to the name of the file. Extension is automatically added based on the
type
argument. Default is “styles.xml”type (str) – Type of data file to export, e.g., XML, JSON (case sensitive). Default is XML. Note: Only XML can be read by
import_visual_styles()
.styles (str) – specified, only the current one is exported.
base_url (str) – Ignore unless you need to specify a custom domain, port or version to connect to the CyREST API. Default is http://127.0.0.1:1234 and the latest version of the CyREST API supported by this version of py4cytoscape.
overwrite_file (bool) – False allows Cytoscape show a message box before overwriting the file if the file already exists; True allows Cytoscape to overwrite it without asking
- Returns
{‘file’: name of file written}
- Return type
dict
- Raises
CyError – if the output file can’t be created, or if file exists and user opts to not overwrite it
requests.exceptions.RequestException – if can’t connect to Cytoscape or Cytoscape returns an error
Examples
>>> export_visual_styles() # export the current style to styles.xml in the current directory {'file': 'C:\Users\CyDeveloper\styles.xml'} >>> export_visual_styles('curstyle') # export the current style to curstyle.xml in the current directory {'file': 'C:\Users\CyDeveloper\curstyle.xml'} >>> export_visual_styles('curstyle', overwrite_file=True) # overwrite any existing curstyle.xml file {'file': 'C:\Users\CyDeveloper\curstyle.xml'} >>> export_visual_styles('curstyle', type='json') # export the current style in cytoscape.js format {'file': 'C:\Users\CyDeveloper\curstyle.json'}
See also