Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions carta/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def macro(self, target, variable):
@cached
def file_name(self):
"""The name of the image.

Returns
-------
string
Expand Down
6 changes: 6 additions & 0 deletions carta/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@

def parse_header(raw_header):
"""Parse raw image header entries from the frontend into a more user-friendly format.

Entries with T or F string values are automatically converted to booleans.

``HISTORY``, ``COMMENT`` and blank keyword entries are aggregated into single entries with list values and with ``'HISTORY'``, ``'COMMENT'`` and ``''`` as keys, respectively. An entry in the history list which begins with ``'>'`` will be concatenated with the previous entry.

Adjacent ``COMMENT`` entries are not concatenated automatically.

Any other header entries with no values are given values of ``None``.

Parameters
----------
raw_header : dict
The raw header entries received from the frontend.

Returns
-------
dict of string to string, integer, float, boolean, ``None`` or list of strings
Expand Down
7 changes: 7 additions & 0 deletions carta/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,12 @@ def description(self):

class MapOf(IterableOf):
"""A dictionary of keys and values which must match the given descriptors.

Parameters
----------
value_param : :obj:`carta.validation.Parameter`
The value parameter descriptor.

Attributes
----------
value_param : :obj:`carta.validation.Parameter`
Expand All @@ -557,6 +559,7 @@ def __init__(self, key_param, value_param, min_size=None, max_size=None):

def validate(self, value, parent):
"""Check if each element of the iterable can be validated with the given descriptor.

See :obj:`carta.validation.Parameter.validate` for general information about this method.
"""

Expand All @@ -573,6 +576,7 @@ def validate(self, value, parent):
@property
def description(self):
"""A human-readable description of this parameter descriptor.

Returns
-------
string
Expand Down Expand Up @@ -875,10 +879,13 @@ def fix_description(s):

def all_optional(*vargs):
"""Wrapper to make all parameters in an iterable optional.

For improved legibility in functions with many sequential optional parameters. Can also enable reuse of validation parameters in functions which call other functions.

Parameters
----------
*vargs : iterable of :obj:`carta.validation.Parameter` objects

Returns
-------
iterable of :obj:`carta.validation.Parameter` objects
Expand Down