Skip to main content

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 hashes)

Uploaded Source

Built Distribution

pycups_po-0.1.1-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page