link.item
Item()
Bases: Data
Representation of a Bip item.
An Item is the highest data entity in a Bip project. It is usually used to represent shots and assets, but it can represent any type of entity needed for the project.
Items are defined by ItemModels, which define a set of rules and behaviours for the Item. For example the model controls the naming convention.
Info
This class inherits from Data, like Project, Document and Version, since they share similar behaviour.
See bip.link.data.Data
for inherited methods.
Attributes:
Name | Type | Description |
---|---|---|
uid |
str
|
Bip unique identifier (uuid4). Edition is forbidden if this is an persistent (saved) entity. |
slug |
str
|
Human-readable unique identifier, namespaced in the parent model scope. |
name |
str
|
Name of the project. |
folder_name |
str
|
Folder name for path generation. |
description |
str
|
Short description of the item. |
model |
ItemModel
|
Bip item model object. |
Source code in client/bip/link/item.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
children_count: int
property
Number of Documents parented to the Item.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Documents count. |
has_children: bool
property
Does the Item have Documents.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the Item has Documents, False otherwise. |
parent: Project
property
path: str
property
Dynamic path of the item directory.
The path is dynamically generated by the running Bip client, based on the working directory.
Warning
The path may differ from a machine to another since the path uses the working_directory
local setting, which might vary between machines, depending on the client config.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path of the item directory. |
delete(safe=True)
Deletes the Item.
By default, if the Item has Documents parented to it, the deletion won't be accepted,
unless safe
is set to True.
Deleting the Item deletes any downstream entity: Document, Version, Group (children only), Task and Attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
safe |
bool
|
bool: Prevents the deletion if the Item has children (Documents) (Default value = True) |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If safe is True and the Item has children. |
Source code in client/bip/link/item.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
generate(name, model=None, groups=(), auto_save=True, **kwargs)
classmethod
Generates an Item object.
By default, the generated Item is saved straight after creation. In some cases, it can be useful to get the
floating (not recorded on the database) object in order to perform further operation, and save after that.
That can be achieved by setting auto_save
to False.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
str: Name of the new item. |
required |
model |
Optional[ItemModel]
|
Optional[Union[ItemModel, str]]: Model of the new item. Can be left to None if the project
has a |
None
|
groups |
Union[List, Tuple]
|
Union[List, Tuple]: If the ItemModel has required_memberships, list of the mandatory groups (Default value = ()) |
()
|
auto_save |
bool
|
bool: If True, the returned object is saved. Otherwise it is floating. (Default value = True) |
True
|
**kwargs |
Any non-mandatory valid attribute of Item can be passed. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
Failed validation, if auto_save is True. |
TypeError
|
Failed validation, if auto_save is True. |
Returns:
Name | Type | Description |
---|---|---|
Item |
Item
|
Generated Item. |
Source code in client/bip/link/item.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
get(model, slug=None, uid=None, group=None)
classmethod
Get a specific Item or all Items from an ItemModel.
It is possible to get a specific Item from its uid
or its slug
.
When providing one, the other can be left to None. If none of these two parameters are specified,
The getter becomes a global getter and returns a collection of Items.
If searching by slug and if the provided ItemModel has has_uniqueness_scope to True, a Group or its slug must be provided in order to defined the searching scope.
Examples:
project = link.project.get(slug="example")
asset = project.get_item_model(slug="asset")
shot = project.get_item_model(slug="shot")
# By slug
Item.get(model=asset, slug="john-doe")
# By uid
asset = project.get_item_model(slug="asset")
Item.get(model=asset, uid="46c12269-d5d9-40fb-8554-ed1dd9b46422")
# By slug with namespace group
Item.get(model=shot, slug="sh0100", group="seq10")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
ItemModel
|
Union[ItemModel, str]: ItemModel object to search within. (Default value = None) |
required |
slug |
Optional[str]
|
Optional[str]: Slug of an Item. If specified, |
None
|
uid |
Optional[str]
|
Optional[str]: Uid of an Item. If specified, |
None
|
group |
Optional[Union[Group, str]]
|
Optional[Union[Group, str]]: If the ItemModel has a uniqueness scope, Group object (or slug) in order to define the searching scope. |
None
|
Raises:
Type | Description |
---|---|
TypeError
|
An argument has an unexpected type. |
LookupError
|
No matching entity found. |
Returns:
Type | Description |
---|---|
Union[Item, List[Item]]
|
|
Union[Item, List[Item]]
|
|
Source code in client/bip/link/item.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
|
get_from_project(project, uid=None)
classmethod
Get a specific Item or all Items from a Project.
It is possible to get a specific Item from its uid
.
If no uid is provided, a collection of all the project Items is returned.
Info
This getter does not allow to search by slug since slugs are namespaced by ItemModel, therefore there can be identical slugs within the same project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
Project
|
Project: Project object to search within. |
required |
uid |
Optional[str]
|
Optional[str]: Uid of an Item. (Default value = None) |
None
|
Raises:
Type | Description |
---|---|
TypeError
|
An argument has an unexpected type. |
LookupError
|
No matching entity found. |
Returns:
Type | Description |
---|---|
|
|
|
Source code in client/bip/link/item.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
|
get_task(model, slug=None, uid=None)
Convenient class implementation of: bip.link.task.get_task
.
Warning
The signature of Item.get_task()
and bip.link.task.get_task
are different since Item.get_task()
passes itself to the function as item=self
.
Source code in client/bip/link/item.py
233 234 235 236 237 238 239 240 241 242 |
|
get_task_model(slug=None, uid=None)
Convenient class implementation of: bip.link.task.get_model
.
Warning
The signature of Item.get_task_model()
and bip.link.task.get_model
are different since Item.get_task_model()
passes itself to the function as item=self
.
Source code in client/bip/link/item.py
269 270 271 272 273 274 275 276 277 278 |
|
get_task_models()
Convenient class implementation of: bip.link.task.get_models
.
Warning
The signature of Item.get_task_models()
and bip.link.task.get_models
are different since Item.get_task_models()
passes itself to the function as item=self
.
Source code in client/bip/link/item.py
280 281 282 283 284 285 286 287 |
|
get_tasks(model=None, open_only=False)
Convenient class implementation of: bip.link.task.get_tasks
.
Warning
The signature of Item.get_task()
and bip.link.task.get_tasks
are different since Item.get_tasks()
passes itself to the function as item=self
.
Source code in client/bip/link/item.py
244 245 246 247 248 249 250 251 |
|
new_document(model, task=None, groups=(), element=None, auto_save=True, **kwargs)
Convenient class implementation of: bip.link.document.new
.
Warning
The signature of Item.new_document()
and bip.link.document.new
are different since Item.new_document()
passes itself to the function as item=self
.
Source code in client/bip/link/item.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
new_task(model, name=None, status=None, auto_save=True, **kwargs)
Convenient class implementation of: bip.link.task.new
.
Warning
The signature of Item.new_task()
and bip.link.task.new
are different since Item.new_task()
passes itself to the function as item=self
.
Source code in client/bip/link/item.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
save()
Saves the Item to the database.
If the Item is floating, saving makes it persistent.
Attributes changes are not applied to the database at modification. Saving the Item does.
Raises:
Type | Description |
---|---|
ValueError
|
Failed validation. |
TypeError
|
Failed validation. |
Source code in client/bip/link/item.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
ItemModel()
Bases: BipObject
Representation of a Bip item model.
The ItemModel is a template, which sets some rules that any Item modelged with this model must follow.
Attributes:
Name | Type | Description |
---|---|---|
uid |
str
|
Bip unique identifier (uuid4). Edition is forbidden if this is an persistent (saved) entity. |
slug |
str
|
Human-readable unique identifier. |
name |
str
|
Name of the model. |
plural |
int
|
Plural of the name. |
path_pattern |
str
|
Path pattern for Items path generation. |
use_suffix |
bool
|
If True, the items must have a suffix. |
suffix_format |
str
|
If use_suffix, "alpha" ( |
suffix_length |
int
|
If use_suffix, length of the suffix. |
suffix_name_separator |
str
|
If use_suffix, separation string between the name and the suffix. |
suffix_folder_name_separator |
str
|
If use_suffix, separation string between the folder name and the suffix. |
default_suffix |
str
|
If use_suffix, default suffix. |
folder_name_case_hint |
str
|
Case hint (see |
name_case_hint |
str
|
Case hint (see |
name_pattern |
str
|
Regular expression used to validate the name when saving an item. |
name_hint |
str
|
Example of a valid name (used for UI). |
force_name_pattern |
bool
|
If True, the name pattern must be matched in order to create or save the item. |
folder_name_pattern |
str
|
Regular expression used to validate the name when saving an item. |
folder_name_hint |
str
|
Example of a valid folder name (used for UI). |
force_folder_name_pattern |
bool
|
If True, the folder name pattern must be matched in order to create or save the item. |
Source code in client/bip/link/item.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
|
children_count: int
property
Number of Items linked to the ItemModel.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Item count. |
has_children: bool
property
Does the ItemModel have Items.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the ItemModel has Items, False otherwise. |
has_memberships: bool
property
Does the ItemModel has memberships.
Lightweight method avoiding querying the database.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the ItemModel has memberships, False otherwise. |
has_optional_memberships: bool
property
Does the ItemModel has optional memberships.
This utility method does not query the database, and is a helper for checking if it is necessary to get the optional memberships.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the ItemModel has optional memberships, False otherwise. |
has_required_memberships: bool
property
Does the ItemModel requires memberships.
This utility method does not query the database, and is a helper for checking if it is necessary to get the required memberships.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the ItemModel requires memberships, False otherwise. |
has_uniqueness_scope: bool
property
Does the ItemModel has a uniqueness scope.
This utility method does not query the database, and is a helper for checking if it is necessary to get the uniqueness scope.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the ItemModel has a uniqueness scope, False otherwise. |
path: str
property
Dynamic path of the item model.
The path is dynamically generated by the running Bip client, based on the working directory.
Warning
The path may differ from a machine to another since the path uses the working_directory
local setting, which might vary between machines, depending on the client config.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path of the item model directory. |
project: Project
property
add_membership(group_model, required=True)
Adds a required or optional membership.
Tip
Required or optional memberships are GroupModel that any new Project created with the current ProjectModel must or can be member of in order to be saved.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_model |
GroupModel
|
GroupModel: GroupModel. |
required |
required |
bool |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
Failed validation. |
TypeError
|
Failed validation. |
Source code in client/bip/link/item.py
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 |
|
delete(safe=True)
Deletes the ItemModel.
By default, if the ItemModel has Items parented to it, the deletion won't be accepted,
unless safe
is set to True.
Deleting the ItemModel deletes any downstream entity: Item, Document,Version, Group (local only), Task and Attribute.
Warning
If the project has a locked model, the operation is not allowed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
safe |
bool
|
bool: Prevents the deletion if the ItemModel has children (Items) (Default value = True) |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If safe is True and the ItemModel has children. |
Source code in client/bip/link/item.py
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
|
generate(name, project, auto_save=True, **kwargs)
classmethod
Generates an ItemModel object.
By default, the generated ItemModel is saved straight after creation.
In some cases, it can be useful to get the floating (not recorded on the database)
object in order to perform further operation, and save after that.
That can be achieved by setting auto_save
to False.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
str: Name of the new model. |
required |
project |
Project
|
str: Parent Project of the new model. |
required |
auto_save |
bool
|
bool: If True, the returned object is saved. Otherwise it is floating. (Default value = True) |
True
|
**kwargs |
Any non-mandatory valid attribute of ItemModel can be passed. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
Failed validation, if auto_save is True. |
TypeError
|
Failed validation, if auto_save is True. |
Returns:
Name | Type | Description |
---|---|---|
ItemModel |
ItemModel
|
Generated ItemModel. |
Source code in client/bip/link/item.py
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 |
|
get(project, slug=None, uid=None)
classmethod
Get a specific ItemModel or all ProjectModels.
It is possible to get a specific ItemModel from its uid
or its slug
.
When providing one, the other can be left to None. If none of these two parameters are filled,
The getter becomes a global getter and returns a collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
str: Parent Project. |
required | |
slug |
Optional[str]
|
Optional[str]: Slug of a ItemModel. If specified, |
None
|
uid |
Optional[str]
|
Optional[str]: Uid of a ItemModel. If specified, |
None
|
Raises:
Type | Description |
---|---|
LookupError
|
No matching ItemModel found. |
Returns:
Type | Description |
---|---|
Union[ItemModel, List[ItemModel], None]
|
|
Union[ItemModel, List[ItemModel], None]
|
|
Source code in client/bip/link/item.py
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
|
get_item(slug=None, uid=None, group=None)
Convenient class implementation of: bip.link.item.get_item
.
Warning
The signature of ItemModel.get_item()
and bip.link.item.get_item()
are different since ItemModel.get_item()
passes itself to the function as model=self
.
Source code in client/bip/link/item.py
782 783 784 785 786 787 788 789 790 791 |
|
get_items()
Convenient class implementation of: bip.link.item.get_items
.
Warning
The signature of ItemModel.get_items()
and bip.link.item.get_items()
are different since ItemModel.get_items()
passes itself to the function as model=self
.
Source code in client/bip/link/item.py
793 794 795 796 797 798 799 800 |
|
get_task_models()
Convenient class implementation of: bip.link.task.get_models_from_item_model
.
Warning
The signature of ItemModel.get_task_models()
and bip.link.task.get_models_from_item_model()
are different since ItemModel.get_task_models()
passes itself to the function as model=self
.
Source code in client/bip/link/item.py
934 935 936 937 938 939 940 941 |
|
get_uniqueness_scope()
Convenient class implementation of: bip.link.group.get_uniqueness_scope
.
Warning
The signature of ItemModel.get_uniqueness_scope()
and bip.link.item.get_uniqueness_scope()
are different since ItemModel.get_uniqueness_scope()
passes itself to the function as entity=self
.
Source code in client/bip/link/item.py
835 836 837 838 839 840 841 842 |
|
new(name, groups=(), auto_save=True, **kwargs)
Convenient class implementation of: bip.link.item.new_item
.
Warning
The signature of ItemModel.new_item()
and bip.link.item.new_item()
are different since ItemModel.new_item()
passes itself to the function as model=self
.
Source code in client/bip/link/item.py
805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
|
new_item(name, groups=(), auto_save=True, **kwargs)
Convenient class implementation of: bip.link.item.new_item
.
Warning
The signature of ItemModel.new_item()
and bip.link.item.new_item()
are different since ItemModel.new_item()
passes itself to the function as model=self
.
Source code in client/bip/link/item.py
820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
|
save()
Saves the ItemModel to the database.
If the ItemModel is floating, saving makes it persistent.
Attributes changes are not applied to the database at modification. Saving the ItemModel does.
Warning
If the project has a locked model, the operation is not allowed.
Raises:
Type | Description |
---|---|
ValueError
|
Failed validation. |
TypeError
|
Failed validation. |
PermissionError
|
The Project doesn't allow post-creation changes of its data model. |
Source code in client/bip/link/item.py
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
|
set_uniqueness_scope(group_model)
Sets a uniqueness scope.
Warning
If the project has a locked model, the operation is not allowed.
Tip
A uniqueness scope is a GroupModel (that must also be a required membership) that will determine the uniqueness scope for the slug and the folder name. For example. If an ItemModel "asset" has a GroupModel "category" as required membership and uniqueness scope, two assets in two different members of category, like characters and props can both be called "AssetA".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_model |
GroupModel
|
GroupModel: Required GroupModel. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Failed validation. |
TypeError
|
Failed validation. |
Source code in client/bip/link/item.py
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 |
|
get(model, slug=None, uid=None, group=None)
Convenient shortcut to Item.get
for getting a specific Item or all Items.
Source code in client/bip/link/item.py
1062 1063 1064 1065 1066 1067 1068 1069 |
|
get_folder_names(project)
Get all Projects folder names.
Utility function for path building.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, str]
|
Pair or uid and folder names. |
Source code in client/bip/link/item.py
1156 1157 1158 1159 1160 1161 1162 1163 1164 |
|
get_from_project(project, uid=None)
Convenient shortcut to Item.get_from_project
for getting a specific Item or all Items from a Project.
Source code in client/bip/link/item.py
1072 1073 1074 1075 1076 |
|
get_item(model, slug=None, uid=None, group=None)
Convenient shortcut to Item.get
for getting a specific Item.
Raises:
Type | Description |
---|---|
ValueError
|
No slug and no uid provided. |
Source code in client/bip/link/item.py
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
|
get_items(model)
Convenient shortcut to Item.get
for getting all Items.
Source code in client/bip/link/item.py
1095 1096 1097 |
|
get_items_by_groups(model, groups)
Convenient shortcut to Item.get
for getting all Items.
Source code in client/bip/link/item.py
1100 1101 1102 |
|
get_model(project, slug=None, uid=None)
Convenient shortcut to ItemModel.get
for specific ItemModel.
Raises:
Type | Description |
---|---|
ValueError
|
No slug and no uid provided. |
Source code in client/bip/link/item.py
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 |
|
get_models(project)
Convenient shortcut to ItemModel.get
for all ItemModel.
Source code in client/bip/link/item.py
1140 1141 1142 |
|
new(name, model=None, groups=(), auto_save=True, **kwargs)
Convenient shortcut to Item.generate
.
Source code in client/bip/link/item.py
1105 1106 1107 1108 1109 1110 1111 1112 1113 |
|
new_item(name, model=None, groups=(), auto_save=True, **kwargs)
Convenient shortcut to Item.generate
.
Source code in client/bip/link/item.py
1116 1117 1118 1119 1120 1121 1122 1123 1124 |
|
new_model(name, project, auto_save=True, **kwargs)
Convenient shortcut to ItemModel.generate
.
Source code in client/bip/link/item.py
1145 1146 1147 1148 1149 1150 1151 1152 |
|