Bug#934273: python3-debian: please support parsing Source: package (version)

Stuart Prescott stuart at debian.org
Sun Oct 25 05:27:19 GMT 2020


Control: tags -1 patch

Hi David

Returning to your excellent idea in #9334273, how does the following seem? It 
adds an accessor for the the `source` and `source_version` to the classes 
generated by the deb822.Packages class:

In [1]: from debian import deb822 

In [2]: def whatmade(name, cat): 
  ...:     p = [pkg for pkg in cat if pkg['Package'] == name][0] 
  ...:     print("Source %s/%s made binary %s/%s" % ( 
  ...:         p.source, 
  ...:         p.source_version, 
  ...:         p['Package'], 
  ...:         p.get_version(), 
  ...:     )) 

In [3]: cat = list(deb822.Packages.iter_paragraphs(open('/var/lib/apt/lists/
deb.debian.org_debian_dists_sid_main_binary-amd64_Packages'))) 

In [4]: whatmade('gcc-10', cat) 
Source gcc-10/10.2.0-15 made binary gcc-10/10.2.0-15 

In [5]: whatmade('gcc-10-base', cat) 
Source gcc-10/10.2.0-15 made binary gcc-10-base/10.2.0-15 

In [6]: whatmade('gcc', cat) 
Source gcc-defaults/1.189 made binary gcc/4:10.2.0-1 

https://salsa.debian.org/python-debian-team/python-debian/-/merge_requests/28

Does that provide the sort of API that you were hoping to have?

cheers
Stuart


-- 
Stuart Prescott    http://www.nanonanonano.net/   stuart at nanonanonano.net
Debian Developer   http://www.debian.org/         stuart at debian.org
GPG fingerprint    90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7



More information about the pkg-python-debian-maint mailing list