+
    QDb                     ~   ^ RI t ^RIHt ^RIHt ^ RIt^ RIt^ RIt^ RIt^ RI	t
^ RIt^ RIt^RIHtHt ^ RIHt RR.tR]P"                  ! R	4      3R
]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3R]P"                  ! R4      3.t/ t] F  w  tt]]]P-                  4       &   K  	  R R!R"R#R$R%R&R'R(R)R*R+/t]P"                  ! R,4      t]P"                  ! R-4      t]P"                  ! R.4      t]P"                  ! R/]P6                  4      tR0 tR1 tR2 t ! R3 R4      t R4 t!R# )5    N)parseDeviceID)xmldriverprefs)_debugprintset_debugprint_fn)reduceppdMakeModelSplitPPDsHPzhdeskjet|dj[ 0-9]?|laserjet|lj|color laserjet|color lj|designjet|officejet|oj|photosmart|ps |psc|edgelineEpsonzstylus|aculaserApplez.stylewriter|imagewriter|deskwriter|laserwriterCanonz%pixus|pixma|selphy|imagerunner|bj|lbpBrotherz
hl|dcp|mfcXeroxz/docuprint|docupage|phaser|workcentre|homecentreLexmarkzoptra|(:color )?jetprinterKONICA MINOLTAzmagicolor|pageworks|pageproKyocerazfs-|km-|taskalfaRicohaficioOce
varioprintOkizokipage|microlinedjDeskJetljLaserJetoj	OfficeJetzcolor ljzColor LaserJetzps 
PhotoSmartzhp  
turboprintz! v(?:er\.)?\d(?:\d*\.\d+)?(?: |$)zn,| hpijs| foomatic/| - | w/| \(| postscript| ps| pdf| pxl| zjs| zxs| pcl3| printer|_bt| pcl| ufr ii| br-scriptz series| all-in-onec                &   V P                  4        RpRpV P                  4       p\         F"  w  rEVP                  V4      '       g   K  TpT p M	  VEf   \        P                  V4      '       d   V P                  R4      pVR%8w  d)   V P                  R4      pWx8w  d   W^,           V p MV RV p  V P                  R^4      w  r\        P                  ! RRT4      p\        P                  ! RRT4      p\        P                  ! RRT4      p\        P                  ! RRT4      p\        P                  ! R	R
T4      p\        P                  ! RRT4      pRpMVP                  R4      '       d   RpV R,          pMVP                  R4      '       d   RpV R,          pMVP                  R4      '       d   RpV R,          pM]VP                  R4      '       d   RpV R,          pM:VP                  R4      '       d   RpV R,          pMRp V P                  R^4      w  rVP                  4       p	V'       d   V	P                  R4      '       d   V	P                  R4      '       d   RpRp	MRV	P                  R 4      '       d   V	P                  R!4      '       d   RpR"p	M\        P                  V	4      pV'       d   TpVP                  4       p
V
P                  R#4      pVR%8w  d8   \        P                  V
4      pV'       d   VP!                  4       pV
RV p
VRV p\"        P                  V
4      pV'       d   VP!                  4       pV
RV p
VRV p\$        P'                  RV^R$7      w  ppV'       d   VP                  4       p
V	R8X  d]   \(        P+                  4        FD  w  ppV
P                  V4      '       g   K  VV\-        V4      R ,           pVP                  4       p
 M	  VP                  4       pW3#    T pRp EL>; i   T pRp EL; i)&z
Split a ppd-make-and-model string into a canonical make and model pair.

@type ppd_make_and_model: string
@param ppd_make_and_model: IPP ppd-make-and-model attribute
@return: a string pair representing the make and the model
NFz TurboPrint_r   z(?<=[a-z])(?=[0-9]) z(?<=[a-z])(?=[A-Z])z JetJetzPhoto Smartr   Tzkonica minolta r   :   NNzlexmark international r   :   NNzkyocera mita r   :   NNzkyocera :   NNzfuji xerox z
Fuji Xerox:   NNhewlettpackardr
   hpkonicaminoltazkonica minoltaz v)count)striplower_MFR_BY_RANGEmatch_RE_turboprintsearchfindrfindsplitresub
