|
3 | 3 | Image objects should not be instantiated directly, and should only be created through methods on the :obj:`carta.session.Session` object. |
4 | 4 | """ |
5 | 5 | from .constants import Colormap, Scaling, SmoothingMode, ContourDashMode, Polarization, CoordinateSystem, SpatialAxis |
6 | | -from .util import Macro, cached |
| 6 | +from .util import Macro, cached, BasePathMixin |
7 | 7 | from .units import PixelValue, AngularSize, WorldCoordinate |
8 | 8 | from .validation import validate, Number, Color, Constant, Boolean, NoneOr, IterableOf, Evaluate, Attr, Attrs, OneOf, Size, Coordinate, all_optional |
9 | 9 | from .metadata import parse_header |
10 | 10 |
|
11 | 11 |
|
12 | | -class Image: |
| 12 | +class Image(BasePathMixin): |
13 | 13 | """This object corresponds to an image open in a CARTA frontend session. |
14 | 14 |
|
15 | 15 | This class should not be instantiated directly. Instead, use the session object's methods for opening new images or retrieving existing images. |
@@ -100,64 +100,6 @@ def from_list(cls, session, image_list): |
100 | 100 | def __repr__(self): |
101 | 101 | return f"{self.session.session_id}:{self.image_id}:{self.file_name}" |
102 | 102 |
|
103 | | - def call_action(self, path, *args, **kwargs): |
104 | | - """Convenience wrapper for the session object's generic action method. |
105 | | -
|
106 | | - This method calls :obj:`carta.session.Session.call_action` after prepending this image's base path to the path parameter. |
107 | | -
|
108 | | - Parameters |
109 | | - ---------- |
110 | | - path : string |
111 | | - The path to an action relative to this image's frame store. |
112 | | - *args |
113 | | - A variable-length list of parameters. These are passed unmodified to the session method. |
114 | | - **kwargs |
115 | | - Arbitrary keyword parameters. These are passed unmodified to the session method. |
116 | | -
|
117 | | - Returns |
118 | | - ------- |
119 | | - object or None |
120 | | - The unmodified return value of the session method. |
121 | | - """ |
122 | | - return self.session.call_action(f"{self._base_path}.{path}", *args, **kwargs) |
123 | | - |
124 | | - def get_value(self, path): |
125 | | - """Convenience wrapper for the session object's generic method for retrieving attribute values. |
126 | | -
|
127 | | - This method calls :obj:`carta.session.Session.get_value` after prepending this image's base path to the *path* parameter. |
128 | | -
|
129 | | - Parameters |
130 | | - ---------- |
131 | | - path : string |
132 | | - The path to an attribute relative to this image's frame store. |
133 | | -
|
134 | | - Returns |
135 | | - ------- |
136 | | - object |
137 | | - The unmodified return value of the session method. |
138 | | - """ |
139 | | - return self.session.get_value(f"{self._base_path}.{path}") |
140 | | - |
141 | | - def macro(self, target, variable): |
142 | | - """Convenience wrapper for creating a :obj:`carta.util.Macro` for an image property. |
143 | | -
|
144 | | - This method prepends this image's base path to the *target* parameter. If *target* is the empty string, the base path will be substituted. |
145 | | -
|
146 | | - Parameters |
147 | | - ---------- |
148 | | - target : str |
149 | | - The target frontend object. |
150 | | - variable : str |
151 | | - The variable on the target object. |
152 | | -
|
153 | | - Returns |
154 | | - ------- |
155 | | - :obj:carta.util.Macro |
156 | | - A placeholder for a variable which will be evaluated dynamically by the frontend. |
157 | | - """ |
158 | | - target = f"{self._base_path}.{target}" if target else self._base_path |
159 | | - return Macro(target, variable) |
160 | | - |
161 | 103 | # METADATA |
162 | 104 |
|
163 | 105 | @property |
|
0 commit comments