Utils
combine_text(lines)
¶
Combines several lines of text together into a str and returns it. If the text strips down to the empty string, None is returned. Only single characters are inserted between lines even if there are multiple new lines between text in the lines parameter.
:param lines: a number of lines of text in an iterable of strs :return: the combined text or None if no text results after combining
Source code in dataimporter/emu/views/utils.py
113 114 115 116 117 118 119 120 121 122 123 124 | |
emu_date(date, time)
cached
¶
Given the date and time from a pair of EMu date and time fields, returns the ISO formatted datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
str
|
an EMu date string |
required |
time
|
str
|
an EMu time string |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
None if either the date or the time are missing, otherwise |
Source code in dataimporter/emu/views/utils.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
is_valid_guid(record)
¶
Checks if the record has a valid GUID. If it does, returns True, else returns False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
SourceRecord
|
the record to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the record has a valid GUID, False if not |
Source code in dataimporter/emu/views/utils.py
70 71 72 73 74 75 76 77 78 | |
is_web_published(record)
¶
Checks if the record should be published on the Data Portal. If it should, returns True, else False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
SourceRecord
|
the record to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the record can be published on the Portal, False if not |
Source code in dataimporter/emu/views/utils.py
59 60 61 62 63 64 65 66 67 | |
orientation_requires_swap(record)
¶
Determines whether the image represented by the given record object requires its width and height values to be swapped based on the EXIF orientation tag. If the tag isn't found or the tag indicates no width/height swap is needed, then False is returned. If the orientation tag is in the range 5-8 then a swap is required and True is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
SourceRecord
|
the SourceRecord object |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the width and height need to be swapped, False if not |
Source code in dataimporter/emu/views/utils.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
translate_collection_code(department)
cached
¶
Given a department from an EMu record, return the short code version we display on the Data Portal in the collectionCode field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
department
|
str
|
the department name |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
the short code version of the department, or None if no match is found |
Source code in dataimporter/emu/views/utils.py
101 102 103 104 105 106 107 108 109 110 | |