)uyc=%dZddlZddlZ ddlmZmZmZmZmZm Z m Z n #e $rYnwxYwdZ ddddd Z ejd ZGd d eZGd deZdZdZGddeZGddeZdS)z'Functions for working with watch files.N)IterableIteratorListOptionalSequenceTextIOTuplez[-_]?(\d[\-+\.:\~\da-zA-Z]*)z2(?i)\.(?:tar\.xz|tar\.bz2|tar\.gz|zip|tgz|tbz|txz)zL(?i)\.(?:tar\.xz|tar\.bz2|tar\.gz|zip|tgz|tbz|txz)\.(?:asc|pgp|gpg|sig|sign)z%[\+~](debian|dfsg|ds|deb)(\.)?(\d+)?$)z @ANY_VERSION@z @ARCHIVE_EXT@z@SIGNATURE_EXT@z @DEB_EXT@z debian.watchceZdZdZdS)MissingVersionzThe version= line is missing.N__name__ __module__ __qualname____doc__./usr/lib/python3/dist-packages/debian/watch.pyr r =s''''rr ceZdZdZdS)WatchFileFormatErrorz(Raised when the input is not valid. Nr rrrrrAsrrctt}||d<|D]\}}|||}|S)zApply substitutions to a string. :param text: text to apply substitutions to :param package: package name, as a string :return: text with subsitutions applied z @PACKAGE@)dict SUBSTITUTIONSitemsreplace)textpackagesubstskvs rexpandr!Fs^-%%'' ( (F"F; ""1||Aq!! Krc\|rt|t|dSN)rloggerwarning)msgstricts r _complainr(Ws0 ("3''' NN3rcDeZdZdZddefdZdZdZeddZ dS) WatchFilezA Debian watch file. :ivar entries: list of Watch entries :ivar options: optional list of global options, applied to all Watch entries :ivar version: watch file version Nc@||_|g}||_|g}||_dSr#)versionentriesoptions)selfr-r.r,s r__init__zWatchFile.__init__gs1  ?G ?G rc*t|jSr#)iterr-r/s r__iter__zWatchFile.__iter__tsDL!!!rcRd}|j|d|jz|jr&|||jdz|jD]}|jr&|||jdz||j|jr|d|jz|jr|d|jz|jr|d|jz|ddS)aOWrite the contents of a watch file to a file-like object. Note that this will not preserve the formatting of the original file, and thus it is currently not possible to use this function to parse and reserialize a file and end up with the same contents. :param f: File-like object to write to cVd|}d|vsd|vrd|zdzSd|zS)N,  zopts=""opts=)join)optsss rserialize_optionsz)WatchFile.dump..serialize_optionss;Aaxx4199!|c))Q; rNz version=%d  r8)r,writer.r-urlmatching_patternscript)r/fr?entrys rdumpzWatchFile.dumpxs>    < # GGNT\1 2 2 2 < < GG%%dl33d: ; ; ;\  E} @))%-883>??? GGEI   % 6e44555} -em+,,,| ,el*+++ GGDMMMM  rFc.g}g}|D]}|dr|s-|ddr)||d~||||g}|r%t d||||sdSd|d} |d d \}}n#t$rtwxYw|d krtt|} g} g} |D]} | d kr d | D} d| }|s?|dr|ddkrF| dd} | dkrtd|z|d| }|| d zd}n? |dddd \}}n#t$r|dd}d}YnwxYw|d}ng}|r |dd \}}n#t$r|}d}YnwxYwtjd|}|r\t|dft!|dd z}|dt#|d d z }n#t!|dd}| t%|g|Rd|i| ||| | | S)a@Parse from the contents that make up a watch file. :param lines: watch file lines to parse :return: instance or None if there are no non-comment lines in the file :raise MissingVersion: if there is no version number declared :raise ValueError: when syntax errors are encountered #r@\z \z*watchfile ended with \; skipping last lineNr=r,c6g|]}|Sr)lstrip).0chunks r z(WatchFile.from_lines..s ???e5<<>>???rr;r:zNot matching " in %rr7z/([^/]*\([^/]*\)[^/]*)$r=)r-r.r,) startswithstriprstripendswithappendr(r<popsplit ValueErrorr intindexrefindallstrtuplelenWatchextend)clslinesr' joined_lines continuedline firstlinekeyvaluer,persistent_optionsr-chunkedoptendopts_strr=rBmpartss r from_lineszWatchFile.from_liness     Ds## ::<< {{4  ))$//   V!4!45555  &&&##I...  + CV L L L    * * * 4GGL,,Q//00  #"a00JC # # # "" " # 99;;) # # "" "ekkmm$$#& 0& 0G{{@?w???777##))++D w'' 7c>>!ZZQ//F||()?$)FGGG#AfH~Hq ?DD"+/8>>$+B+B(44%"""#'8!" ~~c** 0 $ 4 3 3IC!CDDDJ93??7 1YYME$**T12E2E,F,FFEmAaD z!|m,CC!$**T1"5"566EuS<5<<rs$.-                         D  5K &:    > * *(((((Y(((: "IJIJIJIJIJIJIJIJX*/*/*/*/*/F*/*/*/*/*/s ''