python-cath 0.2.5__tar.gz → 0.4.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.
@@ -1,24 +1,27 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-cath
3
- Version: 0.2.5
3
+ Version: 0.4.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.7,<4.0
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.7
16
- Classifier: Programming Language :: Python :: 3.8
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: importlib_metadata (>=1.6.0,<2.0.0); python_version < "3.8"
19
- Requires-Dist: pre-commit (>=2.5.1,<3.0.0)
20
- Requires-Dist: rich (>=2.2.2,<3.0.0)
21
- Requires-Dist: typer[all] (>=0.2.1,<0.3.0)
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
 
@@ -58,7 +61,7 @@ python-cath --help
58
61
  ```
59
62
 
60
63
  ```bash
61
- python-cath file1 file2 outfile
64
+ python-cath file1 file2 --output outfile
62
65
  ```
63
66
 
64
67
  or if installed with `Poetry`:
@@ -68,7 +71,7 @@ poetry run python-cath --help
68
71
  ```
69
72
 
70
73
  ```bash
71
- poetry run python-cath file1 file2 outfile
74
+ poetry run python-cath file1 file2 --output outfile
72
75
  ```
73
76
 
74
77
  ### Makefile usage
@@ -34,7 +34,7 @@ python-cath --help
34
34
  ```
35
35
 
36
36
  ```bash
37
- python-cath file1 file2 outfile
37
+ python-cath file1 file2 --output outfile
38
38
  ```
39
39
 
40
40
  or if installed with `Poetry`:
@@ -44,7 +44,7 @@ poetry run python-cath --help
44
44
  ```
45
45
 
46
46
  ```bash
47
- poetry run python-cath file1 file2 outfile
47
+ poetry run python-cath file1 file2 --output outfile
48
48
  ```
49
49
 
50
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.2.5"
9
+ version = "0.4.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.7"
36
- importlib_metadata = {version = "^1.6.0", python = "<3.8"}
37
- typer = {extras = ["all"], version = "^0.2.1"}
38
- rich = "^2.2.2"
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
- darglint = "^1.4.1"
43
- isort = {extras = ["pyproject"], version = "^4.3.21"}
44
- pyupgrade = "^2.6.1"
45
- black = "^19.10b0"
46
- mypy = "^0.780"
47
- bandit = "^1.6.2"
48
- safety = "^1.9.0"
49
- pytest = "^6.1.2"
50
- pylint = "^2.5.3"
51
- pydocstyle = "^5.0.2"
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 = ["py37"]
56
+ target-version = ["py310", "py311", "py312"]
57
57
 
58
58
  [tool.isort]
59
59
  # https://github.com/timothycrosley/isort/
@@ -0,0 +1,9 @@
1
+ # mypy: disable-error-code="attr-defined"
2
+ """Cat files w/ headers"""
3
+
4
+ from importlib.metadata import PackageNotFoundError, version
5
+
6
+ try:
7
+ __version__ = version(__name__)
8
+ except PackageNotFoundError: # pragma: no cover
9
+ __version__ = "unknown"
@@ -1,23 +1,23 @@
1
- # type: ignore[attr-defined]
1
+ # mypy: disable-error-code="attr-defined"
2
2
 
3
- import random
4
- from enum import Enum
5
- from typing import List, Optional
3
+ from typing import List
6
4
 
7
5
  import typer
8
- from rich.console import Console
9
-
10
6
  from python_cath import __version__
11
7
  from python_cath.concat import concat
12
- from python_cath.example import hello
8
+ from rich.console import Console
13
9
 
14
10
  app = typer.Typer(
15
- name="python-cath", help="Cat files w/ headers", add_completion=False,
11
+ name="python-cath",
12
+ help="Cat files w/ headers",
13
+ add_completion=False,
14
+ invoke_without_command=True,
15
+ no_args_is_help=True,
16
16
  )
17
17
  console = Console()
18
18
 
19
19
 
20
- def version_callback(value: bool):
20
+ def version_callback(value: bool) -> None:
21
21
  """Prints the version of the package."""
22
22
  if value:
23
23
  console.print(
@@ -29,7 +29,9 @@ def version_callback(value: bool):
29
29
  @app.command()
30
30
  def main(
31
31
  file_list: List[str] = typer.Argument(...),
32
- output_file: str = typer.Argument(...),
33
- ):
34
- """Prints a greeting for a giving name."""
32
+ output_file: str = typer.Option(
33
+ ..., "--output", "-o", help="Output file path"
34
+ ),
35
+ ) -> None:
36
+ """Concatenate CSV files with a shared header into output_file."""
35
37
  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,7 +0,0 @@
1
- import os
2
-
3
-
4
- def concat(file_list, output_file):
5
- os.system(f"head -1 {file_list[0]} > {output_file}")
6
- for afile in file_list:
7
- os.system(f"tail -n +2 {afile} >> {output_file}")
@@ -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.5',
22
- 'description': 'Cat files w/ headers',
23
- 'long_description': '# python-cath\n\n<div align="center">\n\n[![Build status](https://github.com/samesense/python-cath/workflows/build/badge.svg?branch=master&event=push)](https://github.com/samesense/python-cath/actions?query=workflow%3Abuild)\n[![Python Version](https://img.shields.io/pypi/pyversions/python-cath.svg)](https://pypi.org/project/python-cath/)\n[![Dependencies Status](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen.svg)](https://github.com/samesense/python-cath/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot)\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Security: bandit](https://img.shields.io/badge/security-bandit-green.svg)](https://github.com/PyCQA/bandit)\n[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/samesense/python-cath/blob/master/.pre-commit-config.yaml)\n[![Semantic Versions](https://img.shields.io/badge/%F0%9F%9A%80-semantic%20versions-informational.svg)](https://github.com/samesense/python-cath/releases)\n[![License](https://img.shields.io/github/license/samesense/python-cath)](https://github.com/samesense/python-cath/blob/master/LICENSE)\n\nCat files w/ headers\n</div>\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 file1 file2 outfile\n```\n\nor if installed with `Poetry`:\n\n```bash\npoetry run python-cath --help\n```\n\n```bash\npoetry run python-cath file1 file2 outfile\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[![License](https://img.shields.io/github/license/samesense/python-cath)](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