Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 5ce03c7

Browse files
committed
Rename placeholder variables
I confused %PROJECT_NAME% and %PROJECT_URLNAME% too many times, and decided to stop it by naming them in a way that I hope makes it more obvious what they are.
1 parent 0952ae8 commit 5ce03c7

22 files changed

+89
-83
lines changed

.flake8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @brief Project-wide Flake8 configuration
44
# @created %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
#
88
# Note: as of version 4.0, flake8 does NOT read global configuration files
99
# from ~/.flake8 or ~/.config/flake8. If you had such a config file of your
@@ -47,4 +47,4 @@ per-file-ignores =
4747
# keyword/parameter equals"). It would be better to disable E251 just for
4848
# that block in the file, BUT flake8 only recognizes per-line annotations,
4949
# so there's no way to tell it to ignore a rule only for a block of code.
50-
%PROJECT_NAME%/__main__.py: E251
50+
%MODULE_NAME%/__main__.py: E251

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ Please summarize what this pull request is about, and what it changes.
55
### Details
66

77
Describe more about the changes you made:
8-
1. (...)
9-
2. (...)
108

119
### Software versions
1210

.github/rename_project.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
# The original file was copied on 2021-10-14.
1212
# =============================================================================
1313

14-
while getopts a:e:n:u:d: flag
15-
do
14+
while getopts a:e:n:u:d: flag; do
1615
case "${flag}" in
1716
a) author=${OPTARG};;
18-
e) email=${OPTARG};;
19-
n) project_name=${OPTARG};;
20-
u) urlname=${OPTARG};;
2117
d) description=${OPTARG};;
18+
e) email=${OPTARG};;
19+
m) module_name=${OPTARG};;
20+
r) repo_name=${OPTARG};;
2221
esac
2322
done
2423

@@ -32,32 +31,34 @@ echo "Author name: $author"
3231
echo "Author first name: $first_name"
3332
echo "Author family name: $family_name"
3433
echo "Author email: $email"
35-
echo "Project name: $project_name"
36-
echo "Project URL name: $urlname"
34+
echo "Repo name: $repo_name"
35+
echo "Module name: $module_name"
3736
echo "Description: $description"
3837
echo "Creation date: $creation_date"
3938
echo "Creation year: $creation_year"
4039

41-
echo "Renaming project ..."
40+
echo "Performing substitutions in files ..."
4241

4342
for filename in $(git ls-files)
4443
do
4544
sed -i "s/%AUTHOR_NAME%/$author/g" $filename
4645
sed -i "s/%AUTHOR_EMAIL%/$email/g" $filename
4746
sed -i "s/%AUTHOR_FIRST_NAME%/$first_name/g" $filename
4847
sed -i "s/%AUTHOR_FAMILY_NAME%/$family_name/g" $filename
49-
sed -i "s/%PROJECT_NAME%/$project_name/g" $filename
50-
sed -i "s/%PROJECT_URLNAME%/$urlname/g" $filename
51-
sed -i "s/%PROJECT_DESCRIPTION%/$description/g" $filename
48+
sed -i "s/%REPO_NAME%/$repo_name/g" $filename
49+
sed -i "s/%DESCRIPTION%/$description/g" $filename
50+
sed -i "s/%MODULE_NAME%/$module_name/g" $filename
5251
sed -i "s/%CREATION_DATE%/$creation_date/g" $filename
5352
sed -i "s/%CREATION_YEAR%/$creation_year/g" $filename
54-
echo "Performed substitutions in $filename"
53+
echo "Finished substitutions in $filename"
5554
done
5655

57-
mv project_name $project_name
56+
echo "Renaming files and directories ..."
57+
58+
mv module_name $module_name
5859
rm -f codemeta.json
5960
mv codemeta-TEMPLATE.json codemeta.json
6061
rm -f CITATION.cff
6162
mv CITATION-TEMPLATE.cff CITATION.cff
6263

63-
echo "Renaming project ... Done."
64+
echo "Renaming ... Done."

