Skip to content

Commit

Permalink
To WeeklyOSM 259 with pt2pb migration
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-mbm committed Aug 28, 2015
1 parent 57121c4 commit 0bcd57b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions paicemana/osmbrasilgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class RSSDownload(object): # TODO class's comment # TODO

def __init__(self):

url = 'http://www.weeklyosm.eu/pt/feed'
url = 'http://www.weeklyosm.eu/pb/feed'
self.feed = feedparser.parse(url)
self.__filter__()
self.__transform__()
Expand Down Expand Up @@ -153,7 +153,7 @@ def __items_for_write__(self):


if __name__ == "__main__":
#RSSDownload()
RSSDownload()
#print(DataCaught())
print(DataCaught().markdown())

33 changes: 29 additions & 4 deletions paicemana/wordpressxmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,48 @@ def __init__(self, user, password, archive, sync=False):
s = re.sub(r'”', '"', s)
markdown = s
#print(markdown)

"""
caption = re.findall(
r'\[caption.*caption\]',
markdown,
flags = re.MULTILINE + re.DOTALL
)[0]
)[0] # TODO bug with 4639
out = re.sub(r'\n', ' ', caption)
out = re.sub(r'(\(http[^\)]*) ', r'\1', out)
markdown = markdown.replace(caption, out)

"""
self.filename = 'archive-%s.md' % archive
self.markdown = markdown

with open(self.filename, 'w') as text_file:
text_file.write(markdown)


class Migrate_pt2pb(object):

def __init__(self, user, password, archive, lfrom='pt', lto='pb'):
client = Client('http://www.weeklyosm.eu/xmlrpc.php', user, password)
post = client.call(posts.GetPost(archive))
tagfrom = '<!--:%s-->' % lfrom
tagto = '<!--:%s-->' % lto
post.title = post.title.replace(tagfrom, tagto)
post.content = post.content.replace(tagfrom, tagto)
#print(post.title)
#print(post.content)
client.call(posts.EditPost(post.id, post))


def test_pages(user, password):
from wordpress_xmlrpc import WordPressPage
client = Client('http://www.weeklyosm.eu/xmlrpc.php', user, password)
pages = client.call(posts.GetPosts({'post_type': 'page'}, results_class=WordPressPage))
p = pages[0]
print(p.id)
print(p.title)


def test_a():
#test()
post = MockPost()
Expand All @@ -154,5 +177,7 @@ def test_a():

if __name__ == "__main__":
#test_a()
MarkdownDownload('alexandre', 'SENHA', 4391, True)
#MarkdownDownload('alexandre', 'SENHA', 4391, True)
Migrate_pt2pb('alexandre', 'SENHA', 10)
#test_pages('alexandre', 'SENHA')

0 comments on commit 0bcd57b

Please sign in to comment.