<s> from urlparse import parse_qs <EOL> import sys <EOL> from digg . api import Digg <EOL> def test_story ( ) : <EOL> digg = Digg ( ) <EOL> for story in digg . story . getHot ( ) [ '<STR_LIT>' ] : <EOL> print story [ '<STR_LIT:title>' ] <EOL> print '<STR_LIT>' % ( story [ '<STR_LIT>' ] , story [ '<STR_LIT>' ] ) <EOL> print '<STR_LIT>' , '<STR_LIT:U+002CU+0020>' . join ( [ x [ '<STR_LIT:user>' ] for x in digg . story . getDiggs ( story_id = story [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] ] ) , '<STR_LIT:\n>' <EOL> def test_oauth ( ) : <EOL> from oauth2 import Consumer , Token <EOL> consumer = Consumer ( key = '<STR_LIT>' , secret = '<STR_LIT>' ) <EOL> digg = Digg ( oauth_consumer = consumer ) <EOL> response = digg . oauth . getRequestToken ( oauth_callback = '<STR_LIT>' ) <EOL> request_token = parse_qs ( response ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % request_token [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> verifier = sys . stdin . readline ( ) . rstrip ( '<STR_LIT:\r\n>' ) <EOL> request_token = Token ( request_token [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , request_token [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> request_token . set_verifier ( verifier ) <EOL> response = digg . oauth . getAccessToken ( oauth_token = request_token ) <EOL> response = parse_qs ( response ) <EOL> access_token = Token ( response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , response [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> print '<STR_LIT>' <EOL> print digg . oauth . verify ( oauth_token = access_token ) <EOL> print '<STR_LIT>' <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_oauth ( ) </s>
