Skip to content

Commit 1142bac

Browse files
authored
Merge branch 'main' into contributors_guide
2 parents 20db304 + aef5b9f commit 1142bac

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

content/_ext/yaml_gallery_generator.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import itertools
12
import pathlib
23
from textwrap import dedent
34

@@ -7,19 +8,13 @@
78
def _tag_in_item(item, tag_str=None):
89
if tag_str is None:
910
return True
10-
all_tags = []
11-
for k, e in item['tags'].items():
12-
all_tags.extend(e)
11+
all_tags = list(item['tags'].values())
1312
return tag_str in all_tags
1413

1514

1615
def _generate_sorted_tag_keys(all_items):
1716

18-
key_set = set()
19-
for item in all_items:
20-
for k, e in item['tags'].items():
21-
key_set.add(k)
22-
17+
key_set = set(itertools.chain(*[item['tags'].keys() for item in all_items]))
2318
return sorted(key_set)
2419

2520

@@ -77,33 +72,23 @@ def build_from_items(items, filename, display_name, menu_html):
7772
if not item.get('thumbnail'):
7873
item['thumbnail'] = '/_static/images/ebp-logo.png'
7974
thumbnail = item['thumbnail']
80-
81-
tag_set = set()
82-
for k, e in item['tags'].items():
83-
for t in e:
84-
tag_set.add(t)
85-
86-
tag_list = sorted(tag_set)
75+
tag_list = sorted((itertools.chain(*item['tags'].values())))
8776
tags = [
8877
f'{{link-badge}}`"/pages/links/{tag.replace(" ", "-")}.html",{tag},cls=badge-primary badge-pill text-light`'
8978
for tag in tag_list
9079
]
9180
tags = '\n'.join(tags)
9281

9382
authors = [a.get('name', 'anonymous') for a in item['authors']]
83+
authors_str = f"Created by: {', '.join(authors)}"
9484

95-
if len(authors) == 1:
96-
authors_str = f'Created by: {authors[0]}'
97-
elif len(authors) == 2:
98-
authors_str = f'Created by: {authors[0]} and {authors[1]}'
99-
100-
email = [a.get('email', None) for a in item['authors']][0]
85+
email = [a.get('email') for a in item['authors']][0]
10186
email_str = '' if email is None else f'Email: {email}'
10287

103-
affiliation = [a.get('affiliation', None) for a in item['authors']][0]
88+
affiliation = [a.get('affiliation') for a in item['authors']][0]
10489
affiliation_str = '' if affiliation is None else f'Affiliation: {affiliation}'
10590

106-
affiliation_url = [a.get('affiliation_url', None) for a in item['authors']][0]
91+
affiliation_url = [a.get('affiliation_url') for a in item['authors']][0]
10792
affiliation_url_str = '' if affiliation_url is None else f'{affiliation} Site: <{affiliation_url}>'
10893

10994
panels_body.append(

content/links.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,3 +735,29 @@
735735
- xarray
736736
formats:
737737
- tutorial
738+
- title: Python Programming for Earth Science Students
739+
description: Python Programming for Earth Science Students
740+
url: https://nbviewer.jupyter.org/github/ltauxe/Python-for-Earth-Science-Students/tree/master/
741+
thumbnail: ''
742+
authors:
743+
- name: Lisa Tauxe
744+
affiliation: Scripps Institution of Oceanography
745+
affiliation_url: https://scripps.ucsd.edu/
746+
email: ltauxe@ucsd.edu
747+
- name: Hanna Asefaw
748+
affiliation: ''
749+
affiliation_url: ''
750+
email: hasefaw@ucsd.edu
751+
- name: Brendan Cych
752+
affiliation: ''
753+
affiliation_url: ''
754+
email: bcych@ucsd.edu
755+
tags:
756+
formats:
757+
- tutorial
758+
packages:
759+
- pure python
760+
- pandas
761+
- scipy
762+
- numpy
763+
- matplotlib

0 commit comments

Comments
 (0)