Commit 458802f7 by murtaugh

feedr

parent 42de2e66
......@@ -92,13 +92,6 @@ def download_url_to_file (href, cachedir):
else:
return wget(href, cachedir)
def pagename_for_url (url):
""" Example: """
p = urlparse(url)
hostname = p.netloc
if ":" in hostname:
hostname = hostname.split(":")[0]
return os.path.join(hostname, os.path.basename(p.path))
############################
# CLASSES
......@@ -106,6 +99,15 @@ def pagename_for_url (url):
class SitePage (object):
""" Wrapper for a wiki page that represents a "Site" record -- aka a URL/RSS Item """
@staticmethod
def pagename_for_url (url):
""" Example: """
p = urlparse(url)
hostname = p.netloc
if ":" in hostname:
hostname = hostname.split(":")[0]
return os.path.join(hostname, os.path.basename(p.path))
def __init__ (self, wiki, url):
self.wiki = wiki
self.url = url
......@@ -127,7 +129,7 @@ class SitePage (object):
self.updated = result['Updated']
else:
# create new wiki page object
pagename = ensure_unique_wiki_pagename(self.wiki, "Site:"+pagename_for_url(self.url))
pagename = ensure_unique_wiki_pagename(self.wiki, "Site:"+self.pagename_for_url(self.url))
self.page = self.wiki.pages.get(pagename)
return self
......@@ -137,9 +139,9 @@ class SitePage (object):
# page, data = get_site_page_and_data(wiki, item.link)
# print ("PAGE", page, data, file=sys.stderr)
if self.page.exists:
print ("Updating wiki page {0}".format(self.page.name), file=sys.stderr)
print ("Updating wiki page \"{0}\"".format(self.page.name), file=sys.stderr)
else:
print ("Creating wiki page {0}".format(self.page.name), file=sys.stderr)
print ("Creating wiki page \"{0}\"".format(self.page.name), file=sys.stderr)
ts = ts2dt(item.updated_parsed)
# ts = datetime.datetime(*item.published_parsed[:6])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment