link.version
Version()
Bases: Data
Representation of a Bip version.
A Version object represent a file or a group of files corresponding to an iteration of a Document. For example, if a document represents a "lighting scene in Maya", the different versions, or iterations of this file are represented with the Version object.
Unlike Projects, Items and Documents, Versions are not defined by any model. Their rules are defined by the upper DocumentModel.
Info
This class inherits from Data, like Project, Item and Document, since they share similar behaviour.
See bip.link.data.Data
for inherited methods.
Tip
All paths are standardized: They use the /
Unix separator.
Attributes:
Name | Type | Description |
---|---|---|
uid |
str
|
Bip unique identifier (uuid4). Edition is forbidden if this is an persistent (saved) entity. |
slug |
str
|
Version number. Same as the |
created_with |
str
|
Optional, name of the software used for creating the file(s). |
Source code in client/bip/link/version.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
author: User
property
creation_time: datetime
property
When the version has been added to the database.
Returns:
Name | Type | Description |
---|---|---|
datetime |
datetime
|
creation time. |
document: Document
property
Convenient alias for Item.parent
.
file: Union[str, None]
property
First file of the version.
Warning
Only works with single file. If the version has multiple files, use full_paths
instead.
Info
File can contain a substructure, with as many sub-folders as needed.
For a Bip version, a file can be my_file.ext
as well as sub/path/my_file.ext
.
Raises:
Type | Description |
---|---|
ValueError
|
The version has multiple files. |
Returns:
Name | Type | Description |
---|---|---|
list |
Union[str, None]
|
Collection of files. |
files: List[str]
property
List of files.
Info
Files can contain a substructure, with as many sub-folders as needed.
For a Bip version, a file can be my_file.ext
as well as sub/path/my_file.ext
.
Returns:
Name | Type | Description |
---|---|---|
list |
List[str]
|
Collection of files. |
folder_name: str
property
Folder name of the Version.
Warning
This is no the path of the file(s). The folder name is the formatted version number. Example: "v001"
.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
folder name. |
full_path: str
property
Full path of the version.
This path includes the file substructure.
Warning
Only works with single file. If the version has multiple files, use full_paths
instead.
Raises:
Type | Description |
---|---|
ValueError
|
The version has multiple files. |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Full path. |
full_paths: List[str]
property
List of full paths.
These paths include the file substructure.
If the version only has one file, prefer full_path
.
Returns:
Name | Type | Description |
---|---|---|
list |
List[str]
|
Collection of full paths for each file of the version. |
is_single: bool
property
Does the version has more than one file entry.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True is only one file, False otherwise. |
item: Item
property
modification_time: datetime
property
When the version has been changed on the database.
Returns:
Name | Type | Description |
---|---|---|
datetime |
datetime
|
modification time. |
number: int
property
Version number
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Version number. |
parent: Document
property
path: str
property
Root path of the version.
Warning
This path does not include the file(s) substructure.
If the parent Document is not collapsed (see Document.collapsed
), the folder name
is appended to the path:
Examples:
- Collapsed:
/path/to/version/
- Not collapsed:
/path/to/version/v001/
Return
str: Root path.
creation_time_to_text()
Human-readable creation time.
Format pattern: "%d/%m/%Y %H:%M:%S"
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Formatted creation time |
Source code in client/bip/link/version.py
327 328 329 330 331 332 333 334 335 |
|
delete()
Deletes the Version.
Deleting the Document deletes any Attribute attached to it.
Source code in client/bip/link/version.py
306 307 308 309 310 311 |
|
generate(document, files, number=None, author=None, published=False, auto_save=True, **kwargs)
classmethod
Generates a Version object.
By default, the generated Version 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 |
---|---|---|---|
document |
Document
|
Document: Parent document. |
required |
files |
Union[str, List[str]]
|
Union[str, List[str]]: Single file name or collection of file names.
The file name can contain a substructure, with as many sub-folders as needed.
It can be |
required |
author |
Optional[User]
|
Optional[User]: Author of the Version. If not specified, the current user (the one running Bip when executing the operation) is used. |
None
|
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 |
---|---|---|
Version |
Version
|
Generated Version. |
Source code in client/bip/link/version.py
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 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
get(document, number=None)
classmethod
Get a specific Version or all Versions from a Document.
It is possible to get a specific Version from its number
.
If no number is specified, the getter becomes a global getter and returns a collection of Versions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
document |
Document
|
Document: Document object to search within. |
required |
number |
Optional[int]
|
Optional[str]: Specific version number. (Default value = None) |
None
|
Raises:
Type | Description |
---|---|
TypeError
|
An argument has an unexpected type. |
LookupError
|
No matching entity found. |
Returns:
Type | Description |
---|---|
Union[List[Version], Version]
|
|
Union[List[Version], Version]
|
|
Source code in client/bip/link/version.py
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 |
|
get_from_filename(filename, document)
classmethod
Get all the Versions containing the given filename.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
str: Looked up filename. |
required |
document |
Document
|
Document: parent Document to look into. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
List[Version]
|
Collection of matching Versions. |
Source code in client/bip/link/version.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
|
get_latest(document, published_only=False)
classmethod
Get only the latest version of a Document.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
document |
Document
|
Document: parent Document to look into. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
Optional[Version]
|
Collection of matching Versions. |
Source code in client/bip/link/version.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
|
modification_time_to_text()
Human-readable modification time.
Format pattern: "%d/%m/%Y %H:%M:%S"
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Formatted modification time |
Source code in client/bip/link/version.py
337 338 339 340 341 342 343 344 345 |
|
save(force=False)
Saves the Version to the database.
If the Version is floating, saving makes it persistent.
Attributes changes are not applied to the database at modification. Saving the Version does.
Raises:
Type | Description |
---|---|
ValueError
|
Failed validation. |
TypeError
|
Failed validation. |
Source code in client/bip/link/version.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
get(document, number=None)
Convenient shortcut to Version.get
for getting a specific Version or all Versions.
Source code in client/bip/link/version.py
522 523 524 525 526 |
|
get_from_filename(filename, document)
Convenient shortcut to Version.get_from_filename
.
Source code in client/bip/link/version.py
572 573 574 |
|
get_latest_version(document, published_only=False)
Convenient shortcut to Version.get_latest
.
Source code in client/bip/link/version.py
567 568 569 |
|
get_version(document, number=None)
Convenient shortcut to Version.get
for getting a specific Version.
Source code in client/bip/link/version.py
529 530 531 |
|
get_versions(document)
Convenient shortcut to Version.get
for getting all Versions.
Source code in client/bip/link/version.py
534 535 536 |
|
new(document, files, author=None, auto_save=True, **kwargs)
Convenient shortcut to Version.generate
.
Source code in client/bip/link/version.py
540 541 542 543 544 545 546 547 548 |
|
new_version(document, files, number=None, author=None, published=False, auto_save=True, **kwargs)
Convenient shortcut to Version.generate
.
Source code in client/bip/link/version.py
551 552 553 554 555 556 557 558 559 560 561 562 563 |
|