initial commit
[ebuildfind.git] / commands / manage_layman.py
bloba490c0ac51368a68e1646ca1581cc093806a6997
1 from subprocess import call
3 from commands import getstatusoutput
5 import sys, ConfigParser, os.path, re
7 from layman.config import Config
8 from layman.action import *
9 from layman.db import DB
11 here = os.path.split(os.path.realpath(__file__))[0]
13 class LaymanManager:
14 def AddAll(self):
15 """add overlays and sync them"""
17 command1 = "./layman -c mylayman.cfg -a ALL"
18 print command1
19 (status, output) = getstatusoutput(command1)
20 print status
21 print output
23 """
24 command2 = "./layman -c mylayman.cfg -s ALL"
25 getstatusoutput(command2)
27 print command1, "\n", command2
28 """
30 def List(self):
31 """return overlays dict"""
33 sys.argv.append('-c')
34 sys.argv.append('mylayman.cfg')
35 config = Config()
37 """
38 l = ListLocal(a)
39 l.run()
40 """
42 db = DB(config)
43 overlays = dict()
45 for name, overlay in db.overlays.items():
46 overlays[name] = dict()
47 overlays[name]["src"] = overlay.src
48 overlays[name]["contact"] = overlay.contact
50 description = overlay.description
51 description = re.compile(u' +').sub(u' ', description)
52 description = re.compile(u'\n ').sub(u'\n', description)
54 overlays[name]["description"] = description
56 if '<link>1' in overlay.data.keys():
57 link = overlay.data['<link>1']['@'].strip()
58 link = re.compile(u' +').sub(u' ', link)
59 link = re.compile(u'\n ').sub(u'\n', link)
60 else:
61 link = ""
63 overlays[name]["link"] = link
64 return overlays
66 def main():
67 h = LaymanManager()
68 h.AddAll()
69 overlays = h.List()
71 if __name__ == '__main__':
72 main()