csvnorm 1.2.15__tar.gz → 1.2.16__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.
Files changed (27) hide show
  1. {csvnorm-1.2.15/src/csvnorm.egg-info → csvnorm-1.2.16}/PKG-INFO +1 -1
  2. {csvnorm-1.2.15 → csvnorm-1.2.16}/pyproject.toml +1 -1
  3. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/cli.py +25 -28
  4. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/ui.py +5 -4
  5. {csvnorm-1.2.15 → csvnorm-1.2.16/src/csvnorm.egg-info}/PKG-INFO +1 -1
  6. {csvnorm-1.2.15 → csvnorm-1.2.16}/LICENSE +0 -0
  7. {csvnorm-1.2.15 → csvnorm-1.2.16}/README.md +0 -0
  8. {csvnorm-1.2.15 → csvnorm-1.2.16}/setup.cfg +0 -0
  9. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/__init__.py +0 -0
  10. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/__main__.py +0 -0
  11. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/core.py +0 -0
  12. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/encoding.py +0 -0
  13. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/mojibake.py +0 -0
  14. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/utils.py +0 -0
  15. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm/validation.py +0 -0
  16. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm.egg-info/SOURCES.txt +0 -0
  17. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm.egg-info/dependency_links.txt +0 -0
  18. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm.egg-info/entry_points.txt +0 -0
  19. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm.egg-info/requires.txt +0 -0
  20. {csvnorm-1.2.15 → csvnorm-1.2.16}/src/csvnorm.egg-info/top_level.txt +0 -0
  21. {csvnorm-1.2.15 → csvnorm-1.2.16}/tests/test_cli.py +0 -0
  22. {csvnorm-1.2.15 → csvnorm-1.2.16}/tests/test_core_helpers.py +0 -0
  23. {csvnorm-1.2.15 → csvnorm-1.2.16}/tests/test_encoding.py +0 -0
  24. {csvnorm-1.2.15 → csvnorm-1.2.16}/tests/test_integration.py +0 -0
  25. {csvnorm-1.2.15 → csvnorm-1.2.16}/tests/test_mojibake.py +0 -0
  26. {csvnorm-1.2.15 → csvnorm-1.2.16}/tests/test_utils.py +0 -0
  27. {csvnorm-1.2.15 → csvnorm-1.2.16}/tests/test_validation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csvnorm
3
- Version: 1.2.15
3
+ Version: 1.2.16
4
4
  Summary: A command-line utility to validate and normalize CSV files
5
5
  Author-email: aborruso <aborruso@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "csvnorm"
7
- version = "1.2.15"
7
+ version = "1.2.16"
8
8
  description = "A command-line utility to validate and normalize CSV files"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -6,7 +6,7 @@ from pathlib import Path
6
6
  from typing import Optional
7
7
 
8
8
  from rich.console import Console
9
- from rich_argparse import RichHelpFormatter
9
+ from rich_argparse import RawDescriptionRichHelpFormatter
10
10
 
11
11
  from importlib.metadata import version
12
12
  from csvnorm.core import process_csv
@@ -23,30 +23,6 @@ def show_banner() -> None:
23
23
  console.print()
24
24
 
25
25
 
26
- def show_examples() -> None:
27
- console.print()
28
- console.print("[orange1]Examples:[/orange1]")
29
- console.print(" # Base command with stdout output")
30
- console.print(" [cyan]csvnorm data.csv[/cyan]")
31
- console.print(" # Output to stdout")
32
- console.print(" [cyan]csvnorm data.csv -o output.csv[/cyan]")
33
- console.print(" # Write to file")
34
- console.print(" [cyan]csvnorm data.csv > output.csv[/cyan]")
35
- console.print(" # Shell redirect")
36
- console.print(" [cyan]csvnorm data.csv | head -20[/cyan]")
37
- console.print(" # Preview with pipe")
38
- console.print(" [cyan]csvnorm data.csv --check[/cyan]")
39
- console.print(" # Validate without processing")
40
- console.print(" [cyan]csvnorm data.csv --strict | process.sh[/cyan]")
41
- console.print(" # Fail-fast mode for pipelines")
42
- console.print(" [cyan]csvnorm data.csv -d ';' -o output.csv[/cyan]")
43
- console.print(" # Custom delimiter")
44
- console.print(" [cyan]csvnorm data.csv --skip-rows 2 -o out.csv[/cyan]")
45
- console.print(" # Skip first 2 rows")
46
- console.print(" [cyan]cat data.csv | csvnorm -[/cyan]")
47
- console.print(" # Read from stdin")
48
- console.print(" [cyan]csvnorm https://example.com/data.csv -o processed.csv[/cyan]")
49
-
50
26
 
51
27
  class VersionAction(argparse.Action):
