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

Uploaded Source

Built Distribution

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

Uploaded Python 3

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

Hashes for pycups_po-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5db37479f402cb6467b94c28dc746caf1b791fc94122fdd98c30fb47d168a9d7
MD5 1ee9cca55f05ea27d68bf8e9bcc7237b
BLAKE2b-256 cc1b925c83fea9e3030d98c02bb475748746cec0434d5194e559961f60e13cac

See more details on using hashes here.

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

Hashes for pycups_po-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d66b86beca70f92362647302e9603aaa16710cfffc899d39ab91e30c88e92238
MD5 9cae412d00fb3517d6f6307a91093901
BLAKE2b-256 282143acb8378a30b3208b2fe7401c0b88cca8a761d6827ee6644fbd5839ff4a

See more details on using hashes here.

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