sharepoint¶
sharepoint ¶
RemoteFile dataclass ¶
A SharePoint driveItem's id and name, as selected by select_latest_remote_file.
Source code in source/src/imarina_load_researchers/core/sharepoint.py
get_token_manager cached ¶
Returns the process-wide TokenManager singleton, creating it on first call.
Returns:
| Name | Type | Description |
|---|---|---|
TokenManager | TokenManager | The cached |
Source code in source/src/imarina_load_researchers/core/token_manager.py
get_list_id ¶
Return the GUID of the named SharePoint list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token_manager | TokenManager | Authenticated token manager. | required |
site_id | str | SharePoint site identifier. | required |
list_name | str | Display name of the target list. | required |
Returns:
| Type | Description |
|---|---|
str | The list's Graph API GUID string. |
Source code in source/src/imarina_load_researchers/core/sharepoint.py
get_site_id ¶
Return the GUID of a SharePoint site given its domain and site path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token_manager | TokenManager | Authenticated token manager. | required |
domain | str | SharePoint tenant domain (e.g. | required |
site_name | str | The site's path segment, as used in its URL. | required |
Returns:
| Type | Description |
|---|---|
Any | The site's Graph API GUID string. |
Source code in source/src/imarina_load_researchers/core/sharepoint.py
upload_file ¶
upload_file(token_manager: TokenManager, drive_id: str, target_folder: Path, local_file_path: Path, remote_file_name: str | None = None) -> str
Upload a local file to SharePoint, returning the uploaded item's id (needed by callers that go on to generate a sharing link for it).
The uploaded item is named local_file_path.name unless remote_file_name is given — needed when the local filename doesn't match what the remote folder's naming convention expects (e.g. download's iMarina fallback, which reads under the fixed local name iMarina.xlsx but re-uploads it under the original datetime-encoded filename so runtime/imarina stays consistent with the other remote folders' naming).
Source code in source/src/imarina_load_researchers/core/sharepoint.py
download_item_content ¶
download_item_content(token_manager: TokenManager, drive_id: str, item_id: str, destination: Path) -> None
Download a driveItem's content by id, writing it to destination.
Source code in source/src/imarina_load_researchers/core/sharepoint.py
download_shared_link_content ¶
Download the file behind an MS List "sharing link" field value (the encoding Graph expects for its /shares/u!{...} endpoint), writing it to destination. Used for the two user-supplied input links (download) and for sourcing publish's file from a request's output link.
Source code in source/src/imarina_load_researchers/core/sharepoint.py
download_files_in_folder_from_sharepoint ¶
download_files_in_folder_from_sharepoint(drive_id: str, local_destiny_folder: Path, remote_origin_folder: Path) -> Any
Downloads every file in a SharePoint folder into a local folder, flat.
This is download's bulk-sync mechanism for the static translation- dictionary files (SHAREPOINT_INPUT_DIR, see CLAUDE.md's download section) — it lists and downloads all .xlsx files as-is, unconditionally. A per-file download failure is logged and skipped rather than aborting the whole sync.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id | str | SharePoint drive identifier the folders live under. | required |
local_destiny_folder | Path | Local folder to download files into (created if it doesn't exist). | required |
remote_origin_folder | Path | Remote SharePoint folder path to list and download files from. | required |
Raises:
| Type | Description |
|---|---|
SharePointError | If listing the remote folder's children fails. |
Source code in source/src/imarina_load_researchers/core/sharepoint.py
get_parameters_list ¶
Reads an MS List item's A3/iMarina input sharing links, by Operation ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id | str | The MS List item's ID (the workflow's Operation ID). | required |
Returns:
| Type | Description |
|---|---|
str | None | A |
str | None | field isn't set (both are optional per CLAUDE.md's "Where the raw |
tuple[str | None, str | None] | inputs come from" section, and |
tuple[str | None, str | None] | the latest remote file when they are). |
Source code in source/src/imarina_load_researchers/core/sharepoint.py
get_list_item_link_field ¶
Read a single Text-type link field off an MS List item, or None if that field isn't set. Used by publish to source its file from the request's output-link field when given an ID (see CLAUDE.md's publish section).
Source code in source/src/imarina_load_researchers/core/sharepoint.py
update_list_item_fields ¶
PATCH one or more fields on an MS List item.
Graph's /fields sub-resource takes the field dict directly as the PATCH body (unlike _get_list_item_fields's GET, which reads the whole item and pulls a fields object back out of the response).
Source code in source/src/imarina_load_researchers/core/sharepoint.py
create_sharing_link ¶
Create an organization-scoped, view-only sharing link for a SharePoint driveItem. Scope is deliberately "organization", not "anonymous" -- these links point at personnel data (see CLAUDE.md's "GDPR implications" section).
Source code in source/src/imarina_load_researchers/core/sharepoint.py
select_latest_remote_file ¶
select_latest_remote_file(token_manager: TokenManager, drive_id: str, remote_folder: Path, suffix: str) -> RemoteFile
List remote_folder's children and pick the latest .xlsx by the filename-encoded datetime (CLAUDE.md's "What this does" section: "the 'latest' of a group of files is always deduced from the file's name"). Remote counterpart of select_file_to_upload (core/file_select.py), which does the same thing against local files -- unlike that function, there is no modification-time fallback here: the rule for remote folders is filename-datetime only, and a SharePoint item's lastModifiedDateTime doesn't carry the same "file was produced at" meaning local mtime does for the local fallback.