Mercurial > kiritsu
annotate RssAtomFeed.py @ 4:df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sat, 16 Feb 2008 21:56:15 -0600 |
parents | |
children |
rev | line source |
---|---|
4
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
1 import Config |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
2 import urllib2 |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
3 |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
4 def getFeedInfo(): |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
5 for feed in Config.RSS_ATOM_FEEDS: |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
6 yield dict( feed ) |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
7 |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
8 def _getHandlers(): |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
9 try: |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
10 import LocalAuth |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
11 handlers = LocalAuth.getAuthHandlers() |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
12 except ImportError: |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
13 print "No LocalAuth.py found, assuming no auth handlers." |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
14 handlers = [] |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
15 return handlers |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
16 |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
17 def update( feed ): |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
18 # Yes, we need to rebuild the opener and the handlers every |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
19 # time through this loop, or else things will fail on multiple |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
20 # Livejournal requests. |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
21 opener = urllib2.build_opener( *_getHandlers() ) |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
22 print "Fetching feed for %s..." % feed["name"] |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
23 data = opener.open( feed["url"] ) |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
24 fileObj = open( feed["filename"], "w" ) |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
25 fileObj.write( data.read() ) |
df9d4e704257
Made the architecture a little cleaner, but it's still pretty messy; I really need to turn some OO-like-hacks into actual OO constructions. At least the Config.py structure is simpler.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
26 fileObj.close() |