atomium.utilities

Contains various file handling helper functions.

atomium.utilities.fetch(code, *args, **kwargs)[source]

Fetches a file from a remote location via HTTP.

If a PDB code is given, the .cif form of that struture will be fetched from the RCSB servers. If that code is given an extension, that file format will be obtained instead of .cif. If a URL is given, the function will simply look in that location.

Parameters:
  • code (str) – the file to fetch.
  • file_dict (bool) – if True, parsing will stop at the file dict.
  • data_dict (bool) – if True, parsing will stop at the data dict.
Raises:

ValueError – if no file is found.

Return type:

File

atomium.utilities.fetch_over_ssh(hostname, username, path, *args, password=None, **kwargs)[source]

Fetches a file from a remote location via SSH.

Parameters:
  • hostname (str) – the remote location.
  • username (str) – the username to use.
  • path (str) – the file location on the remote machine.
  • password (str) – if needed, the password to use.
  • file_dict (bool) – if True, parsing will stop at the file dict.
  • data_dict (bool) – if True, parsing will stop at the data dict.
Return type:

File

atomium.utilities.get_parse_functions(filestring, path)[source]

Works out which parsing functions to use for a given filestring and returns them.

Parameters:
  • filestring (str) – the filestring to inspect.
  • path (str) – the path to inspect.
Return type:

tuple

atomium.utilities.open(path, *args, **kwargs)[source]

Opens a file at a given path, works out what filetype it is, and parses it accordingly.

Parameters:
  • path (str) – the location of the file.
  • file_dict (bool) – if True, parsing will stop at the file dict.
  • data_dict (bool) – if True, parsing will stop at the data dict.
Return type:

File

atomium.utilities.parse_string(filestring, path, file_dict=False, data_dict=False)[source]

Takes a filestring and parses it in the appropriate way.

Parameters:
  • filestring (str) – the contents of some file.
  • path (str) – the filename of the file of origin.
  • file_dict (bool) – if True, parsing will stop at the file dict.
  • data_dict (bool) – if True, parsing will stop at the data dict.
Return type:

File

atomium.utilities.save(filestring, path)[source]

Saves a filestring to file.

Parameters:
  • filestring (str) – the string to save.
  • path (str) – the place to save it.