Skip to content

Commit 34c958a

Browse files
committed
Initial release
0 parents  commit 34c958a

File tree

14 files changed

+613
-0
lines changed

14 files changed

+613
-0
lines changed

.github/pull_request_template.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
----
3+
4+
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: build
2+
on:
3+
pull_request: {}
4+
workflow_dispatch: {}
5+
jobs:
6+
build:
7+
name: Build package
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: setup python
15+
uses: actions/setup-python@v2
16+
- name: Install dependencies
17+
run: python -m pip install --upgrade pip setuptools wheel build
18+
- name: Build a binary wheel and a source tarball
19+
run: python -m build

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
build:
8+
name: Build package
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Get history and tags for SCM versioning to work
16+
run: |
17+
git fetch --prune --unshallow
18+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
19+
- name: setup python
20+
uses: actions/setup-python@v2
21+
- name: Install dependencies
22+
run: python -m pip install --upgrade pip setuptools wheel build
23+
- name: Build a binary wheel and a source tarball
24+
run: python -m build
25+
- name: copy version file and changelog
26+
run: |-
27+
cp version.txt dist/version.txt
28+
cp CHANGELOG.md dist/changelog.md
29+
- name: Upload artifact
30+
uses: actions/upload-artifact@v2.1.1
31+
with:
32+
name: dist
33+
path: dist
34+
release_github:
35+
name: Publish to GitHub Releases
36+
needs: build
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: write
40+
steps:
41+
- name: Download build artifacts
42+
uses: actions/download-artifact@v2
43+
with:
44+
name: dist
45+
path: dist
46+
- name: Release
47+
run: gh release create v$(cat dist/version.txt) -R ${{ github.repository }} -F
48+
dist/changelog.md -t v$(cat dist/version.txt)
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
release_pypi:
52+
name: Publish package to PyPI
53+
needs: build
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: read
57+
steps:
58+
- name: Download build artifacts
59+
uses: actions/download-artifact@v2
60+
with:
61+
name: dist
62+
path: dist
63+
- name: remove version file and changelog
64+
run: |-
65+
rm dist/version.txt
66+
rm dist/changelog.md
67+
- name: Publish package to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
user: ${{ secrets.PYPI_USER }}
71+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
version.txt
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.nox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
*.py,cover
52+
.hypothesis/
53+
.pytest_cache/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
.python-version
87+
88+
# pipenv
89+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
90+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
91+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
92+
# install all needed dependencies.
93+
#Pipfile.lock
94+
95+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
96+
__pypackages__/
97+
98+
# Celery stuff
99+
celerybeat-schedule
100+
celerybeat.pid
101+
102+
# SageMath parsed files
103+
*.sage.py
104+
105+
# Environments
106+
.env
107+
.venv
108+
env/
109+
venv/
110+
ENV/
111+
env.bak/
112+
venv.bak/
113+
114+
# Spyder project settings
115+
.spyderproject
116+
.spyproject
117+
118+
# Rope project settings
119+
.ropeproject
120+
121+
# mkdocs documentation
122+
/site
123+
124+
# mypy
125+
.mypy_cache/
126+
.dmypy.json
127+
dmypy.json
128+
129+
# Pyre type checker
130+
.pyre/

.pre-commit-config.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2021 Arun Donti
2+
# SPDX-License-Identifier: MIT
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.0.1
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-docstring-first
10+
- id: check-json
11+
- id: check-added-large-files
12+
- id: check-yaml
13+
- id: debug-statements
14+
- id: name-tests-test
15+
- id: double-quote-string-fixer
16+
- id: requirements-txt-fixer
17+
- repo: https://github.com/PyCQA/flake8
18+
rev: 3.9.2
19+
hooks:
20+
- id: flake8
21+
additional_dependencies: [flake8-typing-imports==1.7.0]
22+
- repo: https://github.com/pre-commit/mirrors-autopep8
23+
rev: v1.5.7
24+
hooks:
25+
- id: autopep8
26+
- repo: https://github.com/asottile/reorder_python_imports
27+
rev: v2.6.0
28+
hooks:
29+
- id: reorder-python-imports
30+
args: [--py3-plus]
31+
- repo: https://github.com/asottile/pyupgrade
32+
rev: v2.24.0
33+
hooks:
34+
- id: pyupgrade
35+
args: [--py36-plus]
36+
- repo: https://github.com/asottile/add-trailing-comma
37+
rev: v2.1.0
38+
hooks:
39+
- id: add-trailing-comma
40+
args: [--py36-plus]
41+
- repo: https://github.com/asottile/setup-cfg-fmt
42+
rev: v1.17.0
43+
hooks:
44+
- id: setup-cfg-fmt
45+
- repo: https://github.com/pre-commit/mirrors-mypy
46+
rev: v0.910
47+
hooks:
48+
- id: mypy
49+
additional_dependencies: [types-all]