startswithendswith_MFR_NAMES_BY_LOWERget_RE_version_numbersstart_RE_ignore_suffix_RE_ignore_seriessubn_HP_MODEL_BY_NAMEitemslen)ppd_make_and_modelmakecleanup_makelmfrregexpmodeltt2makelmodellvvmatchvstartsuffixsuffixstartnnamefullnames   &                  d/tmp/fempkg/build/system-config-printer/DESTDIR/usr/lib/python3.14/site-packages/cupshelpers/ppds.pyr   r   w   s    DL  #A$<<D&E	 % |--q11##]37#))=9Bw%7Br%B"%7%;"	,223:KD vv-sD9vv-sD9.U;.U;.e< 
(	)	)"3'	
/	0	0"3'	
	'	'"3'	
z	"	""2&	
}	%	%"3' 	,223:KD JJMEi((NNI&&DE))nni((#D$E &))51C [[^FTABw %++V4\\_FGV_F'6NE%%v.Fllo%l{# #''U!'<JUA}/558ND(  $'' 5d#55	 9 KKNE=C	%DE>	%DEs   2O; P ;PPc                   V P                  4       P                  4       pRp^ p^p^pTpRp\        \        V4      4       F  pW,          P	                  4       '       d   Wd8w  d   V'       d
   VR,          pTpM8W,          P                  4       '       d   We8w  d   V'       d
   VR,          pTpMTpW,          P                  4       '       g   K  W!V,          ,          pRpK  	  V# )a  
This function normalizes manufacturer and model names for comparing.
The string is turned to lower case and leading and trailing white
space is removed. After that each sequence of non-alphanumeric
characters (including white space) is replaced by a single space and
also at each change between letters and numbers a single space is added.
This makes the comparison only done by alphanumeric characters and the
words formed from them. So mostly two strings which sound the same when
you pronounce them are considered equal. Printer manufacturers do not
market two models whose names sound the same but differ only by
upper/lower case, spaces, dashes, ..., but in printer drivers names can
be easily supplied with these details of the name written in the wrong
way, especially if the IEEE-1284 device ID of the printer is not known.
This way we get a very reliable matching of printer model names.
Examples:
- Epson PM-A820 -> epson pm a 820
- Epson PM A820 -> epson pm a 820
- HP PhotoSmart C 8100 -> hp photosmart c 8100
- hp Photosmart C8100  -> hp photosmart c 8100

@type strin: string that can be the make or the model
@return: a normalized lowercase string in which punctuations have been replaced with spaces.
r   Fr#   T)r1   r2   rangerG   isalphaisdigitisalnum)	strinlstrin
normalizedBLANKALPHADIGITlastchar
alnumfoundis	   &        r[   	normalizerj      s    0 [[^!!$FJ
E
E
EHJCL!9 Zc!
HY!! Zc!
HH9)#JJ "      c                D    \        V \        4      '       d
   V ^ ,          # V # )zwIf we don't know whether getPPDs() or getPPDs2() was used, this
function can unwrap an item from a list in either case.)
isinstancelist)xs   &r[   
_singletonrp   .  s     1dtHrk   c            
         a  ] tR tRt o Rt^ t^t^t^t]	P                  P                  t]	P                  P                  t]	P                  P                  t]	P                  P                  t]	P                  P                  t]]]]]]]]]]/tRR ltR tR tR tR tR	 tRR
 ltRR ltRR ltR tRR ltR tR tRtV tR# )r	   i5  aD  
This class is for handling the list of PPDs returned by CUPS.  It
indexes by PPD name and device ID, filters by natural language so
that foreign-language PPDs are not included, and sorts by driver
type.  If an exactly-matching PPD is not available, it can
substitute with a PPD for a similar model or for a generic driver.
Nc                
   VP                  4       V n        RV n        RV n        \        P
                  ! 4       V n        \        P                  ! 4       V n        VfT   \        P                  P                  R4      pVf1   ^RIHp \        P                  P                  VP                   R4      p \        P                  P                  VR4      p\        P"                  ! V4      w  rgV P                  P%                  V4       V P                  P%                  V4       Ve   VR8X  g   VR	8X  d   R
pVP+                  R4      p	V	R8w  d   VRV	 p
MTp
. pV P                  P-                  4        FB  w  r \/        VR,          4      pTR8X  d   K!  Y8X  d   K)  Y8X  d   K1  TP3                  T4       KD  	  V F  pV P                  V K  	  RV P                  9   d\   \/        V P                  R,          R,          4      pVP5                  R4      '       g    RV,           V P                  R,          R&   R# R# R#   \&         d-   p\)        RX: RT: 24       RT n        RT n         Rp?ELLRp?ii ; i  \0         d     EK  i ; i)z
@type ppds: dict
@param ppds: dict of PPDs as returned by cups.Connection.getPPDs()
or cups.Connection.getPPDs2()

