&=d!ddlZddlZddlmZddlmZddlmZddl m Z ddl m Z dZ d Zd Zd Zdd ZddZ ddZdS)N)utils)open_url) NoNetwork)Deb822)debian_supportz4https://qa.debian.org/madison.php?package=%s&text=onz$http://ftp-master.debian.org/new.822c8|r|sdStj||S)a Compare package version strings This is a wrapper around `debian_support.version_compare()` that returns 0 if one if the versions is empty. Parameters ---------- current : str version assumed to be currently installed upstream : str version assumed to be available upstream Returns ------- int 1 if upstream is newer than current, -1 if current is newer than upstream, and 0 if the same. r)rversion_compare)currentupstreams 9/usr/lib/python3/dist-packages/reportbug/checkversions.pycompare_versionsr)s+( (q  )(G < <<c2t||dkr|S|S)ad Pick the later version of two version strings This is a helper function originally used in :func:`get_incoming_version()`, but currently not used. Parameters ---------- a : str first package version b : str second package version Returns ------- str the later (higher) version string r)r)abs r later_versionrBs#&1!! Hri386ctj}t|z}|r|dd|zz }|d|zz } t |||}nL#t $ricYSt jj$r(}td|tj icYd}~Sd}~wwxYw|siS| dd }i} |d D]Z} | d \} } } }n#t$rY*wxYw|d kr5tj| | }| | |<[| S) a> Get package versions available. If `dists` is not given, get versions from all dists known to the version lookup service at https://qa.debian.org/madison.php Parameters ---------- package : str package name timeout : int connection timeout in seconds dists : (str, ...), optional tuple of dist names ('stable', 'testing' etc.) to check http_proxy : str, optional http proxy url arch : str, optional architecture name Returns ------- {str: str, ...} dictionary with found dists as keys and versions as values, e.g.,: { "oldstable": "46.1", "stable": "1:26.1+1-3.2+deb10u1", "testing": "1:26.1+1-4", "unstable": "1:26.3+1-1" } z&s=,z&a=source,all,Warning:fileN  |source)rget_arch RMADISON_URLjoinrrurlliberror HTTPErrorprintsysstderrreplacestripsplit ValueErrorCODENAME2SUITEget)packagetimeoutdists http_proxyarchurlpagexcontentversionslinepvdrdists r get_versions_availabler=ZsB >  D  C ' usxx&& d ""CZ11  < ! j!#*----   ll3##))++GH d## CJAq!QQ    H  == #''1-- Os6A B$B7BBB(D DDc|d} tt||}nL#t$ricYStjj$r(}t d|tjicYd}~Sd}~wwxYw|siSi}tj |D]O}|d|krA|ddz|dzd z} t|d  || <P|S) aj Get package versions available in the NEW queue If `dists` is not given, get versions from unstable (NEW queue). This is a helper function for :func:`check_available()`. Parameters ---------- package : str package name timeout : int connection timeout in seconds dists : (str, ...), optional tuple of dist names ('stable', 'testing' etc.) to check http_proxy : str, optional http proxy url arch : str, optional unused Returns ------- {str: str, ...} dictionary with found dists as keys and versions as values N)zunstable (new queue)rrSource Distributionz (Queue)Version) r NEWQUEUE_URLrr"r#r$r%r&r'riter_paragraphsmaxr*) r.r/r0r1r2r4r5r7paraks r get_newqueue_availablerIs4 }) j'::  < ! j!#*----   H&t,,77 >W $ $^$t+d7m;cAAd9o335566HQK Os A&A&A!A&!A&Tci}t|||||} || |r@tj|} | |} t | ||||} || i} d} |D]5} t ||| }|dkr || | | <*|dkr| dz } 6| o| t |k}| |fS)a Check a package version against other available versions The package archive contains many different versions of most packages. This function determines whether a given package version is newer than all versions available in the archive, and (if not) which available versions are newer. Parameters ---------- package : str package name version : str package version timeout : int connection timeout in seconds dists : (str, ...), optional tuple of dist names ('stable', 'testing' etc.) to check check_incoming : bool unused/ignored check_newqueue : bool True if the NEW queue should be checked for new versions http_proxy : str, optional http proxy url arch : str, optional architecture name Returns ------- (dict, bool) Tuple with a dictionary and a bool. The dictionary contains the versions found to be newer than the given version. E.g., {"unstable": "42.1", "testing": "42.0"} The bool indicates whether the checked (installed) version is strictly newer than all available versions. Nrr)r=updaterget_source_namerIrlen)r.versionr/r0check_incomingcheck_newqueuer1r2availstuff srcpackagenewnewerr< comparisontoo_news r check_availablerXsP E "7GUJ M ME LL*733   J&z7E:tTT U C E%guT{;; >>d CII !^^ QJE,#e**,G <r)NNr)NTTNr)r& urllib.errorr"rrurlutilsrreportbug.exceptionsr debian.deb822rdebianrr rDrrr=rIrXrr r_s 0  ! !!!!!!E 5 ===2   0PPPPf////d6:8<*0CCCCCCr