summaryrefslogtreecommitdiff
path: root/watchnews/web.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2015-11-23 23:14:17 +0100
committerYves Fischer <yvesf-git@xapek.org>2015-11-23 23:14:17 +0100
commit4c2a9d256623360b34a37dbde19531919af41c21 (patch)
treefa8f87435d8108d071963283aea0b6bb0f0da62a /watchnews/web.py
parent6b37966de51c01e6a55dd0188d9d2ac953559c14 (diff)
downloadwatchnews-4c2a9d256623360b34a37dbde19531919af41c21.tar.gz
watchnews-4c2a9d256623360b34a37dbde19531919af41c21.zip
replace all " with '
Diffstat (limited to 'watchnews/web.py')
-rw-r--r--watchnews/web.py89
1 files changed, 43 insertions, 46 deletions
diff --git a/watchnews/web.py b/watchnews/web.py
index b38f354..b212349 100644
--- a/watchnews/web.py
+++ b/watchnews/web.py
@@ -40,9 +40,9 @@ class DiffSupport:
'-': 'em',
'^': 'strong'}
elems = []
- nextpos = line.find("\x00")
+ nextpos = line.find('\x00')
while nextpos != -1 and nextpos + 1 < len(line):
- endpos = line.find("\x01", nextpos + 2)
+ endpos = line.find('\x01', nextpos + 2)
if nextpos != 0: # intermediate unchanged text
elems += [html.span(line[:nextpos])]
@@ -56,9 +56,9 @@ class DiffSupport:
elems += [html.span(text, **{'class':actionclass[line[nextpos+1]]})]
line = line[endpos:]
- nextpos = line.find("\x00")
+ nextpos = line.find('\x00')
- if line != "": # trailing unchanged text
+ if line != '': # trailing unchanged text
elems += [html.span(line)]
return elems
@@ -68,7 +68,7 @@ class Difftable(html.div, DiffSupport):
def __init__(self, to_version, from_version=None, inline_style=False):
html.div.__init__(self)
DiffSupport.__init__(self)
- self.xmlname = "div"
+ self.xmlname = 'div'
self.inline_style = inline_style
if from_version == None:
self.single_version(to_version)
@@ -77,19 +77,18 @@ class Difftable(html.div, DiffSupport):
def single_version(self, version):
self.append(html.table(
- html.tr(html.th("Title"), html.td(version.title)),
- html.tr(html.th("Authors"), html.td(version.authors)),
- html.tr(html.th("Date"), html.td(
- version.created_date.strftime("%x %X"))),
- html.tr(html.th("Link"), html.td(
- html.a(version.url, href=version.url))),
- html.tr(html.th("Text", colspan=2)),
- html.tr(html.td(map(html.p, version.text.split("\n")), colspan=2))
+ html.tr(html.th('Title'), html.td(html.a(version.title,
+ href=version.url))),
+ html.tr(html.th('Authors'), html.td(version.authors)),
+ html.tr(html.th('Date'), html.td(
+ version.created_date.strftime('%x %X'))),
+ html.tr(html.th('Text', colspan=2)),
+ html.tr(html.td(map(html.p, version.text.split('\n')), colspan=2))
))
def two_versions(self, to_version, from_version):
def prepare_text(text):
- return re.sub("\n\n\n*", "\n\n", text).split("\n")
+ return re.sub('\n\n\n*', '\n\n', text).split('\n')
from_text = prepare_text(from_version.text)
to_text = prepare_text(to_version.text)
@@ -101,21 +100,19 @@ class Difftable(html.div, DiffSupport):
diff = difflib._mdiff(from_text, to_text)
self.append(html.div(html.table(
- html.tr(html.th("Title"),
- html.td(from_difftitle),
- html.td(to_difftitle), **{'class': 'textdiff'}),
- html.tr(html.th("Authors"),
+ html.tr(html.th('Title'),
+ html.td(html.a(from_difftitle, href=from_version.url)),
+ html.td(html.a(to_difftitle, href=to_version.url)),
+ **{'class': 'textdiff'}),
+ html.tr(html.th('Authors'),
html.td(from_authors),
html.td(to_authors), **{'class': 'textdiff'}),
- html.tr(html.th("Date"),
- html.td(from_version.created_date.strftime("%x %X")),
- html.td(to_version.created_date.strftime("%x %X"))),
- html.tr(html.th("Link"),
- html.td(html.a(from_version.url, href=from_version.url)),
- html.td(html.a(to_version.url, href=to_version.url))),
- html.tr(html.th("Text", colspan=3))),
+ html.tr(html.th('Date'),
+ html.td(from_version.created_date.strftime('%x %X')),
+ html.td(to_version.created_date.strftime('%x %X'))),
+ html.tr(html.th('Text', colspan=3))),
self._diff_lines(from_text, to_text),
- **{'class': "versiondiff"}
+ **{'class': 'versiondiff'}
))
@@ -141,8 +138,8 @@ class ItemWidget(html.div, DiffSupport):
from_difftitle, to_difftitle = self._diff(
from_version.title, to_version.title)
title = html.span(to_difftitle, **{'class': 'textdiff'})
- return html.li(html.span(to_version.created_date.strftime("%x %X")),
- html.span(" - "),
+ return html.li(html.span(to_version.created_date.strftime('%x %X')),
+ html.span(' - '),
title)
@@ -151,28 +148,28 @@ class Template:
@staticmethod
def template(title, body):
return xsc.Frag(
- html.DocTypeXHTML10transitional(), "\n",
+ html.DocTypeXHTML10transitional(), '\n',
html.html(
html.head(
html.meta(charset='utf-8'),
html.title(title),
html.style(css.string(
- css.Rule(".textdiff", ".diff_add",
- backgroundColor="#CEF6CE"),
- css.Rule(".textdiff", ".diff_next",
- backgroundColor="#c0c0c0"),
- css.Rule(".textdiff", ".diff_sub",
- backgroundColor="#FFDADA"),
- css.Rule(".textdiff", ".diff_chg",
- backgroundColor="#E5E1FF")
+ css.Rule('.textdiff', '.diff_add',
+ backgroundColor='#CEF6CE'),
+ css.Rule('.textdiff', '.diff_next',
+ backgroundColor='#c0c0c0'),
+ css.Rule('.textdiff', '.diff_sub',
+ backgroundColor='#FFDADA'),
+ css.Rule('.textdiff', '.diff_chg',
+ backgroundColor='#E5E1FF')
))
- ), "\n",
+ ), '\n',
html.body(body)))
@staticmethod
def index(feeds):
return Template.template(
- "Index",
+ 'Index',
html.ul(
*map(lambda feed: html.li(
html.a(feed.title or feed.url, href=url_for('feed', id=feed.id))),
@@ -181,9 +178,9 @@ class Template:
@staticmethod
def feed(feed, items):
return Template.template(
- "Feed {}".format(feed.title or feed.url),
+ 'Feed {}'.format(feed.title or feed.url),
html.div(
- html.a("Back", href=url_for('index')),
+ html.a('Back', href=url_for('index')),
html.h1(feed.title),
*map(ItemWidget, items)))
@@ -192,9 +189,9 @@ class Template:
versionsA = versions
versionsB = [None] + versions[:-1]
versions = list(zip(versionsA, versionsB))
- return Template.template("Item: {}".format(item.title),
+ return Template.template('Item: {}'.format(item.title),
html.div(
- html.a("Back to {}".format(item.feed.title),
+ html.a('Back to {}'.format(item.feed.title),
href=url_for('feed', id=item.feed.id)),
html.h1(item.title),
*map(lambda versionAB: html.div(
@@ -208,7 +205,7 @@ def get_app():
@app.route('/')
def index():
- return Template.index(data.Feed.select()).string("utf-8")
+ return Template.index(data.Feed.select()).string('utf-8')
@app.route('/feed/<id>')
def feed(id):
@@ -216,7 +213,7 @@ def get_app():
items = data.Item.select() \
.where(data.Item.feed == feed) \
.order_by(data.Item.created_date.desc())
- return Template.feed(feed, items).string("utf-8")
+ return Template.feed(feed, items).string('utf-8')
@app.route('/item/<id>')
def item(id):
@@ -224,7 +221,7 @@ def get_app():
versions = data.Version.select() \
.where(data.Version.item == item) \
.order_by(data.Version.created_date)
- return Template.item(item, list(versions)).string("utf-8")
+ return Template.item(item, list(versions)).string('utf-8')
return app