|
23 | 23 | with path.open('r') as fin:
|
24 | 24 | package = safe_load(fin)
|
25 | 25 |
|
26 |
| - # Divide the yml files into sections based on the section tag... |
27 |
| - if 'section' not in package: |
28 |
| - package['section'] = 'miscellaneous' |
29 |
| - package['section'] = section_names[package['section'].lower()] |
| 26 | + package['section'] = section_names[package.get('section', 'miscellaneous').lower()] |
30 | 27 |
|
31 | 28 | print(f" {package['repo']} -> {package['section']}")
|
32 | 29 | try:
|
33 | 30 | package['user'], package['repo_name'] = package['repo'].split('/')
|
34 | 31 | except:
|
35 | 32 | raise Warning('Package.repo is not in correct format', package)
|
36 | 33 | continue
|
37 |
| - package['conda_package'] = package.get('conda_package', package['repo_name']) |
38 |
| - package['pypi_name'] = package.get('pypi_name', package['repo_name']) |
| 34 | + package.setdefault('conda_package', package['repo_name']) |
| 35 | + package.setdefault('pypi_name', package['repo_name']) |
39 | 36 |
|
40 | 37 | if package.get('badges'):
|
41 | 38 | package['badges'] = [x.strip() for x in package['badges'].split(',')]
|
|
54 | 51 | package['badges'].remove('pypi')
|
55 | 52 | if package.get('conda_channel') and 'conda' not in package['badges']:
|
56 | 53 | package['badges'].append('conda')
|
57 |
| - if 'conda_channel' not in package: |
58 |
| - package['conda_channel'] = 'conda-forge' |
| 54 | + package.setdefault('conda_channel', 'conda-forge') |
59 | 55 | if 'conda' in package['badges']:
|
60 | 56 | needs_newline = True
|
61 | 57 | print(' conda: ', end='')
|
|
77 | 73 | if package.get('dormant') and 'dormant' not in package['badges']:
|
78 | 74 | package['badges'].append('dormant')
|
79 | 75 |
|
80 |
| - if 'rtd' in package['badges'] and 'rtd_name' not in package: |
81 |
| - package['rtd_name'] = package['repo_name'] |
| 76 | + if 'rtd' in package['badges']: |
| 77 | + package.setdefault('rtd_name', package['repo_name']) |
82 | 78 |
|
83 | 79 | if 'site' in package['badges']:
|
84 | 80 | if 'site' not in package:
|
85 | 81 | package['site'] = f'https://{package["repo_name"]}.org'
|
86 | 82 | else:
|
87 | 83 | package['site'] = package['site'].rstrip('/')
|
88 | 84 |
|
| 85 | + # Divide the yml files into sections based on the section tag... |
89 | 86 | config[package['section']].append(package)
|
90 | 87 |
|
91 | 88 | # Turn defaultdict into plain dict.
|
|
0 commit comments