source: lliurex-up/trunk/fuentes/lliurex-up-pool-scripts/usr/bin/getinfofromdeb @ 2968

Last change on this file since 2968 was 2968, checked in by kbut, 3 years ago

add scripts for pool

  • Property svn:executable set to *
File size: 666 bytes
Line 
1#!/usr/bin/python3
2import debian.debfile
3import sys
4import os.path
5from string import Template
6if not os.path.exists(sys.argv[1]):
7        print('')
8        sys.exit(1)
9printstring = Template(sys.argv[2])
10debfileraw = debian.debfile.DebFile(sys.argv[1])
11debfilecontrol = [ x.decode('utf-8') for x in debfileraw.control.get_file('control').readlines() ]
12debinfo = {}
13key = None
14for x in debfilecontrol:
15        raw = x.split(":")
16        if len(raw) > 1:
17                key = raw[0].strip()
18                debinfo[key] = x.replace(raw[0]+":",'').strip()
19        else:
20                debinfo[key] = debinfo[key] + "\n" + x.strip()
21if not 'Source' in debinfo:
22        debinfo['Source']= debinfo['Package']
23print(printstring.safe_substitute(debinfo))
Note: See TracBrowser for help on using the repository browser.