编程参考¶
CGTeamWork python client for humans.
-
cgtwq.
login
(account, password)[源代码]¶ Login on server.
- 参数
account (str) – Account name.
password (str) – Password.
- 引发
ValueError – When login fail.
- 返回
Account information.
- 返回类型
AccountInfo
-
cgtwq.
get_account
(token=None)[源代码]¶ Get account from token.
- 参数
token (str) – Server token
- 返回
Account name.
- 返回类型
str
-
cgtwq.
get_account_id
(token=None)[源代码]¶ Get account id from token.
- 参数
token (str) – Server token
- 返回
Account id.
- 返回类型
str
-
class
cgtwq.
DesktopClient
(socket_url=None)[源代码]¶ Communicate with a CGTeamWork official GUI clients.
-
call
(controller, method, **kwargs)[源代码]¶ Call method on the cgteamwork client.
- 参数
controller (str) – Client defined controller name.
method (str) – Client defined method name on the controller.
**kwargs – Client defined method keyword arguments.
- 返回
Received data.
- 返回类型
dict or str
-
refresh
(database, module)[源代码]¶ Refresh specified view in client if matched view is opened.
- 参数
database (text_type) – Database of view.
module (text_type) – Module of view.
-
-
class
cgtwq.
Database
(name)[源代码]¶ Database on server.
-
create_field
(sign, type_, name=None, label=None)¶ Create new field in the module.
- 参数
sign (str) – Field sign
type_ (str) – Field type, see core.FIELD_TYPES.
name (str, optional) – Defaults to None. Field english name.
label (str, optional) – Defaults to None. Field chinese name.
-
delete_field
(field_id)¶ Delete field in the module.
- 参数
id_ (str) – Field id.
-
filter
(*filters)[源代码]¶ Filter modules in this database.
- 参数
*filters (FilterList, Filter) – Filters for server.
- 返回
Modules
- 返回类型
tuple[Module]
-
get_data
(key, is_user=True)¶ Get additional data set in this database.
- 参数
key (text_type) – Data key.
is_user (bool, optional) – Defaults to True.
is_user is True, this data will be user specific. (If) –
- 返回
Data value.
- 返回类型
text_type
-
get_field
(filters)¶ - Get one field in the database.
filters (Filter or FilterList): Filter.
- 返回
Field information.
- 返回类型
FieldMeta
-
get_fields
(filters=None)¶ - Get fields in the database.
filters (Filter or FilterList, optional): Defaults to None. Filter.
- 返回
Field information.
- 返回类型
tuple[FieldMeta]
-
get_fileboxes
(filters=None, id_=None)¶ Get fileboxes in this database.
- 参数
filters (FilterList, optional) – Defaults to None. Filters to get filebox.
id_ (text_type, optional) – Defaults to None. Filebox id.
- 引发
ValueError – Not enough arguments.
ValueError – No matched filebox.
- 返回
namedtuple for (‘id’, ‘pipeline_id’, ‘title’)
- 返回类型
tuple[FileBoxCategoryInfo]
-
get_pipelines
(*filters)¶ Get piplines from database.
- 参数
*filters (FilterList) – Filter to get pipeline.
- 返回
namedtuple for (‘id’, ‘name’, ‘module’)
- 返回类型
tuple[PipelineInfo]
-
get_software
(name)¶ Get software path for this database.
- 参数
name (text_type) – Software name.
- 返回
Path set in 系统设置 -> 软件设置.
- 返回类型
path
-
set_data
(key, value, is_user=True)¶ Set additional data in this database.
- 参数
key (text_type) – Data key.
value (text_type) – Data value
is_user (bool, optional) – Defaults to True.
is_user is True, this data will be user specific. (If) –
-
property
token
¶ User token.
-
-
class
cgtwq.
Filter
(key, value, operator=None)[源代码]¶ CGTeamWork style filter.
-
class
cgtwq.
FilterList
(list_)[源代码]¶ CGTeamWork style filter list.
-
class
cgtwq.
Module
(name, database, module_type='task')[源代码]¶ Module(Database table) in database.
-
count
(*filters, **kwargs)[源代码]¶ Count matched entity in database.
- 参数
\*filters (FilterList, Filter) – Filters for server.
**kwargs – namespace (str, optional): Default field namespace.
- 返回
Count value.
- 返回类型
int
-
count_history
(filters)¶ Count history records in the module.
- 参数
filters (Filter or FilterList) – History filters.
- 返回
Records count.
- 返回类型
int
-
create
(kwargs=None, **data)[源代码]¶ Create entry from data.
- 参数
kwargs (dict) –
Any] (**data[str,) – Data to create a entry.
- **data:
namespace (str, optional): Default field namespace.
-
create_field
(sign, type_, name=None, label=None)¶ Create new field in the module.
- 参数
sign (str) – Field sign
type_ (str) – Field type, see core.FIELD_TYPES.
name (str, optional) – Defaults to None. Field english name.
label (str, optional) – Defaults to None. Field chinese name.
-
delete_field
(id_)¶ Delete field in the module.
- 参数
id_ (str) – Field id.
-
distinct
(*filters, **kwargs)[源代码]¶ Get distinct value in the module.
- 参数
*filters (FilterList, Filter) – Filters for server.
**kwargs –
- **kwargs:
key: Distinct key, defaults to field of first filter. namespace (str, optional): Default field namespace.
- 返回
tuple
-
fields
()¶ Get fields in this module.
-
filter
(*filters, **kwargs)[源代码]¶ Create selection with filter on this module.
- 参数
*filters (FilterList, Filter) – Filters for server.
**kwargs –
- **kwargs:
namespace (str, optional): Default field namespace.
- 返回
Created selection.
- 返回类型
-
format_field
(name)¶ Formatted field name for this module.
- 参数
name (text_type) – Short field name.
- 返回
Full field name, for server.
- 返回类型
text_type
-
format_filters
(filters)¶ Format field name in filters.
- 参数
filters (FilterList, Filter) – Format target.
- 返回
Formatted filters.
- 返回类型
-
get_history
(filters)¶ - Get history record from the module.
filters (Filter or FilterList): History filters.
- 返回
History records.
- 返回类型
tuple[HistoryInfo]
-
pipelines
()[源代码]¶ All pipeline in this module.
- 返回
namedtuple for (‘id’, ‘name’, ‘module’).
- 返回类型
tuple[Pipeline]
-
select
(*id_list)[源代码]¶ Create selection on this module.
- 参数
*id_list (text_type) – Id list to select.
- 返回
Created selection.
- 返回类型
-
property
token
¶ User token.
-
undo_history
(history)¶ Undo a history.
- 参数
history (HistoryInfo) – History information.
-
-
class
cgtwq.
PluginMeta
(uuid)[源代码]¶ CGTeamWork plug-in metadata.
-
classmethod
filter
(filters=None, token=None)[源代码]¶ Filter plugins from server.
- 参数
filters (Filter or FilterList, optional) – Defaults to None. Plugin filter
token (str, optional) – Defaults to None. User token.
- 返回
Matched plug-ins.
- 返回类型
list[Plugin]
-
classmethod
from_info
(info)[源代码]¶ Initialize Plugin object from info.
- 参数
info (PluginInfo) – Plugin information.
- 返回
Plugin
-
get_argument
(key, token=None)[源代码]¶ Get argument information.
- 参数
key (str) – Argument key.
token (str, optional) – Defaults to None. User token.
- 返回
Plug-in argument information.
- 返回类型
PluginArgumentInfo
-
classmethod
-
class
cgtwq.
Entry
(module, id_)[源代码]¶ A selection that only has one item.
-
get_fields
(*fields, **kwargs)[源代码]¶ Get multiple fields.
- 返回
Result fields with exactly same order with fields.
- 返回类型
tuple
Select related entries.
- 参数
*filters – Pipeline filters.
- 返回
Selection
-
-
class
cgtwq.
Selection
(module, *id_list)[源代码]¶ Selection with all feature.
- 引发
EmptySelection – when selection size is 0.
-
count
(*filters)[源代码]¶ Count matched entity in the selection.
- 参数
*filters (Filter,FilterList) – Filters.
- 返回
Count value.
- 返回类型
int
-
distinct
(*filters, **kwargs)[源代码]¶ Get distinct value in the selection.
- 参数
*filters (FilterList, Filter) – Filters for server.
**kwargs –
- **kwargs:
key: Distinct key, defaults to field of first filter.
- 返回
tuple
-
filter
(*filters)[源代码]¶ Filter selection again.
- 参数
*filters (Filter,FilterList) – Additional filters.
- 返回
Filtered selection.
- 返回类型
-
classmethod
from_data
(**kwargs)[源代码]¶ Get selection from dictionary-like data.
- 参数
**kwargs – database(str): Database name. module(str): Module name. module_type(str): Module type. id_list(list): Id list.
-
get_fields
(*fields, **kwargs)[源代码]¶ Get field information for the selection.
- 参数
*fields – Server defined field sign.
**kwargs –
- **kwargs:
namespace (str, optional): Default namespace for key.
- 返回
Optimized tuple object contains fields data.
- 返回类型
-
get_folder
(*sign_list)[源代码]¶ Get signed folder path.
- 参数
sign_list (six.text_type) – Sign name defined in CGTeemWork: 项目设置 -> 目录文件 -> 标识
- 返回
- Server returned path dictionary.
id as key, path as value.
- 返回类型
dict
-
get_image
(field='image')¶ Get imageinfo used on the field.
- 参数
field (six.text_type) – Defaults to ‘image’, Server defined field name,
- 返回
Image information.
- 返回类型
set[ImageInfo]
-
has_permission_on_status
(field)¶ Return if user has permission to edit field.
- 参数
field (str) – Field name.
- 返回
bool
-
set_fields
(kwargs=None, **data)[源代码]¶ Set field data for the selection.
- 参数
kwargs (dict) –
**data – Field name as key, Value as value.
- kwargs:
namespace (str, optional): Default namespace for key.
-
set_image
(path, field='image')¶ Set image for the field.
- 参数
field (six.text_type) – Defaults to ‘image’, Server defined field name,
path (six.text_type) – File path.
- 返回
Uploaded image.
- 返回类型
ImageInfo
-
submit
(pathnames=(), filenames=(), note='')¶ Submit file to task, then change status to Check.
- 参数
pathnames (tuple, optional) – Defaults to (). Server pathnames.
filenames (tuple, optional) – Defaults to (). Local filenames.
note (str, optional) – Defaults to “”. Submit note.
-
to_entry
()[源代码]¶ Convert selection to one entry.
- 引发
ValueError – Not exactly one selected item.
- 返回
Entry.
- 返回类型
-
property
token
¶ User token.