Created
January 14, 2010 14:58
-
-
Save luispedro/277224 to your computer and use it in GitHub Desktop.
Generate an email signature from identi.ca
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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