@type language: string
@param language: language name, as given by the first element
of the pair returned by locale.getlocale()
NCUPSHELPERS_XMLDIR)configcupshelperszpreferreddrivers.xmlzError loading : CPOSIXen_USr"   zppd-natural-languageenrawppd-make-and-modelzGeneric r0   )copyppdsmakesidsr   DriverTypesdrivertypesPreferenceOrder	preforderosenvironr?   r   rt   pathjoin
sysconfdirPreferredDriversload	Exceptionprintr7   rF   rp   KeyErrorappendr<   )selfr~   languagexml_dirrt   xmlfiler   preferenceordereushort_language	to_removeppdnameppddictnatural_language	makemodels   &&&&            r[   __init__PPDs.__init__P  s)    IIL	
)558'77:?jjnn&:;G$'',,(9(9=I		"ggllG-CDG//9 +[!!;/NN1 OHMM37%bq\N%N	 $		 2G#-w7M/N#O   4' +1g&# !3& !G		'" ! DII"DIIe$45I$JKI''449Ci9O		% !56 5 U  	"GQ78#D!DNN	"(  s+   0A.H8 4I28I/!I**I/2JJc                   V P                  4        \        V P                  P                  4       4      pVP	                  \
        P                  R7        VP                  R4       VP                  ^ R4       V#   \         d     T# i ; i)zX
