Refactor to move logic into enrich_msg
This commit is contained in:
parent
9034775a48
commit
c0ec365561
30
src/rss.py
30
src/rss.py
@ -38,9 +38,16 @@ def _is_image_token(token: str, extensions):
|
|||||||
return len(parts) == 2 and parts[1] in extensions
|
return len(parts) == 2 and parts[1] in extensions
|
||||||
|
|
||||||
# this is similar to the markup function in microblog
|
# this is similar to the markup function in microblog
|
||||||
def enrich_msg(lines, is_atom=True, accepted_images=[], base_url=None):
|
def enrich_msg(
|
||||||
|
lines,
|
||||||
|
is_atom=True,
|
||||||
|
accepted_images=[],
|
||||||
|
base_url=None,
|
||||||
|
trailing_punctuation=None,
|
||||||
|
desc_len_limit=-1,
|
||||||
|
):
|
||||||
if not is_atom:
|
if not is_atom:
|
||||||
return lines
|
return line2words(lines, desc_len_limit, trailing_punctuation)
|
||||||
content = []
|
content = []
|
||||||
parser = My_Html_Parser([])
|
parser = My_Html_Parser([])
|
||||||
for line in lines:
|
for line in lines:
|
||||||
@ -99,17 +106,16 @@ def write_feed(posts, filename, params, tagname=None):
|
|||||||
msg = post.message
|
msg = post.message
|
||||||
ti = " ".join(
|
ti = " ".join(
|
||||||
line2words(msg, TITLE_LEN_LIMIT, params["trailing_punctuation"]))
|
line2words(msg, TITLE_LEN_LIMIT, params["trailing_punctuation"]))
|
||||||
if params["use_atom"]:
|
de = " ".join(
|
||||||
de = " ".join(
|
enrich_msg(
|
||||||
enrich_msg(
|
msg,
|
||||||
msg,
|
is_atom=params["use_atom"],
|
||||||
base_url=params["url"],
|
base_url=params["url"],
|
||||||
accepted_images=params["accepted_images"],
|
accepted_images=params["accepted_images"],
|
||||||
)
|
trailing_punctuation=params["trailing_punctuation"],
|
||||||
|
desc_len_limit=DESC_LEN_LIMIT,
|
||||||
)
|
)
|
||||||
else:
|
)
|
||||||
de = " ".join(
|
|
||||||
line2words(msg, DESC_LEN_LIMIT, params["trailing_punctuation"]))
|
|
||||||
li = base_url + ("#%i" % post.num)
|
li = base_url + ("#%i" % post.num)
|
||||||
p = dateutil.parser.parse(post.timestamp)
|
p = dateutil.parser.parse(post.timestamp)
|
||||||
if params["use_atom"]:
|
if params["use_atom"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user