.pre-commit-hooks.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2021 Arun Donti
2+
# SPDX-License-Identifier: MIT
3+
- id: text-prepender
4+
name: Add Notice to files
5+
entry: text-prepender
6+
language: python
7+
types: [text]

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!--
2+
Copyright 2021 Arun Donti
3+
SPDX-License-Identifier: MIT
4+
-->
5+
# Changelog
6+
7+
All notable changes to this project will be documented in this file.
8+
9+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
10+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
11+
12+
## [0.1.0] 2021-08-25
13+
14+
### Added
15+
16+
- Initial release

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Arun Donti
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NOTICE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Copyright 2021 Arun Donti
2+
SPDX-License-Identifier: MIT

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!--
2+
Copyright 2021 Arun Donti
3+
SPDX-License-Identifier: MIT
4+
-->
5+
# Text Prepender
6+
7+
[![PyPI version](https://badge.fury.io/py/text-prepender.svg)](https://badge.fury.io/py/text-prepender)
8+
9+
Created in mind to add Legal Text to the top of code
10+
11+
text-prepender recursively goes through a specified directory/list of files, and adds text to the top of supported filetypes.
12+
If there is a filetype that you want to add/know how to add, please make a pull request!
13+
14+
### Parameters
15+
16+
Optional parameters:
17+
18+
| Command Line | Input | Description |
19+
| -------------------- | -------------------- | ---------------------------------------------------------------------------- |
20+
| -h, --help | | Get description of text-prepender |
21+
| -p, --path | dirpath | The path to the directory which text-prepender will start at (default: '.') |
22+
| -t, --text-file | filepath | The path to the file which text-prepender will start at (default: NOTICE) |
23+
| -i, --extra-ignores | space delimited list | Additional file paths/names to ignore. Ex. (-i file1 path1 path2) |
24+
| -v, --enable-verbose | | Flag to turn on verbose logging to list skipped files at the end |
25+
26+
## To Run:
27+
28+
```bash
29+
# run on all files in current directory
30+
text-prepender
31+
# text-prepender --path path/to different directory
32+
```
33+
34+
or
35+
36+
```bash
37+
# run on a specific set of files
38+
text-prepender file1 path/to/file2
39+
```
40+
41+
`text-prepender --text-file path/to/file`
42+
43+
## pre-commit
44+
45+
If you'd like text-prepender to be run automatically when making changes to files in your Git repository, you can install [pre-commit](https://pre-commit.com/) and add the following text to your repositories' `.pre-commit-config.yaml`:
46+
47+
```yaml
48+
repos:
49+
- repo: https://github.com/dontirun/text-prepender
50+
rev: v0.1.0 # The version of text-prepender
51+
hooks:
52+
- id: text-prepender
53+
# args:
54+
# - '--text-file'
55+
# - 'NOTICE'
56+
```
57+
## Manual Build
58+
59+
1. Clone the repo
60+
2. Build the package
61+
- `pip install build`
62+
- `python -m build`
63+
3. Install the latest version of the package
64+
- whl
65+
- `pip install dist/text_prepender-x.x.x-py3-none-any.whl`
66+
- .tar.gz
67+
- `pip install dist/text-prepender-x.x.x.tar.gz`
68+
69+
</details>

0 commit comments

Comments
 (0)