Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ta2xeo/python3
Python3 support. Fix coding style for pep8.
- Loading branch information
Showing
8 changed files
with
280 additions
and
224 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import sys | ||
sys.path.append('plurk_oauth/') | ||
from PlurkAPI import PlurkAPI | ||
from plurk_oauth import PlurkAPI | ||
import getopt | ||
import json | ||
|
||
|
||
def usage(): | ||
print '''Help Information: | ||
print('''Help Information: | ||
-h: Show help information | ||
''' | ||
''') | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) | ||
except getopt.GetoptError, err: | ||
print str(err) # will print something like "option -a not recognized" | ||
except getopt.GetoptError as err: | ||
print(str(err)) # will print something like "option -a not recognized" | ||
usage() | ||
sys.exit(2) | ||
file = open('API.keys', 'r+') | ||
data = json.load(file) | ||
plurk = PlurkAPI(data["CONSUMER_KEY"], data["CONSUMER_SECRET"]) | ||
if data.get('ACCESS_TOKEN'): | ||
plurk.authorize(data["ACCESS_TOKEN"],data["ACCESS_TOKEN_SECRET"]) | ||
else: | ||
plurk.authorize() | ||
data["ACCESS_TOKEN"] = plurk._oauth.oauth_token['oauth_token'] | ||
data["ACCESS_TOKEN_SECRET"] = plurk._oauth.oauth_token['oauth_token_secret'] | ||
json.dump(data,file) | ||
|
||
print plurk.callAPI('/APP/Profile/getOwnProfile') | ||
|
||
with open('API.keys', 'r+') as f: | ||
data = json.load(f) | ||
plurk = PlurkAPI(data["CONSUMER_KEY"], data["CONSUMER_SECRET"]) | ||
if data.get('ACCESS_TOKEN'): | ||
plurk.authorize(data["ACCESS_TOKEN"], data["ACCESS_TOKEN_SECRET"]) | ||
else: | ||
plurk.authorize() | ||
data["ACCESS_TOKEN"] = plurk._oauth.oauth_token['oauth_token'] | ||
data["ACCESS_TOKEN_SECRET"] = plurk._oauth.oauth_token['oauth_token_secret'] | ||
f.seek(0) | ||
json.dump(data, f) | ||
|
||
print(plurk.callAPI('/APP/Profile/getOwnProfile')) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,44 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import sys | ||
sys.path.append('plurk_oauth/') | ||
from PlurkAPI import PlurkAPI | ||
from plurk_oauth import PlurkAPI | ||
import getopt | ||
import json | ||
|
||
|
||
def usage(): | ||
print '''Help Information: | ||
print('''Help Information: | ||
-h: Show help information | ||
''' | ||
''') | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) | ||
except getopt.GetoptError, err: | ||
print str(err) # will print something like "option -a not recognized" | ||
except getopt.GetoptError as err: | ||
print(str(err)) # will print something like "option -a not recognized" | ||
usage() | ||
sys.exit(2) | ||
file = open('API.keys', 'r+') | ||
data = json.load(file) | ||
plurk = PlurkAPI(data["CONSUMER_KEY"], data["CONSUMER_SECRET"]) | ||
if data.get('ACCESS_TOKEN'): | ||
plurk.authorize(data["ACCESS_TOKEN"],data["ACCESS_TOKEN_SECRET"]) | ||
else: | ||
plurk.authorize() | ||
data["ACCESS_TOKEN"] = plurk._oauth.oauth_token['oauth_token'] | ||
data["ACCESS_TOKEN_SECRET"] = plurk._oauth.oauth_token['oauth_token_secret'] | ||
json.dump(data,file) | ||
with open('API.keys', 'r+') as f: | ||
data = json.load(f) | ||
plurk = PlurkAPI(data["CONSUMER_KEY"], data["CONSUMER_SECRET"]) | ||
if data.get('ACCESS_TOKEN'): | ||
plurk.authorize(data["ACCESS_TOKEN"], data["ACCESS_TOKEN_SECRET"]) | ||
else: | ||
plurk.authorize() | ||
data["ACCESS_TOKEN"] = plurk._oauth.oauth_token['oauth_token'] | ||
data["ACCESS_TOKEN_SECRET"] = plurk._oauth.oauth_token['oauth_token_secret'] | ||
f.seek(0) | ||
json.dump(data, f) | ||
|
||
content = 'Test from Plurk OAuth API' | ||
if len(sys.argv) > 1: | ||
if len(sys.argv) > 1: | ||
content = sys.argv[1] | ||
qualifier = 'says' | ||
if len(sys.argv) > 2: | ||
if len(sys.argv) > 2: | ||
qualifier = sys.argv[2] | ||
print plurk.callAPI('/APP/Timeline/plurkAdd', { | ||
print(plurk.callAPI('/APP/Timeline/plurkAdd', { | ||
'content': content, | ||
'qualifier': qualifier } ) | ||
|
||
'qualifier': qualifier | ||
})) |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
from .oauth import PlurkOAuth | ||
from .api import PlurkAPI | ||
|
||
__all__ = (PlurkAPI, PlurkOAuth) |
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
Oops, something went wrong.