|
|
|
|
15
|
def __init__(self,country="lv",cfg_path=None, cfg_file=""):
|
15
|
def __init__(self,country="lv",cfg_path=None, cfg_file=""):
|
16
|
self.name = "config"
|
16
|
self.name = "config"
|
17
|
self.country=country
|
17
|
self.country=country
|
|
|
18
|
+ self.lists = collections.OrderedDict()
|
|
|
19
|
+ self.titles = {}
|
18
|
if not cfg_file: cfg_file = "streams.cfg"
|
20
|
if not cfg_file: cfg_file = "streams.cfg"
|
19
|
cur_directory = os.path.dirname(os.path.abspath(__file__))
|
21
|
cur_directory = os.path.dirname(os.path.abspath(__file__))
|
20
|
if not cfg_path: cfg_path = cur_directory
|
22
|
if not cfg_path: cfg_path = cur_directory
|
21
|
self.cfg_path = cfg_path
|
23
|
self.cfg_path = cfg_path
|
22
|
- self.cfg_file = cfg_file
|
|
|
|
|
24
|
+ self.set_streams_file(cfg_file)
|
|
|
25
|
+ print "streams_file=", self.streams_file
|
|
|
26
|
+ self.read_streams()
|
|
|
27
|
+
|
|
|
28
|
+ def set_streams_file(self, cfg_file):
|
23
|
if not ("/" in cfg_file or "\\" in cfg_file): # ja tikai faila nosaukums, tad meklē to source folderi
|
29
|
if not ("/" in cfg_file or "\\" in cfg_file): # ja tikai faila nosaukums, tad meklē to source folderi
|
24
|
- self.streams_file = os.path.join(cfg_path,cfg_file)
|
|
|
|
|
30
|
+ self.streams_file = os.path.join(self.cfg_path,cfg_file)
|
25
|
else:
|
31
|
else:
|
26
|
self.streams_file = cfg_file
|
32
|
self.streams_file = cfg_file
|
27
|
- self.lists = collections.OrderedDict()
|
|
|
28
|
- self.titles = {}
|
|
|
29
|
- self.read_streams()
|
|
|
30
|
|
33
|
|
31
|
def get_content(self, data):
|
34
|
def get_content(self, data):
|
32
|
print "[config] get_content",data
|
35
|
print "[config] get_content",data
|
|
|
|
|
46
|
try:
|
49
|
try:
|
47
|
sf = urllib2.urlopen(self.streams_file, "r")
|
50
|
sf = urllib2.urlopen(self.streams_file, "r")
|
48
|
except Exception as e:
|
51
|
except Exception as e:
|
49
|
- raise Exception("Can not open streams file %s" % self.cfg_file)
|
|
|
|
|
52
|
+ raise Exception("Can not open streams file %s" % self.streams_file)
|
50
|
#print "Warning: can not open streams file %s, callback to default" % self.streams_file
|
53
|
#print "Warning: can not open streams file %s, callback to default" % self.streams_file
|
51
|
#self.streams_file = os.path.join(self.cfg_path, "streams.cfg")
|
54
|
#self.streams_file = os.path.join(self.cfg_path, "streams.cfg")
|
52
|
#sf = open(self.streams_file, "r")
|
55
|
#sf = open(self.streams_file, "r")
|
|
|
|
|
117
|
else:
|
120
|
else:
|
118
|
f.close()
|
121
|
f.close()
|
119
|
|
122
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
def get_lists(self):
|
123
|
def get_lists(self):
|
123
|
return self.lists.keys()
|
124
|
return self.lists.keys()
|
124
|
|
125
|
|
|
|
|
|
154
|
|
155
|
|
155
|
def move_item(self, name, pos, pos2):
|
156
|
def move_item(self, name, pos, pos2):
|
156
|
# l.insert(newindex, l.pop(oldindex))
|
157
|
# l.insert(newindex, l.pop(oldindex))
|
157
|
- if pos2 < pos:
|
|
|
|
|
158
|
+ if pos2 == None:
|
|
|
159
|
+ self.lists[name].append(self.lists[name].pop(pos))
|
|
|
160
|
+ elif pos2 < pos:
|
158
|
self.lists[name].insert(pos2, self.lists[name].pop(pos))
|
161
|
self.lists[name].insert(pos2, self.lists[name].pop(pos))
|
159
|
elif pos2 > pos:
|
162
|
elif pos2 > pos:
|
160
|
self.lists[name].insert(pos2-1, self.lists[name].pop(pos))
|
163
|
self.lists[name].insert(pos2-1, self.lists[name].pop(pos))
|
|
|
|
|
162
|
if __name__ == "__main__":
|
165
|
if __name__ == "__main__":
|
163
|
|
166
|
|
164
|
source = Source(cfg_file="ftp://user:Kaskade7@home.blue.lv/hdd/streams.cfg")
|
167
|
source = Source(cfg_file="ftp://user:Kaskade7@home.blue.lv/hdd/streams.cfg")
|
|
|
168
|
+ #source = Source(cfg_file="streams.cfg")
|
165
|
source.read_streams()
|
169
|
source.read_streams()
|
166
|
source.write_streams()
|
170
|
source.write_streams()
|
167
|
import sys
|
171
|
import sys
|