mirror of https://gitlab.com/bashrc2/epicyon
Tidying of newswire dictionary creation
parent
4513a19329
commit
5bd133ffff
50
newswire.py
50
newswire.py
|
@ -52,6 +52,17 @@ def rss2Footer() -> str:
|
||||||
return rssStr
|
return rssStr
|
||||||
|
|
||||||
|
|
||||||
|
def addNewswireDictEntry(newswire: {}, dateStr: str,
|
||||||
|
title: str, link: str,
|
||||||
|
votesStatus: str, postFilename: str,
|
||||||
|
description: str, moderated: bool) -> None:
|
||||||
|
"""Update the newswire dictionary
|
||||||
|
"""
|
||||||
|
newswire[dateStr] = [title, link,
|
||||||
|
votesStatus, postFilename,
|
||||||
|
description, moderated]
|
||||||
|
|
||||||
|
|
||||||
def xml2StrToDict(baseDir: str, xmlStr: str, moderated: bool,
|
def xml2StrToDict(baseDir: str, xmlStr: str, moderated: bool,
|
||||||
maxPostsPerSource: int) -> {}:
|
maxPostsPerSource: int) -> {}:
|
||||||
"""Converts an xml 2.0 string to a dictionary
|
"""Converts an xml 2.0 string to a dictionary
|
||||||
|
@ -97,9 +108,10 @@ def xml2StrToDict(baseDir: str, xmlStr: str, moderated: bool,
|
||||||
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S %z")
|
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S %z")
|
||||||
postFilename = ''
|
postFilename = ''
|
||||||
votesStatus = []
|
votesStatus = []
|
||||||
result[str(publishedDate)] = [title, link,
|
addNewswireDictEntry(result, str(publishedDate),
|
||||||
votesStatus, postFilename,
|
title, link,
|
||||||
description, moderated]
|
votesStatus, postFilename,
|
||||||
|
description, moderated)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
@ -112,10 +124,10 @@ def xml2StrToDict(baseDir: str, xmlStr: str, moderated: bool,
|
||||||
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S UT")
|
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S UT")
|
||||||
postFilename = ''
|
postFilename = ''
|
||||||
votesStatus = []
|
votesStatus = []
|
||||||
result[str(publishedDate) + '+00:00'] = \
|
addNewswireDictEntry(result, str(publishedDate) + '+00:00',
|
||||||
[title, link,
|
title, link,
|
||||||
votesStatus, postFilename,
|
votesStatus, postFilename,
|
||||||
description, moderated]
|
description, moderated)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
@ -171,9 +183,10 @@ def atomFeedToDict(baseDir: str, xmlStr: str, moderated: bool,
|
||||||
datetime.strptime(pubDate, "%Y-%m-%dT%H:%M:%SZ")
|
datetime.strptime(pubDate, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
postFilename = ''
|
postFilename = ''
|
||||||
votesStatus = []
|
votesStatus = []
|
||||||
result[str(publishedDate)] = [title, link,
|
addNewswireDictEntry(result, str(publishedDate),
|
||||||
votesStatus, postFilename,
|
title, link,
|
||||||
description, moderated]
|
votesStatus, postFilename,
|
||||||
|
description, moderated)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
@ -186,10 +199,10 @@ def atomFeedToDict(baseDir: str, xmlStr: str, moderated: bool,
|
||||||
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S UT")
|
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S UT")
|
||||||
postFilename = ''
|
postFilename = ''
|
||||||
votesStatus = []
|
votesStatus = []
|
||||||
result[str(publishedDate) + '+00:00'] = \
|
addNewswireDictEntry(result, str(publishedDate) + '+00:00',
|
||||||
[title, link,
|
title, link,
|
||||||
votesStatus, postFilename,
|
votesStatus, postFilename,
|
||||||
description, moderated]
|
description, moderated)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
@ -363,10 +376,11 @@ def addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(fullPostFilename + '.votes'):
|
if os.path.isfile(fullPostFilename + '.votes'):
|
||||||
votes = loadJson(fullPostFilename + '.votes')
|
votes = loadJson(fullPostFilename + '.votes')
|
||||||
description = ''
|
description = ''
|
||||||
newswire[published] = \
|
addNewswireDictEntry(newswire, published,
|
||||||
[postJsonObject['object']['summary'],
|
postJsonObject['object']['summary'],
|
||||||
postJsonObject['object']['url'], votes,
|
postJsonObject['object']['url'],
|
||||||
fullPostFilename, description, moderated]
|
votes, fullPostFilename,
|
||||||
|
description, moderated)
|
||||||
|
|
||||||
ctr += 1
|
ctr += 1
|
||||||
if ctr >= maxBlogsPerAccount:
|
if ctr >= maxBlogsPerAccount:
|
||||||
|
|
Loading…
Reference in New Issue