Skip to content

Instantly share code, notes, and snippets.

@Ch00k
Created October 18, 2012 10:53
Show Gist options
  • Save Ch00k/3910977 to your computer and use it in GitHub Desktop.
Save Ch00k/3910977 to your computer and use it in GitHub Desktop.
Get PPA list to insert into Allowed-Origins
#!/usr/bin/env python
import os
os.chdir("/var/lib/apt/lists")
for file in os.listdir("."):
if file.endswith("Release"):
with open(file) as f:
content = f.readlines()
d = {}
for line in content:
if 'Origin: ' in line or 'Suite: ' in line:
key = line.split(': ')[0].rstrip()
value = line.split(': ')[1].rstrip()
d[key] = value
if (d['Origin'] != 'Ubuntu') and (d['Origin'] != 'Canonical'):
if not 'Suite' in d:
print '"%s:";' % d['Origin']
else:
print '"%s: %s";' % (d['Origin'], d['Suite'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment