Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorhobenshield committed Jun 7, 2023
1 parent 00f6325 commit ef9ca62
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="twitter-api-client",
version="0.9.2",
version="0.9.3",
python_requires=">=3.10.10",
description="Twitter API",
long_description=dedent('''
Expand Down
8 changes: 4 additions & 4 deletions twitter/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
class Account:

def __init__(self, email: str = None, username: str = None, password: str = None, session: Client = None, **kwargs):
self.logger = self.init_logger(kwargs.get('log_config', False))
self.session = self.validate_session(email, username, password, session, **kwargs)
self.logger = self._init_logger(kwargs.get('log_config', False))
self.session = self._validate_session(email, username, password, session, **kwargs)
self.save = kwargs.get('save', True)
self.debug = kwargs.get('debug', 0)
self.gql_api = 'https://twitter.com/i/api/graphql'
Expand Down Expand Up @@ -557,7 +557,7 @@ def _add_alt_text(self, media_id: int, text: str) -> Response:
return r

@staticmethod
def init_logger(cfg: dict) -> Logger:
def _init_logger(cfg: dict) -> Logger:
if cfg:
logging.config.dictConfig(cfg)
else:
Expand All @@ -571,7 +571,7 @@ def init_logger(cfg: dict) -> Logger:
return logging.getLogger(LOGGER_NAME)

@staticmethod
def validate_session(*args, **kwargs):
def _validate_session(*args, **kwargs):
email, username, password, session = args
if session and all(session.cookies.get(c) for c in {'ct0', 'auth_token'}):
# authenticated session provided
Expand Down
8 changes: 4 additions & 4 deletions twitter/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

class Search:
def __init__(self, email: str = None, username: str = None, password: str = None, session: Client = None, **kwargs):
self.logger = self.init_logger(kwargs.get('log_config', False))
self.session = self.validate_session(email, username, password, session, **kwargs)
self.logger = self._init_logger(kwargs.get('log_config', False))
self.session = self._validate_session(email, username, password, session, **kwargs)
self.api = 'https://api.twitter.com/2/search/adaptive.json?'
self.save = kwargs.get('save', True)
self.debug = kwargs.get('debug', 0)
Expand Down Expand Up @@ -135,7 +135,7 @@ def make_output_dirs(self, path: str) -> Path:
return p

@staticmethod
def init_logger(cfg: dict) -> Logger:
def _init_logger(cfg: dict) -> Logger:
if cfg:
logging.config.dictConfig(cfg)
else:
Expand All @@ -149,7 +149,7 @@ def init_logger(cfg: dict) -> Logger:
return logging.getLogger(LOGGER_NAME)

@staticmethod
def validate_session(*args, **kwargs):
def _validate_session(*args, **kwargs):
email, username, password, session = args
if session and all(session.cookies.get(c) for c in {'ct0', 'auth_token'}):
# authenticated session provided
Expand Down

0 comments on commit ef9ca62

Please sign in to comment.