Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
Converters for nbsp
Browse files Browse the repository at this point in the history
  • Loading branch information
veloc1 committed Apr 18, 2020
1 parent 65a17f6 commit afbf5ae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions converters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from converters import blogs
from converters import comments
from converters import cut
from converters import nbsp
from converters import posts
from converters import spoilers
from converters import stickers
Expand All @@ -22,6 +23,8 @@ def convert(convert_type):
comments.convert()
elif convert_type == "cut":
cut.convert()
elif convert_type == "nbsp":
nbsp.convert()
elif convert_type == "posts":
posts.convert()
elif convert_type == "spoilers":
Expand Down
26 changes: 26 additions & 0 deletions converters/nbsp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from src import create_app
from src.model.models import Post, Comment

# &nbsp -> space


def process_text(text):
text = text.replace("&nbsp", " ")

return text


def convert():
create_app()

for p in Post.select():
if not p.text:
continue
p.text = process_text(p.text)
p.save()

for c in Comment.select():
if not c.text:
continue
c.text = process_text(c.text)
c.save()

0 comments on commit afbf5ae

Please sign in to comment.