Library Reference
The lib.i18n
Module
Localization management.
The lib.utils
Module
Some various utilities.
- ciowarehouse2.lib.utils.files2response(request: Request, abs_paths: list[str], common_path: str | None = None, download_name: str | None = None) FileResponse | None [source]
Prepare files for download and return a Pyramid response.
- Parameters:
request (pyramid.request.Request) – Current request.
abs_paths (list) – List of absolute paths to files to download.
common_path (str) – (optional) Root of all files.
download_name (str) – (optional) Visible name during download.
- Return type:
- Returns:
Return a FileResponse or raise a
pyramid.httpexceptions.HTTPNotFound
exception.
- ciowarehouse2.lib.utils.file2response(request: Request, abs_path: str, download_name: str | None = None, content_type: str | None = None) FileResponse [source]
Return a Pyramid FileResponse containing the given file.
- Parameters:
request (pyramid.request.Request) – Current request.
abs_path (str) – Absolute path to file to encapsulate.
download_name (str) – Visible name during download.
- Return type:
- ciowarehouse2.lib.utils.file_move_check(warehouse1_root: str, ciopath1: CioPath, warehouse2_root: str, ciopath2: CioPath, overwrite_ok: bool = False, mode: str = 'move') tuple[CioPath | None, str | None] [source]
Check files for a move or copy and return absolute paths.
- Parameters:
warehouse1_root (str) – Root of warehouse of the source.
ciopaht1 – CioPath of the first file.
warehouse2_root (str) – Root of the warehouse of the target.
ciopath2 (.lib.ciopath.CioPath) – CioPath of the srecond file.
overwrite_ok (bool) – (default=False) If
True
, silently overwrite the destination file.mode (str) – (
'move'
,'copy'
,'rename'
) The way the move must operate.
- Return type:
- Returns:
A tuple such as
(ciopath2, error)
.
- ciowarehouse2.lib.utils.normalize_filename(filename: str, mode: str = 'simple', is_dir: bool = False) str [source]
Normalize file name.
- ciowarehouse2.lib.utils.ciopaths2absolute_paths(request: Request, ciopaths_str: list[str]) list[str] [source]
Convert a list of CioPath into a list of absolute paths.
- Parameters:
request (pyramid.request.Request) – Current request.
ciopaths_str (list) – List of strings representing CioPath.
- Return type:
- ciowarehouse2.lib.utils.build_callback(registry, build_env: dict, result: dict, request: Request | None = None)[source]
Function called after the build is completed.
- Parameters:
registry – Application registry.
build_env (dict) – Build environment.
result (dict) – Result of the processing. See:
cioservice.lib.build.Build
.request (pyramid.request.Request) – (optional) Current request.
- ciowarehouse2.lib.utils.cache_user_renderings(namespace_prefix: str, region: str | None = None)[source]
A decorator to retrieve in the user cache the dictionary renderings.
- ciowarehouse2.lib.utils.cache_user_seeds(namespace_prefix: str, region: str | None = None)[source]
A decorator to retrieve in the user cache the dictionary of seeds.
- ciowarehouse2.lib.utils.isodt2str(isodt: str) str [source]
Return a string representing the given datetime in local time zone in an ISO format.
- ciowarehouse2.lib.utils.isodt2age(request: Request, isodt: str) str [source]
Return a string representing the given datetime as an age.
- Parameters:
request (pyramid.request.Request) – Current request.
isodt (str) – ISO datetime format.
- Return type:
- ciowarehouse2.lib.utils.wait4thumbnails(request: Request, thumbnails: list[tuple[CioPath, str, str | None]], trials: int = 4)[source]
Wait a while to be sure each thumbnail of the list is created.
- Parameters:
request (pyramid.request.Request) – Current request.
thumbnails (list) – A list of tuples such as
(ciopath, size, thumbnail_ext)
.trails (int) – (default=``THUMBNAIL_TRIALS``) Number of trials for each thumbnail.
- ciowarehouse2.lib.utils.ciotype_thumbnails(request: Request, ciopaths: tuple[CioPath]) dict[CioPath, tuple[CioType, str, str | None]] [source]
Retrieve CioType`s and extensions of a given list of `CioPath.
- Parameters:
request (pyramid.request.Request) – Current request.
ciopaths (tuple) – A tuple of CioPath.
- Return type:
- ciowarehouse2.lib.utils.thumbnail_absolute_path(request: Request, ciotype: CioType, ciopath: CioPath, icon: str, thumbnail_ext: str | None) str [source]
Return the absolute path to the thumbnail or to the icon.
- Parameters:
request (pyramid.request.Request) – Current request.
ciotype (.lib.ciotype.CioType) – CioType of the file.
ciopath – CioPath of the file.
icon (str) – File name of the icon.
thumbnail_ext (str) – Extension of the thumbnail.
- Path ciopath:
.lib.ciopath.CioPath
- Return type:
- ciowarehouse2.lib.utils.query_in(field: str, values: tuple | list) str [source]
Create an optimized query for a multivalued field.
- ciowarehouse2.lib.utils.query_in_quoted(field: str, values: tuple | list) str [source]
Create an optimized query for a multivalued field with quoted values.
- ciowarehouse2.lib.utils.scope_query(request: Request, scope: str, directory_ciopath: CioPath, flat: bool = False) str | None [source]
Create a query to restrick the search in the current and authorized scope.
- Parameters:
request (pyramid.request.Request) – Current request.
scope (str) – Scope of the search:
'all'
,'favorite'
,'warehouse'
or'directory'
.directory_ciopath – CioPath of the current directory, possibly an empty one.
flat (bool) – if
True
usefacet
field instead ofdirectory
field.
- Return type:
- ciowarehouse2.lib.utils.warehouses_in_scope(request: Request, scope: str, warehouse_id: str | None) tuple[str, ...] [source]
Find ID of warehouses in the scope.
- Parameters:
request (pyramid.request.Request) – Current request.
scope (str) – Scope of the search:
'all'
,'favorite'
,'warehouse'
or'directory'
.warehouse_id (str) – Warehouse ID if exists.
- Return type:
- ciowarehouse2.lib.utils.warehouses_favorite(request: Request) tuple[str, ...] [source]
Return a dictionary of favorite warehouses.
- Parameters:
request (pyramid.request.Request) – Current request.
- Return type:
Return a dictionary of warehouses in the menu.
- Parameters:
request (pyramid.request.Request) – Current request.
- Return type:
- ciowarehouse2.lib.utils.apply_regex(request: Request, regex_file: str, content: str) str [source]
Apply a list of regular expressions from a file.
- Parameters:
request (pyramid.request.Request) – Current request.
regex_file (str) – Absolute path to the file containing regular expressions.
content (str) – Content to process.
- Return type:
The lib.backend
Module
Backend management.
- class ciowarehouse2.lib.backend.CioBackend(settings: dict, uid: str)[source]
Class to manage backend calls.
- Parameters:
settings (pyramid.registry.Registry.settings) – Settings object.
uid (str) – UID of the current site (ex. ciodemosite).
- inspect(segments: bool = False) tuple[InspectReply | None, str | None] [source]
Inspect the index.
- Return type:
- Returns:
A tuple such as
(reply, error)
.
- reset(not_thumbs: bool = False) str | None [source]
Reset the index and remove thumbnails.
- Parameters:
not_thumbs (bool) – (optional) Do not remove thumbnails.
- Return type:
pyramid.i18n.TranslationString
- index(warehouse: Warehouse, paths: list | tuple | None = None, force: bool = False, skip_thumbs: bool = False, no_thumbs: bool = False) str | None [source]
Index paths inside a given warehouse.
- delete(warehouse: Warehouse, paths: list | tuple | None = None, not_thumbs: bool = False) str | None [source]
Delete index entries of a given warehouse.
- search(query: str, limit: int = 10, offset: int = 0, sort_by: str | None = None, reverse: bool = False, snippets: int = 0) tuple[SearchReply | None, str | None] [source]
Search files.
- Parameters:
query (str) – Query.
limit (int) – (default = 10) Maximum of returned hits.
offset (int) – (default = 0) Offset of the range of returned hits.
sort_by (str) – (default = None) Name of the field for sorting the result.
reverse (bool) – (default = False) Reverse the sort.
snippets (int) – (default = 0) Length of the context to show.
- Return type:
- Returns:
A tuple such as
(reply, error)
The lib.ciotype
Module
CioType
is similar to a MIME type:
type/subtype+suffix?parameter=value.
- class ciowarehouse2.lib.ciotype.CioType(type_: str | None, subtype: str | None = None)[source]
A class to manage CioType.
- Parameters:
string (str) – String representation of a CioType.
- classmethod from_str(string: str | None) CioType [source]
Return a new CioType created from a string.
- classmethod from_request(request: Request) CioType [source]
Look for a CioType in a request.
- Parameters:
request (pyramid.request.Request) – Current request.
- Return type:
.lib.ciotype.CioType
The lib.ciopath
Module
A class that uniquely represents a file.
- class ciowarehouse2.lib.ciopath.CioPath(wid: str | None, path: str | None = None, is_dir: bool = False)[source]
A class to manage CioPath.
- Parameters:
- classmethod from_str(string: str | None, is_dir: bool = False) CioPath [source]
Return a new CioPath created from a string.
- Parameters:
string (str) – String representing a CioPath
- classmethod from_paths(wid: str, root: str, paths: list[str] | set[str]) list[CioPath] [source]
Return a list or CioPath from a list of relative paths.
- classmethod from_request(request: Request, is_dir: bool = False) CioPath [source]
Look for a CioPath in a request.
- Parameters:
request (pyramid.request.Request) – Current request.
is_dir (bool) – (default=False)
True
if the given CioPath is a directory.
- facet(of_file: bool = False) str | None [source]
Return the facet repesentation of the directory containing the file or of the file itself.
- absolute_info(root: str | None) str | None [source]
Return the absolute path to the information file linked to the given CioPath.
- absolute_lock(root: str | None) str | None [source]
Return the absolute path to the lock file linked to the given CioPath.
- contains(other: CioPath) bool [source]
True if the given CioPath is strictly contained in current one.
The lib.vcs
Module
Class for warehouses with Git as VCS.
- class ciowarehouse2.lib.vcs_git.VcsGit(uid: str, root: str, dbwarehouse: DBWarehouse, password: str | None = None)[source]
Class to manage warehouses with Git as VCS.
- Parameters:
uid (str) – ID of this VCS i.e. ID of the corresponding warehouse.
root (str) – Absolute path to the warehouse directory.
dbwarehouse (.models.dbwarehouse.DBWarehouse) – (optional) DBWarehouse defining the warehouse managed by this VCS.
password (str) – (optional) Clear password for clone/pull access.
- init()[source]
Initialize a local Git repository.
- Return type:
pyramid.i18n.TranslationString
orNone
- Returns:
Error message or
None
if it succeeds.
- clone() str | None [source]
Create a copy of an existing repository.
- Return type:
pyramid.i18n.TranslationString
orNone
- pull() str | None [source]
Pull from a remote repository or do nothing.
- Return type:
pyramid.i18n.TranslationString
orNone
- add(ciopath: CioPath | None = None) str | None [source]
Add new files in path
path
.- Parameters:
ciopath (.lib.ciopath.CioPath) – (optional) CioPath of the file to add.
- Return type:
pyramid.i18n.TranslationString
orNone
- remove(ciopath: CioPath) str | None [source]
Remove a file or a directory.
- Parameters:
ciopath (.lib.ciopath.CioPath) – CioPath of the file to remove.
- Return type:
pyramid.i18n.TranslationString
orNone
- move(ciopath1: CioPath, ciopath2: CioPath, overwrite_ok: bool = False, mode: str = 'move') tuple[CioPath | None, str | None] [source]
Move or copy a file inside the warehouse.
- Parameters:
- Return type:
- Returns:
A tuple such as
(final_ciopath2, error)
.
- copy(ciopath1: CioPath, ciopath2: CioPath, overwrite_ok: bool = False) tuple[CioPath | None, str | None] [source]
Copy a file.
- Parameters:
ciopaht1 – CioPath of the first file.
ciopath2 (.lib.ciopath.CioPath) – CioPath of the srecond file.
overwrite_ok (bool) – (default=False) If
True
, do nothing if files are the same.
- Return type:
pyramid.i18n.TranslationString
orNone
Class for warehouses without Version Control System.
- class ciowarehouse2.lib.vcs_none.VcsNone(uid: str, root: str, dbwarehouse: DBWarehouse | None = None)[source]
Class to manage warehouses without VCS.
- Parameters:
- remove(ciopath: CioPath) str | None [source]
Remove a file or a directory.
- Parameters:
ciopath (.lib.ciopath.CioPath) – CioPath of the file to remove.
- Return type:
pyramid.i18n.TranslationString
orNone
- move(ciopath1: CioPath, ciopath2: CioPath, overwrite_ok: bool = False, mode: str = 'move') tuple[CioPath | None, str | None] [source]
Move or copy a file inside the warehouse.
- Parameters:
- Return type:
- Returns:
A tuple such as
(final_ciopath2, error)
.
- move_(ciopath1: CioPath, ciopath2: CioPath, overwrite_ok: bool, mode: str) tuple[CioPath | None, str | None] [source]
Method used by
VcsNone
andVcsGit
to move files.
- copy(ciopath1: CioPath, ciopath2: CioPath, overwrite_ok: bool = False) tuple[CioPath | None, str | None] [source]
Copy a file.
- Parameters:
ciopaht1 – CioPath of the first file.
ciopath2 (.lib.ciopath.CioPath) – CioPath of the second file.
overwrite_ok (bool) – (default=False) If
True
, do nothing if files are the same.
- Return type:
pyramid.i18n.TranslationString
orNone
The lib.warehouse
Module
Warehouse class.
- class ciowarehouse2.lib.warehouse.Warehouse(registry, dbwarehouse: DBWarehouse, locations: dict)[source]
Class to manage a warehouse.
- Parameters:
- label(request: Request) str [source]
Return a translated label.
- Parameters:
request (pyramid.request.Request) – Current request.
- Return type:
- description(request: Request) str [source]
Return a translated description.
- Parameters:
request (pyramid.request.Request) – Current request.
- Return type:
- must_refresh(now: bool = False, force: bool = False) bool [source]
Check if the warehouse must be refreshed.
- refresh(request: Request, ciopaths: list[CioPath] | set[CioPath] | None = None, now: bool = False, force: bool = False, in_thread: bool = False) str | None [source]
Call the backend for refreshing the index. If
paths
isNone
, do a full refresh.- Parameters:
request (pyramid.request.Request) – Current request.
paths (list) – (optional) List of CioPath to refresh.
now (bool) – (default=False) If
True
, force refreshing even if the deadline is not reached.force (bool) – (default=False) If
True
, force refreshing even if the source is older than the index.in_thread (bool) – (default=False) Launch the refresh in a thread.
- Return type:
- to_refresh(inputs: list[str], paths: list[str]) list[CioPath] [source]
Compute an optimized list of CioPath to refresh.
- commit_and_refresh(request: Request, ciopaths: list[CioPath] | set[CioPath], message: str, force: bool = False, in_thread: bool = False)[source]
Commit new files and refresh the warehouse.
- Parameters:
request (pyramid.request.Request) – Current request.
ciopaths (list) – List of CioPath.
message (pyramid.i18n.TranslationString) – Commit message.
force (bool) – (default=False) If
True
, force refreshing even if the source is older than the index.in_thread (bool) – (default=False) Launch the refresh in a thread.
- file_trail(request: Request, ciopath: CioPath) str [source]
Return a HTML trail of the given CioPath.
- Parameters:
request (pyramid.request.Request) – Current request.
ciopath (.lib.ciopath.CioPath) – CioPath of the current directory.
- Return type:
- file_normalize(file_name: str, is_dir: bool = False) str | None [source]
Return a normalized file name or
None
if the file is in the excluded file list.
- move_from(from_warehouse: Warehouse, from_ciopath: CioPath, to_ciopath: CioPath, overwrite_ok: bool = False, mode: str = 'move') tuple[CioPath | None, str | None] [source]
Move or copy a file from an another warehouse.
- Parameters:
from_warehouse (.lib.warehouse.Warehouse) – Source warehouse object.
from_ciopath (.lib.ciopath.CioPath) – CioPath of the source file.
to_ciopath (.lib.ciopath.CioPath) – CioPath of the destination file.
overwrite_ok (bool) – (default=False) If
True
, silently overwrite the destination file.mode (str) – (
'move'
,'copy'
,'rename'
) The way the move must operate.
- Return type:
- Returns:
A tuple such as
(final_to_ciopath, error)
.
- lock(name: str, ciopath: CioPath | None = None, relock: bool = False) tuple[bool, str] [source]
Lock a file, a directory or the whole warehouse with a name.
- unlock(ciopath: CioPath | None = None)[source]
Unlock a file, a directory or the whole warehouse.
- Parameters:
ciopath (.lib.ciopath.CioPath) – (optional) CioPath of the file to unlock.
- seeds(request, *args, **kwargs)
Use of user cache.
- jobs(request: Request) dict [source]
Return a dictionary of available jobs for this warehouse.
- Parameters:
request (pyramid.request.Request) – Current request.
- Return type:
- job(request: Request, job_id: str, config: ConfigParser | None = None) dict | None [source]
Return a dictionary representing the job.
- Parameters:
request (pyramid.request.Request) – Current request.
job_id (str) – Job ID.
config (configparser.ConfigParser) – (optional) Configuration parser based on application configuration file.
- Return type:
- Returns:
A dictionary with keys
'job_id'
,'i18n_label'
,'i18n_description'
,'icon'
,'threaded'
,'ttl'
,'priority'
,'settings'
,'service_id'
. If a problem succeeds, it returnsNone
.
The lib.manager
Module
A file manager is responsible for displaying and, possibly, editing a file.
- class ciowarehouse2.lib.manager.Manager[source]
Base class for file managers.
This object provides rendering for a particular type of file.
viewings
andeditings
attributes are lists of dictionaries with the following keys:'label'
: (required) label of the rendering'template'
: (required) Chameleon template to use'css'
: list of paths to CSS file'js'
: list of path to Javascript file'only4groups'
: set of groups of authorized users for editing
- classmethod register(environment: Configurator | dict, manager_class) Manager [source]
Method to register the manager.
- Parameters:
environment (
pyramid.config.Configurator
ordict
) – Object used to do configuration declaration within the application or a ScriptRegistry to simulate the application registry.manager_class – Manager class.
kwargs (dict) – Keyworded arguments
- Return type:
.lib.manager.Manager
- initialize(config: dict)[source]
Initialize the manager.
- Parameters:
config (dict) – Dictionary with keys
'root'
and'develop'
where'root'
is the absolute path to the root directory for manager with imports.
- install(force: bool = False)[source]
Install a manager in an alternative home directory with its imports.
- Parameters:
force (bool) – If
True
, force installation.
- match(ciotype: CioType) bool [source]
Check whether this file manager matches with the CioType.
- Parameters:
ciotype (.lib.ciotype.CioType) – The CioType to compare with mine.
- Return type:
- current_rendering(request: Request, warehouse: Warehouse, rendering_type: str) dict | None [source]
Find the current rendering.
- Parameters:
request (pyramid.request.Request) – Current request.
warehouse (.lib.warehouse.Warehouse) – Object describing the warehouse containing the file.
rendering_type (str) – (‘viewing’ or ‘editing’) Type of rendering.
- Return type:
- view(request: Request, warehouse: Warehouse, ciopath: CioPath, ts_factory=None) str | None [source]
Return a string containing HTML to display the file.
- Parameters:
request (pyramid.request.Request) – Current request.
warehouse (.lib.warehouse.Warehouse) – Object describing the warehouse containing the file.
ciopath (.lib.ciopath.CioPath) – CioPath of the current file.
ts_factory – (optional) Translation String Factory fucntion.
- Return type:
str
orNone
- edit(request: Request, warehouse: Warehouse, ciopath: CioPath, ts_factory=None) str | None [source]
Return a string containing HTML to edit the file.
- Parameters:
request (pyramid.request.Request) – Current request.
warehouse (.lib.warehouse.Warehouse) – Object describing the warehouse containing the file.
ciopath (.lib.ciopath.CioPath) – CioPath of the current file.
ts_factory – (optional) Translation String Factory fucntion.
- Return type:
str
orNone
- save(request: Request, warehouse: Warehouse, ciopath: CioPath, editing: dict, values: dict, go_on: bool, original: ElementTree | None = None) str | None [source]
Save the file.
- Parameters:
request (pyramid.request.Request) – Current request.
warehouse (.lib.warehouse.Warehouse) – Object describing the warehouse containing the file.
ciopath (.lib.ciopath.CioPath) – CioPath of the current file.
editing (dict) – Dictionary representing the editing.
values (dict) – Modified values.
go_on (bool) –
True
if the modification continues after saving.original (
lxml.etree._ElementTree
) – (optional) Initial content of the file.
- Return type:
str
orNone
- Returns:
An error message or
None
.
- edit_finalization(request: Request, warehouse: Warehouse, ciopath: CioPath, message: str | None = None)[source]
Commit changes, unlock files and refresh warehouse.
- Parameters:
request (pyramid.request.Request) – Current request.
warehouse (.lib.warehouse.Warehouse) – Object describing the warehouse containing the file.
ciopath (.lib.ciopath.CioPath) – CioPath of the current file.
message (str) – (optional) Commit meesage.
- Return type:
- classmethod file_lock(request: Request, warehouse: Warehouse, ciopath: CioPath) tuple[bool, str] [source]
Lock a file for myself for the purpose of editing it.
- Parameters:
request (pyramid.request.Request) – Current request.
warehouse (.lib.warehouse.Warehouse) – Object describing the warehouse containing the file.
ciopath (.lib.ciopath.CioPath) – CioPath of the file to lock.
- Return type:
- classmethod file_unlock(request: Request, warehouse: Warehouse, ciopath: CioPath)[source]
Unlock a file.
- Parameters:
request (pyramid.request.Request) – Current request.
warehouse (.lib.warehouse.Warehouse) – Object describing the warehouse containing the file.
ciopath (.lib.ciopath.CioPath) – CioPath of the file to unlock.
- classmethod themed_urls(request, rendering, name)[source]
Return a list of URLs possibly completed with theme prefix.
- Parameters:
request (pyramid.request.Request) – Current request.
rendering (dict) – Dictionary defining the rendering.
name (str) – Name of the bunch of URLs (‘css’, ‘js’)
- Return type:
The lib.file_info
Module
File information class.
- ciowarehouse2.lib.file_info.info_read(request: Request, warehouse: Warehouse, ciopath: CioPath, metafields: list | tuple | None = None) tuple[dict, set[str], set[str] | None] [source]
Return fields, sharings and only4groups for the given path.
- Parameters:
request (pyramid.request.Request) – Current request or
None
if called by a script.warehouse (.lib.warehouse.Warehouse) – Current warehouse object.
CioPath (.lib.ciopath.CioPath) – CioPath of the file.
metafields (list) – (optional) List of metadata field IDS to retrieve. If not defined, return all metadata fields of the warehouse.
- Return type:
- Returns:
A tuple such as
(metadata, sharings, only4groups)
.
- ciowarehouse2.lib.file_info.info_get_root(warehouse_root: str, ciopath: CioPath, remove_fields: bool = False, remove_only4groups: bool = False) etree.Element | None [source]
Load or create the information XML structure of a given CioPath.
- Parameters:
- Return type:
lxml.etree._Element
- Returns:
Root element of the information XML file.
- ciowarehouse2.lib.file_info.info_save(root_elt: Element, warehouse_root: str, ciopath: CioPath, request: Request | None = None) bool [source]
Save an information XML file of a given CioPath.
- Parameters:
root_elt (lxml.etree.Element) – Root of the XML document.
warehouse_root – Absolute path to the warehouse root.
ciopath (.lib.ciopaht.CioPath) – The current CioPath.
request (pyramid.request.Request) – (optional) Current request.
- Return type:
- ciowarehouse2.lib.file_info.info_get_field(request: Request, root_elt: Element, field_id: str)[source]
Return the value of a field in its correct type or
None
.- Parameters:
request (pyramid.request.Request) – Current request.
root_elt (lxml.etree.Element) – Root of the XML document.
meta_id (str) – ID of the metadata to retrieve.
- Returns:
Value of field or
None
.
- ciowarehouse2.lib.file_info.info_set_fields(root_elt: Element, fields: list)[source]
Update metadata fields.
- Parameters:
root_elt (lxml.etree.Element) – Root of the XML document.
fields (list) – List of metadata fields. Each item is a tuple such as
(field_id, value, display)
.
- ciowarehouse2.lib.file_info.info_get_sharings(root_elt: etree.Element | None) set[str] [source]
Return a list of sharing IDs.
- Parameters:
root_elt (lxml.etree.Element) – Root of the XML document.
- Return type:
- ciowarehouse2.lib.file_info.info_add_sharing(root_elt: Element, sharing_id: str) bool [source]
Add a sharing ID.
- ciowarehouse2.lib.file_info.info_remove_sharing(root_elt: Element, sharing_id: str)[source]
Remove a sharing ID.
- Parameters:
root_elt (lxml.etree.Element) – Root of the XML document.
sharing_id (str) – Sharing ID.
The lib.file_paging
Module
Class to divide large lists of direcrories and files into pages.
- ciowarehouse2.lib.file_paging.sortable_column(request: Request, label: str, sort: str, current_sorting: str | None = None, sortable: bool = True) str [source]
Output a header of column with sort up and sort down buttons.
- Parameters:
request (pyramid.request.Request) – Current request.
label (str) – Label of column.
sort (str) – Sort criteria.
current_sorting (str) – (optional) Default current sorting.
sortable (bool) – (default=True) Non sortable field management.
- Return type:
helpers.literal.Literal
- class ciowarehouse2.lib.file_paging.FilePaging(request: Request, ciopath: CioPath, query: str, params: dict | None = None, keep_list: bool = False, snippets: int = 0)[source]
Divide large lists of direcrories and files into pages using a backend.
- Parameters:
request (pyramid.request.Request) – Current request.
ciopath (.lib.ciopath.CioPath) – CioPath of the current directory, possibly an empty one.
query (str) – Tantivy query.
params (dict) – (optional) Paging parameters: page number, page size, display mode and sort.
keep_list (bool) – if
True
, save a list of(ciopath, cioptype)
in the user session.snippets (int) – (default = 0) Length of the context to show.
- classmethod params(request: Request, ciopath: CioPath, default_sort: str | None = None, default_display: str = 'cards') dict [source]
Set paging parameters into the paging session return it.
- Parameters:
request (pyramid.request.Request) – Current request.
ciopath (.lib.ciopath.CioPath) – CioPath of the current directory, possibly an empty one.
default_sort (str) – (optional) Default sorting (ex. ‘+file_name’).
default_display (str) – (optional) Default display (ex. ‘cards’).
- Return type:
- get_pfile(ciopath: CioPath) dict | None [source]
Retrieve the first item whose CioPath matches.
- Parameters:
ciopath (.lib.ciopath.CioPath) – CioPath to search.
- Return type:
- pager_top() str [source]
Output a string with links to first, previous, next and last pages.
- Rtye:
str
- pager_bottom(pager_format: str = '~4~') str [source]
Output a string with links to some previous and next pages.
- display_modes(modes: tuple = ('cards', 'list')) str [source]
Output buttons to switch between snippets, cards and list mode.
The lib.wfile
Module
Warehouse file class.
- class ciowarehouse2.lib.wfile.WFile(request: Request)[source]
Class to operate on files in a warehouse or in a result of search.
- Parameters:
request (pyramid.request.Request) – Current request.
- upload(warehouse: Warehouse, directory_ciopath: CioPath)[source]
Import several files in the current directory.
- Parameters:
warehouse (.lib.warehouse.Warehouse) – Current warehouse object if exists.
directory_ciopath (.lib.ciopath.CioPath) – CioPath of the current directory .
- remove(targets: tuple[str])[source]
Remove files.
- Parameters:
targets (tuple) – List of CioType`ǁ`CioPath.
- new_file(warehouse: Warehouse | None, directory_ciopath: CioPath, action: str, values: dict) CioPath | None [source]
Create a new file or a new directory.
- Parameters:
warehouse (.lib.warehouse.Warehouse) – Current warehouse object.
form – Current form.
directory_ciopath (.lib.ciopath.CioPath) – CioPath of the current directory, possibly an empty one.
values (dict) – Values needed by the seeder.
- Return type:
.lib.ciopath.CioPath
The lib.wjob
Module
Warehouse job class.
- class ciowarehouse2.lib.wjob.WJob(request)[source]
Class to manage jobs manually called in a warehouse.
- Parameters:
request (pyramid.request.Request) – Current request.
- available(warehouse: Warehouse, caller: str = 'browse_view') OrderedDict | None [source]
Return a list of available jobs for the current warehouse.
- prepare(warehouse: Warehouse | None, form: Form, action: str) tuple[str, str | None] [source]
Prepare a job and a build.
- run(build_id: str)[source]
Execute a job on a build.
- Parameters:
build_id (str) – ID of a registered build.