qraft-cli 0.1.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.
- qraft_cli-0.1.0/LICENSE +21 -0
- qraft_cli-0.1.0/PKG-INFO +57 -0
- qraft_cli-0.1.0/README.md +41 -0
- qraft_cli-0.1.0/pyproject.toml +26 -0
- qraft_cli-0.1.0/setup.cfg +4 -0
- qraft_cli-0.1.0/src/qraft/__init__.py +1 -0
- qraft_cli-0.1.0/src/qraft/cli.py +166 -0
- qraft_cli-0.1.0/src/qraft/generator.py +148 -0
- qraft_cli-0.1.0/src/qraft/main.py +4 -0
- qraft_cli-0.1.0/src/qraft_cli.egg-info/PKG-INFO +57 -0
- qraft_cli-0.1.0/src/qraft_cli.egg-info/SOURCES.txt +14 -0
- qraft_cli-0.1.0/src/qraft_cli.egg-info/dependency_links.txt +1 -0
- qraft_cli-0.1.0/src/qraft_cli.egg-info/entry_points.txt +2 -0
- qraft_cli-0.1.0/src/qraft_cli.egg-info/requires.txt +7 -0
- qraft_cli-0.1.0/src/qraft_cli.egg-info/top_level.txt +1 -0
- qraft_cli-0.1.0/tests/test_generator.py +52 -0
qraft_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andreea Patrascu-Udrea
|
|
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.
|
qraft_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qraft-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A customizable QR code generator built with Python.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: qrcode[pil]>=8.0
|
|
10
|
+
Requires-Dist: Pillow>=10.0
|
|
11
|
+
Requires-Dist: typer>=0.12
|
|
12
|
+
Requires-Dist: rich>=13.0
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# Qraft
|
|
18
|
+
|
|
19
|
+
A customizable QR code generator built with Python.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Generate QR codes from URLs and text.
|
|
24
|
+
- Customize foreground and background colors.
|
|
25
|
+
- Add logos to QR codes.
|
|
26
|
+
- Choose different QR module styles.
|
|
27
|
+
- Configure error correction levels.
|
|
28
|
+
- Interactive CLI.
|
|
29
|
+
- Export QR codes as PNG images.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone YOUR_REPOSITORY_URL
|
|
35
|
+
cd qraft
|
|
36
|
+
|
|
37
|
+
python -m venv .venv
|
|
38
|
+
pip install -e ".[dev]"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
qraft create "https://github.com"
|
|
45
|
+
qraft interactive
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Technologies
|
|
49
|
+
- Python
|
|
50
|
+
- qrcode
|
|
51
|
+
- Pillow
|
|
52
|
+
- Typer
|
|
53
|
+
- Rich
|
|
54
|
+
- Pytest
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
MIT
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Qraft
|
|
2
|
+
|
|
3
|
+
A customizable QR code generator built with Python.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Generate QR codes from URLs and text.
|
|
8
|
+
- Customize foreground and background colors.
|
|
9
|
+
- Add logos to QR codes.
|
|
10
|
+
- Choose different QR module styles.
|
|
11
|
+
- Configure error correction levels.
|
|
12
|
+
- Interactive CLI.
|
|
13
|
+
- Export QR codes as PNG images.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone YOUR_REPOSITORY_URL
|
|
19
|
+
cd qraft
|
|
20
|
+
|
|
21
|
+
python -m venv .venv
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
qraft create "https://github.com"
|
|
29
|
+
qraft interactive
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Technologies
|
|
33
|
+
- Python
|
|
34
|
+
- qrcode
|
|
35
|
+
- Pillow
|
|
36
|
+
- Typer
|
|
37
|
+
- Rich
|
|
38
|
+
- Pytest
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qraft-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A customizable QR code generator built with Python."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"qrcode[pil]>=8.0",
|
|
14
|
+
"Pillow>=10.0",
|
|
15
|
+
"typer>=0.12",
|
|
16
|
+
"rich>=13.0"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
qraft = "qraft.main:app"
|
|
21
|
+
|
|
22
|
+
[tool.setuptools.packages.find]
|
|
23
|
+
where = ["src"]
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
dev = ["pytest>=8.0"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from rich.panel import Panel
|
|
6
|
+
from rich import print
|
|
7
|
+
|
|
8
|
+
from qraft.generator import generate_qr
|
|
9
|
+
|
|
10
|
+
app = typer.Typer(
|
|
11
|
+
name="qraft",
|
|
12
|
+
help="A customizable QR code generator.",
|
|
13
|
+
no_args_is_help=True,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
console = Console()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@app.command()
|
|
20
|
+
def create(
|
|
21
|
+
data: str = typer.Argument(
|
|
22
|
+
...,
|
|
23
|
+
help="Text or URL to encode.",
|
|
24
|
+
),
|
|
25
|
+
output: Path = typer.Option(
|
|
26
|
+
Path("output/qr.png"),
|
|
27
|
+
"--output",
|
|
28
|
+
"-o",
|
|
29
|
+
help="Output image path.",
|
|
30
|
+
),
|
|
31
|
+
foreground: str = typer.Option(
|
|
32
|
+
"#000000",
|
|
33
|
+
"--color",
|
|
34
|
+
"-c",
|
|
35
|
+
help="QR foreground color.",
|
|
36
|
+
),
|
|
37
|
+
background: str = typer.Option(
|
|
38
|
+
"#FFFFFF",
|
|
39
|
+
"--background",
|
|
40
|
+
"-b",
|
|
41
|
+
help="QR background color.",
|
|
42
|
+
),
|
|
43
|
+
box_size: int = typer.Option(
|
|
44
|
+
10,
|
|
45
|
+
"--size",
|
|
46
|
+
"-s",
|
|
47
|
+
min=1,
|
|
48
|
+
help="QR module size.",
|
|
49
|
+
),
|
|
50
|
+
border: int = typer.Option(
|
|
51
|
+
4,
|
|
52
|
+
"--border",
|
|
53
|
+
min=4,
|
|
54
|
+
help="QR border width.",
|
|
55
|
+
),
|
|
56
|
+
correction: str = typer.Option(
|
|
57
|
+
"H",
|
|
58
|
+
"--correction",
|
|
59
|
+
"-e",
|
|
60
|
+
help="Error correction: L, M, Q or H.",
|
|
61
|
+
),
|
|
62
|
+
style: str = typer.Option(
|
|
63
|
+
"square",
|
|
64
|
+
"--style",
|
|
65
|
+
help="QR style: square, rounded or circle.",
|
|
66
|
+
),
|
|
67
|
+
logo: Path | None = typer.Option(
|
|
68
|
+
None,
|
|
69
|
+
"--logo",
|
|
70
|
+
help="Optional center logo.",
|
|
71
|
+
exists=True,
|
|
72
|
+
dir_okay=False,
|
|
73
|
+
readable=True,
|
|
74
|
+
),
|
|
75
|
+
):
|
|
76
|
+
"""Generate a customizable QR code."""
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
result = generate_qr(
|
|
80
|
+
data=data,
|
|
81
|
+
output=str(output),
|
|
82
|
+
foreground=foreground,
|
|
83
|
+
background=background,
|
|
84
|
+
box_size=box_size,
|
|
85
|
+
border=border,
|
|
86
|
+
error_correction=correction.upper(),
|
|
87
|
+
style=style.lower(),
|
|
88
|
+
logo=str(logo) if logo else None,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
console.print(
|
|
92
|
+
Panel(
|
|
93
|
+
f"[bold green]QR code generated successfully![/bold green]\n\n"
|
|
94
|
+
f"Saved to: [cyan]{result}[/cyan]",
|
|
95
|
+
title="Qraft",
|
|
96
|
+
border_style="green",
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
except (ValueError, FileNotFoundError) as error:
|
|
101
|
+
console.print(f"[bold red]Error:[/bold red] {error}")
|
|
102
|
+
raise typer.Exit(code=1)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@app.command()
|
|
106
|
+
def interactive():
|
|
107
|
+
"""Generate a QR code using interactive prompts."""
|
|
108
|
+
|
|
109
|
+
console.print(
|
|
110
|
+
Panel(
|
|
111
|
+
"[bold cyan]Welcome to Qraft![/bold cyan]\n"
|
|
112
|
+
"Create your own customizable QR code.",
|
|
113
|
+
border_style="cyan",
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
data = typer.prompt("Enter your URL or text")
|
|
118
|
+
|
|
119
|
+
foreground = typer.prompt(
|
|
120
|
+
"Foreground color",
|
|
121
|
+
default="#000000",
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
background = typer.prompt(
|
|
125
|
+
"Background color",
|
|
126
|
+
default="#FFFFFF",
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
style = typer.prompt(
|
|
130
|
+
"Style (square/rounded/circle)",
|
|
131
|
+
default="square",
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
correction = typer.prompt(
|
|
135
|
+
"Error correction (L/M/Q/H)",
|
|
136
|
+
default="H",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
output = typer.prompt(
|
|
140
|
+
"Output path",
|
|
141
|
+
default="output/qr.png",
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
logo = typer.prompt(
|
|
145
|
+
"Logo path (leave empty to skip)",
|
|
146
|
+
default="",
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
try:
|
|
150
|
+
result = generate_qr(
|
|
151
|
+
data=data,
|
|
152
|
+
output=output,
|
|
153
|
+
foreground=foreground,
|
|
154
|
+
background=background,
|
|
155
|
+
style=style.lower(),
|
|
156
|
+
error_correction=correction.upper(),
|
|
157
|
+
logo=logo or None,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
console.print(
|
|
161
|
+
f"\n[bold green]Success![/bold green] QR saved to {result}"
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
except (ValueError, FileNotFoundError) as error:
|
|
165
|
+
console.print(f"[bold red]Error:[/bold red] {error}")
|
|
166
|
+
raise typer.Exit(code=1)
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import qrcode
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from PIL import Image, ImageColor
|
|
5
|
+
|
|
6
|
+
from qrcode.constants import (
|
|
7
|
+
ERROR_CORRECT_L,
|
|
8
|
+
ERROR_CORRECT_M,
|
|
9
|
+
ERROR_CORRECT_Q,
|
|
10
|
+
ERROR_CORRECT_H,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from qrcode.image.styledpil import StyledPilImage
|
|
14
|
+
from qrcode.image.styles.colormasks import SolidFillColorMask
|
|
15
|
+
from qrcode.image.styles.moduledrawers import (
|
|
16
|
+
SquareModuleDrawer,
|
|
17
|
+
RoundedModuleDrawer,
|
|
18
|
+
CircleModuleDrawer,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
ERROR_LEVELS = {
|
|
23
|
+
"L": ERROR_CORRECT_L,
|
|
24
|
+
"M": ERROR_CORRECT_M,
|
|
25
|
+
"Q": ERROR_CORRECT_Q,
|
|
26
|
+
"H": ERROR_CORRECT_H,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
MODULE_STYLES = {
|
|
30
|
+
"square": SquareModuleDrawer,
|
|
31
|
+
"rounded": RoundedModuleDrawer,
|
|
32
|
+
"circle": CircleModuleDrawer,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def generate_qr(
|
|
37
|
+
data: str,
|
|
38
|
+
output: str = "output/qr.png",
|
|
39
|
+
foreground: str = "#000000",
|
|
40
|
+
background: str = "#FFFFFF",
|
|
41
|
+
box_size: int = 10,
|
|
42
|
+
border: int = 4,
|
|
43
|
+
error_correction: str = "H",
|
|
44
|
+
style: str = "square",
|
|
45
|
+
logo: str | None = None,
|
|
46
|
+
):
|
|
47
|
+
"""
|
|
48
|
+
Generate a customizable QR code.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
data: Text or URL to encode.
|
|
52
|
+
output: Output image path.
|
|
53
|
+
foreground: QR foreground color.
|
|
54
|
+
background: QR background color.
|
|
55
|
+
box_size: Size of each QR module.
|
|
56
|
+
border: QR border width.
|
|
57
|
+
error_correction: L, M, Q or H.
|
|
58
|
+
style: square, rounded or circle.
|
|
59
|
+
logo: Optional path to a center logo.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
if not data.strip():
|
|
63
|
+
raise ValueError("QR content cannot be empty.")
|
|
64
|
+
|
|
65
|
+
if error_correction not in ERROR_LEVELS:
|
|
66
|
+
raise ValueError("Invalid error correction level.")
|
|
67
|
+
|
|
68
|
+
if style not in MODULE_STYLES:
|
|
69
|
+
raise ValueError("Invalid QR style.")
|
|
70
|
+
|
|
71
|
+
if box_size < 1:
|
|
72
|
+
raise ValueError("Box size must be positive.")
|
|
73
|
+
|
|
74
|
+
if border < 4:
|
|
75
|
+
raise ValueError("Border should be at least 4 modules.")
|
|
76
|
+
|
|
77
|
+
qr = qrcode.QRCode(
|
|
78
|
+
version=None,
|
|
79
|
+
error_correction=ERROR_LEVELS[error_correction],
|
|
80
|
+
box_size=box_size,
|
|
81
|
+
border=border,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
qr.add_data(data)
|
|
85
|
+
qr.make(fit=True)
|
|
86
|
+
|
|
87
|
+
image = qr.make_image(
|
|
88
|
+
image_factory=StyledPilImage,
|
|
89
|
+
module_drawer=MODULE_STYLES[style](),
|
|
90
|
+
color_mask=SolidFillColorMask(
|
|
91
|
+
front_color=ImageColor.getrgb(foreground),
|
|
92
|
+
back_color=ImageColor.getrgb(background),
|
|
93
|
+
),
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
image = image.convert("RGB")
|
|
97
|
+
|
|
98
|
+
if logo:
|
|
99
|
+
image = add_logo(image, logo)
|
|
100
|
+
|
|
101
|
+
output_path = Path(output)
|
|
102
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
103
|
+
|
|
104
|
+
image.save(output_path)
|
|
105
|
+
|
|
106
|
+
return output_path
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def add_logo(image: Image.Image, logo_path: str) -> Image.Image:
|
|
110
|
+
"""Add a small logo in the center of the QR code."""
|
|
111
|
+
|
|
112
|
+
logo_file = Path(logo_path)
|
|
113
|
+
|
|
114
|
+
if not logo_file.is_file():
|
|
115
|
+
raise FileNotFoundError(f"Logo not found: {logo_path}")
|
|
116
|
+
|
|
117
|
+
logo = Image.open(logo_file).convert("RGBA")
|
|
118
|
+
|
|
119
|
+
qr_width, qr_height = image.size
|
|
120
|
+
|
|
121
|
+
# Keep the logo relatively small for scan reliability.
|
|
122
|
+
max_size = int(min(qr_width, qr_height) * 0.18)
|
|
123
|
+
|
|
124
|
+
logo.thumbnail((max_size, max_size), Image.Resampling.LANCZOS)
|
|
125
|
+
|
|
126
|
+
# Add a white background behind the logo.
|
|
127
|
+
padding = max(8, int(max_size * 0.12))
|
|
128
|
+
|
|
129
|
+
logo_background = Image.new(
|
|
130
|
+
"RGB",
|
|
131
|
+
(logo.width + padding * 2, logo.height + padding * 2),
|
|
132
|
+
"white",
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
logo_background.paste(
|
|
136
|
+
logo,
|
|
137
|
+
(padding, padding),
|
|
138
|
+
logo,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
position = (
|
|
142
|
+
(qr_width - logo_background.width) // 2,
|
|
143
|
+
(qr_height - logo_background.height) // 2,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
image.paste(logo_background, position)
|
|
147
|
+
|
|
148
|
+
return image
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qraft-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A customizable QR code generator built with Python.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: qrcode[pil]>=8.0
|
|
10
|
+
Requires-Dist: Pillow>=10.0
|
|
11
|
+
Requires-Dist: typer>=0.12
|
|
12
|
+
Requires-Dist: rich>=13.0
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# Qraft
|
|
18
|
+
|
|
19
|
+
A customizable QR code generator built with Python.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Generate QR codes from URLs and text.
|
|
24
|
+
- Customize foreground and background colors.
|
|
25
|
+
- Add logos to QR codes.
|
|
26
|
+
- Choose different QR module styles.
|
|
27
|
+
- Configure error correction levels.
|
|
28
|
+
- Interactive CLI.
|
|
29
|
+
- Export QR codes as PNG images.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone YOUR_REPOSITORY_URL
|
|
35
|
+
cd qraft
|
|
36
|
+
|
|
37
|
+
python -m venv .venv
|
|
38
|
+
pip install -e ".[dev]"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
qraft create "https://github.com"
|
|
45
|
+
qraft interactive
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Technologies
|
|
49
|
+
- Python
|
|
50
|
+
- qrcode
|
|
51
|
+
- Pillow
|
|
52
|
+
- Typer
|
|
53
|
+
- Rich
|
|
54
|
+
- Pytest
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/qraft/__init__.py
|
|
5
|
+
src/qraft/cli.py
|
|
6
|
+
src/qraft/generator.py
|
|
7
|
+
src/qraft/main.py
|
|
8
|
+
src/qraft_cli.egg-info/PKG-INFO
|
|
9
|
+
src/qraft_cli.egg-info/SOURCES.txt
|
|
10
|
+
src/qraft_cli.egg-info/dependency_links.txt
|
|
11
|
+
src/qraft_cli.egg-info/entry_points.txt
|
|
12
|
+
src/qraft_cli.egg-info/requires.txt
|
|
13
|
+
src/qraft_cli.egg-info/top_level.txt
|
|
14
|
+
tests/test_generator.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
qraft
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from PIL import Image
|
|
4
|
+
|
|
5
|
+
from qraft.generator import generate_qr
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_generate_qr(tmp_path):
|
|
9
|
+
output = tmp_path / "test_qr.png"
|
|
10
|
+
|
|
11
|
+
result = generate_qr(
|
|
12
|
+
data="https://github.com",
|
|
13
|
+
output=str(output),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
assert result.exists()
|
|
17
|
+
assert result.suffix == ".png"
|
|
18
|
+
|
|
19
|
+
image = Image.open(result)
|
|
20
|
+
|
|
21
|
+
assert image.format == "PNG"
|
|
22
|
+
assert image.width > 0
|
|
23
|
+
assert image.height > 0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_generate_custom_qr(tmp_path):
|
|
27
|
+
output = tmp_path / "custom.png"
|
|
28
|
+
|
|
29
|
+
generate_qr(
|
|
30
|
+
data="Hello Qraft!",
|
|
31
|
+
output=str(output),
|
|
32
|
+
foreground="#263238",
|
|
33
|
+
background="#FFFFFF",
|
|
34
|
+
style="rounded",
|
|
35
|
+
error_correction="H",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
assert output.exists()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_empty_input(tmp_path):
|
|
42
|
+
output = tmp_path / "empty.png"
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
generate_qr(
|
|
46
|
+
data="",
|
|
47
|
+
output=str(output),
|
|
48
|
+
)
|
|
49
|
+
assert False, "Expected ValueError"
|
|
50
|
+
|
|
51
|
+
except ValueError:
|
|
52
|
+
assert not output.exists()
|