Register¤
Register
¤
Represents the register element in an equipment register.
Specifying multiple sources allows for storing an equipment register across multiple files for the same team. Not specifying a source creates a new (empty) register.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sources
|
XMLSource | Element[str]
|
()
|
Source code in src/msl/equipment/schema.py
2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 |
|
NAMESPACE
class-attribute
instance-attribute
¤
NAMESPACE: str = (
"https://measurement.govt.nz/equipment-register"
)
Default XML namespace.
team
property
writable
¤
team: str
str — The name of the team that is responsible for the equipment register.
add
¤
add(equipment: Equipment) -> None
Add equipment to the register.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
equipment
|
Equipment
|
The equipment to add. |
required |
Source code in src/msl/equipment/schema.py
2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 |
|
find
¤
Find equipment in the register.
The following attributes are used in the search:
- keywords: Equipment
- description: Equipment
- manufacturer: Equipment
- model: Equipment
- serial: Equipment
- id: Equipment, Report, DigitalReport
- location: Equipment
- quantity: Measurand
- name: Component
- entered_by: Equipment, PerformanceCheck, Report
- checked_by: Equipment, PerformanceCheck, Report
- performed_by: Alteration, CompletedTask, PlannedTask
- comment: CVDEquation, Equation, File, Table, Deserialised, DigitalReport
- format: DigitalReport
- details: Alteration, Adjustment
- task: CompletedTask, PlannedTask
- asset_number: CapitalExpenditure
- service_agent: QualityManual
- technical_procedures: QualityManual
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern
|
str | Pattern[str]
|
A regular-expression pattern to use to find equipment. |
required |
flags
|
int
|
The flags to use to compile the |
0
|
Yields:
Type | Description |
---|---|
Equipment
|
Equipment that match the |
Source code in src/msl/equipment/schema.py
2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 |
|
get
¤
Get an Equipment item from the register.
This method will ignore all errors if the register does not contain the requested Equipment item.
Tip
You can also treat a register instance as a sequence of Equipment items.
Using the indexable notation on a register instance to access an Equipment item by using the alias of the equipment or the index within the register could raise an exception
>>> register["unknown-alias"]
Traceback (most recent call last):
...
ValueError: No equipment exists with the alias or id 'unknown-alias'
>>> register[243]
Traceback (most recent call last):
...
IndexError: list index out of range
whereas these errors can be silenced by using the get method
>>> assert register.get("unknown") is None
>>> assert register.get(243) is None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
int | str
|
The index number, equipment id value or the equipment alias value in the register. |
required |
Returns:
Type | Description |
---|---|
Equipment | None
|
The Equipment item if |
Source code in src/msl/equipment/schema.py
2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 |
|
tree
¤
tree(
namespace: str | None = "DEFAULT", indent: int = 4
) -> ElementTree[Element[str]]
Convert the Register class into an XML element tree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | None
|
The namespace to associate with the root element. If the value is
|
'DEFAULT'
|
indent
|
int
|
The number of spaces to indent sub elements. The value must be ≥ 0. This parameter is ignored if the version of Python is < 3.9. |
4
|
Returns:
Type | Description |
---|---|
ElementTree[Element[str]]
|
The Register as an ElementTree. |
Source code in src/msl/equipment/schema.py
2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 |
|