No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
1 | + | import base64 |
|
1 | 2 | import logging |
|
2 | 3 | import os |
|
3 | 4 | ||
4 | 5 | from mopidy import backend, exceptions, models |
|
5 | 6 | from mopidy.audio import scan, tags |
|
7 | + | from mopidy.exceptions import ScannerError |
|
6 | 8 | from mopidy.internal import path |
|
9 | + | from mopidy.models import Image |
|
7 | 10 | ||
8 | 11 | logger = logging.getLogger(__name__) |
|
9 | 12 |
36 | 39 | ||
37 | 40 | self._scanner = scan.Scanner(timeout=config["file"]["metadata_timeout"]) |
|
38 | 41 | ||
42 | + | self._folder_image_names = config["file"].get("folder_image_names", []) |
|
43 | + | ||
39 | 44 | def browse(self, uri): |
|
40 | 45 | logger.debug("Browsing files at: %s", uri) |
|
41 | 46 | result = [] |
146 | 151 | path.is_path_inside_base_dir(local_path, media_dir["path"]) |
|
147 | 152 | for media_dir in self._media_dirs |
|
148 | 153 | ) |
|
154 | + | ||
155 | + | def get_images(self, uris): |
|
156 | + | images = {} |
|
157 | + | for uri in uris: |
|
158 | + | images[uri] = () |
|
159 | + | try: |
|
160 | + | result = self._scanner.scan(uri) |
|
161 | + | except ScannerError as e: |
|
162 | + | logger.warning(str(e)) |
|
163 | + | continue |
|
164 | + | if len(result.tags.get("image", [])) > 0: |
|
165 | + | image = result.tags["image"][0] |
|
166 | + | images[uri] = ( |
|
167 | + | Image( |
|
168 | + | uri=f"data:;base64, {base64.b64encode(image).decode('utf-8')}" |
|
169 | + | ), |
|
170 | + | ) |
|
171 | + | continue |
|
172 | + | for i in self._folder_image_names: |
|
173 | + | if (path.uri_to_path(uri).parent / i).exists(): |
|
174 | + | with open(path.uri_to_path(uri).parent / i, "rb",) as f: |
|
175 | + | images[uri] = ( |
|
176 | + | Image( |
|
177 | + | uri=f"data:;base64," |
|
178 | + | f"{base64.b64encode(f.read()).decode('utf-8')}" |
|
179 | + | ), |
|
180 | + | ) |
|
181 | + | break |
|
182 | + | return images |
Files | Coverage |
---|---|
mopidy | -0.27% 76.52% |
Project Totals (55 files) | 76.52% |
#1925
b021af6
#1925
8cd289e
#1925
808e8a4
#1925
1d36eb4
#1925
7f189d2
c52bfba