MCPcopy
hub / github.com/codelucas/newspaper / purge_articles

Method purge_articles

newspaper/source.py:105–118  ·  view source on GitHub ↗

Delete rejected articles, if there is an articles param, purge from there, otherwise purge from source instance. Reference this StackOverflow post for some of the wonky syntax below: http://stackoverflow.com/questions/1207406/remove-items-from-a- list-while-i

(self, reason, articles)

Source from the content-addressed store, hash-verified

103 self.generate_articles()
104
105 def purge_articles(self, reason, articles):
106 """Delete rejected articles, if there is an articles param,
107 purge from there, otherwise purge from source instance.
108
109 Reference this StackOverflow post for some of the wonky
110 syntax below:
111 http://stackoverflow.com/questions/1207406/remove-items-from-a-
112 list-while-iterating-in-python
113 """
114 if reason == 'url':
115 articles[:] = [a for a in articles if a.is_valid_url()]
116 elif reason == 'body':
117 articles[:] = [a for a in articles if a.is_valid_body()]
118 return articles
119
120 @utils.cache_disk(seconds=(86400*1), cache_folder=ANCHOR_DIRECTORY)
121 def _get_category_urls(self, domain):

Callers 3

feeds_to_articlesMethod · 0.95
parse_articlesMethod · 0.95

Calls 2

is_valid_urlMethod · 0.80
is_valid_bodyMethod · 0.80

Tested by

no test coverage detected