\(\renewcommand\AA{\unicode{x212B}}\)

ScriptRepository

This is a Python binding to the C++ class Mantid::API::ScriptRepository.

class mantid.api.ScriptRepository

Manage the interaction between the users and the Script folder (mantid subproject).

Inside the mantid repository (https://github.com/mantidproject) there is also a subproject called scripts (https://github.com/mantidproject/scripts), created to allow users to share their scripts, as well as to allow Mantid Team to distribute to the Mantid community scripts for analysis and also to enhance the quality of the scripts used for the sake of data analysis.

The ScriptRepository aims to provide a simple way to interact with that repository in order to promote its usage. In order to enhance the usage, it is necessary:

  • List all scripts available at the repository

  • Download selected scripts.

  • Check for updates

  • Allow to publish users scripts/folders.

Basically, you will need to install the repository through ::install(local_path). After, you will be able to ::listFiles inside your repository to check the files that are available, eventually, you may want to check the information of a single entry ::fileInfo(path). You may also be interested to know if there is a new version available, or if the file has been modified since last downloaded (::fileStatus(path)). You may want to download scripts through ::download(path), or check for updates through ::update().

‘’’NOTE:’’’ Upload is not implemented yet.

description((ScriptRepository)self, (str)path) object :

Return description of the entry inside ScriptRepository.

Arguments:

  • path: Path to the entry.

Return:
  • string with the description

download((ScriptRepository)self, (str)file_path) None :

Download from repository into your local file system.

You may give a file or folder. If the later is given, ScriptRepository will download all the files inside that folder from the remote repository to you.

Arguments:

  • path (str): Path for the entry do download

fileInfo((ScriptRepository)self, (str)path) tuple :

Return general information from the entries inside ScriptRepository.

The author, description and publication date are available through this method.

Arguments:

  • path(str): Path to the entry.

Returns: n - tuple: (author, last publication date)

fileStatus((ScriptRepository)self, (str)path) object :

Return the status of a given entry.

The following status are applied to the entries:
  • REMOTE_ONLY: The file is only at the central repository

  • LOCAL_ONLY: The file is only in your file system

  • BOTH_UNCHAGED: The file is in your file system and remotely, and are iqual.

  • REMOTE_CHANGED: A new version is available for this file.

  • LOCAL_CHANGED: You have edited the file

  • BOTH_CHANGED: There is a new version and you have changed as well

‘’’NOTE:’’’ ScriptRepository recognizes changes locally and remotely only through listFiles method. Arguments:

  • path (str): The path for the entry.

Returns:

  • str: Status of the entry.

install((ScriptRepository)self, (str)local_path) None :

Install the ScriptRepository in your local file system

The installation of the ScriptRepository is very simple. You must only provide a path, existing or new folder, where the ScriptRepository will put the database it requires to run itself. The installation requires network connection, to connect to the central repository but usually takes very few moments to be installed. After installing, all the others methods will be available. Arguments:

  • path (str): An existing or path to a new folder to be created, where the ScriptRepository will install itself.

listFiles((ScriptRepository)self) object :

Return an array with all the entries inside the repository.

Folder os files, locally or remotely, all will be listed together through the listFiles. The listFiles has another function, which is related to update the internal cache about the status and information of the files. So, local changes or remote changes will only be available to fileStatus of fileInfo after listFiles.

Returns:

list: entries inside the repository.

update((ScriptRepository)self) std_vector_str :

Check for updates at the remote repository.

New versions of the files may be available, and the update method will check the remote repository to see if there is anything new. It will not download new versions of the available files unless you ask to do so. You should do this often to check if there is a new script to solve your problem ;)