HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
rssNewGen.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 '''
4 Created on Nov 4, 2014
5 @author: scorp
6 '''
7 
8 import ppath# pylint: disable=W0611
9 import hashlib
10 import json
11 
12 pPath = "../ftests/rss/rss_list.txt"
13 pTmp = "../ftests/rss/rss_tmp.json"
14 sPathTmp = "../ftests/rss/snew/site_new_%s.json"
15 
16 ffile = open(pPath, "r")
17 obj = json.load(ffile)
18 ffile.close()
19 
20 tfile = open(pTmp, "r")
21 tObj = json.load(tfile)
22 tfile.close()
23 
24 for url in obj["rss_list"]:
25  md5 = hashlib.md5(url).hexdigest()
26  tObj["id"] = md5
27  if "filters" in tObj and hasattr(tObj["filters"], '__iter__'):
28  for lFilter in tObj["filters"]:
29  if "siteId" in lFilter:
30  lFilter["siteId"] = md5
31  urls = []
32  urls.append(url)
33  tObj["urls"] = urls
34 
35  sPath = sPathTmp % md5
36 
37  sfile = open(sPath, "w")
38  json.dump(tObj, sfile, indent=4)
39  sfile.close()
40 
41 if __name__ == '__main__':
42  pass