Skip to content

Instantly share code, notes, and snippets.

@luispedro
Created January 14, 2010 14:58
Show Gist options
  • Save luispedro/277224 to your computer and use it in GitHub Desktop.
Save luispedro/277224 to your computer and use it in GitHub Desktop.
Generate an email signature from identi.ca
#!/usr/bin/env python
# Copyright 2010 (C) Luis Pedro Coelho
# License: MIT
import urllib2
header = '''\
Luis Pedro Coelho
http://luispedro.org
'''
username = 'luispedro'
microsummary = urllib2.urlopen('http://identi.ca/%s/microsummary' % username).read()
status = microsummary
def wrap(status):
if len(status) < 72: return status
words = status.split()
lines = []
line = []
while words:
next_word = words.pop(0)
if line and sum(map(len,line)) + len(line) + len(next_word) > 72:
lines.append(" ".join(line))
line = [' ']
line.append(next_word)
lines.append(" ".join(line))
return "\n".join(lines)
status = wrap(status)
print header
print status
print 'Follow me on http://identi.ca/%s' % username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment