def __init__(self, env_key): self.env_key = env_key self.google_sheets_creds = self.common_dir + "/Google API - StevensLTBots.json" self.groupme_access_token = self.common_dir + "/Groupme Access Token.txt" self.yahoo_weather_api_json = self.common_dir + "/yahoo_weather_api_creds.json" self.profile_json_path = self.get_profile_json_path() self.profile_dict = Functions.parse_json(self.profile_json_path)
def get_spotipy_client(): spotify_credentials_dict = Functions.parse_json(Constants.spotify_credentials_file_path) scope = "user-read-currently-playing" redirect_uri = "http://localhost:44444/callback" return SpotifyLib.get_spotipy_client( client_id=spotify_credentials_dict["client_id"], client_secret=spotify_credentials_dict["secret"], scope=scope, redirect_uri=redirect_uri )
def to_dict(self): bank_logins_dict_list = Functions.parse_json(self.bank_logins_json) for bank_logins_dict in bank_logins_dict_list: bank_logins_dict["password"] = len( bank_logins_dict["password"]) * "*" return { "name": self.name, "source_dir": self.source_dir, "photo_path": self.photo_path, "bank_logins_dict_list": bank_logins_dict_list }
def __init__(self, profile, scenario_json_path): self.profile = profile self.scenario_json_path = scenario_json_path self.name = self.get_name() self.projection_dict_list = Functions.parse_json(self.scenario_json_path) self.projection_list = [Projection.json_dict_to_projection(p_d) for p_d in self.projection_dict_list] self.complete_df = self.get_complete_df() self.create_graph()
def get_account_list(self): account_list = [] for dir_name in os.listdir(self.accounts_dir_path): account_json_path = self.accounts_dir_path + "/" + dir_name + "/" + "account.json" account_dict = Functions.parse_json(account_json_path) account_list.append( Account.Account( parent_bank=self, dir_name=dir_name, type_to_statement_class_dict=self.type_to_statement_class_dict, **account_dict ) ) return account_list
def main(): twitch_credentials_dict = Functions.parse_json(Constants.twitch_credentials_file_path) twitch_oauth_dict = TwitchLib.get_oauth_dict(twitch_credentials_dict["client_id"], twitch_credentials_dict["secret"]) streamer = Streamer.Streamer( credentials_dict=twitch_credentials_dict, oauth_dict=twitch_oauth_dict, **TwitchLib.get_streamer_dict(twitch_credentials_dict["client_id"], twitch_oauth_dict["access_token"])["data"][0] ) print("Current followers as of {}:".format(Functions.get_pretty_time(datetime.datetime.now()))) print(Functions.tab_str("\n".join([str(x) for x in streamer.get_follower_list()]), 1)) print("-------------\n") streamer.listen_for_followers()
def get_existing_bank_list(self, banks_dir): existing_bank_list = [] for dir_name in os.listdir(banks_dir): if not os.path.isdir(banks_dir + "/" + dir_name): continue bank_json_path = banks_dir + "/" + dir_name + "/" + "bank.json" bank_dict = Functions.parse_json(bank_json_path) bank_class = self.type_to_bank_class_dict.get(bank_dict["type"]) if bank_class: existing_bank_list.append( bank_class(self, dir_name=dir_name, **bank_dict)) print("Found Bank:", existing_bank_list[-1].type, existing_bank_list[-1].username) else: print("unknown bank type:", bank_dict["type"]) return existing_bank_list
def get_full_bank_list(self): existing_bank_list = self.get_existing_bank_list(self.banks_dir) bank_dict_list = Functions.parse_json(self.bank_logins_json) new_bank_list = self.get_bank_list(bank_dict_list, existing_bank_list) return existing_bank_list + new_bank_list
def get_full_bank_list(): existing_bank_list = get_existing_bank_list(Constants.banks_dir) bank_dict_list = Functions.parse_json(Constants.bank_logins_json) new_bank_list = get_bank_list(bank_dict_list, existing_bank_list) return existing_bank_list + new_bank_list