2 Commits

Author SHA1 Message Date
eyedeekay
deb775d243 Port it to python3 2023-11-23 09:43:42 -05:00
eyedeekay
8ebc4de1a7 Re-attempt migration with modernize 2023-11-22 14:48:24 -05:00
31 changed files with 182 additions and 122 deletions

View File

@@ -1,7 +1,7 @@
export venv_dir="env"
export spec=""
export venv="`which virtualenv-2.7`"
if [ x"$venv" = x ]; then
export venv="`which virtualenv`"
export spec="-p 2.7"
fi
export venv="/usr/bin/virtualenv"
#if [ x"$venv" = x ]; then
# export venv="`which virtualenv`"
# export spec="-p 2.7"
#fi

View File

@@ -1,11 +1,13 @@
pytz>=2012
Flask==1.0.2
Babel==1.3
Flask-Babel==0.9
Flask-Caching==1.4.0
Jinja2==2.10
Pygments==1.6
python-ctags
docutils==0.11
Flask==3.0.0
Babel==2.13.1
Flask-Babel==4.0.0
Flask-Caching==2.1.0
Jinja2==3.1.2
Pygments>=1.6
python-ctags3
docutils==0.20.1
gunicorn==0.17.2
werkzeug==0.16.1
werkzeug>=0.16.1
markupsafe>=2.0.1
six

View File