52
28
  """Custom action to show banner with version."""
@@ -74,12 +50,28 @@ class VersionAction(argparse.Action):
74
50
  parser.exit()
75
51
 
76
52
 
53
+ _EXAMPLES = """
54
+ Examples:
55
+ csvnorm data.csv Output to stdout (default)
56
+ csvnorm data.csv -o output.csv Write to file
57
+ csvnorm data.csv > output.csv Shell redirect
58
+ csvnorm data.csv | head -20 Pipe to another command
59
+ csvnorm data.csv --check Validate only, no output
60
+ csvnorm data.csv --strict | process.sh Fail-fast pipeline
61
+ csvnorm data.csv -d ';' -o output.csv Custom delimiter
62
+ csvnorm data.csv --skip-rows 2 -o out.csv Skip metadata rows
63
+ cat data.csv | csvnorm - Read from stdin
64
+ csvnorm https://example.com/data.csv -o out.csv Remote URL
65
+ """
66
+
67
+
77
68
  def create_parser() -> argparse.ArgumentParser:
78
69
  """Create and return the argument parser."""
79
70
  parser = argparse.ArgumentParser(
80
71
  prog="csvnorm",
81
72
  description="Validate and normalize CSV files for exploratory data analysis",
82
- formatter_class=RichHelpFormatter,
73
+ formatter_class=RawDescriptionRichHelpFormatter,
74
+ epilog=_EXAMPLES,
83
75
  )
84
76
 
85
77
  parser.add_argument(
@@ -224,7 +216,6 @@ def main(argv: Optional[list[str]] = None) -> int:
224
216
  )
225
217
  console.print()
226
218
  parser.print_help()
227
- show_examples()
228
219
  return 0 if argv else 2
229
220
 
230
221
  args = parser.parse_args(argv)
@@ -266,12 +257,18 @@ def main(argv: Optional[list[str]] = None) -> int:
266
257
  return 1
267
258
 
268
259
  if auto_output.exists() and not args.force:
260
+ if not sys.stdin.isatty():
261
+ console.print(
262
+ f"[red]Error:[/red] Output file already exists: {auto_output}\n"
263
+ "Use --force to overwrite."
264
+ )
265
+ return 1
269
266
  console.print(f"[yellow]Output file already exists:[/yellow] {auto_output}")
270
267
  try:
271
268
  confirm = input("Overwrite? [y/N] ").strip().lower()
272
269
  except (EOFError, KeyboardInterrupt):
273
270
  console.print("\nAborted.")
274
- return 0
271
+ return 1
275
272
  if confirm != "y":
276
273
  console.print("Aborted.")
277
274
  return 0
@@ -11,6 +11,7 @@ from csvnorm.encoding import needs_conversion
11
11
  from csvnorm.utils import format_file_size
12
12
 
13
13
  console = Console()
14
+ err_console = Console(stderr=True)
14
15
 
15
16
 
16
17
  def show_error_panel(message: str, title: str = "Error") -> None:
@@ -20,7 +21,7 @@ def show_error_panel(message: str, title: str = "Error") -> None:
20
21
  message: Error message to display.
21
22
  title: Panel title (default: "Error").
22
23
  """
23
- console.print(Panel(f"[bold red]{title}:[/bold red] {message}", border_style="red"))
24
+ err_console.print(Panel(f"[bold red]{title}:[/bold red] {message}", border_style="red"))
24
25
 
25
26
 
26
27
  def show_warning_panel(message: str, title: str = "Warning") -> None:
@@ -30,7 +31,7 @@ def show_warning_panel(message: str, title: str = "Warning") -> None:
30
31
  message: Warning message to display.
31
32
  title: Panel title (default: "Warning").
32
33
  """
33
- console.print(
34
+ err_console.print(
34
35
  Panel(f"[bold yellow]{title}:[/bold yellow] {message}", border_style="yellow")
35
36
  )
36
37
 
@@ -118,9 +119,9 @@ def show_validation_error_panel(
118
119
  reject_count: Number of rejected rows (including header).
119
120
  error_types: List of error type descriptions.
120
121
  reject_file: Path to reject errors CSV file.
121
- console_out: Optional console to use (defaults to module console).
122
+ console_out: Optional console to use (defaults to stderr).
122
123
  """
123
- target_console = console_out or console
124
+ target_console = console_out or err_console
124
125
  target_console.print()
125
126
  error_lines = []
126
127
  error_lines.append("[bold red]Validation Errors:[/bold red]")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csvnorm
3
- Version: 1.2.15
3
+ Version: 1.2.16
4
4
  Summary: A command-line utility to validate and normalize CSV files
5
5
  Author-email: aborruso <aborruso@gmail.com>
6
6
  License: MIT License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes