thomasf/exitwp — pull request #35 by cedricporter (2012-12-24 16:58:04+00:00)
Title: Fix decode bug, and change body_replace to re replace

If img url contains Chinese, it will throw exception. It seems that img is already a unicode object, so I change img.decode() to img.encode().

```python
urlretrieve(urljoin(data['header']['link'],
img.encode('utf-8')),
get_attachment_path(img, i['uid']))
```
After moidified, it works on Linux.

And I think body_replace will be better if use re.
I use WP-Syntax to highlight, and WP-Syntax use `

` to block code.
If I don't use re, I can't migrate the syntax highlight.

```python
for key in body_replace:
# body = body.replace(key, body_replace[key])
body = re.sub(key, body_replace[key], body)

```

And in config.yaml I can do re replace.
```
body_replace: {
'': '\n{% codeblock \1 lang:\1 %}\n',
'': '\n{% codeblock %}\n',
'

': '\n{% endcodeblock %}\n',

# '[python]': '{% codeblock lang:python %}',
# '[/python]': '{% endcodeblock %}',
}
```