@returns: a list of strings representing makes, sorted according
to the current locale
keyGeneric)
_init_makesrn   r   keyssortlocalestrxfrmremoveinsert
ValueError)r   
makes_lists   & r[   getMakesPPDs.getMakes  s|    
 	$**//,-
V^^,	y)q),   		s   #A: :B	B	c                    V P                  4         \        V P                  V,          P                  4       4      pR pTP                  \        P                  ! T4      R7       T#   \         d    . u # i ; i)zP
@returns: a list of strings representing models, sorted using
cups.modelSort()
c                 Z    \        V 4      p\        V4      p\        P                  ! W#4      # N)rj   cups	modelSort)abfirstseconds   &&  r[   compare_models&PPDs.getModels.<locals>.compare_models  s#    qME]F>>%00rk   r   )r   rn   r   r   r   r   	functools
cmp_to_key)r   rI   models_listr   s   &&  r[   	getModelsPPDs.getModels  sp    
 		tzz$/4478K	1 	Y11.AB  	I	s   *A' 'A76A7c                ~    V P                  4         V P                  V,          V,          #   \         d    / u # i ; i)z
Obtain a list of PPDs that are suitable for use with a
particular printer model, given its make and model name.

@returns: a dict, indexed by ppd-name, of dicts representing
PPDs (as given by cups.Connection.getPPDs)
)r   r   r   )r   rI   rN   s   &&&r[   getInfoFromModelPPDs.getInfoFromModel  s=     		::d#E** 	I	s   , <<c                (    V P                   V,          # )zJ
@returns: a dict representing a PPD, as given by
cups.Connection.getPPDs
)r~   )r   r   s   &&r[   getInfoFromPPDNamePPDs.getInfoFromPPDName  s    
 yy!!rk   c                j    V P                   P                  V\        P                  P                  4      # r   )_fit_to_statusr?   r   
DriverTypeFIT_NONE)r   fits   &&r[   getStatusFromFitPPDs.getStatusFromFit  s'    ""&&^-F-F-O-OPPrk   c                ^   Vf   . pVf   . pVf   / pV P                   '       d   V P                  '       d   / pV F  pV P                  V,          Wg&   K  	  V P                  P                  V P                   VV4      p\	        R\        V4      ,          4       V P                   P                  VWe4      p	\	        R\        V	4      ,          4       V	 U
u. uF  q^,          NK  	  pp
\	        R\        V4      ,          4       \        4       pV F(  pVP                  R4      w  rpVP                  V4       K*  	  V'       dg   . pV F1  pVP                  R4      w  rpVV9   g   K   VP                  V4       K3  	  V'       d&   V F  pVV9  g   K  VP                  V4       K  	  TpV# u up
i )a  

Sort a list of PPD names by preferred driver type.

@param ppdnamelist: PPD names
@type ppdnamelist: string list
@param downloadedfiles: Filenames from packages downloaded
@type downloadedfiles: string list
@param make_and_model: device-make-and-model name
@type make_and_model: string
@param devid: Device ID dict
@type devid: dict indexed by Device ID field name, of strings;
except for CMD field which must be a string list
@param fit: Driver fit string for each PPD name
@type fit: dict of PPD name:fit
@returns: string list
z9Valid driver types for this printer in priority order: %sz5PPDs with assigned driver types in priority order: %sz(Resulting PPD list in priority order: %s/)r   r   r~   get_ordered_typesr   reprget_ordered_ppdnamesset
rpartitionaddr   )r   ppdnamelistdownloadedfilesmake_and_modeldevidr   r~   r   orderedtypesorderedppdstyp_namedownloadedfnamesdownloadedfiler   slashfnamedownloadedppdnamesppdfnames   &&&&&&            r[   orderPPDNamesByPreferencePPDs.orderPPDNamesByPreference  s   * K" O;CD& $		' 2 '  >>;;T=M=M=K=BDL SVZ[gVhhi**??AELKORVWbRccd7BC{8A;;{KCBT+EVVW 5-N#1#<#<c#B T%  %( . !#&*1*<*<c*B'h//&--w7 ' "*G&88*117;  + 15 Ds   F*c           	        \        RV: RV: 24       TpTpV P                  4        Vf   . p/ p	VP                  4       p
VP                  4       pRp V P                  V
,          V,           F  pV P                  W&   K  	  RpV
R8X  d|    V P                  R,          V,           F  pV P                  W&   K  	  \        RV P                  R,          V,          ,          4       \        R	V: R
V: R24       \        R4       Rp\        R4       RpV P                  4        RpV
R8X  d$   \        V4      w  r\        V4      p
\        V4      p\        RV
,          4       \        RV,          4       RRRRRR/pWP                  9   d   V P                  V
,          pMJV
V9   dD   VV
,          pVV P                  9   d*   TpTp
\        RV
,          4       V P                  V
,          p\        RV,          4       VEe   V P                  V,          pV P                  \        V4      ,          pV
RR3 FU  pVP                  VR,           4      '       g   K#  V\        V4      ^,           R p\        V4      p\        RV,          4       KW  	  WP                  V
,          9   dO   VV,          pVV,          P                  4        F)  pV P                  W&   \        W,          : RV: 24       K+  	  M\        VR,           V,           4      w  pp\        V4      p\        RV,          4       VV P                  V
,          9   dW   VV,          p\        VV,          P                  4       4       F)  pV P                  W&   \        W,          : RV: 24       K+  	  V	'       gS   V'       dK   V P!                  W4      w  ppVV P"                  8w  d&   V F  pVW&   \        W,          : RV: 24       K!  	  V'       d{   \%        V4      \        8w  d   VP'                  R4      p\        R4       V P)                  V4      pV'       d2   V F+  pV P*                  V	V&   \        V	V,          : RV: 24       K-  	  V'       dM   VP                  R4      '       g   VP                  R4      '       g   VP                  R4      '       d   RV9   g   \-        4       pV	P                  4        F-  pVP                  R 4      '       g   K  VP/                  V4       K/  	  \        V4      ^ 8  d   \        R!V,          4       V F  pW K  	  \-        4       pV'       Ed   \        V4      ^ 8  Ed   \-        4       p\-        4       pV	P                  4        F  pRpV P0                  V,          p \3        V P5                  R"4      4      p!V!'       d   \7        V!4      p"V"R#,          pV'       g;   VP9                  R$4      R;8X  d%   \3        V P5                  R%4      4      p#V#R&8X  d   R'.pV'       g   K  Rp$V F  p%V%V9   g   K  Rp$ M	  V$'       d   VP/                  V4       K  VP/                  V4       K  	  V FM  pW,          V P                  8X  g   K  V P:                  W&   \        V P:                  R(V,          ,           4       KO  	  \        V4      \        V	P=                  4        U&U'u. uF  w  p&p'V'R)8w  g   K  V&NK  	  up'p&4      8  d   \        R*V,          4       V F  pW K  	  M\        R+V,          R,,           4       V	'       g   R-R..p(Rp)V( F  p*\        R/V*,          4       V*R0,           p+V P0                  P                  4        FD  p,V,P?                  V*4      '       g   V,P?                  V+4      '       g   K3  V P"                  V	V,&   Rp) M	  V)'       d    M\        R1V*,          4       K  	  V)'       gC   \        R24       V P"                  V	\        V P0                  P                  4       4      ^ ,          &   V'       g   \@        PB                  ! R3R4\E        V4      R57      p- \G        R6 V4      p.R7V: R
V: R2p/V.'       d   V/R8V.,          ,          p/V'       d   V/R9V,          ,          p/\        R:V-,          4       \        V/4       V	#   \
         d     ELNi ; i  \
         d     ELi ; iu up'p&i   \H         d    Rp. Li ; i)<a  
Obtain a best-effort PPD match for an IEEE 1284 Device ID.

@param mfg: MFG or MANUFACTURER field
@type mfg: string
@param mdl: MDL or MODEL field
@type mdl: string
@param description: DES or DESCRIPTION field, optional
@type description: string
@param commandsets: CMD or COMMANDSET field, optional
@type commandsets: string
@param uri: device URI, optional (only needed for debugging)
@type uri: string
@param make_and_model: device-make-and-model string
@type make_and_model: string
@returns: a dict of fit (string) indexed by PPD name

r#   NFTzhewlett-packardr,   z&**** Incorrect IEEE 1284 Device ID: %sz**** Actual ID is MFG:z;MDL:;z4**** Please report a bug against the HPLIP componentzTrying make/model namesr   zmfgl: %szmdll: %szlexmark internationallexmarkkyocerazkyocera mitazremapped mfgl: %szmake: %szunprefixed mdll: %srv   zre-split mdll: %s,zChecking CMD fieldzipp:zipps:dnssdz._ippzdriverless:z$Removed %s due to non-IPP connectionppd-device-idCMD:zppd-type
postscript
POSTSCRIPTz: %sgenericzRemoved %s due to CMD mis-matchzNot removing %s z3due to CMD mis-match as it would leave nothing goodztextonly.ppdzpostscript.ppdz'%s' fallbackz.gzzFallback '%s' not availablez#No fallback available; choosing anyz
//[^@]*@/?z//)patternreplstringc                 "    V R ,           V,           # )r    ro   ys   &&r[   <lambda>.PPDs.getPPDNamesFromDeviceID.<locals>.<lambda>  s    1s7A:rk   zMFG:zCMD:%s;zDES:%s;zNo ID match for device %s:r0   )%r   	_init_idsr2   r   	FIT_EXACTr   r   r   rj   lmakesr   lmodelsr<   rG   r   rn   _findBestMatchPPDsr   typer9   _getPPDNameFromCommandSetFIT_GENERICr   r   r~   rp   r?   r   r7   FIT_EXACT_CMDrF   r=   r:   r;   strr   	TypeError)0r   mfgmdldescriptioncommandsetsurir   orig_mfgorig_mdlr   mfglmdll
id_matchedeachmdlsrI   mfgreplrmfgmdlslprefixrN   mfg2mdl2mdl2lsr~   r   driverfailedr   	exact_cmdppd_cmd_fieldppdppd_device_idppd_device_id_dictppd_typeusablepdldm	fallbacksfoundfallback
fallbackgzppdpathsanitised_uricmdids0   &&&&&&&                                         r[   getPPDNamesFromDeviceIDPPDs.getPPDNamesFromDeviceID  s   ( 	#s+,K 
 yy|yy|
	t,, NN	 -J
 $$	 HHTN400D $CI 1E!XXd^D12 33LMST!

 	./2:*C0JSc?Dc?DZ$&'Z$&'$d*In. ;;;;t$DW_4=Dt{{"0478{{4(Z$&'::d#DLL41E  !2D9??FSL11c6lQ./0C$c?D!6!=>	 : ||D))d K,,/D $CISYY!=> 0  1#)c/Bt!4(0589DLL..!%LE $T%[%5%5%8 9$(NN	#D%AB !: t//;IQDMM! D !CISYY!=> ! [!T))//5-.44kBG%F"&"2"2CKS[[&!AB & ''((..))S.UF88;&&}55JJ( ' FaCfLM"D	 #UF0 :#{+a/UFI88; $ii( *CGG_,E F )6)F&$6u$=M%
 LL#&",  *377J+?@H</)5$ (Ck)!% )
 MM7+JJ(E 'L "9. $ 2 2CI!3!3ftm!CD "
 F|cCIIL $7L&1a'(I~ %&AL $7 8 8>GH"D	 # /&822 3 ')9:IE%_x78%-
#yy~~0G(((33((*55'+}}G $  1 :XEF & BC26--D*+A./FFLt+.96M5{C &.x8Bi#o%i+--5EF
A  		  F$7J  sC   1c A:c c(/c(c. ccc%$c%.c>=c>c                h   Vf   . pVf   . pV P                  WVWEV4      pRVRVRVRV/p	V P                  \        VP                  4       4      VVW4      p
\	        R\        V
4      ,          4       V P                  W^ ,          ,          4      p\	        RV
^ ,          V3,          4       W^ ,          3# )aJ  
Obtain a best-effort PPD match for an IEEE 1284 Device ID.
The status is one of:

  - L{STATUS_SUCCESS}: the match was successful, and an exact
    match was found

  - L{STATUS_MODEL_MISMATCH}: a similar match was found, but
    the model name does not exactly match

  - L{STATUS_GENERIC_DRIVER}: no match was found, but a
    generic driver is available that can drive this device
    according to its command set list

  - L{STATUS_NO_DRIVER}: no match was found at all, and the
    returned PPD name is a last resort

@param mfg: MFG or MANUFACTURER field
@type mfg: string
@param mdl: MDL or MODEL field
@type mdl: string
@param description: DES or DESCRIPTION field, optional
@type description: string
@param commandsets: CMD or COMMANDSET field, optional
@type commandsets: string
@param uri: device URI, optional (only needed for debugging)
@type uri: string
@param downloadedfiles: filenames from downloaded packages
@type downloadedfiles: string list
@param make_and_model: device-make-and-model string
@type make_and_model: string
@returns: an integer,string pair of (status,ppd-name)
MFGMDLDESr   zFound PPDs: %szUsing %s (status: %d))r+  r   rn   r   r   r  r   )r   r  r  r  r  r  r   r   r   r   r   statuss   &&&&&&&&    r[   getPPDNameFromDeviceIDPPDs.getPPDNameFromDeviceID(  s    L K" O**Ck,7,:< eS' 44d388;6G6E6D6;B 	%[(99:&&N(;<,A/GGHA''rk   c                <	   \        R4       VP                  4       pVP                  R4      '       d   VRR pVRR pRp^ p\        VP	                  4       4      pV Uu. uF  qwVP                  4       3NK  	  ppVP                  W#34       VP                  \        P                  ! R 4      R7       VP                  W#34      p	W^,
          ,          .p
V	^,           \        V4      8  dc   V
P                  W^,           ,          4       \        V
^ ,          ^ ,          R,           V,           R,           V
^,          ^ ,          ,           4       M'\        V
^ ,          ^ ,          R,           V,           4       V
 Ft  w  r\        P                  P                  W.4      p\        V4      V8  g   K7  \        W,          P	                  4       4      p\        V4      p\        RW3,          4       Kv  	  V'       dI   V\        V4      ^,          8  d2   TpV\        V4      8X  d   V P                  pW3# V P                  p W3# V P                   pRpVP                  \        P                  ! \"        P$                  4      R7       V Uu. uF  qwP                  4       W,          3NK  	  ppRpVP'                  R4       FS  pVf   TpR	p\)        \        V4      4       F$  p	VV	,          P+                  4       '       g   K"  R
p M	  V'       g   KQ  Tp M	  ^ pRpRp\)        \        V4      4       F?  p	VV	,          P+                  4       '       d   VR8X  d   T	pT	pV^,          pK6  VR8w  g   K?   M	  V^,          p^ pV^ 8  Ed   \-        VVV 4      pVRV R,           VVR ,           p\        RVVV3,          4       ^ pRpR	pVV8  d   \/        ^
V4      pVVV,          V,          ,          p\        RVVV3,          4       V FZ  w  ppVP'                  R4       F  pVP                  4       V8X  g   K  R
p M	  V'       g   KA  \        VP	                  4       4      p M	  V'       d   MV^,          pV^8  g   K   V'       d   TpV P                  pW3# u upi u upi )zd
Find the best-matching PPDs based on the MDL Device ID.
This function could be made a lot smarter.
zTrying best matchz seriesNc                 L    \         P                  ! V ^,          V^,          4      # )   )r   r   r   s   &&r[   r   )PPDs._findBestMatchPPDs.<locals>.<lambda>|  s    dnnQqTSTUVSW>Xrk   r   z <= z%s: match length %dr#   FTz%dz'Searching for model ID '%s', '%s' %% %dz#Ignoring %d of %d digits, trying %sir0   )r   r2   r=   rn   r   r   r   r   r   indexrG   r   r   commonprefixr   	FIT_CLOSEr   r   r   r9   r]   r_   intpow)r   r  r  r  best_mdlbest_matchlenmdlnamesro   	mdlnameslri   
candidates	candidate
candidatelr  r   r   mdlitemsmodelidwordhave_digitsdigitsdigits_start
digits_endmodelnumbermodelpatternignore_digitsr$  divrY   r~   s   &&&                           r[   r   PPDs._findBestMatchPPDsi  sA    	()yy|==)$$9Dcr(C		% .66X^X	63+&I001XYZOOc[)A&'
q53	?"yQ/0Aq)F2S86A"1a() * Aq)F2S89 (2#YWW))J+=>FF|m+ 4 4 78 #V2i5OOP (2 da8"KT
*nnZ !!W nnV !!S --CK MMy33DNNCMD7?@x!TW-xH@G

C(?"G#T
+AAw))&* ,
 ;"G ) FLJCM*1:%%((#r)'(!"JaKF!R' + !OJKz!7<
#CD ' 6 = '
 4!5F%|[AB C !#f,r=1C*{S/@C.GHG!F"/!A"B C )1t$(JJ$4D#zz}7(, % %5
 !5'+DIIL'9H! )1 !Q&Mz"*K..C!!M 7J As   R Rc                "  a a Vf   . p S P                  4        S P                  R,          oTT 3R lpT Uu. uF  q3P                  4       NK  	  ppRT9   g   RT9   g   RT9   d	   T! R4      # RT9   g   R	T9   g   R
T9   g   RT9   d
   T! RR4      # RT9   d
   T! RR4      # RT9   d
   T! RR4      # RT9   g   RT9   d
   T! RR4      # RT9   d
   T! RR4      # RT9   g   RT9   g   RT9   d	   T! R4      # R#   \         d     R# i ; iu upi )z^Return ppd-name list or None, given a list of strings representing
the command sets supported.Nr   c                  l   < V  F,  pSP                  SV4      w  r#VSP                  8X  g   K*  Vu # 	  R # r   )r   r   )rA  rN   r  r~   modelsr   s   *   r[   r?   +PPDs._getPPDNameFromCommandSet.<locals>.get  s7    # 33VUC	&K $ rk   r   postscript2zpostscript level 2 emulation
PostScriptpclxlzpcl-xlpcl6zpcl 6 emulationzPCL 6/PCL XLz	PCL Laserpcl5ezPCL 5epcl5czPCL 5cpcl5zpcl 5 emulationzPCL 5pclzPCL 3escpl2zesc/p2escp2ezESC/P Dot Matrix)r   r   r   r2   )r   r  r?   ro   cmdsetsrR  s   f&   @r[   r   PPDs._getPPDNameFromCommandSet  s6    K	ZZ	*F	 (33{!77:{3W$-7*B+w6%%'!x7': &77&B44+..+..%6'%A--g--7"G(;7"*++9  		 4s   #C: D:D	D	c           	        V P                   '       d   R # \        P                  ! 4       p/ p/ p/ p/ pV P                  P                  4        EF  w  rg\	        VR,          4      p\        V4      p	\        V	.4      p
VP                  R. 4      p\        V\        4      '       g   V.p\        V Uu. uF  qP                  R4      '       g   K  VNK  	  up4      pV'       d   \        V4      ^8X  d   \        4       p\	        VP                  RR4      4      P                  4       pV'       d
   VR,          p\        V4      pV F  pVP                  R4      '       d-   VP                  R4      '       d   V^\        V4      ^,
           pV'       g   KP  \        V4      pVP                  V4      '       g	   W,           pV
P                  \        V4      4       K  	  V
 F|  w  pp\        V4      p\        V4      pW9  d   WV&   / WN&   / W-&   MW>,          pVWN,          9  d   VWN,          V&   / W-,          V&   MWN,          V,          pWrV,          V,          V&   K~  	  W9   d   V
P!                  V	4       V
'       g   EK2  V	w  ppW9   d"   W],          P                  V\        4       4      pM/ W]&   \        4       pTP#                  V
 Uu. uF  q^,          NK  	  up4      pVW],          V&   EK  	  VP                  4        F  w  pp\        V4      pW>,          pVP                  4        F  w  ppWN,          P                  \        V4      4      pV'       g   K0  VV,          V,          pV FD  pWN,          P                  \        V4      4      pVV,          V,          pVP%                  V4       KF  	  K  	  K  	  W n         W0n        W@n        \+        R\        P                  ! 4       V,
          ,          4       R # u upi u upi )	Nr|   zppd-product(zppd-maker   r#   )zinit_makes: %.3fs)r   timer~   rF   rp   r   r   r?   rm   rn   r<   rG   rstriprj   r=   r   r   unionupdater   r   r   )r   tstartr   r   r   aliasesr   r   rH   ppd_mm_splitppd_makes_and_modelsppd_productsro   rI   lmakeppd_productlprodrN   lmodelrR  	main_make
modelnames
main_model	main_ppds	eachmodel
this_modelr~   s   &                          r[   r   PPDs._init_makes
  sh   ::: $		 2G!+W5I-J!K,.@AL#&~#6  #;;r:L|T22 ,~L OLqLL#<NL OPL %*#&5L!7;;
B#?@GGJCKD!4(#/K#..44#,,c22&1!C4E4I&J&  &{3E ++U33&*&8(,,.?.MN $0"  4e!4("E*&$(5M%'GN"$EK!=D/-2GN6*)+EK&#N62E.5dE"7+!  4& 3$++\:## ,u?$]..su=F$&GM UF6J'K6J!6J'KL'-e$Y !3` $MM,LD&t$EI%+\\_!z$^//E1BC
!!),Z8	!+I!(!3!3Y	5J!KJ +J7DKK+ ", &5 - 
(DIIL6,ABCc !Pt (Ls   /O:
O:
O?
c                   V P                   '       d   R # / pV P                  P                  4        F  w  r#\        VP	                  R4      4      pV'       g   K)  \        V4      pVR,          P                  4       pVR,          P                  4       pRp\        V4      ^ 8X  d   Rp\        V4      ^ 8X  d   RpV'       d   K  Wa9  d   / W&   WqV,          9  d   . W,          V&   W,          V,          P                  V4       K  	  Wn         R # )Nr   r.  r/  FT)	r   r~   rF   rp   r?   r   r2   rG   r   )	r   r   r   r   r*  id_dictlmfglmdlbads	   &        r[   r   PPDs._init_idsw  s    888 $		 2GW[[/:;B#R(G5>''*D5>''*DCDzQDzQ	t9$"$	$IdO""G,/ !32 rk   )r   r   r   r   r   r~   r   )NN)NNNNN)r   NNN)r   NNNNr   ) __name__
__module____qualname____firstlineno____doc__STATUS_SUCCESSSTATUS_MODEL_MISMATCHSTATUS_GENERIC_DRIVERSTATUS_NO_DRIVERr   r   r   r   r:  r   r   r   r   r   r   r   r   r   r   r+  r2  r   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r[   r	   r	   5  s      N"--;;M))33I))33I ++77K((11H$n . "7"$9!1	4NIPV $"QDLKZ?(Bw"r&PkDZ rk   c                      \        R 4       R# )zBusage: ppds.py [--deviceid] [--list-models] [--list-ids] [--debug]N)r   r   rk   r[   
_show_helpr    s    	OPrk   )"r   ru   r   r   r   	itertoolsr   rc  r   os.pathr   r   r:   r   r   r   __all__compiler3   r>   rL   rM   r2   rE   r5   r@   rB   IrC   r   rj   rp   r	   r  r   rk   r[   <module>r     s	  .  &        	 , 
 
2:: " # $ bjj*+,bjj ( ) * bjj   ! " 

<()bjj ' ( )
 

789rzz #- . / 

 ' ( ) bjj"#
BJJ|$%
BJJ*+,S*X   KC(+		% ! 	)*+ 	<	2  \*jj"FG JJ !. " & JJ 5rtt< BH1f` `DQrk   