.github/workflows/rename_project.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ jobs:
3131
# Token needs to be set in order to use the GitHub CLI `gh` program.
3232
GH_TOKEN: ${{ github.token }}
3333
run: |
34-
echo NAME="$(gh repo view --json name -q .name | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
35-
echo URLNAME="$(gh repo view --json name -q .name)" >> $GITHUB_ENV
36-
echo AUTHOR="$(gh api https://api.github.com/users/${{ github.actor }} -q .name)" >> $GITHUB_ENV
37-
echo EMAIL="$(gh api https://api.github.com/users/${{ github.actor }} -q .email)" >> $GITHUB_ENV
38-
echo DESCRIPTION="$(gh repo view --json description -q .description)" >> $GITHUB_ENV
34+
# The meanings of the variables:
35+
# REPO_NAME = the repository name used on GitHub at creation time
36+
# MODULE_NAME = like NAME but all lower-case
37+
# DESCRIPTION = the description given on GitHub at creation time
38+
# AUTHOR = the name of the author
39+
# EMAIL = the email address of the author
40+
41+
echo REPO_NAME="$(gh repo view --json name -q .name)" >> $GITHUB_ENV
42+
echo MODULE_NAME="$(gh repo view --json name -q .name | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
43+
echo DESCRIPTION="$(gh repo view --json description -q .description)" >> $GITHUB_ENV
44+
echo AUTHOR="$(gh api https://api.github.com/users/${{ github.actor }} -q .name)" >> $GITHUB_ENV
45+
echo EMAIL="$(gh api https://api.github.com/users/${{ github.actor }} -q .email)" >> $GITHUB_ENV
3946
4047
- name: Test that this is a repo based on our template.
4148
id: check_template
@@ -48,7 +55,7 @@ jobs:
4855
shell: bash
4956
run: |
5057
echo "Performing substitutions."
51-
.github/rename_project.sh -a "${{ env.AUTHOR }}" -e "${{ env.EMAIL }}" -n "${{ env.NAME }}" -u "${{ env.URLNAME }}" -d "${{ env.DESCRIPTION }}"
58+
.github/rename_project.sh -a "${{ env.AUTHOR }}" -e "${{ env.EMAIL }}" -r "${{ env.REPO_NAME }}" -m "${{ env.MODULE_NAME }}" -d "${{ env.DESCRIPTION }}"
5259
5360
- name: Clean up.
5461
shell: bash

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @brief Files and patterns for files and subdirs that git should ignore
44
# @date %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
#
88
# The approach we suggest is to add ONLY project-specific rules here. Put
99
# rules that apply to your way of doing things (and the particular tools you

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Change log for %PROJECT_NAME%
1+
# Change log for %REPO_NAME%
22

33
## Version 0.0.0 (%CREATION_DATE%)
44

5-
Project repository created at https://github.com/caltechlibrary/%PROJECT_URLNAME%
5+
Project repository created at https://github.com/caltechlibrary/%REPO_NAME%
66
by %AUTHOR_NAME%.

CITATION-TEMPLATE.cff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
cff-version: 1.2
22
message: "If you use this software, please cite it using these metadata."
3-
title: "%PROJECT_NAME%"
3+
title: "%REPO_NAME%"
44
authors:
55
- family-names: %AUTHOR_FAMILY_NAME%
66
given-names: %AUTHOR_FIRST_NAME%
77
affiliation: "Caltech Library"
88
orcid: "https://orid.org/YOUR-ORCID-NUMBER"
99
version: "0.0.0"
10-
abstract: "%PROJECT_DESCRIPTION%"
11-
repository-code: "https://github.com/caltechlibrary/%PROJECT_URLNAME%"
10+
abstract: "%DESCRIPTION%"
11+
repository-code: "https://github.com/caltechlibrary/%REPO_NAME%"
1212
type: software
13-
license-url: "https://github.com/caltechlibrary/%PROJECT_URLNAME%/blob/main/LICENSE"
13+
license-url: "https://github.com/caltechlibrary/%REPO_NAME%/blob/main/LICENSE"
1414
keywords:
1515
- "KEYWORDS"
1616
date-released: "RELEASE-DATE"

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ authors:
2323
family-names: Keswick
2424
orcid: "https://orcid.org/0000-0001-5644-440X"
2525
version: "1.9.0"
26-
abstract: "GitHub template project for non-web Python application projects"
26+
abstract: "GitHub repository template for non-web Python programs"
2727
repository-code: "https://github.com/caltechlibrary/py-cli-template"
2828
type: software
2929
license-url: "https://github.com/caltechlibrary/py-cli-template/blob/main/LICENSE"

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Guidelines for contributing to this project
1+
# Guidelines for contributing to this project repository
22

