pyrevit.coreutils.appdata

Utility functions for creating data files within pyRevit environment.

Most times, scripts need to save some data to share between different scripts that work on a similar topic or between script executions. This module provides the necessary and consistent mechanism for creating and maintaining such files.

Example

>>> from pyrevit.coreutils import appdata
>>> appdata.list_data_files()
pyrevit.coreutils.appdata.cleanup_appdata_folder()

Cleanup appdata folder of all temporary appdata files.

pyrevit.coreutils.appdata.find_data_files(file_ext)

Find data files in all data files directories

Parameters:file_ext (str) – data files with this extension will be listed only
Returns:list of files
Return type:list
pyrevit.coreutils.appdata.find_instance_data_files(file_ext, instance_id)

Find instance data files in all data files directories

Parameters:
  • file_ext (str) – data files with this extension will be listed only
  • instance_id (int) – list data files for this instance id only
Returns:

list of files

Return type:

list

pyrevit.coreutils.appdata.garbage_data_file(file_path)

Mark and remove the given appdata file.

Current implementation removes the file immediately.

Parameters:file_path (str) – path to the target file
pyrevit.coreutils.appdata.get_data_file(file_id, file_ext, name_only=False)

Get path to file that will not be cleaned up at Revit load.

e.g pyrevit_2016_eirannejad_file_id.file_ext

Parameters:
  • file_id (str) – Unique identifier for the file
  • file_ext (str) – File extension
  • name_only (bool) – If true, function returns file name only
Returns:

File name or full file path (depending on name_only)

Return type:

str

pyrevit.coreutils.appdata.get_instance_data_file(file_id, file_ext='tmp', name_only=False)

Get path to file that should be used by current instance only.

These data files will be cleaned up at Revit restart. e.g pyrevit_2016_eirannejad_2353_file_id.file_ext

Parameters:
  • file_id (str) – Unique identifier for the file
  • file_ext (str) – File extension
  • name_only (bool) – If true, function returns file name only
Returns:

File name or full file path (depending on name_only)

Return type:

str

pyrevit.coreutils.appdata.get_universal_data_file(file_id, file_ext, name_only=False)

Get path to file that is shared between all host versions.

These data files are not cleaned up at Revit restart. e.g pyrevit_eirannejad_file_id.file_ext

Parameters:
  • file_id (str) – Unique identifier for the file
  • file_ext (str) – File extension
  • name_only (bool) – If true, function returns file name only
Returns:

File name or full file path (depending on name_only)

Return type:

str

pyrevit.coreutils.appdata.is_data_file_available(file_id, file_ext)

Check if given file is available within appdata directory.

Parameters:
  • file_id (str) – data file id
  • file_ext (str) – file extension
Returns:

file path if file is available

Return type:

str

pyrevit.coreutils.appdata.is_file_available(file_name, file_ext, universal=False)

Check if given file is available within appdata directory.

Parameters:
  • file_name (str) – file name
  • file_ext (str) – file extension
  • universal (bool) – Check against universal data files
Returns:

file path if file is available

Return type:

str

pyrevit.coreutils.appdata.is_pyrevit_data_file(file_name)

Check if given file is a pyRevit data file.

Parameters:file_name (str) – file name
Returns:True if file is a pyRevit data file
Return type:bool
pyrevit.coreutils.appdata.list_data_files(file_ext, universal=False)

List all data files with given extension.

Parameters:
  • file_ext (str) – file extension
  • universal (bool) – Check against universal data files
Returns:

list of files

Return type:

list

pyrevit.coreutils.appdata.list_instance_data_files(file_ext)

List all data files associated with current session.

Parameters:file_ext (str) – data files with this extension will be listed only.
Returns:list of data files
Return type:list