A reference to a file in a files listing from a manifest or data file.
| 484 | |
| 485 | @attr.attributes(slots=True) |
| 486 | class FileReference(ModelMixin): |
| 487 | """ |
| 488 | A reference to a file in a files listing from a manifest or data file. |
| 489 | """ |
| 490 | path = String( |
| 491 | label='Path of this file.', |
| 492 | help='The file or directory POSIX path. The actual root for this path ' |
| 493 | 'is specific to a datafile format. For instance it is the rootfs ' |
| 494 | 'root for Linux system packages.', |
| 495 | repr=True, |
| 496 | ) |
| 497 | |
| 498 | size = Integer( |
| 499 | label='file size', |
| 500 | help='size of the file in bytes', |
| 501 | repr=False, |
| 502 | ) |
| 503 | |
| 504 | sha1 = String( |
| 505 | label='SHA1 checksum', |
| 506 | help='SHA1 checksum for this file in hexadecimal', |
| 507 | repr=False, |
| 508 | ) |
| 509 | |
| 510 | md5 = String( |
| 511 | label='MD5 checksum', |
| 512 | help='MD5 checksum for this file in hexadecimal', |
| 513 | repr=False, |
| 514 | ) |
| 515 | |
| 516 | sha256 = String( |
| 517 | label='SHA256 checksum', |
| 518 | help='SHA256 checksum for this file in hexadecimal', |
| 519 | repr=False, |
| 520 | ) |
| 521 | |
| 522 | sha512 = String( |
| 523 | label='SHA512 checksum', |
| 524 | help='SHA512 checksum for this file in hexadecimal', |
| 525 | repr=False, |
| 526 | ) |
| 527 | |
| 528 | extra_data = Mapping( |
| 529 | label='extra data', |
| 530 | help='A mapping of arbitrary extra file reference data.', |
| 531 | ) |
| 532 | |
| 533 | def update(self, other): |
| 534 | """ |
| 535 | Update this reference with an other file reference only for non-empty |
| 536 | values. |
| 537 | """ |
| 538 | for name, value in other.to_dict().items(): |
| 539 | if not value: |
| 540 | continue |
| 541 | current = getattr(self, name, None) |
| 542 | if not current: |
| 543 | setattr(self, name, value) |