Skip to content

Commit

Permalink
wordpressrxmlrpc.py: ExtractorPosting()
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-mbm committed Jul 14, 2015
1 parent c2c7c9a commit b0e4aac
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions paicemana/wordpressrxmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,37 @@ def print_test(self):
print(self.post)


class ExtractorPosting(object):

def __init__(self, post, lang='Ja'):
self.post = post
self.lang = lang

def do(src, lang):
return re.findall(
r'<!--:%s-->((.(?<!<\!--:-->))*)' % lang,
src,
flags = re.MULTILINE + re.DOTALL
)[0][0][:-7]

def do_content(self):
return ExtractorPosting.do(self.post.content, self.lang)

def do_title(self):
return ExtractorPosting.do(self.post.title, self.lang)


if __name__ == "__main__":
#test()
post = MockPost()
#print(post)
"""
changer = ChangerPosting(post)
s = 'My text here'
changer.do_for(s, s)
changer.print_test()
"""
extractor = ExtractorPosting(post, 'pt')
print(extractor.do_title())
print(extractor.do_content())

0 comments on commit b0e4aac

Please sign in to comment.