1
0
Fork 0
mirror of synced 2024-06-29 11:30:30 +12:00

Little refactoring

This commit is contained in:
Ali Parlakci 2018-07-24 13:17:37 +03:00
parent 400ce01918
commit 93732b0367

View file

@ -14,7 +14,8 @@ from src.errors import (NoMatchingSubmissionFound, NoPrawSupport,
print = printToFile
class GetAuth:
def beginPraw(config,user_agent = str(socket.gethostname())):
class GetAuth:
def __init__(self,redditInstance,port):
self.redditInstance = redditInstance
self.PORT = int(port)
@ -33,7 +34,9 @@ class GetAuth:
def send_message(self, message):
"""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()
def getRefreshToken(self,*scopes):
@ -67,7 +70,6 @@ class GetAuth:
)
return (self.redditInstance,refresh_token)
def beginPraw(config,user_agent = str(socket.gethostname())):
"""Start reddit instance"""
scopes = ['identity','history','read']
@ -245,8 +247,6 @@ def getPosts(args):
raise MultiredditNotFound
elif "submitted" in args:
# TODO
# USE REDDIT.USER.ME() INSTEAD WHEN "ME" PASSED AS A --USER
print (
"submitted posts of {user}\nsort: {sort}\n" \
"time: {time}\nlimit: {limit}\n".format(
@ -263,8 +263,6 @@ def getPosts(args):
)
elif "upvoted" in args:
# TODO
# USE REDDIT.USER.ME() INSTEAD WHEN "ME" PASSED AS A --USER
print (
"upvoted posts of {user}\nlimit: {limit}\n".format(
user=args["user"],