trestle.core.commands.href
trestle.core.commands.href
¤
Trestle Href Command.
Attributes¤
logger = logging.getLogger(__name__)
module-attribute
¤
Classes¤
HrefCmd
¤
Bases: CommandPlusDocs
Change href of import in profile to point to catalog in trestle workspace.
This command is needed when generating an SSP with a profile that imports a catalog from a temporary location different from the final intended location of the catalog. Omit the href argument to see the list of current imports in the profile.
Source code in trestle/core/commands/href.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
Attributes¤
name = 'href'
class-attribute
instance-attribute
¤
Functions¤
change_import_href(trestle_root, profile_name, new_href, import_num)
classmethod
¤
Change the href of the import in the profile to point to a catalog in a specific location.
A Profile has an Imports list containing at least one href of a catalog or profile to be imported. If the item being referenced is currently in the same trestle workspace as the main profile, the original href is likely different from the one needed to access the item from the profile. Therefore, in order for trestle to find the item directly from the profile, the href must be modified in a way that trestle can load it.
If the item is already at the link referred to by the href as a valid URI or absolute file path then no change is needed. But if the item is being worked on in the same trestle directory as the profile, the href should be modified to something like trestle://catalogs/my_catalog/catalog.json
This change only needs to be made once to the profile while the profile is being used to generate SSP's from the local item, but if the final profile is released the href would need to be changed to the intended final location of the referenced item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trestle_root | Path | trestle_root for this call | required |
profile_name | str | Name of profile already imported into trestle containing href's to be changed | required |
new_href | str | New value for the href of the import. If blank just list the hrefs | required |
import_num | int | Item number of the href to change. | required |
Returns:
Type | Description |
---|---|
int | 0 on success, 1 on failure |
Assumptions and requirements
The profile must be a valid profile in the trestle workspace. The import must either be a valid uri, including local file, or trestle:// The original href is not checked and will be overwritten. If href is the empty string, just list all hrefs.
Future work
Allow multiple imports with matching hrefs. Allow href to point to profile in trestle rather than catalog, and by name. Allow full chaining of linked catalogs and profiles.
Source code in trestle/core/commands/href.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
Functions¤
handler: python