33
Any constructive contributions – bug reports, pull requests (code or documentation), suggestions for improvements, and more – are welcome.
44

@@ -8,7 +8,7 @@ Everyone is asked to read and respect the [code of conduct](CODE_OF_CONDUCT.md)
88

99
## Coordinating work
1010

11-
A quick way to find out what is currently in the near-term plans for this project is to look at the [GitHub issue tracker](https://github.com/caltechlibrary/%PROJECT_URLNAME%/issues), but the possibilities are not limited to what you see there – if you have ideas for new features and enhancements, please feel free to write them up as a new issue or contact the developers directly!
11+
A quick way to find out what is currently in the near-term plans for this project is to look at the [GitHub issue tracker](https://github.com/caltechlibrary/%REPO_NAME%/issues), but the possibilities are not limited to what you see there – if you have ideas for new features and enhancements, please feel free to write them up as a new issue or contact the developers directly!
1212

1313
## Submitting contributions
1414

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @brief Makefile for some steps in creating new releases on GitHub
44
# @date %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
# =============================================================================
88

99
.ONESHELL: # Run all commands in the same shell.
@@ -146,10 +146,10 @@ report: vars
146146
# make lint & make test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147147

148148
lint:
149-
flake8 %PROJECT_URLNAME%
149+
flake8 %MODULE_NAME%
150150

151151
test tests:;
152-
pytest -v --cov=%PROJECT_URLNAME% -l tests/
152+
pytest -v --cov=%MODULE_NAME% -l tests/
153153

154154

155155
# make install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# %PROJECT_NAME%
1+
# %REPO_NAME%
22

3-
%PROJECT_DESCRIPTION%
3+
%DESCRIPTION%
44

5-
[![License](https://img.shields.io/badge/License-BSD--like-lightgrey.svg)](https://github.com/caltechlibrary/%PROJECT_URLNAME%/LICENSE)
6-
[![Latest release](https://img.shields.io/github/v/release/caltechlibrary/%PROJECT_URLNAME%.svg?color=b44e88)](https://github.com/caltechlibrary/%PROJECT_URLNAME%/releases)
5+
[![License](https://img.shields.io/badge/License-BSD--like-lightgrey.svg)](https://github.com/caltechlibrary/%REPO_NAME%/LICENSE)
6+
[![Latest release](https://img.shields.io/github/v/release/caltechlibrary/%REPO_NAME%.svg?color=b44e88)](https://github.com/caltechlibrary/%REPO_NAME%/releases)
77

88

99
## Table of contents
@@ -21,7 +21,7 @@
2121

2222
## Introduction
2323

24-
> _This README file is in Markdown format, and is meant to provide a template for README files as well an illustration of what the README file can be expected to look like. For a software project, this [Introduction](#introduction) section – which you are presently reading – should provide background for the project, a brief explanation of what the project is about, and optionally, pointers to resources that can help orient readers. Ideally, this section should be short._
24+
> _This README file is in Markdown format, and is meant to provide a template for README files as well an illustration of what the README file can be expected to look like. For software, this [Introduction](#introduction) section – which you are presently reading – should provide background for the program, a brief explanation of what the project is about, and optionally, pointers to resources that can help orient readers. Ideally, this section should be short._
2525
2626

2727
## Installation
@@ -39,7 +39,7 @@
3939
>
4040
> _Begin with the simplest possible example of how to use your software. Provide example command lines and/or screen images, as appropriate, to help readers understand how the software is expected to be used. Many readers are likely to look for command lines they can copy-paste directly from your explanations, so it's best to keep that in mind as you write examples._
4141
>
42-
> _Some projects need to communicate additional information to users and can benefit from additional sections in the README file. It's difficult to give specific instructions – a lot depends on your software, your intended audience, etc. Use your judgment and ask for feedback from users or colleagues to help figure out what else is worth explaining._
42+
> _Some programs are complicated and users can benefit from additional sections in the README file. It's difficult to give specific instructions – a lot depends on your software, your intended audience, etc. Use your judgment and ask for feedback from users or colleagues to help figure out what else is worth explaining._
4343
4444

4545
## Known issues and limitations
@@ -49,12 +49,12 @@
4949

5050
## Getting help
5151

52-
If you find an issue, please submit it in [the GitHub issue tracker](https://github.com/caltechlibrary/%PROJECT_URLNAME%/issues) for this repository.
52+
If you find an issue, please submit it in [the GitHub issue tracker](https://github.com/caltechlibrary/%REPO_NAME%/issues) for this repository.
5353

5454

5555
## Contributing
5656

57-
Your help and participation in enhancing %PROJECT_NAME% is welcome! Please visit the [guidelines for contributing](CONTRIBUTING.md) for some tips on getting started.
57+
Your help and participation in enhancing %REPO_NAME% is welcome! Please visit the [guidelines for contributing](CONTRIBUTING.md) for some tips on getting started.
5858

5959

6060
## License
@@ -64,7 +64,7 @@ Software produced by the Caltech Library is Copyright © %CREATION_YEAR% Califor
6464

6565
## Authors and history
6666

67-
> _In this section, list the authors and contributors to your software project. Adding additional notes here about the history of the project can make it more interesting and compelling. This is also a place where you can acknowledge other contributions to the work and the use of other people's software or tools._
67+
> _In this section, list the authors and contributors to this software project. Adding additional notes here about the history of the software and the overall project can make it more interesting and compelling. This is also a place where you can acknowledge other contributions to the work and the use of other people's software or tools._
6868
6969

7070
## Acknowledgments
@@ -74,6 +74,6 @@ This work was funded by the California Institute of Technology Library.
7474
<div align="center">
7575
<br>
7676
<a href="https://www.caltech.edu">
77-
<img width="100" height="100" src="https://github.com/caltechlibrary/%PROJECT_URLNAME%/blob/main/.graphics/caltech-round.png">
77+
<img width="100" height="100" src="https://github.com/caltechlibrary/%REPO_NAME%/blob/main/.graphics/caltech-round.png">
7878
</a>
7979
</div>

SUPPORT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ Support
33

44
Thank you for your interest in this project. If you are experiencing problems or have questions, the following are the preferred methods of reaching someone:
55

6-
1. Report a new issue using the [issue tracker](https://github.com/caltechlibrary/%PROJECT_URLNAME%/issues).
6+
1. Report a new issue using the [issue tracker](https://github.com/caltechlibrary/%REPO_NAME%/issues).
77
2. Send email to the Caltech Library: [[email protected]](mailto:[email protected]).
88
3. Send email to an individual involved in the project. People's names appear in the top-level `README.md` file in the source code repository.

codemeta-TEMPLATE.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
33
"@type": "SoftwareSourceCode",
4-
"description": "%PROJECT_DESCRIPTION%",
5-
"name": "%PROJECT_NAME%",
6-
"codeRepository": "https://github.com/caltechlibrary/%PROJECT_URLNAME%",
7-
"issueTracker": "https://github.com/caltechlibrary/%PROJECT_URLNAME%/issues",
8-
"license": "https://github.com/caltechlibrary/%PROJECT_URLNAME%/blob/main/LICENSE",
4+
"description": "%DESCRIPTION%",
5+
"name": "%REPO_NAME%",
6+
"codeRepository": "https://github.com/caltechlibrary/%REPO_NAME%",
7+
"issueTracker": "https://github.com/caltechlibrary/%REPO_NAME%/issues",
8+
"license": "https://github.com/caltechlibrary/%REPO_NAME%/blob/main/LICENSE",
99
"version": "0.0.0",
1010
"author": [
1111
{
@@ -17,7 +17,7 @@
1717
"@id": "https://orcid.org/YOUR-ORCID"
1818
}],
1919
"developmentStatus": "active",
20-
"downloadUrl": "https://github.com/caltechlibrary/%PROJECT_URLNAME%/archive/main.zip",
20+
"downloadUrl": "https://github.com/caltechlibrary/%REPO_NAME%/archive/main.zip",
2121
"keywords": [
2222
"software",
2323
"science"

codemeta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"python",
4343
"software"
4444
],
45-
"name": "Caltech Library Python Software Repository Template",
46-
"description": "Template repository for software projects by the Caltech Library",
45+
"name": "py-cli-template",
46+
"description": "GitHub repository template for non-web Python programs",
4747
"version": "1.9.0",
4848
"maintainer": "https://orcid.org/0000-0001-9105-5960",
4949
"funder": {

project_name/__init__.py renamed to module_name/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
__init__.py for %PROJECT_NAME%
2+
__init__.py for %MODULE_NAME%
33
44
Copyright
55
---------
@@ -18,8 +18,8 @@
1818
# ╰────────────────────── Notice ── Notice ── Notice ─────────────────────╯
1919

2020
__version__ = '0.0.0'
21-
__description__ = '%PROJECT_DESCRIPTION%'
22-
__url__ = 'https://github.com/caltechlibrary/%PROJECT_URLNAME%'
21+
__description__ = '%DESCRIPTION%'
22+
__url__ = 'https://github.com/caltechlibrary/%REPO_NAME%'
2323
__author__ = '%AUTHOR_NAME%'
2424
__email__ = '[email protected]'
2525
__license__ = 'https://data.caltech.edu/license'

project_name/__main__.py renamed to module_name/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
__main__.py: main function for %PROJECT_NAME%.
2+
__main__.py: main function for %MODULE_NAME%.
33
44
Copyright
55
---------
@@ -11,7 +11,7 @@
1111

1212
import sys
1313
if sys.version_info <= (3, 8):
14-
print('%PROJECT_NAME% requires Python version 3.8 or higher,')
14+
print('%MODULE_NAME% requires Python version 3.8 or higher,')
1515
print('but the current version of Python is ' + str(sys.version_info.major)
1616
+ '.' + str(sys.version_info.minor) + '.')
1717
sys.exit(1)
@@ -30,7 +30,7 @@
3030
args = 'arguments'
3131
)
3232
def main(version=False, debug='OUT', *args):
33-
'''%PROJECT_DESCRIPTION%'''
33+
'''%DESCRIPTION%'''
3434

3535
# Set up debug logging as soon as possible, if requested ------------------
3636

@@ -71,7 +71,7 @@ def print_version_info():
7171
# Precaution: add parent dir in case user is running from our source dir.
7272
from os import path
7373
sys.path.append(path.join(path.dirname(path.abspath(__file__)), '..'))
74-
from %PROJECT_NAME% import print_version
74+
from %MODULE_NAME% import print_version
7575
print_version()
7676

7777

@@ -85,7 +85,7 @@ def console_scripts_main():
8585
plac.call(main)
8686

8787

88-
# The following allows users to invoke this using "python3 -m %PROJECT_NAME%".
88+
# The following allows users to invoke this using "python3 -m %MODULE_NAME%".
8989
if __name__ == '__main__':
9090
# Print help if the user supplied no command-line arguments.
9191
if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1] == 'help'):

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# =============================================================================
22
# @file requirements-dev.txt
3-
# @brief Python dependencies for %PROJECT_URLNAME% for development & testing
3+
# @brief Python dependencies for %REPO_NAME% for development & testing
44
# @created %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
# =============================================================================
88

99
-r requirements.txt

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# =============================================================================
22
# @file requirements.txt
3-
# @brief Python dependencies for %PROJECT_URLNAME%
3+
# @brief Python dependencies for %REPO_NAME%
44
# @created %CREATION_DATE%
55
# @license Please see the file named LICENSE in the project directory
6-
# @website https://github.com/caltechlibrary/%PROJECT_URLNAME%
6+
# @website https://github.com/caltechlibrary/%REPO_NAME%
77
# =============================================================================
88

99
boltons

0 commit comments

Comments
 (0)