1 from input import inputChoices
7 def setDatasources(self, datasources):
8 self.datasources = datasources
10 def getCapabilities(self):
17 text = str(len(self.transponderlist.keys())) + " Satellites" + "\n"
21 for sat in self.transponderlist.keys():
23 print "sat:", sat, self.satnames[sat]
24 for transponder in self.transponderlist[sat]:
28 self.transponderlist = {}
37 def addSat(self, satname, satpos):
38 if not self.transponderlist.has_key(satpos):
39 self.transponderlist[satpos] = []
40 self.satnames[satpos] = satname
42 def addTransponder(self, satpos, transponder):
43 if len(transponder.keys()) >= 6:
44 self.transponderlist[satpos].append(transponder)
46 class genericdatasource(datasource):
48 datasource.__init__(self)
49 self.source = self.destination = None
52 return "Generic Datasource"
54 def getCapabilities(self):
55 return [("copy data from one source to another", self.copy), ("merge data from one source into another", self.merge)]
58 self.copymerge(action = "copy")
61 self.copymerge(action = "merge")
63 def copymerge(self, action = "copy"):
65 while choice is not None:
66 choice = inputChoices(["select source", "select destination", "copy now!"])
68 print "\nselect source:"
69 self.source = self.selectDatasource()
71 print "\nselect destination"
72 self.destination = self.selectDatasource()
74 self.docopymerge(action)
76 def docopymerge(self, action = "copy"):
77 if self.source is None:
78 print "select a source first!"
79 elif self.destination is None:
80 print "select a destination first!"
84 elif action == "merge":
86 print "from %s to %s" % (self.source.getName(), self.destination.getName())
90 self.destination.clear()
91 for satpos in self.source.transponderlist.keys():
93 self.destination.addSat(self.source.satnames[satpos], satpos)
94 for transponder in self.source.transponderlist[satpos]:
96 self.destination.addTransponder(satpos, transponder)
97 print "copied %d sats with %d transponders" % (countsat, counttransponder)
99 def selectDatasource(self):
102 for source in self.datasources:
104 list.append(source.getName() + (" (%d sats)" % len(source.transponderlist.keys())))
105 sources.append(source)
106 choice = inputChoices(list)
109 return sources[choice]