Today I was showning someone my old Blogger website and one of the reasons I moved away from blogger is that it was hard to edit and did not work well with my workflow. It occured to me that it may be easy to migrate from Blogger to my new Pelican Blog.

## STEP 1: Download Blog's Atom Feed¶

First thing I noticed is the atom link at the bottom of the page. I right clicked on the feed and saved it as a file called "Family_Making.xml".

## STEP 2: Find, install and test atom parser for python¶

I then googled aroud for a atom feed parser in Python. Came up with feedparser

pip install feedparser

The following verified that feedparser was working

In [1]:
import feedparser

In [2]:
d = feedparser.parse('./Family_making.xml')


After looking at the entries I realized that i needed the title, published, and summary fields.

In [3]:
d.entries[1].title

Out[3]:
'Ultimaker 2, cleaning a clogged nozzle'
In [4]:
d.entries[1].published

Out[4]:
'2015-05-02T12:07:00.000-04:00'
In [1]:
#d.entries[1].summary


## STEP 3: Convert xlm/html and save as a markdown file suitable for pelican¶

Notice that thesummary field was stored as HTML instead of markdown. Another quick google lead me to html2text. Either I have already pip installed this library or it came with my anaconda installtion. In either case it loaded just fine.

In [6]:
import html2text


The following function takes an entriy in the atom feed and converts it to markdown format.

In [7]:
#Stub function. Does nothing. I added this later (see below)
def geturls(s, makelocal=True):
return s


In [13]:
def parseentry(e, save=False, show=True):
date = e.published[0:10]
title = e.title
filename = date.replace('-','')+"_"+e.title.replace(' ','_')+'.md'

s='Title: '+title+'\n'
s+='Date: '+date+'\n'
s+='Tags: Maker, 3DPrinting\n'
s+='\n'
s+=geturls(html2text.html2text(e.summary))#, makelocal=not(show))

s+='Blogpost migrated from [Blogger]('+url+') using costom python script. Comment on errors below.\n'
if save:
print('Saving: '+filename)
f=open(filename,'w')
f.write(s)
f.close()
if show:
print(filename)
print(s)
return s


Lets test it here...

In [14]:
s = parseentry(d.entries[0])

20150509_Intrducing_a_3D_printer_to_my_daughter's_Kindergarten_class.md
Title: Intrducing a 3D printer to my daughter's Kindergarten class
Date: 2015-05-09
Tags: Maker, 3DPrinting

We had fun showing off my 3D printer to the Kindergarten class.  Although the
printer is fun to watch, kids tend to get board with it in just a few minutes.
I like to come up with classroom projects that let the kids use things that
are printed with the printer. Since it is so cheep it is also fun to print
something ahead of time that they can take home.

For the kindergarten class we printed some flowers that the kids could use to
put together a cut spring  time flower pots just in time for mother's day:

It even lights up:

The kids had a great time. Here are some pictures

Turned out to be a lot of fun.  If you are interested in makeing your own here
is a list of instructions on Instructables:

<http://www.instructables.com/id/Spring-kindergarten-Class-Project-with-3D-Printer/>

And the 3D files on YouMagine:

<https://www.youmagine.com/designs/light-up-flower>

Blogpost migrated from [Blogger](https://apprenticemaker.blogspot.com/2015/05/showing-off-3d-printer-to-daughters.html) using costom python script. Comment on errors below.



Now lets run though all of the entires and save them...

In [15]:
for e in d.entries:
parseentry(e, save=False, show=False)


# Future Work¶

I notieced that there are a lot of minor errors in my posts (spelling, tags,? etc). There also seems to be a problem with URLs with dashes (-) where the file seems to add a charage return. Not sure why. I tried fixing it with a program but realized I have to read and verify each entry anyway so I will just fix them by hand.

Overall the entire project took me less than 40 minutes sitting at the airport (including writing this post) :-)

• Dirk

I got board on the plane so I thought I would try to write a program to download the pictures. This also fixes a weird problem with my URLs.

In [11]:
from urllib.request import urlopen, urlretrieve

def geturls(s, makelocal=False):
pictures=s.split('![](')
imageurls = []
urls=[]
if pictures:
for p in pictures:
if(p[0:4] == 'http'):
url_list = p.split(')')
url1_old = url_list[0]
url1_new = url1_old.replace('\n','')
filename = url1_new.split('/')[-1]
if(makelocal):
fullpath='./images/'+filename
print('saving '+fullpath)
urlretrieve(url1_new, fullpath);
url1_new = fullpath

imageurls.append(url1_new)

url2_old = url_list[1].split('()')[0]
url2_new = url2_old.replace('\n','')
if(makelocal):
url2_new = '](../images/'+filename

s = s.replace(url1_old,url1_new)
s = s.replace(url2_old,url2_new)
refs = s.split('<http')
refs = refs[1:]
for r in refs:
url = r.split('>')[0]
url2 = url.replace('\n','')
s = s.replace(url,url2)

return s


In [12]:
print(geturls(html2text.html2text(d.entries[2].summary)))

I have been having trouble with my 3D printer over the last couple of months.
It turns out that the fans got disconnected. Once I fixed the problem my
printer is working better than ever. I was itching for something to print so I
came up with this simple spacer.

I installed a motion sensor in my basement because the light switch is in an
inconvenient place and most of the time we go in this part of the basement my
hands seem to be full. The motion sensor fixes this problem and even found a
outlet plate on thingiverse that fit perfectly.

<http://www.thingiverse.com/thing:457658>

The only problem is that the installed switch box is too small for the new
sensor and my printed play sticks out a good 15 mm from the box.

A few minutes with OpenScad and a two hour print later I have a nice looking
solution.

Here is a link to the OpenSCAD file if you are interested in printing your
own:

<https://www.youmagine.com/designs/wall-switch-spacer>

Easy and fun! Nice to have my printer back!

\- Dirk



## Commit Early and Often

Tue 26 June 2018 by Dr. Dirk Colbry

Ugh! Rookie mistake! I just spent all morning working on my website and blog. I was really happy with the improvements. I was making some modifications to the Makefile in the pelican folder to streamline my workflow when... all of my files disappeared.

Rookie Mistake #1: I unintentionally did a …