Little refactoring
This commit is contained in:
parent
400ce01918
commit
93732b0367
|
@ -14,7 +14,8 @@ from src.errors import (NoMatchingSubmissionFound, NoPrawSupport,
|
||||||
|
|
||||||
print = printToFile
|
print = printToFile
|
||||||
|
|
||||||
class GetAuth:
|
def beginPraw(config,user_agent = str(socket.gethostname())):
|
||||||
|
class GetAuth:
|
||||||
def __init__(self,redditInstance,port):
|
def __init__(self,redditInstance,port):
|
||||||
self.redditInstance = redditInstance
|
self.redditInstance = redditInstance
|
||||||
self.PORT = int(port)
|
self.PORT = int(port)
|
||||||
|
@ -33,7 +34,9 @@ class GetAuth:
|
||||||
|
|
||||||
def send_message(self, message):
|
def send_message(self, message):
|
||||||
"""Send message to client and close the connection."""
|
"""Send message to client and close the connection."""
|
||||||
self.client.send('HTTP/1.1 200 OK\r\n\r\n{}'.format(message).encode('utf-8'))
|
self.client.send(
|
||||||
|
'HTTP/1.1 200 OK\r\n\r\n{}'.format(message).encode('utf-8')
|
||||||
|
)
|
||||||
self.client.close()
|
self.client.close()
|
||||||
|
|
||||||
def getRefreshToken(self,*scopes):
|
def getRefreshToken(self,*scopes):
|
||||||
|
@ -67,7 +70,6 @@ class GetAuth:
|
||||||
)
|
)
|
||||||
return (self.redditInstance,refresh_token)
|
return (self.redditInstance,refresh_token)
|
||||||
|
|
||||||
def beginPraw(config,user_agent = str(socket.gethostname())):
|
|
||||||
"""Start reddit instance"""
|
"""Start reddit instance"""
|
||||||
|
|
||||||
scopes = ['identity','history','read']
|
scopes = ['identity','history','read']
|
||||||
|
@ -245,8 +247,6 @@ def getPosts(args):
|
||||||
raise MultiredditNotFound
|
raise MultiredditNotFound
|
||||||
|
|
||||||
elif "submitted" in args:
|
elif "submitted" in args:
|
||||||
# TODO
|
|
||||||
# USE REDDIT.USER.ME() INSTEAD WHEN "ME" PASSED AS A --USER
|
|
||||||
print (
|
print (
|
||||||
"submitted posts of {user}\nsort: {sort}\n" \
|
"submitted posts of {user}\nsort: {sort}\n" \
|
||||||
"time: {time}\nlimit: {limit}\n".format(
|
"time: {time}\nlimit: {limit}\n".format(
|
||||||
|
@ -263,8 +263,6 @@ def getPosts(args):
|
||||||
)
|
)
|
||||||
|
|
||||||
elif "upvoted" in args:
|
elif "upvoted" in args:
|
||||||
# TODO
|
|
||||||
# USE REDDIT.USER.ME() INSTEAD WHEN "ME" PASSED AS A --USER
|
|
||||||
print (
|
print (
|
||||||
"upvoted posts of {user}\nlimit: {limit}\n".format(
|
"upvoted posts of {user}\nlimit: {limit}\n".format(
|
||||||
user=args["user"],
|
user=args["user"],
|
||||||
|
|
Loading…
Reference in a new issue