|
|
|
@ -18,20 +18,21 @@ def list_snippets(articles):
|
|
|
|
|
limit = 4
|
|
|
|
|
total = len(articles)
|
|
|
|
|
head = count_lines('entries/raw/res/head.txt')
|
|
|
|
|
tail = count_lines('entries/raw/res/tail.txt')
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
|
|
for article in articles:
|
|
|
|
|
text = []
|
|
|
|
|
a = []
|
|
|
|
|
|
|
|
|
|
length = 0
|
|
|
|
|
with open('entries/feature/' + article) as f:
|
|
|
|
|
text = f.readlines()
|
|
|
|
|
|
|
|
|
|
length = len(text)
|
|
|
|
|
a.append(text[head])
|
|
|
|
|
a.append(snip_article("words words words"))
|
|
|
|
|
a.append("11/22/33")
|
|
|
|
|
a.append(snip_article(find_content(article, length, head, tail)))
|
|
|
|
|
a.append(text[head + 1])
|
|
|
|
|
a.append("social")
|
|
|
|
|
a.append("link")
|
|
|
|
|
a.append('entries/feature/' + article)
|
|
|
|
|
result.append(a)
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
@ -41,6 +42,14 @@ def count_lines(fname):
|
|
|
|
|
pass
|
|
|
|
|
return linenum
|
|
|
|
|
|
|
|
|
|
def find_content(article, length, head, tail):
|
|
|
|
|
content = ""
|
|
|
|
|
with open('entries/feature/' + article) as f:
|
|
|
|
|
for pos, line in enumerate(f):
|
|
|
|
|
if pos > head and pos < length - tail:
|
|
|
|
|
content += line
|
|
|
|
|
return content
|
|
|
|
|
|
|
|
|
|
def snip_article(article):
|
|
|
|
|
# read text in article
|
|
|
|
|
# clean 250 first characters
|
|
|
|
|