🖨 Python CUPS print options generator from PPD
📥 Installation
📦 From pip:
python -m pip install -U pycups_po
🏗 From git:
git clone https://github.com/WhiteApfel/pycups_po.git
cd pycups_po
python setup.py install
🧑🏫 How to use
🐍 Example
import cups
from pycups_po import PrinterOptionsGenerator
from pycups_po.models import PrinterOption
conn = cups.Connection()
generator = PrinterOptionsGenerator(conn, "CT-S2000")
ops: list[PrinterOption] = generator.get_ppd_options()
for op in ops:
print(op)
with open("tr4500.py", "w+") as f:
f.write(generator.generate_options_dataclass(printer_name="TR-4500"))
You can specify name of printer when init PrinterOptionsGenerator, then it will be used by default.
Or you can pass name to function.
📋 Dataclasses
@dataclass
class OptionValue:
value: str
pretty_value: str
content: str
@dataclass
class PrinterOption:
name: str
pretty_name: Optional[str]
type: Literal["PickOne"]
default_value: str
values: List[OptionValue]
💻 CLI
Show list of printers
pycups_po printers
# or
pycups_po printers --host 192.168.1.12
# or
pycups_po printers --host 192.168.1.12 --port 6631
🖨 Printers
├── CT-S2000
│ ├── Info: CITIZEN CT-S2000
│ └── State: ⏳ idle
└── TR4540
├── Info: Canon TR4540
└── State: ⏳ idle
Show options
pycups_po options TR4540
# You can set the --host and --port in the same way
⚙️ Options
├── MediaType (Media Type)
│ ├── Type: PickOne
│ ├── Default: matte
│ └── Values:
│ ├── 'plain' (Plain Paper): <</MediaType(plain)>>setpagedevice
│ ├── 'glossygold' (Photo Paper Plus Glossy II): <</MediaType(glossygold)>>setpagedevice
...
├── Duplex (Duplex Printing)
│ ├── Type: PickOne
│ ├── Default: None
│ └── Values:
│ ├── 'None' (Off):
│ ├── 'DuplexNoTumble' (Long-side stapling):
│ └── 'DuplexTumble' (Short-side stapling):
└── ColorModel (Color Model)
├── Type: PickOne
├── Default: rgb
└── Values:
└── 'rgb' (RGB):
Generate dataclass file
pycups_po generate -o ./tr4540.py TR4540
# or
pycups_po generate --output-file ~/printer.py TR4540
# You can set the --host and --port in the same way
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycups_po-0.1.1.tar.gz
(11.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pycups_po-0.1.1-py3-none-any.whl
(12.1 kB
view details)
File details
Details for the file pycups_po-0.1.1.tar.gz.
File metadata
- Download URL: pycups_po-0.1.1.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5db37479f402cb6467b94c28dc746caf1b791fc94122fdd98c30fb47d168a9d7
|
|
| MD5 |
1ee9cca55f05ea27d68bf8e9bcc7237b
|
|
| BLAKE2b-256 |
cc1b925c83fea9e3030d98c02bb475748746cec0434d5194e559961f60e13cac
|
File details
Details for the file pycups_po-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pycups_po-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d66b86beca70f92362647302e9603aaa16710cfffc899d39ab91e30c88e92238
|
|
| MD5 |
9cae412d00fb3517d6f6307a91093901
|
|
| BLAKE2b-256 |
282143acb8378a30b3208b2fe7401c0b88cca8a761d6827ee6644fbd5839ff4a
|