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/   stu...@nanonanonano.net
Debian Developer   http://www.debian.org/         stu...@debian.org
GPG fingerprint    90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7

Reply via email to