server-cli-todo-cleanup

This commit is contained in:
2022-08-11 14:22:10 +03:00
parent 0ba5047ff9
commit f13f40c89a
18 changed files with 106 additions and 33 deletions

View File

@@ -9,11 +9,11 @@ s3 = 'https://discours-io.s3.amazonaws.com/'
cdn = 'https://assets.discours.io'
def replace_tooltips(body):
# FIXME: if you prefer regexp
# change if you prefer regexp
newbody = body
matches = list(re.finditer(TOOLTIP_REGEX, body, re.IGNORECASE | re.MULTILINE))[1:]
for match in matches:
newbody = body.replace(match.group(1), '<Tooltip text="' + match.group(2) + '" />') # FIXME: doesn't work
newbody = body.replace(match.group(1), '<Tooltip text="' + match.group(2) + '" />') # NOTE: doesn't work
if len(matches) > 0:
print('[extract] found %d tooltips' % len(matches))
return newbody
@@ -54,7 +54,7 @@ cache = {}
def reextract_images(body, oid):
# FIXME: if you prefer regexp
# change if you prefer regexp
matches = list(re.finditer(IMG_REGEX, body, re.IGNORECASE | re.MULTILINE))[1:]
i = 0
for match in matches:
@@ -63,7 +63,7 @@ def reextract_images(body, oid):
name = oid + str(i)
link = public + '/upload/image-' + name + '.' + ext
img = match.group(4)
title = match.group(1) # FIXME: this is not the title
title = match.group(1) # NOTE: this is not the title
if img not in cache:
content = base64.b64decode(img + '==')
print(str(len(img)) + ' image bytes been written')
@@ -72,7 +72,7 @@ def reextract_images(body, oid):
i += 1
else:
print('[extract] image cached ' + cache[img])
body.replace(str(match), '![' + title + '](' + cdn + link + ')') # FIXME: this does not work
body.replace(str(match), '![' + title + '](' + cdn + link + ')') # WARNING: this does not work
return body
IMAGES = {

View File

@@ -30,8 +30,7 @@ from .utils import (
__version__ = (2020, 1, 16)
# TODO:
# Support decoded entities with UNIFIABLE.
# TODO: Support decoded entities with UNIFIABLE.
class HTML2Text(html.parser.HTMLParser):
@@ -503,7 +502,7 @@ class HTML2Text(html.parser.HTMLParser):
self.handle_emphasis(start, tag_style, parent_style)
if tag in ["kbd", "code", "tt"] and not self.pre:
self.o("`") # TODO: `` `this` ``
self.o("`") # `` `this` ``
self.code = not self.code
if tag == "abbr":
@@ -681,7 +680,7 @@ class HTML2Text(html.parser.HTMLParser):
# Indent two spaces per list, except use three spaces for an
# unordered list inside an ordered list.
# https://spec.commonmark.org/0.28/#motivation
# TODO: line up <ol><li>s > 9 correctly.
# WARNING: does not line up <ol><li>s > 9 correctly.
parent_list = None
for list in self.list:
self.o(
@@ -761,7 +760,6 @@ class HTML2Text(html.parser.HTMLParser):
self.out("\n[/code]")
self.p()
# TODO: Add docstring for these one letter functions
def pbr(self) -> None:
"Pretty print has a line break"
if self.p_p == 0:
@@ -807,7 +805,7 @@ class HTML2Text(html.parser.HTMLParser):
return
if self.startpre:
# self.out(" :") #TODO: not output when already one there
# self.out(" :") # not an output when already one there
if not data.startswith("\n") and not data.startswith("\r\n"):
# <pre>stuff...
data = "\n" + data

View File

@@ -47,8 +47,8 @@ def migrate(entry, storage):
}
'''
reaction_dict = {}
# FIXME: comment_dict['createdAt'] = ts if not entry.get('createdAt') else date_parse(entry.get('createdAt'))
# print('[migration] comment original date %r' % entry.get('createdAt'))
reaction_dict['createdAt'] = ts if not entry.get('createdAt') else date_parse(entry.get('createdAt'))
print('[migration] reaction original date %r' % entry.get('createdAt'))
# print('[migration] comment date %r ' % comment_dict['createdAt'])
reaction_dict['body'] = html2text(entry.get('body', ''))
reaction_dict['oid'] = entry['_id']

View File

@@ -118,8 +118,8 @@ def migrate(entry, storage):
s = object()
shout_dict = r.copy()
user = None
del shout_dict['topics'] # FIXME: AttributeError: 'str' object has no attribute '_sa_instance_state'
#del shout_dict['rating'] # FIXME: TypeError: 'rating' is an invalid keyword argument for Shout
del shout_dict['topics'] # NOTE: AttributeError: 'str' object has no attribute '_sa_instance_state'
#del shout_dict['rating'] # NOTE: TypeError: 'rating' is an invalid keyword argument for Shout
#del shout_dict['ratings']
email = userdata.get('email')
slug = userdata.get('slug')