API Reference#

class overlincs_git.SyncClient(*, base_url: str = 'https://overleaf.irisa.fr', username: str = '', password: str = '', verify: bool = True, authenticator: Authenticator | None = None)[source]#

Bases: object

Sync client

check_or_create_folder(metadata: ProjectData, folder_path: str) str[source]#

Check if a given folder exists on sharelatex side.

Create it recursively if needed and return its id. It looks in the metadata and create the missing directories. Make sure the metadata are up-to-date when calling this.

Parameters:
  • metadata (dict) – The sharelatex metadata as a structure basis

  • folder_path (str) – The folder path

Returns:

The folder id of the deepest folder created.

clone(project_id: str, project_name: str) Any[source]#

Copy a project.

Parameters:
  • project_id (str) – The project id of the project to copy

  • project_name (str) – The project name of the destination project

Returns:

response (dict) containing the project_id of the created project

Raises:

Exception if something is wrong with the compilation

compile(project_id: str) Any[source]#

Trigger a remote compilation.

Note that this is run against the remote version not the local one.

Parameters:

project_id (str) – The project id of the project to compile

Returns:

response (dict) status of the request as returned by sharelatex

Raises:

Exception if something is wrong with the compilation

create_folder(project_id: str, parent_folder: str, name: str) Any[source]#

Create a folder on sharelatex.

Parameters:
  • project_id (str) – The project id of the project to create the folder in

  • parent_folder (str) – The id of the folder to create the folder in

  • name (str) – Name of the folder

Returns:

response (dict) status of the request as returned by sharelatex

Raises:
  • Something wrong with sharelatex

  • - 500 server error

  • - 400 the folder already exists

delete(project_id: str, *, forever: bool = False) Any[source]#

Delete a project for the current user.

Parameters:

project_id (str) – The project id of the project to delete

delete_document(project_id: str, doc_id: str) Response[source]#

Delete a single document (e.g tex file).

Parameters:
  • project_id (str) – The project id of the project where the document is

  • doc_id (str) – The document id

Returns:

requests response

Raises:

Exception if the document can't be deleted

delete_file(project_id: str, file_id: str) Response[source]#

Delete a single file (e.g image).

Parameters:
  • project_id (str) – The project id of the project where the file is

  • file_id (str) – The file id

Returns:

requests response

Raises:

Exception if the file can't be deleted

delete_folder(project_id: str, folder_id: str) Response[source]#

Delete a single folder (with all data inside).

Parameters:
  • project_id (str) – The project id of the project where the folder is

  • folder_id (str) – The folder id

Returns:

requests response

Raises:

Exception if the folder can't be deleted

download_project(project_id: str, *, path: str = '.', keep_zip: bool = False) None[source]#

Download and unzip the project.

Beware that this will overwrite any existing project file under path.

Parameters:
  • project_id (str) – The id of the project to download

  • path (Path) – A valid path where the files will be saved

Raises:

Exception if the project can't be downloaded/unzipped.

get_chats_messages(project_id: str) Any[source]#

Get a list of messages in chat channel of a project.

Parameters:

project_id (str) – The id of the project that have chat messages

Raises:

Exception if the get failed

Returns:

such content, timestamp of posted message, poster(user) information dictionary

Return type:

a list of dictionaries contains messages information

get_document(project_id: str, doc_id: str, dest_path: str | None = None) bool | str[source]#

Get a document from a project .

This mimics the browser behavior when opening the project editor. This will open a websocket connection to the server to get the information.

Parameters:
  • project_id (str) – The id of the project

  • doc_id (str) – The id of the doc

  • dest_path (str) – the path to write the document, must be None if output is a string with the contents of document

Returns:

A string corresponding to the document if dest_path is None or True if dest_path is correctly written

get_file(project_id: str, file_id: str, dest_path: str | None = None) str | bool[source]#

Get an individual file (e.g image).

Parameters:
  • project_id (str) – The project id of the project where the file is

  • file_id (str) – The file id

  • dest_path (str) – the path to write the document, must be None if output is a string with the contents of document

Returns:

A string corresponding to the file if dest_path is None or True if dest_path is correctly written

Raises:

Exception if the file can't be downloaded

get_project_data(project_id: str) ProjectData[source]#

Get the project hierarchy and some metadata.

This mimics the browser behaviour when opening the project editor. This will open a websocket connection to the server to get the information.

Parameters:

project_id (str) – The id of the project

get_project_update_data(project_id: str) UpdateDatum[source]#

Get update (history) data of a project.

Parameters:

project_id (str) – The id of the project to download

Raises:

Exception if the project update data can't be downloaded.

get_projects_data() list[source]#

Get list of projects data. Every element of return list is a dictionary of some data of a project

new(project_name: str, template: str = 'example') Any[source]#

Create a new example project for the current user.

Parameters:
  • project_name (str) – The project name of the project to create

  • template (str) – template used for create the new project (default: example)

post_chat_message(project_id: str, message: str) bool[source]#

Post a message in chat channel of a project.

Parameters:
  • project_id (str) – The id of the project where post message

  • message (str) – the message to post from current user connected

Raises:

Exception if the post failed

Returns:

a bool True if message post has succeeded

share(project_id: str, email: str, can_edit: bool = True) Any[source]#

Send an invitation to share (edit/view) a project.

Parameters:
  • project_id (str) – The project id of the project to share

  • email (str) – Email of the recipient of the invitation

  • can_edit (boolean) – True (resp. False) gives read/write (resp. read-only)

  • project (access to the) –

Returns:

response (dict) status of the request as returned by sharelatex

Raises:

Exception if something is wrong with the compilation

update_project_settings(project_id: str, **settings: Any) Response[source]#

Update the project settings.

Update the project settings.

Parameters:
  • project_id (str) – The project id

  • settings – the key/value of the settings to change (as keyword arguments)

Examples:

client.update_project_settings("5f326e4150cb80007f99a7c0",
                               compiler="xelatex",
                               name="newname")

Returns

The request response.

upload(path: str) Any[source]#

Upload a project (zip) to sharelatex.

Parameters:

path (str) – Path to the zip file of a project.

Returns:

response (dict) status of the request as returned by sharelatex

Raises:

Exception if something is wrong with the zip of the upload.

upload_file(project_id: str, folder_id: str, c_path: str) Any[source]#

Upload a file to sharelatex.

Parameters:
  • project_id (str) – The project id

  • folder_id (str) – The parent folder

  • path_as_path (str) – Local path to the file

Returns:

requests response

Raises:

Exception if the file can't be uploaded