@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from flask import Flask, request, g, redirect, url_for, abort, render_template, send_from_directory, safe_join
from __future__ import absolute_import
from flask import Flask, request, g, redirect, url_for, abort, render_template, send_from_directory
from werkzeug.utils import safe_join
try:
from flaskext.babel import Babel
except ImportError:
@@ -67,32 +69,32 @@ SUPPORTED_LANGS = [
]
SUPPORTED_LANG_NAMES = {
'ar': 'Arabic العربية',
'id': 'Bahasa Indonesia',
'zh': 'Chinese 中文',
'zh_TW': 'Chinese 中文 (繁體中文, 台灣)',
'de': 'Deutsch',
'en': 'English',
'es': 'Castellano',
'fr': 'Français',
'el': 'Greek Ελληνικά',
'he': 'Hebrew עברית',
'hu': 'Hungarian',
'it': 'Italiano',
'ja': 'Japanese 日本語',
'ko': 'Korean 한국말',
'mg': 'Fiteny Malagasy',
'nl': 'Nederlands',
'fa': 'Persian فارسی',
'pl': 'Polski',
'pt': 'Português',
'pt_BR': 'Português do Brasil',
'ro': 'Română',
'ru': 'Russian Русский язык',
'fi': 'Suomi',
'sv': 'Svenska',
'tr': 'Türkçe',
'uk': 'Ukrainian Українська',
'ar': u'Arabic العربية',
'id': u'Bahasa Indonesia',
'zh': u'Chinese 中文',
'zh_TW': u'Chinese 中文 (繁體中文, 台灣)',
'de': u'Deutsch',
'en': u'English',
'es': u'Castellano',
'fr': u'Français',
'el': u'Greek Ελληνικά',
'he': u'Hebrew עברית',
'hu': u'Hungarian',
'it': u'Italiano',
'ja': u'Japanese 日本語',
'ko': u'Korean 한국말',
'mg': u'Fiteny Malagasy',
'nl': u'Nederlands',
'fa': u'Persian فارسی',
'pl': u'Polski',
'pt': u'Português',
'pt_BR': u'Português do Brasil',
'ro': u'Română',
'ru': u'Russian Русский язык',
'fi': u'Suomi',
'sv': u'Svenska',
'tr': u'Türkçe',
'uk': u'Ukrainian Українська',
}
RTL_LANGS = [
@@ -140,7 +142,7 @@ cache = Cache(app, config=CACHE_CONFIG)
#################
# Babel selectors
@babel.localeselector
#@babel.localeselector
def get_locale():
# If viewing specs, require English
if request.path.startswith('/spec'):
@@ -152,7 +154,7 @@ def get_locale():
# header the browser transmits. The best match wins.
return request.accept_languages.best_match(SUPPORTED_LANGS)
@babel.domainselector
#@babel.domainselector
def get_domains():
domains = []
frags = request.path.split('/', 2)
@@ -167,6 +169,7 @@ def get_domains():
domains.append(DEFAULT_GETTEXT_DOMAIN)
return domains
babel.init_app(app, locale_selector=get_locale, default_domain=get_domains)
##########################
# Hooks - helper functions

View File

@@ -6,7 +6,9 @@
Based on perl code by Eddie Kohler; heavily modified.
"""
import io
from __future__ import absolute_import
from __future__ import print_function
import cStringIO
import re
import sys
import os
@@ -14,6 +16,9 @@ import os
from . import config
from . import rank
from six.moves import map
from six.moves import range
from six.moves import zip
__all__ = [ 'ParseError', 'BibTeX', 'BibTeXEntry', 'htmlize',
'ParsedAuthor', 'FileIter', 'Parser', 'parseFile',
@@ -89,7 +94,7 @@ class BibTeX:
if cr.entryLine < ent.entryLine:
print("Warning: crossref %s used after declaration"%cr.key)
for k in list(cr.entries.keys()):
for k in cr.entries.keys():
if k in ent.entries:
print("ERROR: %s defined both in %s and in %s"%(
k,ent.key,cr.key))
@@ -122,7 +127,7 @@ def buildAuthorTable(entries):
authorsByLast.setdefault(tuple(a.last), []).append(a)
# map from author to collapsed author.
result = {}
for k,v in list(config.COLLAPSE_AUTHORS.items()):
for k,v in config.COLLAPSE_AUTHORS.items():
a = parseAuthor(k)[0]
c = parseAuthor(v)[0]
result[c] = c
@@ -141,7 +146,7 @@ def buildAuthorTable(entries):
result[author] = c
if 0:
for a,c in list(result.items()):
for a,c in result.items():
if a != c:
print("Collapsing authors: %s => %s" % (a,c))
if 0:
@@ -312,7 +317,7 @@ class BibTeXEntry:
d = ["@%s{%s,\n" % (self.type, self.key)]
if v:
df = DISPLAYED_FIELDS[:]
for k in list(self.entries.keys()):
for k in self.entries.keys():
if k not in df:
df.append(k)
else:
@@ -403,7 +408,7 @@ class BibTeXEntry:
if self.get('title'):
errs.append("ERROR: %s is a proceedings: it should have a booktitle, not a title." % self.key)
for field, value in list(self.entries.items()):
for field, value in self.entries.items():
if value.translate(ALLCHARS, PRINTINGCHARS):
errs.append("ERROR: %s.%s has non-ASCII characters"%(
self.key, field))
@@ -864,14 +869,14 @@ class FileIter:
if fname:
file = open(fname, 'r')
if string:
file = io.StringIO(string)
file = cStringIO.StringIO(string)
if file:
it = iter(file)
self.iter = it
assert self.iter
self.lineno = 0
self._next = it.__next__
def __next__(self):
self._next = it.next
def next(self):
self.lineno += 1
return self._next()
@@ -995,7 +1000,7 @@ class Parser:
self.strings.update(initial_strings)
self.newStrings = {}
self.invStrings = {}
for k,v in list(config.INITIAL_STRINGS.items()):
for k,v in config.INITIAL_STRINGS.items():
self.invStrings[v]=k
self.fileiter = fileiter
if result is None:

View File

@@ -1,5 +1,6 @@
# Copyright 2003-2006, Nick Mathewson. See LICENSE for licensing info.
from __future__ import absolute_import
import re
_KEYS = [ "ALL_TAGS",
@@ -28,7 +29,7 @@ def load(cfgFile):
INITIAL_STRINGS.update(_EXTRA_INITIAL_STRINGS)
AUTHOR_RE_LIST[:] = [
(re.compile(k, re.I), v,) for k, v in list(AUTHOR_URLS.items())
(re.compile(k, re.I), v,) for k, v in AUTHOR_URLS.items()
]
NO_COLLAPSE_AUTHORS_RE_LIST[:] = [
@@ -36,7 +37,7 @@ def load(cfgFile):
]
ALPHABETIZE_AUTHOR_AS_RE_LIST[:] = [
(re.compile(k, re.I), v,) for k,v in list(ALPHABETIZE_AUTHOR_AS.items())
(re.compile(k, re.I), v,) for k,v in ALPHABETIZE_AUTHOR_AS.items()
]
_EXTRA_INITIAL_STRINGS = {

View File

@@ -8,6 +8,9 @@
Based on the original C++ metaphone implementation.)
"""
from __future__ import print_function
from six.moves import map
from six.moves import range
TRIPLES = {
'dge': 'j',

View File

@@ -4,6 +4,8 @@
# http://scholar.google.com/scholar?as_epq=
# Take care of the caching setup
from __future__ import absolute_import
from __future__ import print_function
cache_expire = 60*60*24*30 # 30 days
# Checks
@@ -32,8 +34,8 @@ def cache_folder():
return r
import re
from urllib.request import urlopen, build_opener
from urllib.parse import quote
from six.moves.urllib.request import urlopen, build_opener
from six.moves.urllib.parse import quote
from datetime import date
import hashlib
@@ -64,7 +66,7 @@ def getPageForTitle(title, cache=True, update=True, save=True):
# Access cache or network
if exists(join(cache_folder(), md5h(url))) and cache:
return url, file(join(cache_folder(), md5h(url)),'r').read()
return url, open(join(cache_folder(), md5h(url)),'r').read()
elif update:
print("Downloading rank for %r."%title)
@@ -78,7 +80,7 @@ def getPageForTitle(title, cache=True, update=True, save=True):
page = connection.read()
print("done")
if save:
file(join(cache_folder(), md5h(url)),'w').write(page)
open(join(cache_folder(), md5h(url)),'w').write(page)
return url, page
else:
return url, None

View File

@@ -8,8 +8,11 @@
cleaned up a little, and all the duplicate entries commented out.
"""
from __future__ import absolute_import
from __future__ import print_function
import sys
import re
from six.moves import zip
assert sys.version_info[:3] >= (2,2,0)
@@ -210,7 +213,7 @@ def emit(f,ent):
note = ent.get("note")
if ent.getURL() and not note:
ent['note'] = "\\url{%s}"%ent.getURL()
ent['note'] = "\url{%s}"%ent.getURL()
elif note:
m = re.match(r'\\url{(.*)}', note)
if m:

View File

@@ -3,6 +3,7 @@
"""Unit tests for anonbib."""
from __future__ import absolute_import
from . import BibTeX
from . import metaphone
#import reconcile
@@ -18,40 +19,40 @@ class MetaphoneTests(unittest.TestCase):
class BibTeXTests(unittest.TestCase):
def testTranslation(self):
ut = BibTeX.url_untranslate
self.assertEqual(ut("Fred"),"Fred")
self.assertEqual(ut("Hello, World."), "Hello_2c_20World.")
self.assertEquals(ut("Fred"),"Fred")
self.assertEquals(ut("Hello, World."), "Hello_2c_20World.")
te = BibTeX.TeXescapeURL
ute = BibTeX.unTeXescapeURL
self.assertEqual(te("http://example/~me/my_file"),
self.assertEquals(te("http://example/~me/my_file"),
r"http://example/\{}~me/my\_file")
self.assertEqual(ute(r"http:{}//example/\{}~me/my\_file"),
self.assertEquals(ute(r"http:{}//example/\{}~me/my\_file"),
"http://example/~me/my_file")
h = BibTeX.htmlize
self.assertEqual(h("Hello, world"), "Hello, world")
self.assertEqual(h(r"\'a\`e\'{i}(\'\i)\"o&\^u"),
self.assertEquals(h("Hello, world"), "Hello, world")
self.assertEquals(h(r"\'a\`e\'{i}(\'\i)\"o&\^u"),
"&aacute;&egrave;&iacute;(&iacute;)&ouml;&amp;"
"&ucirc;")
self.assertEqual(h(r"\~n and \c{c}"), "&ntilde; and &ccedil;")
self.assertEqual(h(r"\AE---a ligature"), "&AElig;&mdash;a ligature")
self.assertEqual(h(r"{\it 33}"), " 33")
self.assertEqual(h(r"Pages 33--99 or vice--versa?"),
self.assertEquals(h(r"\~n and \c{c}"), "&ntilde; and &ccedil;")
self.assertEquals(h(r"\AE---a ligature"), "&AElig;&mdash;a ligature")
self.assertEquals(h(r"{\it 33}"), " 33")
self.assertEquals(h(r"Pages 33--99 or vice--versa?"),
"Pages 33-99 or vice&ndash;versa?")
t = BibTeX.txtize
self.assertEqual(t("Hello, world"), "Hello, world")
self.assertEqual(t(r"\'a\`e\'{i}(\'\i)\"o&\^u"),
self.assertEquals(t("Hello, world"), "Hello, world")
self.assertEquals(t(r"\'a\`e\'{i}(\'\i)\"o&\^u"),
"aei(i)o&u")
self.assertEqual(t(r"\~n and \c{c}"), "n and c")
self.assertEqual(t(r"\AE---a ligature"), "AE---a ligature")
self.assertEqual(t(r"{\it 33}"), " 33")
self.assertEqual(t(r"Pages 33--99 or vice--versa?"),
self.assertEquals(t(r"\~n and \c{c}"), "n and c")
self.assertEquals(t(r"\AE---a ligature"), "AE---a ligature")
self.assertEquals(t(r"{\it 33}"), " 33")
self.assertEquals(t(r"Pages 33--99 or vice--versa?"),
"Pages 33--99 or vice--versa?")
def authorsParseTo(self,authors,result):
pa = BibTeX.parseAuthor(authors)
self.assertEqual(["|".join(["+".join(item) for item in
self.assertEquals(["|".join(["+".join(item) for item in
[a.first,a.von,a.last,a.jr]])
for a in pa],
result)

View File

@@ -4,6 +4,8 @@
"""Download files in bibliography into a local cache.
"""
from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import signal
@@ -12,11 +14,11 @@ import gzip
from . import BibTeX
from . import config
import urllib.request, urllib.error, urllib.parse
import six.moves.urllib.request, six.moves.urllib.error, six.moves.urllib.parse
import getopt
import socket
import errno
import http.client
import six.moves.http_client
FILE_TYPES = [ "txt", "html", "pdf", "ps", "ps.gz", "abstract" ]
BIN_FILE_TYPES = [ 'pdf', 'ps.gz' ]
@@ -53,8 +55,8 @@ def downloadFile(key, ftype, section, url,timeout=None):
signal.alarm(timeout)
try:
try:
infile = urllib.request.urlopen(url)
except http.client.InvalidURL as e:
infile = six.moves.urllib.request.urlopen(url)
except six.moves.http_client.InvalidURL as e:
raise UIError("Invalid URL %s: %s"%(url,e))
except IOError as e:
raise UIError("Cannot connect to url %s: %s"%(url,e))
@@ -115,7 +117,7 @@ def downloadAll(bibtex, missingOnly=0):
urls = getURLs(e)
key = e.key
section = e.get("www_cache_section", ".")
for ftype, url in list(urls.items()):
for ftype, url in urls.items():
if missingOnly:
cachedURL = getCachedURL(key, ftype, section)
if cachedURL == url:

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from flask import render_template
from i2p2www import ANONBIB_CFG, ANONBIB_FILE

View File

@@ -3,10 +3,14 @@
"""Generate indices by author, topic, date, and BibTeX key."""
from __future__ import absolute_import
from __future__ import print_function
import sys
import re
import os
import json
from six.moves import map
from six.moves import range
assert sys.version_info[:3] >= (2,2,0)
os.umask(0o22)
@@ -242,5 +246,5 @@ if __name__ == '__main__':
bib = BibTeX.parseFile(config.MASTER_BIB)
for tag in list(config.TAG_DIRECTORIES.keys()):
for tag in config.TAG_DIRECTORIES.keys():
writePageSet(config, bib, tag)

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
import codecs
import datetime
from docutils.core import publish_parts
@@ -10,10 +11,10 @@ from i2p2www import helpers
BLOG_METATAGS = {
'author': 'I2P devs',
'author': u'I2P devs',
'category': None,
'date': None,
'excerpt': '',
'excerpt': u'',
}
BLOG_LIST_METATAGS = [

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from flask import abort, g, redirect, render_template, request, url_for
from werkzeug.contrib.atom import AtomFeed

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from flask import redirect, render_template, request
from i2p2www import CURRENT_I2P_VERSION, MIRRORS_FILE

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from flask import abort, redirect, render_template, request
try:
import json
@@ -141,12 +142,12 @@ def downloads_config():
def downloads_select(version, file):
mirrors=read_mirrors()
obj=[]
for net in list(mirrors.keys()):
for net in mirrors.keys():
a={}
a['key']=net
a['name']=net
a['protocols']=[]
for protocol in list(mirrors[net].keys()):
for protocol in mirrors[net].keys():
b={}
b['key']=protocol
b['name']=protocol

View File

@@ -1,5 +1,7 @@
# -*- coding: utf8 -*-
from __future__ import absolute_import
from __future__ import print_function
import os
import sys
from jinja2 import nodes
@@ -9,6 +11,7 @@ from pygments import highlight
from pygments.lexers import get_lexer_by_name, guess_lexer
from pygments.formatters import HtmlFormatter
from pygments.util import ClassNotFound
import six
try:
import ctags
@@ -29,8 +32,8 @@ def we_are_frozen():
def module_path():
encoding = sys.getfilesystemencoding()
if we_are_frozen():
return os.path.dirname(str(sys.executable, encoding))
return os.path.dirname(str(__file__, encoding))
return os.path.dirname(six.text_type(sys.executable, encoding))
return os.path.dirname(six.text_type(__file__, encoding))
class HighlightExtension(Extension):

View File

@@ -9,14 +9,21 @@
:license: BSD, see LICENSE for details.
"""
from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import os.path
import io
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from pygments.formatter import Formatter
from pygments.token import Token, Text, STANDARD_TYPES
from pygments.util import get_bool_opt, get_int_opt, get_list_opt, bytes
from pygments.util import get_bool_opt, get_int_opt, get_list_opt#, bytes
import six
from six.moves import range
try:
import ctags
@@ -27,11 +34,11 @@ __all__ = ['I2PHtmlFormatter', 'TextSpecFormatter']
_escape_html_table = {
ord('&'): '&amp;',
ord('<'): '&lt;',
ord('>'): '&gt;',
ord('"'): '&quot;',
ord("'"): '&#39;',
ord('&'): u'&amp;',
ord('<'): u'&lt;',
ord('>'): u'&gt;',
ord('"'): u'&quot;',
ord("'"): u'&#39;',
}
kinds = {
@@ -459,7 +466,7 @@ class I2PHtmlFormatter(Formatter):
"""
if arg is None:
arg = ('cssclass' in self.options and '.'+self.cssclass or '')
if isinstance(arg, str):
if isinstance(arg, six.string_types):
args = [arg]
else:
args = list(arg)
@@ -473,7 +480,7 @@ class I2PHtmlFormatter(Formatter):
return ', '.join(tmp)
styles = [(level, ttype, cls, style)
for cls, (style, ttype, level) in self.class2style.items()
for cls, (style, ttype, level) in six.iteritems(self.class2style)
if cls and style]
styles.sort()
lines = ['%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:])
@@ -540,7 +547,7 @@ class I2PHtmlFormatter(Formatter):
yield 0, DOC_FOOTER
def _wrap_tablelinenos(self, inner):
dummyoutfile = io.StringIO()
dummyoutfile = StringIO.StringIO()
lncount = 0
for t, line in inner:
if t:
@@ -884,7 +891,7 @@ class TextSpecFormatter(Formatter):
else:
outfile.write(value)
for ref in list(refs.values()):
for ref in refs.values():
if enc:
outfile.write(ref.encode(enc))
else:

View File

@@ -1,5 +1,7 @@
from __future__ import absolute_import
from math import ceil
from werkzeug import import_string, cached_property
from werkzeug.utils import cached_property, import_string
from six.moves import range
########################
# General helper methods

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from flask import g, redirect, url_for

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from pygments.lexer import RegexLexer, bygroups
from pygments.token import *

View File

@@ -1,3 +1,5 @@
from __future__ import absolute_import
from __future__ import print_function
import codecs
import datetime
from docutils.core import publish_parts

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
import codecs
from flask import abort, render_template, request, safe_join, send_from_directory
import os.path

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from flask import g, make_response, render_template, request, safe_join
import os.path

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
import codecs
from collections import defaultdict
from docutils import io
@@ -23,6 +24,7 @@ import os.path
from i2p2www import PROPOSAL_DIR, SPEC_DIR
from i2p2www import helpers
from six.moves import range
SPEC_METATAGS = {
@@ -40,12 +42,12 @@ SPEC_CATEGORY_SORT = defaultdict(lambda: 999, {
})
PROPOSAL_METATAGS = {
'author': 'I2P devs',
'author': u'I2P devs',
'created': None,
'editor': None,
'implementedin': None,
'lastupdated': None,
'status': 'Draft',
'status': u'Draft',
'supercededby': None,
'supercedes': None,
'target': None,
@@ -70,18 +72,18 @@ PROPOSAL_STATUS_SORT = defaultdict(lambda: 999, {
})
METATAG_LABELS = {
'accuratefor': 'Accurate for',
'author': 'Author',
'category': 'Category',
'created': 'Created',
'editor': 'Editor',
'implementedin': 'Implemented in',
'lastupdated': 'Last updated',
'status': 'Status',
'supercededby': 'Superceded by',
'supercedes': 'Supercedes',
'target': 'Target',
'thread': 'Thread',
'accuratefor': u'Accurate for',
'author': u'Author',
'category': u'Category',
'created': u'Created',
'editor': u'Editor',
'implementedin': u'Implemented in',
'lastupdated': u'Last updated',
'status': u'Status',
'supercededby': u'Superceded by',
'supercedes': u'Supercedes',
'target': u'Target',
'thread': u'Thread',
}
@@ -150,7 +152,7 @@ def render_rst(directory, name, meta_parser, template):
# Change highlight formatter
content = content.replace('{% highlight', "{% highlight formatter='textspec'")
# Metatags
for (metatag, label) in list(METATAG_LABELS.items()):
for (metatag, label) in METATAG_LABELS.items():
content = content.replace(' :%s' % metatag, label)
# render the post with Jinja2 to handle URLs etc.

View File

@@ -1,7 +1,9 @@
from __future__ import absolute_import
import ctags
from flask import g, request, safe_join, url_for
from flask import g, request, url_for
from werkzeug.utils import safe_join
import os.path
from urllib.parse import urlsplit, urlunsplit
from six.moves.urllib.parse import urlsplit, urlunsplit
from i2p2www import (
CANONICAL_DOMAIN,

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from werkzeug.routing import BaseConverter
from i2p2www import app

View File

@@ -1,3 +1,4 @@
from __future__ import absolute_import
from flask import abort, redirect, render_template, safe_join, send_from_directory, url_for
import os.path

View File

@@ -1,9 +1,11 @@
from __future__ import absolute_import
from werkzeug import BaseRequest, BaseResponse, ETagResponseMixin, escape, run_simple, SharedDataMiddleware
from werkzeug.exceptions import HTTPException
import os
import sha
from time import time
from random import choice
from six.moves import range
class Request(BaseRequest):
"""Useful subclass of the default request that knows how to build urls."""
@@ -23,7 +25,7 @@ def app(environ, start_response):
path = req.path[1:]
if path == '':
# page
page = '<html><head><title>NetDB</title></head><body><ul>%s</ul></body></html>'
page = u'<html><head><title>NetDB</title></head><body><ul>%s</ul></body></html>'
# generate links
entries = os.listdir('netdb')
@@ -46,7 +48,7 @@ def app(environ, start_response):
res += '<li><a href="%s">%s</a></li>' % (entry, entry)
resp = Response(page % res, mimetype='text/html')
elif path == 'robots.txt':
dat = "User-agent: *\nDisallow: /routerInfo-*.dat$\n"
dat = u"User-agent: *\nDisallow: /routerInfo-*.dat$\n"
resp = Response(dat, mimetype='text/plain')
else:
# load file

View File

@@ -14,6 +14,8 @@
# Modify as needed, or use a symlink.
from __future__ import absolute_import
from six.moves import range
netdbdir = 'netdb'
database = 'Driver=SQLite;DATABASE=I2PnetDb'
@@ -122,7 +124,7 @@ def application(environ, start_response):
if path == '':
page = '<html><head><title>NetDB</title></head><body><ul>%s</ul></body></html>'
page = u'<html><head><title>NetDB</title></head><body><ul>%s</ul></body></html>'
if len(info) == 0:
# tag the ip as new
@@ -179,7 +181,7 @@ def application(environ, start_response):
resp.add_etag()
elif path == 'robots.txt':
dat = "User-agent: *\nDisallow: /routerInfo-*.dat$\n"
dat = u"User-agent: *\nDisallow: /routerInfo-*.dat$\n"
resp = Response(dat, mimetype='text/plain')
resp.add_etag()

View File

@@ -1,4 +1,5 @@
#!env/bin/python
from __future__ import absolute_import
from i2p2www import app
import os