Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
dontirun committed Aug 26, 2021
0 parents commit 34c958a
Show file tree
Hide file tree
Showing 14 changed files with 613 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: build
on:
pull_request: {}
workflow_dispatch: {}
jobs:
build:
name: Build package
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel build
- name: Build a binary wheel and a source tarball
run: python -m build
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: release
on:
push:
branches:
- main
jobs:
build:
name: Build package
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: setup python
uses: actions/setup-python@v2
- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel build
- name: Build a binary wheel and a source tarball
run: python -m build
- name: copy version file and changelog
run: |-
cp version.txt dist/version.txt
cp CHANGELOG.md dist/changelog.md
- name: Upload artifact
uses: actions/upload-artifact@v2.1.1
with:
name: dist
path: dist
release_github:
name: Publish to GitHub Releases
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Release
run: gh release create v$(cat dist/version.txt) -R ${{ github.repository }} -F
dist/changelog.md -t v$(cat dist/version.txt)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_pypi:
name: Publish package to PyPI
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: remove version file and changelog
run: |-
rm dist/version.txt
rm dist/changelog.md
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USER }}
password: ${{ secrets.PYPI_API_TOKEN }}
130 changes: 130 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
version.txt

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2021 Arun Donti
# SPDX-License-Identifier: MIT
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- id: check-added-large-files
- id: check-yaml
- id: debug-statements
- id: name-tests-test
- id: double-quote-string-fixer
- id: requirements-txt-fixer
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [flake8-typing-imports==1.7.0]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.7
hooks:
- id: autopep8
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
hooks:
- id: reorder-python-imports
args: [--py3-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v2.24.0
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.1.0
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
hooks:
- id: mypy
additional_dependencies: [types-all]
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2021 Arun Donti
# SPDX-License-Identifier: MIT
- id: text-prepender
name: Add Notice to files
entry: text-prepender
language: python
types: [text]
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
Copyright 2021 Arun Donti
SPDX-License-Identifier: MIT
-->
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] 2021-08-25

### Added

- Initial release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Arun Donti

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright 2021 Arun Donti
SPDX-License-Identifier: MIT
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!--
Copyright 2021 Arun Donti
SPDX-License-Identifier: MIT
-->
# Text Prepender

[![PyPI version](https://badge.fury.io/py/text-prepender.svg)](https://badge.fury.io/py/text-prepender)

Created in mind to add Legal Text to the top of code

text-prepender recursively goes through a specified directory/list of files, and adds text to the top of supported filetypes.
If there is a filetype that you want to add/know how to add, please make a pull request!

### Parameters

Optional parameters:

| Command Line | Input | Description |
| -------------------- | -------------------- | ---------------------------------------------------------------------------- |
| -h, --help | | Get description of text-prepender |
| -p, --path | dirpath | The path to the directory which text-prepender will start at (default: '.') |
| -t, --text-file | filepath | The path to the file which text-prepender will start at (default: NOTICE) |
| -i, --extra-ignores | space delimited list | Additional file paths/names to ignore. Ex. (-i file1 path1 path2) |
| -v, --enable-verbose | | Flag to turn on verbose logging to list skipped files at the end |

## To Run:

```bash
# run on all files in current directory
text-prepender
# text-prepender --path path/to different directory
```

or

```bash
# run on a specific set of files
text-prepender file1 path/to/file2
```

`text-prepender --text-file path/to/file`

## pre-commit

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`:

```yaml
repos:
- repo: https://github.com/dontirun/text-prepender
rev: v0.1.0 # The version of text-prepender
hooks:
- id: text-prepender
# args:
# - '--text-file'
# - 'NOTICE'
```
## Manual Build

1. Clone the repo
2. Build the package
- `pip install build`
- `python -m build`
3. Install the latest version of the package
- whl
- `pip install dist/text_prepender-x.x.x-py3-none-any.whl`
- .tar.gz
- `pip install dist/text-prepender-x.x.x.tar.gz`

</details>
Loading

0 comments on commit 34c958a

Please sign in to comment.