API¶
-
class
birding.spout.
TermCycleSpout
[source]¶
-
class
birding.bolt.
TwitterSearchBolt
[source]¶ -
initialize
(conf, ctx)[source]¶ Initialization steps:
- Get
search_manager_from_config()
. - Prepare to track searched terms as to avoid redundant searches.
- Get
-
-
class
birding.bolt.
TwitterLookupBolt
[source]¶ -
-
process
(tup)[source]¶ Process steps:
- Stream in (term, timestamp, search_result).
- Perform
lookup_search_result()
. - Emit (term, timestamp, lookup_result).
-
-
class
birding.bolt.
ElasticsearchIndexBolt
[source]¶
-
class
birding.bolt.
ResultTopicBolt
[source]¶
-
birding.search.
search_manager_from_config
()[source]¶ Get a SearchManager instance dynamically based on config.
config is a dictionary containing
class
andinit
keys as defined inbirding.config
.
-
class
birding.search.
SearchManager
[source]¶ Abstract base class for service object to search for tweets.
-
class
birding.twitter.
Twitter
(format=u'json', domain=u'api.twitter.com', secure=True, auth=None, api_version=<class 'twitter.api._DEFAULT'>, retry=False)[source]¶ -
classmethod
from_oauth_file
(filepath=None)[source]¶ Get an object bound to the Twitter API using your own credentials.
The twitter library ships with a twitter command that uses PIN OAuth. Generate your own OAuth credentials by running twitter from the shell, which will open a browser window to authenticate you. Once successfully run, even just one time, you will have a credential file at ~/.twitter_oauth.
This factory function reuses your credential file to get a Twitter object. (Really, this code is just lifted from the twitter.cmdline module to minimize OAuth dancing.)
-
classmethod
-
class
birding.twitter.
TwitterSearchManager
(twitter)[source]¶ Service object to provide fully-hydrated tweets given a search query.
-
birding.twitter.
TwitterSearchManagerFromOAuth
()[source]¶ Build
TwitterSearchManager
from user OAuth file.Arguments are passed to
birding.twitter.Twitter.from_oauth_file()
.
-
class
birding.gnip.
Gnip
(base_url, stream, username, password, **params)[source]¶ Simple binding to Gnip search API.
-
session_class
¶ alias of
Session
-
-
class
birding.gnip.
GnipSearchManager
(*a, **kw)[source]¶ Service object to provide fully-hydrated tweets given a search query.
-
birding.config.
get_config
(filepath=None, default_loader=None, on_missing=None)[source]¶ Get a dict for the current birding configuration.
The resulting dictionary is fully populated with defaults, such that all valid keys will resolve to valid values. Invalid and extra values in the configuration result in an exception.
See Configuring birding (module-level docstring) for discussion on how birding configuration works, including filepath loading. Note that a non-default filepath set via env results in a
OSError
when the file is missing, but the default filepath is ignored when missing.This function caches its return values as to only parse configuration once per set of inputs. As such, treat the resulting dictionary as read-only as not to accidentally write values which will be seen by other handles of the dictionary.
Parameters: Returns: dict of current birding configuration; treat as read-only.
Return type:
-
birding.shelf.
shelf_from_config
()[source]¶ Get a Shelf instance dynamically based on config.
config is a dictionary containing
shelf_*
keys as defined inbirding.config
.
-
class
birding.shelf.
Shelf
[source]¶ Abstract base class for a shelf to track – but not iterate – values.
Provides a dict-interface.
-
unpack
(key, value)[source]¶ Unpack value from
getitem
.This is useful for Shelf implementations which require metadata be stored with the shelved values, in which case
pack
should implement the inverse operation. By default, the value is simply passed through without modification. Theunpack
implementation is called on__getitem__
and therefore can raise KeyError if packed metadata indicates that a value is invalid.
-
-
class
birding.shelf.
FreshPacker
[source]¶ Mixin for pack/unpack implementation to expire shelf content.
-
expire_after
= 300¶ Values are no longer fresh after this value, in seconds.
-
-
class
birding.shelf.
LRUShelf
(maxsize=1000)[source]¶ An in-memory Least-Recently Used shelf up to maxsize..
-
class
birding.shelf.
FreshLRUShelf
(maxsize=1000)[source]¶ A Least-Recently Used shelf which expires values.