|
9 | 9 | # distributed with this code, or at
|
10 | 10 | # https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
|
11 | 11 |
|
12 |
| -import pkg_resources |
13 |
| -from os import makedirs |
14 |
| -from lxml import etree |
15 |
| -from collections import OrderedDict |
16 |
| -import subprocess |
17 | 12 | import os
|
| 13 | +import subprocess |
18 | 14 | import sys
|
| 15 | +from collections import OrderedDict |
| 16 | +from os import makedirs |
| 17 | +from pathlib import Path |
| 18 | + |
| 19 | +import pkg_resources |
| 20 | +from lxml import etree |
19 | 21 |
|
20 | 22 | import mpas_analysis.version
|
21 | 23 | from mpas_analysis.shared.io.utility import build_config_full_path, copyfile
|
@@ -222,7 +224,7 @@ def generate(self):
|
222 | 224 |
|
223 | 225 | for componentName, componentDict in self.components.items():
|
224 | 226 | subdirectory = componentDict['subdirectory']
|
225 |
| - imageFileName = componentDict['imageFileName'] |
| 227 | + imageFileName = _to_jpg(componentDict['imageFileName']) |
226 | 228 | replacements = {'@componentDir': subdirectory,
|
227 | 229 | '@componentName': componentName,
|
228 | 230 | '@firstImage': imageFileName}
|
@@ -555,7 +557,9 @@ def _get_required_xml_text(root, tag, fileName):
|
555 | 557 |
|
556 | 558 | def _generate_image_text(self, imageFileName, imageDict):
|
557 | 559 | """fill in the template for a given image with the desired content"""
|
558 |
| - replacements = {'@imageFileName': imageFileName} |
| 560 | + thumbnailFileName = _to_jpg(imageFileName) |
| 561 | + replacements = {'@imageFileName': imageFileName, |
| 562 | + '@thumbnailFileName': thumbnailFileName} |
559 | 563 | for tag in ['imageSize', 'imageDescription', 'imageCaption',
|
560 | 564 | 'thumbnailDescription', 'orientation', 'thumbnailWidth',
|
561 | 565 | 'thumbnailHeight']:
|
@@ -627,11 +631,11 @@ def _generate_quick_link_text(self, groupName, groupDict):
|
627 | 631 | """
|
628 | 632 |
|
629 | 633 | firstGallery = next(iter(groupDict['galleries'].values()))
|
630 |
| - firstImageFileName = next(iter(firstGallery['images'])) |
| 634 | + thumbnailFileName = _to_jpg(next(iter(firstGallery['images']))) |
631 | 635 |
|
632 | 636 | replacements = {'@analysisGroupName': groupName,
|
633 | 637 | '@analysisGroupLink': groupDict['link'],
|
634 |
| - '@imageFileName': firstImageFileName} |
| 638 | + '@thumbnailFileName': thumbnailFileName} |
635 | 639 |
|
636 | 640 | quickLinkText = _replace_tempate_text(self.templates['quicklink'],
|
637 | 641 | replacements)
|
@@ -666,3 +670,11 @@ def _get_git_hash():
|
666 | 670 |
|
667 | 671 | githash = githash.decode('utf-8').strip('\n').replace('"', '')
|
668 | 672 | return githash
|
| 673 | + |
| 674 | + |
| 675 | +def _to_jpg(filename): |
| 676 | + """ |
| 677 | + change the file extention to jpg (presumably from png) |
| 678 | + """ |
| 679 | + filename = str(Path(filename).with_suffix('.jpg')) |
| 680 | + return filename |
0 commit comments