CUPS print options generator from PPD
Project description
๐จ 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
Project details
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
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 |