python-cath 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python-cath-0.2.0 → python_cath-0.3.0}/PKG-INFO +15 -122
- {python-cath-0.2.0 → python_cath-0.3.0}/README.md +2 -112
- {python-cath-0.2.0 → python_cath-0.3.0}/pyproject.toml +17 -17
- python_cath-0.3.0/python_cath/__init__.py +9 -0
- python_cath-0.3.0/python_cath/__main__.py +33 -0
- python_cath-0.3.0/python_cath/concat.py +49 -0
- python-cath-0.2.0/python_cath/__init__.py +0 -13
- python-cath-0.2.0/python_cath/__main__.py +0 -41
- python-cath-0.2.0/setup.py +0 -38
- {python-cath-0.2.0 → python_cath-0.3.0}/LICENSE +0 -0
- {python-cath-0.2.0 → python_cath-0.3.0}/python_cath/example.py +0 -0
- {python-cath-0.2.0 → python_cath-0.3.0}/python_cath/py.typed +0 -0
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-cath
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Cat files w/ headers
|
|
5
|
-
Home-page: https://github.com/samesense/python-cath
|
|
6
5
|
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
7
|
Author: samesense
|
|
8
8
|
Author-email: candptea@gmail.com
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
10
|
Classifier: Development Status :: 3 - Alpha
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
|
|
21
|
+
Requires-Dist: pre-commit (>=3.0.0,<4.0.0)
|
|
22
|
+
Requires-Dist: rich (>=10.0.0)
|
|
23
|
+
Requires-Dist: typer[all] (>=0.9.0,<0.10.0)
|
|
24
|
+
Project-URL: Homepage, https://github.com/samesense/python-cath
|
|
22
25
|
Project-URL: Repository, https://github.com/samesense/python-cath
|
|
23
26
|
Description-Content-Type: text/markdown
|
|
24
27
|
|
|
@@ -39,116 +42,6 @@ Description-Content-Type: text/markdown
|
|
|
39
42
|
Cat files w/ headers
|
|
40
43
|
</div>
|
|
41
44
|
|
|
42
|
-
## Very first steps
|
|
43
|
-
|
|
44
|
-
### Initial
|
|
45
|
-
|
|
46
|
-
1. Initialize `git` inside your repo:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
git init
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
2. If you don't have `Poetry` installed run:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
make download-poetry
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
3. Initialize poetry and install `pre-commit` hooks:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
make install
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
4. Upload initial code to GitHub (ensure you've run `make install` to use `pre-commit`):
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
git add .
|
|
68
|
-
git commit -m ":tada: Initial commit"
|
|
69
|
-
git remote add origin https://github.com/samesense/python-cath.git
|
|
70
|
-
git push -u origin master
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Initial setting up
|
|
74
|
-
|
|
75
|
-
- Set up [Dependabot](https://docs.github.com/en/github/administering-a-repository/enabling-and-disabling-version-updates#enabling-github-dependabot-version-updates) to ensure you have the latest dependencies.
|
|
76
|
-
- Set up [Stale bot](https://github.com/apps/stale) for automatic issue closing.
|
|
77
|
-
|
|
78
|
-
### Poetry
|
|
79
|
-
|
|
80
|
-
All manipulations with dependencies are executed through Poetry. If you're new to it, look through [the documentation](https://python-poetry.org/docs/).
|
|
81
|
-
|
|
82
|
-
<details>
|
|
83
|
-
<summary>Notes about Poetry</summary>
|
|
84
|
-
<p>
|
|
85
|
-
|
|
86
|
-
Poetry's [commands](https://python-poetry.org/docs/cli/#commands) are very intuitive and easy to learn, like:
|
|
87
|
-
|
|
88
|
-
- `poetry add numpy`
|
|
89
|
-
- `poetry run pytest`
|
|
90
|
-
- `poetry build`
|
|
91
|
-
- etc
|
|
92
|
-
|
|
93
|
-
</p>
|
|
94
|
-
</details>
|
|
95
|
-
|
|
96
|
-
### Building your package
|
|
97
|
-
|
|
98
|
-
Building a new version of the application contains steps:
|
|
99
|
-
|
|
100
|
-
- Bump the version of your package `poetry version <version>`. You can pass the new version explicitly, or a rule such as `major`, `minor`, or `patch`. For more details, refer to the [Semantic Versions](https://semver.org/) standard.
|
|
101
|
-
- Make a commit to `GitHub`.
|
|
102
|
-
- Create a `GitHub release`.
|
|
103
|
-
- And... publish 🙂 `poetry publish --build`
|
|
104
|
-
|
|
105
|
-
## What's next
|
|
106
|
-
|
|
107
|
-
Well, that's up to you. I can only recommend the packages and articles that helped me.
|
|
108
|
-
|
|
109
|
-
Packages:
|
|
110
|
-
|
|
111
|
-
- [`Typer`](https://github.com/tiangolo/typer) is great for creating CLI applications.
|
|
112
|
-
- [`Rich`](https://github.com/willmcgugan/rich) makes it easy to add beautiful formatting in the terminal.
|
|
113
|
-
- [`FastAPI`](https://github.com/tiangolo/fastapi) is a type-driven asynchronous web framework.
|
|
114
|
-
- [`IceCream`](https://github.com/gruns/icecream) is a little library for sweet and creamy debugging
|
|
115
|
-
|
|
116
|
-
Articles:
|
|
117
|
-
|
|
118
|
-
- [Open Source Guides](https://opensource.guide/)
|
|
119
|
-
- [GitHub Actions Documentation](https://help.github.com/en/actions)
|
|
120
|
-
- Maybe you would like to add [gitmoji](https://gitmoji.carloscuesta.me/) to commit names. This is really funny. 😄
|
|
121
|
-
|
|
122
|
-
## 🚀 Features
|
|
123
|
-
|
|
124
|
-
For your development we've prepared:
|
|
125
|
-
|
|
126
|
-
- Supports for `Python 3.7` and higher.
|
|
127
|
-
- [`Poetry`](https://python-poetry.org/) as the dependencies manager. See configuration in [`pyproject.toml`](https://github.com/samesense/python-cath/blob/master/pyproject.toml) and [`setup.cfg`](https://github.com/samesense/python-cath/blob/master/setup.cfg).
|
|
128
|
-
- Power of [`black`](https://github.com/psf/black), [`isort`](https://github.com/timothycrosley/isort) and [`pyupgrade`](https://github.com/asottile/pyupgrade) formatters.
|
|
129
|
-
- Ready-to-use [`pre-commit`](https://pre-commit.com/) hooks with formatters above.
|
|
130
|
-
- Type checks with the configured [`mypy`](https://mypy.readthedocs.io).
|
|
131
|
-
- Testing with [`pytest`](https://docs.pytest.org/en/latest/).
|
|
132
|
-
- Docstring checks with [`darglint`](https://github.com/terrencepreilly/darglint).
|
|
133
|
-
- Security checks with [`safety`](https://github.com/pyupio/safety) and [`bandit`](https://github.com/PyCQA/bandit).
|
|
134
|
-
- Well-made [`.editorconfig`](https://github.com/samesense/python-cath/blob/master/.editorconfig), [`.dockerignore`](https://github.com/samesense/python-cath/blob/master/.dockerignore), and [`.gitignore`](https://github.com/samesense/python-cath/blob/master/.gitignore). You don't have to worry about those things.
|
|
135
|
-
|
|
136
|
-
For building and deployment:
|
|
137
|
-
|
|
138
|
-
- `GitHub` integration.
|
|
139
|
-
- [`Makefile`](https://github.com/samesense/python-cath/blob/master/Makefile#L89) for building routines. Everything is already set up for security checks, codestyle checks, code formatting, testing, linting, docker builds, etc. More details at [Makefile summary](#makefile-usage)).
|
|
140
|
-
- [Dockerfile](https://github.com/samesense/python-cath/blob/master/docker/Dockerfile) for your package.
|
|
141
|
-
- `Github Actions` with predefined [build workflow](https://github.com/samesense/python-cath/blob/master/.github/workflows/build.yml) as the default CI/CD.
|
|
142
|
-
- Always up-to-date dependencies with [`@dependabot`](https://dependabot.com/) (You will only [enable it](https://docs.github.com/en/github/administering-a-repository/enabling-and-disabling-version-updates#enabling-github-dependabot-version-updates)).
|
|
143
|
-
- Automatic drafts of new releases with [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). It creates a list of changes based on labels in merged `Pull Requests`. You can see labels (aka `categories`) in [`release-drafter.yml`](https://github.com/samesense/python-cath/blob/master/.github/release-drafter.yml). Works perfectly with [Semantic Versions](https://semver.org/) specification.
|
|
144
|
-
|
|
145
|
-
For creating your open source community:
|
|
146
|
-
|
|
147
|
-
- Ready-to-use [Pull Requests templates](https://github.com/samesense/python-cath/blob/master/.github/PULL_REQUEST_TEMPLATE.md) and several [Issue templates](https://github.com/samesense/python-cath/tree/master/.github/ISSUE_TEMPLATE).
|
|
148
|
-
- Files such as: `LICENSE`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, and `SECURITY.md` are generated automatically.
|
|
149
|
-
- [`Stale bot`](https://github.com/apps/stale) that closes abandoned issues after a period of inactivity. (You will only [need to setup free plan](https://github.com/marketplace/stale)). Configuration is [here](https://github.com/samesense/python-cath/blob/master/.github/.stale.yml).
|
|
150
|
-
- [Semantic Versions](https://semver.org/) specification with [`Release Drafter`](https://github.com/marketplace/actions/release-drafter).
|
|
151
|
-
|
|
152
45
|
## Installation
|
|
153
46
|
|
|
154
47
|
```bash
|
|
@@ -168,7 +61,7 @@ python-cath --help
|
|
|
168
61
|
```
|
|
169
62
|
|
|
170
63
|
```bash
|
|
171
|
-
python-cath
|
|
64
|
+
python-cath file1 file2 outfile
|
|
172
65
|
```
|
|
173
66
|
|
|
174
67
|
or if installed with `Poetry`:
|
|
@@ -178,7 +71,7 @@ poetry run python-cath --help
|
|
|
178
71
|
```
|
|
179
72
|
|
|
180
73
|
```bash
|
|
181
|
-
poetry run python-cath
|
|
74
|
+
poetry run python-cath file1 file2 outfile
|
|
182
75
|
```
|
|
183
76
|
|
|
184
77
|
### Makefile usage
|
|
@@ -15,116 +15,6 @@
|
|
|
15
15
|
Cat files w/ headers
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
## Very first steps
|
|
19
|
-
|
|
20
|
-
### Initial
|
|
21
|
-
|
|
22
|
-
1. Initialize `git` inside your repo:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
git init
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
2. If you don't have `Poetry` installed run:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
make download-poetry
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
3. Initialize poetry and install `pre-commit` hooks:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
make install
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
4. Upload initial code to GitHub (ensure you've run `make install` to use `pre-commit`):
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
git add .
|
|
44
|
-
git commit -m ":tada: Initial commit"
|
|
45
|
-
git remote add origin https://github.com/samesense/python-cath.git
|
|
46
|
-
git push -u origin master
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Initial setting up
|
|
50
|
-
|
|
51
|
-
- Set up [Dependabot](https://docs.github.com/en/github/administering-a-repository/enabling-and-disabling-version-updates#enabling-github-dependabot-version-updates) to ensure you have the latest dependencies.
|
|
52
|
-
- Set up [Stale bot](https://github.com/apps/stale) for automatic issue closing.
|
|
53
|
-
|
|
54
|
-
### Poetry
|
|
55
|
-
|
|
56
|
-
All manipulations with dependencies are executed through Poetry. If you're new to it, look through [the documentation](https://python-poetry.org/docs/).
|
|
57
|
-
|
|
58
|
-
<details>
|
|
59
|
-
<summary>Notes about Poetry</summary>
|
|
60
|
-
<p>
|
|
61
|
-
|
|
62
|
-
Poetry's [commands](https://python-poetry.org/docs/cli/#commands) are very intuitive and easy to learn, like:
|
|
63
|
-
|
|
64
|
-
- `poetry add numpy`
|
|
65
|
-
- `poetry run pytest`
|
|
66
|
-
- `poetry build`
|
|
67
|
-
- etc
|
|
68
|
-
|
|
69
|
-
</p>
|
|
70
|
-
</details>
|
|
71
|
-
|
|
72
|
-
### Building your package
|
|
73
|
-
|
|
74
|
-
Building a new version of the application contains steps:
|
|
75
|
-
|
|
76
|
-
- Bump the version of your package `poetry version <version>`. You can pass the new version explicitly, or a rule such as `major`, `minor`, or `patch`. For more details, refer to the [Semantic Versions](https://semver.org/) standard.
|
|
77
|
-
- Make a commit to `GitHub`.
|
|
78
|
-
- Create a `GitHub release`.
|
|
79
|
-
- And... publish 🙂 `poetry publish --build`
|
|
80
|
-
|
|
81
|
-
## What's next
|
|
82
|
-
|
|
83
|
-
Well, that's up to you. I can only recommend the packages and articles that helped me.
|
|
84
|
-
|
|
85
|
-
Packages:
|
|
86
|
-
|
|
87
|
-
- [`Typer`](https://github.com/tiangolo/typer) is great for creating CLI applications.
|
|
88
|
-
- [`Rich`](https://github.com/willmcgugan/rich) makes it easy to add beautiful formatting in the terminal.
|
|
89
|
-
- [`FastAPI`](https://github.com/tiangolo/fastapi) is a type-driven asynchronous web framework.
|
|
90
|
-
- [`IceCream`](https://github.com/gruns/icecream) is a little library for sweet and creamy debugging
|
|
91
|
-
|
|
92
|
-
Articles:
|
|
93
|
-
|
|
94
|
-
- [Open Source Guides](https://opensource.guide/)
|
|
95
|
-
- [GitHub Actions Documentation](https://help.github.com/en/actions)
|
|
96
|
-
- Maybe you would like to add [gitmoji](https://gitmoji.carloscuesta.me/) to commit names. This is really funny. 😄
|
|
97
|
-
|
|
98
|
-
## 🚀 Features
|
|
99
|
-
|
|
100
|
-
For your development we've prepared:
|
|
101
|
-
|
|
102
|
-
- Supports for `Python 3.7` and higher.
|
|
103
|
-
- [`Poetry`](https://python-poetry.org/) as the dependencies manager. See configuration in [`pyproject.toml`](https://github.com/samesense/python-cath/blob/master/pyproject.toml) and [`setup.cfg`](https://github.com/samesense/python-cath/blob/master/setup.cfg).
|
|
104
|
-
- Power of [`black`](https://github.com/psf/black), [`isort`](https://github.com/timothycrosley/isort) and [`pyupgrade`](https://github.com/asottile/pyupgrade) formatters.
|
|
105
|
-
- Ready-to-use [`pre-commit`](https://pre-commit.com/) hooks with formatters above.
|
|
106
|
-
- Type checks with the configured [`mypy`](https://mypy.readthedocs.io).
|
|
107
|
-
- Testing with [`pytest`](https://docs.pytest.org/en/latest/).
|
|
108
|
-
- Docstring checks with [`darglint`](https://github.com/terrencepreilly/darglint).
|
|
109
|
-
- Security checks with [`safety`](https://github.com/pyupio/safety) and [`bandit`](https://github.com/PyCQA/bandit).
|
|
110
|
-
- Well-made [`.editorconfig`](https://github.com/samesense/python-cath/blob/master/.editorconfig), [`.dockerignore`](https://github.com/samesense/python-cath/blob/master/.dockerignore), and [`.gitignore`](https://github.com/samesense/python-cath/blob/master/.gitignore). You don't have to worry about those things.
|
|
111
|
-
|
|
112
|
-
For building and deployment:
|
|
113
|
-
|
|
114
|
-
- `GitHub` integration.
|
|
115
|
-
- [`Makefile`](https://github.com/samesense/python-cath/blob/master/Makefile#L89) for building routines. Everything is already set up for security checks, codestyle checks, code formatting, testing, linting, docker builds, etc. More details at [Makefile summary](#makefile-usage)).
|
|
116
|
-
- [Dockerfile](https://github.com/samesense/python-cath/blob/master/docker/Dockerfile) for your package.
|
|
117
|
-
- `Github Actions` with predefined [build workflow](https://github.com/samesense/python-cath/blob/master/.github/workflows/build.yml) as the default CI/CD.
|
|
118
|
-
- Always up-to-date dependencies with [`@dependabot`](https://dependabot.com/) (You will only [enable it](https://docs.github.com/en/github/administering-a-repository/enabling-and-disabling-version-updates#enabling-github-dependabot-version-updates)).
|
|
119
|
-
- Automatic drafts of new releases with [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). It creates a list of changes based on labels in merged `Pull Requests`. You can see labels (aka `categories`) in [`release-drafter.yml`](https://github.com/samesense/python-cath/blob/master/.github/release-drafter.yml). Works perfectly with [Semantic Versions](https://semver.org/) specification.
|
|
120
|
-
|
|
121
|
-
For creating your open source community:
|
|
122
|
-
|
|
123
|
-
- Ready-to-use [Pull Requests templates](https://github.com/samesense/python-cath/blob/master/.github/PULL_REQUEST_TEMPLATE.md) and several [Issue templates](https://github.com/samesense/python-cath/tree/master/.github/ISSUE_TEMPLATE).
|
|
124
|
-
- Files such as: `LICENSE`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, and `SECURITY.md` are generated automatically.
|
|
125
|
-
- [`Stale bot`](https://github.com/apps/stale) that closes abandoned issues after a period of inactivity. (You will only [need to setup free plan](https://github.com/marketplace/stale)). Configuration is [here](https://github.com/samesense/python-cath/blob/master/.github/.stale.yml).
|
|
126
|
-
- [Semantic Versions](https://semver.org/) specification with [`Release Drafter`](https://github.com/marketplace/actions/release-drafter).
|
|
127
|
-
|
|
128
18
|
## Installation
|
|
129
19
|
|
|
130
20
|
```bash
|
|
@@ -144,7 +34,7 @@ python-cath --help
|
|
|
144
34
|
```
|
|
145
35
|
|
|
146
36
|
```bash
|
|
147
|
-
python-cath
|
|
37
|
+
python-cath file1 file2 outfile
|
|
148
38
|
```
|
|
149
39
|
|
|
150
40
|
or if installed with `Poetry`:
|
|
@@ -154,7 +44,7 @@ poetry run python-cath --help
|
|
|
154
44
|
```
|
|
155
45
|
|
|
156
46
|
```bash
|
|
157
|
-
poetry run python-cath
|
|
47
|
+
poetry run python-cath file1 file2 outfile
|
|
158
48
|
```
|
|
159
49
|
|
|
160
50
|
### Makefile usage
|
|
@@ -6,7 +6,7 @@ build-backend = "poetry.masonry.api"
|
|
|
6
6
|
|
|
7
7
|
[tool.poetry]
|
|
8
8
|
name = "python-cath"
|
|
9
|
-
version = "0.
|
|
9
|
+
version = "0.3.0"
|
|
10
10
|
description = "Cat files w/ headers"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
authors = [
|
|
@@ -32,28 +32,28 @@ classifiers = [ # Update me
|
|
|
32
32
|
"python-cath" = "python_cath.__main__:app"
|
|
33
33
|
|
|
34
34
|
[tool.poetry.dependencies]
|
|
35
|
-
python = "^3.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
pre-commit = "^2.5.1"
|
|
35
|
+
python = "^3.10"
|
|
36
|
+
typer = {extras = ["all"], version = "^0.9.0"}
|
|
37
|
+
rich = ">=10.0.0"
|
|
38
|
+
pre-commit = "^3.0.0"
|
|
40
39
|
|
|
41
40
|
[tool.poetry.dev-dependencies]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
setuptools = ">=65.0.0"
|
|
42
|
+
darglint = "^1.8.1"
|
|
43
|
+
isort = {extras = ["pyproject"], version = "^5.10.0"}
|
|
44
|
+
pyupgrade = "^3.3.0"
|
|
45
|
+
black = "^24.0.0"
|
|
46
|
+
mypy = "^1.0"
|
|
47
|
+
bandit = "^1.7.0"
|
|
48
|
+
safety = "^2.0.0"
|
|
49
|
+
pytest = "^7.0.0"
|
|
50
|
+
pylint = "^3.0.0"
|
|
51
|
+
pydocstyle = "^6.0.0"
|
|
52
52
|
|
|
53
53
|
[tool.black]
|
|
54
54
|
# https://github.com/psf/black
|
|
55
55
|
line-length = 80
|
|
56
|
-
target-version = ["
|
|
56
|
+
target-version = ["py310", "py311", "py312"]
|
|
57
57
|
|
|
58
58
|
[tool.isort]
|
|
59
59
|
# https://github.com/timothycrosley/isort/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# mypy: disable-error-code="attr-defined"
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from python_cath import __version__
|
|
7
|
+
from python_cath.concat import concat
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
app = typer.Typer(
|
|
11
|
+
name="python-cath",
|
|
12
|
+
help="Cat files w/ headers",
|
|
13
|
+
add_completion=False,
|
|
14
|
+
)
|
|
15
|
+
console = Console()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def version_callback(value: bool) -> None:
|
|
19
|
+
"""Prints the version of the package."""
|
|
20
|
+
if value:
|
|
21
|
+
console.print(
|
|
22
|
+
f"[yellow]python-cath[/] version: [bold blue]{__version__}[/]"
|
|
23
|
+
)
|
|
24
|
+
raise typer.Exit()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@app.command()
|
|
28
|
+
def main(
|
|
29
|
+
file_list: List[str] = typer.Argument(...),
|
|
30
|
+
output_file: str = typer.Argument(...),
|
|
31
|
+
) -> None:
|
|
32
|
+
"""Concatenate CSV files with a shared header into output_file."""
|
|
33
|
+
concat(file_list, output_file)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def concat(file_list, output_file):
|
|
6
|
+
"""Concatenate CSV files that share the same header.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
file_list: Paths to input files.
|
|
10
|
+
output_file: Path to write the concatenated output.
|
|
11
|
+
|
|
12
|
+
Raises:
|
|
13
|
+
ValueError: If no input files are provided, any file has an empty
|
|
14
|
+
header, an input file path collides with the output file, or
|
|
15
|
+
file headers differ.
|
|
16
|
+
"""
|
|
17
|
+
file_list = list(file_list)
|
|
18
|
+
if not file_list:
|
|
19
|
+
raise ValueError("file_list must not be empty")
|
|
20
|
+
|
|
21
|
+
real_output = os.path.realpath(output_file)
|
|
22
|
+
for afile in file_list:
|
|
23
|
+
if os.path.realpath(afile) == real_output:
|
|
24
|
+
raise ValueError(
|
|
25
|
+
f"Input file {afile!r} is the same path as the output file"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# First pass: read and validate headers one file at a time
|
|
29
|
+
file_headers = {}
|
|
30
|
+
for afile in file_list:
|
|
31
|
+
with open(afile, encoding="utf-8") as fh:
|
|
32
|
+
header = fh.readline().rstrip("\n")
|
|
33
|
+
if not header:
|
|
34
|
+
raise ValueError(f"File {afile!r} has an empty or missing header")
|
|
35
|
+
file_headers[afile] = header
|
|
36
|
+
|
|
37
|
+
unique_headers = set(file_headers.values())
|
|
38
|
+
if len(unique_headers) > 1:
|
|
39
|
+
detail = ", ".join(f"{f!r}: {h!r}" for f, h in file_headers.items())
|
|
40
|
+
raise ValueError(f"Headers do not match: {detail}")
|
|
41
|
+
|
|
42
|
+
# Second pass: write output one file at a time
|
|
43
|
+
shared_header = next(iter(unique_headers))
|
|
44
|
+
with open(output_file, "w", encoding="utf-8") as out:
|
|
45
|
+
out.write(shared_header + "\n")
|
|
46
|
+
for afile in file_list:
|
|
47
|
+
with open(afile, encoding="utf-8") as fh:
|
|
48
|
+
fh.readline() # skip header
|
|
49
|
+
shutil.copyfileobj(fh, out)
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# type: ignore[attr-defined]
|
|
2
|
-
"""Cat files w/ headers"""
|
|
3
|
-
|
|
4
|
-
try:
|
|
5
|
-
from importlib.metadata import version, PackageNotFoundError
|
|
6
|
-
except ImportError: # pragma: no cover
|
|
7
|
-
from importlib_metadata import version, PackageNotFoundError
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
try:
|
|
11
|
-
__version__ = version(__name__)
|
|
12
|
-
except PackageNotFoundError: # pragma: no cover
|
|
13
|
-
__version__ = "unknown"
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# type: ignore[attr-defined]
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import random
|
|
5
|
-
from enum import Enum
|
|
6
|
-
from typing import List, Optional
|
|
7
|
-
|
|
8
|
-
import typer
|
|
9
|
-
from rich.console import Console
|
|
10
|
-
|
|
11
|
-
from python_cath import __version__
|
|
12
|
-
from python_cath.example import hello
|
|
13
|
-
|
|
14
|
-
app = typer.Typer(
|
|
15
|
-
name="python-cath", help="Cat files w/ headers", add_completion=False,
|
|
16
|
-
)
|
|
17
|
-
console = Console()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def version_callback(value: bool):
|
|
21
|
-
"""Prints the version of the package."""
|
|
22
|
-
if value:
|
|
23
|
-
console.print(
|
|
24
|
-
f"[yellow]python-cath[/] version: [bold blue]{__version__}[/]"
|
|
25
|
-
)
|
|
26
|
-
raise typer.Exit()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def concat(file_list, output_file):
|
|
30
|
-
os.system(f"head -1 {file_list[0]} > {output_file}")
|
|
31
|
-
for afile in file_list:
|
|
32
|
-
os.system(f"tail -n +2 {afile} >> {output_file}")
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@app.command()
|
|
36
|
-
def main(
|
|
37
|
-
file_list: List[str] = typer.Argument(...),
|
|
38
|
-
output_file: str = typer.Argument(...),
|
|
39
|
-
):
|
|
40
|
-
"""Prints a greeting for a giving name."""
|
|
41
|
-
concat(file_list, output_file)
|
python-cath-0.2.0/setup.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from setuptools import setup
|
|
3
|
-
|
|
4
|
-
packages = \
|
|
5
|
-
['python_cath']
|
|
6
|
-
|
|
7
|
-
package_data = \
|
|
8
|
-
{'': ['*']}
|
|
9
|
-
|
|
10
|
-
install_requires = \
|
|
11
|
-
['pre-commit>=2.5.1,<3.0.0', 'rich>=2.2.2,<3.0.0', 'typer[all]>=0.2.1,<0.3.0']
|
|
12
|
-
|
|
13
|
-
extras_require = \
|
|
14
|
-
{':python_version < "3.8"': ['importlib_metadata>=1.6.0,<2.0.0']}
|
|
15
|
-
|
|
16
|
-
entry_points = \
|
|
17
|
-
{'console_scripts': ['python-cath = python_cath.__main__:app']}
|
|
18
|
-
|
|
19
|
-
setup_kwargs = {
|
|
20
|
-
'name': 'python-cath',
|
|
21
|
-
'version': '0.2.0',
|
|
22
|
-
'description': 'Cat files w/ headers',
|
|
23
|
-
'long_description': '# python-cath\n\n<div align="center">\n\n[](https://github.com/samesense/python-cath/actions?query=workflow%3Abuild)\n[](https://pypi.org/project/python-cath/)\n[](https://github.com/samesense/python-cath/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot)\n\n[](https://github.com/psf/black)\n[](https://github.com/PyCQA/bandit)\n[](https://github.com/samesense/python-cath/blob/master/.pre-commit-config.yaml)\n[](https://github.com/samesense/python-cath/releases)\n[](https://github.com/samesense/python-cath/blob/master/LICENSE)\n\nCat files w/ headers\n</div>\n\n## Very first steps\n\n### Initial\n\n1. Initialize `git` inside your repo:\n\n```bash\ngit init\n```\n\n2. If you don\'t have `Poetry` installed run:\n\n```bash\nmake download-poetry\n```\n\n3. Initialize poetry and install `pre-commit` hooks:\n\n```bash\nmake install\n```\n\n4. Upload initial code to GitHub (ensure you\'ve run `make install` to use `pre-commit`):\n\n```bash\ngit add .\ngit commit -m ":tada: Initial commit"\ngit remote add origin https://github.com/samesense/python-cath.git\ngit push -u origin master\n```\n\n### Initial setting up\n\n- Set up [Dependabot](https://docs.github.com/en/github/administering-a-repository/enabling-and-disabling-version-updates#enabling-github-dependabot-version-updates) to ensure you have the latest dependencies.\n- Set up [Stale bot](https://github.com/apps/stale) for automatic issue closing.\n\n### Poetry\n\nAll manipulations with dependencies are executed through Poetry. If you\'re new to it, look through [the documentation](https://python-poetry.org/docs/).\n\n<details>\n<summary>Notes about Poetry</summary>\n<p>\n\nPoetry\'s [commands](https://python-poetry.org/docs/cli/#commands) are very intuitive and easy to learn, like:\n\n- `poetry add numpy`\n- `poetry run pytest`\n- `poetry build`\n- etc\n\n</p>\n</details>\n\n### Building your package\n\nBuilding a new version of the application contains steps:\n\n- Bump the version of your package `poetry version <version>`. You can pass the new version explicitly, or a rule such as `major`, `minor`, or `patch`. For more details, refer to the [Semantic Versions](https://semver.org/) standard.\n- Make a commit to `GitHub`.\n- Create a `GitHub release`.\n- And... publish 🙂 `poetry publish --build`\n\n## What\'s next\n\nWell, that\'s up to you. I can only recommend the packages and articles that helped me.\n\nPackages:\n\n- [`Typer`](https://github.com/tiangolo/typer) is great for creating CLI applications.\n- [`Rich`](https://github.com/willmcgugan/rich) makes it easy to add beautiful formatting in the terminal.\n- [`FastAPI`](https://github.com/tiangolo/fastapi) is a type-driven asynchronous web framework.\n- [`IceCream`](https://github.com/gruns/icecream) is a little library for sweet and creamy debugging\n\nArticles:\n\n- [Open Source Guides](https://opensource.guide/)\n- [GitHub Actions Documentation](https://help.github.com/en/actions)\n- Maybe you would like to add [gitmoji](https://gitmoji.carloscuesta.me/) to commit names. This is really funny. 😄\n\n## 🚀 Features\n\nFor your development we\'ve prepared:\n\n- Supports for `Python 3.7` and higher.\n- [`Poetry`](https://python-poetry.org/) as the dependencies manager. See configuration in [`pyproject.toml`](https://github.com/samesense/python-cath/blob/master/pyproject.toml) and [`setup.cfg`](https://github.com/samesense/python-cath/blob/master/setup.cfg).\n- Power of [`black`](https://github.com/psf/black), [`isort`](https://github.com/timothycrosley/isort) and [`pyupgrade`](https://github.com/asottile/pyupgrade) formatters.\n- Ready-to-use [`pre-commit`](https://pre-commit.com/) hooks with formatters above.\n- Type checks with the configured [`mypy`](https://mypy.readthedocs.io).\n- Testing with [`pytest`](https://docs.pytest.org/en/latest/).\n- Docstring checks with [`darglint`](https://github.com/terrencepreilly/darglint).\n- Security checks with [`safety`](https://github.com/pyupio/safety) and [`bandit`](https://github.com/PyCQA/bandit).\n- Well-made [`.editorconfig`](https://github.com/samesense/python-cath/blob/master/.editorconfig), [`.dockerignore`](https://github.com/samesense/python-cath/blob/master/.dockerignore), and [`.gitignore`](https://github.com/samesense/python-cath/blob/master/.gitignore). You don\'t have to worry about those things.\n\nFor building and deployment:\n\n- `GitHub` integration.\n- [`Makefile`](https://github.com/samesense/python-cath/blob/master/Makefile#L89) for building routines. Everything is already set up for security checks, codestyle checks, code formatting, testing, linting, docker builds, etc. More details at [Makefile summary](#makefile-usage)).\n- [Dockerfile](https://github.com/samesense/python-cath/blob/master/docker/Dockerfile) for your package.\n- `Github Actions` with predefined [build workflow](https://github.com/samesense/python-cath/blob/master/.github/workflows/build.yml) as the default CI/CD.\n- Always up-to-date dependencies with [`@dependabot`](https://dependabot.com/) (You will only [enable it](https://docs.github.com/en/github/administering-a-repository/enabling-and-disabling-version-updates#enabling-github-dependabot-version-updates)).\n- Automatic drafts of new releases with [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). It creates a list of changes based on labels in merged `Pull Requests`. You can see labels (aka `categories`) in [`release-drafter.yml`](https://github.com/samesense/python-cath/blob/master/.github/release-drafter.yml). Works perfectly with [Semantic Versions](https://semver.org/) specification.\n\nFor creating your open source community:\n\n- Ready-to-use [Pull Requests templates](https://github.com/samesense/python-cath/blob/master/.github/PULL_REQUEST_TEMPLATE.md) and several [Issue templates](https://github.com/samesense/python-cath/tree/master/.github/ISSUE_TEMPLATE).\n- Files such as: `LICENSE`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, and `SECURITY.md` are generated automatically.\n- [`Stale bot`](https://github.com/apps/stale) that closes abandoned issues after a period of inactivity. (You will only [need to setup free plan](https://github.com/marketplace/stale)). Configuration is [here](https://github.com/samesense/python-cath/blob/master/.github/.stale.yml).\n- [Semantic Versions](https://semver.org/) specification with [`Release Drafter`](https://github.com/marketplace/actions/release-drafter).\n\n## Installation\n\n```bash\npip install python-cath\n```\n\nor install with `Poetry`\n\n```bash\npoetry add python-cath\n```\n\nThen you can run\n\n```bash\npython-cath --help\n```\n\n```bash\npython-cath --name Roman\n```\n\nor if installed with `Poetry`:\n\n```bash\npoetry run python-cath --help\n```\n\n```bash\npoetry run python-cath --name Roman\n```\n\n### Makefile usage\n\n[`Makefile`](https://github.com/samesense/python-cath/blob/master/Makefile) contains many functions for fast assembling and convenient work.\n\n<details>\n<summary>1. Download Poetry</summary>\n<p>\n\n```bash\nmake download-poetry\n```\n\n</p>\n</details>\n\n<details>\n<summary>2. Install all dependencies and pre-commit hooks</summary>\n<p>\n\n```bash\nmake install\n```\n\nIf you do not want to install pre-commit hooks, run the command with the NO_PRE_COMMIT flag:\n\n```bash\nmake install NO_PRE_COMMIT=1\n```\n\n</p>\n</details>\n\n<details>\n<summary>3. Check the security of your code</summary>\n<p>\n\n```bash\nmake check-safety\n```\n\nThis command launches a `Poetry` and `Pip` integrity check as well as identifies security issues with `Safety` and `Bandit`. By default, the build will not crash if any of the items fail. But you can set `STRICT=1` for the entire build, or you can configure strictness for each item separately.\n\n```bash\nmake check-safety STRICT=1\n```\n\nor only for `safety`:\n\n```bash\nmake check-safety SAFETY_STRICT=1\n```\n\nmultiple\n\n```bash\nmake check-safety PIP_STRICT=1 SAFETY_STRICT=1\n```\n\n> List of flags for `check-safety` (can be set to `1` or `0`): `STRICT`, `POETRY_STRICT`, `PIP_STRICT`, `SAFETY_STRICT`, `BANDIT_STRICT`.\n\n</p>\n</details>\n\n<details>\n<summary>4. Check the codestyle</summary>\n<p>\n\nThe command is similar to `check-safety` but to check the code style, obviously. It uses `Black`, `Darglint`, `Isort`, and `Mypy` inside.\n\n```bash\nmake check-style\n```\n\nIt may also contain the `STRICT` flag.\n\n```bash\nmake check-style STRICT=1\n```\n\n> List of flags for `check-style` (can be set to `1` or `0`): `STRICT`, `BLACK_STRICT`, `DARGLINT_STRICT`, `ISORT_STRICT`, `MYPY_STRICT`.\n\n</p>\n</details>\n\n<details>\n<summary>5. Run all the codestyle formaters</summary>\n<p>\n\nCodestyle uses `pre-commit` hooks, so ensure you\'ve run `make install` before.\n\n```bash\nmake codestyle\n```\n\n</p>\n</details>\n\n<details>\n<summary>6. Run tests</summary>\n<p>\n\n```bash\nmake test\n```\n\n</p>\n</details>\n\n<details>\n<summary>7. Run all the linters</summary>\n<p>\n\n```bash\nmake lint\n```\n\nthe same as:\n\n```bash\nmake test && make check-safety && make check-style\n```\n\n> List of flags for `lint` (can be set to `1` or `0`): `STRICT`, `POETRY_STRICT`, `PIP_STRICT`, `SAFETY_STRICT`, `BANDIT_STRICT`, `BLACK_STRICT`, `DARGLINT_STRICT`, `ISORT_STRICT`, `MYPY_STRICT`.\n\n</p>\n</details>\n\n<details>\n<summary>8. Build docker</summary>\n<p>\n\n```bash\nmake docker\n```\n\nwhich is equivalent to:\n\n```bash\nmake docker VERSION=latest\n```\n\nMore information [here](https://github.com/samesense/python-cath/tree/master/docker).\n\n</p>\n</details>\n\n<details>\n<summary>9. Cleanup docker</summary>\n<p>\n\n```bash\nmake clean_docker\n```\n\nor to remove all build\n\n```bash\nmake clean\n```\n\nMore information [here](https://github.com/samesense/python-cath/tree/master/docker).\n\n</p>\n</details>\n\n## 📈 Releases\n\nYou can see the list of available releases on the [GitHub Releases](https://github.com/samesense/python-cath/releases) page.\n\nWe follow [Semantic Versions](https://semver.org/) specification.\n\nWe use [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can categorize pull requests in release notes using labels.\n\nFor Pull Request this labels are configured, by default:\n\n| **Label** | **Title in Releases** |\n|:-------------------------------------:|:----------------------:|\n| `enhancement`, `feature` | 🚀 Features |\n| `bug`, `refactoring`, `bugfix`, `fix` | 🔧 Fixes & Refactoring |\n| `build`, `ci`, `testing` | 📦 Build System & CI/CD |\n| `breaking` | 💥 Breaking Changes |\n| `documentation` | 📝 Documentation |\n| `dependencies` | ⬆️ Dependencies updates |\n\nYou can update it in [`release-drafter.yml`](https://github.com/samesense/python-cath/blob/master/.github/release-drafter.yml).\n\nGitHub creates the `bug`, `enhancement`, and `documentation` labels for you. Dependabot creates the `dependencies` label. Create the remaining labels on the Issues tab of your GitHub repository, when you need them.\n\n## 🛡 License\n\n[](https://github.com/samesense/python-cath/blob/master/LICENSE)\n\nThis project is licensed under the terms of the `MIT` license. See [LICENSE](https://github.com/samesense/python-cath/blob/master/LICENSE) for more details.\n\n## 📃 Citation\n\n```\n@misc{python-cath,\n author = {samesense},\n title = {Cat files w/ headers},\n year = {2020},\n publisher = {GitHub},\n journal = {GitHub repository},\n howpublished = {\\url{https://github.com/samesense/python-cath}}\n}\n```\n\n## Credits\n\nThis project was generated with [`python-package-template`](https://github.com/TezRomacH/python-package-template).\n',
|
|
24
|
-
'author': 'samesense',
|
|
25
|
-
'author_email': 'candptea@gmail.com',
|
|
26
|
-
'maintainer': None,
|
|
27
|
-
'maintainer_email': None,
|
|
28
|
-
'url': 'https://github.com/samesense/python-cath',
|
|
29
|
-
'packages': packages,
|
|
30
|
-
'package_data': package_data,
|
|
31
|
-
'install_requires': install_requires,
|
|
32
|
-
'extras_require': extras_require,
|
|
33
|
-
'entry_points': entry_points,
|
|
34
|
-
'python_requires': '>=3.7,<4.0',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setup(**setup_kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|