import os import getpass class Config: def __init__(self): for db_path in ['Dropbox', 'Dropbox (Personal)']: self.dir_project = os.path.join(os.path.expanduser('~'), '{0}/Projects/NewsSocialSignaling'.format(db_path)) if os.path.exists(self.dir_project): break self.dir_project = os.path.join(os.path.expanduser('~'), '{0}/1research/2projects/5mit/4alex/1newsSocialSignalign/NewsSocialSignaling'.format(db_path)) if os.path.exists(self.dir_project): break if os.path.exists('/pool001/moehring/NewsSocialSignaling'): self.dir_project = '/pool001/moehring/NewsSocialSignaling' self.heroku = False if '/app/' in self.dir_project: self.heroku = True self.dir_project = os.path.join(os.path.expanduser('~'), 'NewsSocialSignalingProject') if not os.path.exists(self.dir_project): os.makedirs(self.dir_project) print(self.dir_project) print(self.heroku) self.use_memory_db = False if getpass.getuser() == 'carlosmolina': self.use_memory_db = True self.dir_data = os.path.join(self.dir_project, 'data') self.dir_raw_data = os.path.join(self.dir_data, 'raw') self.dir_scraped = os.path.join(self.dir_raw_data, 'scraped') self.dir_twitter_data = os.path.join(self.dir_raw_data, 'twitter') self.dir_quality_data = os.path.join(self.dir_raw_data, 'newspaper_quality') self.dir_twitter_api_cache = os.path.join(self.dir_twitter_data, 'api_cache') if self.heroku: self.fn_twitter_db = ':memory:' else: self.fn_twitter_db = os.path.join(self.dir_twitter_data, 'twitter_db.db') if getpass.getuser() == 'carlosmolina': self.fn_twitter_db='/Users/carlosmolina/Dropbox/1research/2projects/5mit/4alex/1newsSocialSignalign' #create this temporarily while fixing twitter V2 self.fn_mbfc = os.path.join(self.dir_scraped, 'mbfc.p') # self.fn_twitter_streaming_db = os.path.join(self.dir_twitter_data, 'twitter_db_streaming.db') self.fn_publisher_slant_500 = os.path.join(self.dir_twitter_data, 'top500.csv') self.fn_publisher_handles = os.path.join(self.dir_quality_data, 'newspaper_handles.csv') self.key_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'keys/keys.json') self.key_pathApiV2 = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),'keys/keysApiV2.json') self.google_credentials_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'keys/google_creds.json') self.dir_survey = os.path.join(self.dir_data, '1_Survey') self.dir_asian_barometer = os.path.join(self.dir_survey, '2_AsianBarometer') self.dir_asian_barometer_figs = os.path.join(self.dir_survey, '2_AsianBarometer', '3_Figs') self.fn_asian_barometer = os.path.join(self.dir_asian_barometer, '2_Cleaned', 'cleaned_asian_survey.txt') self.dir_anes = os.path.join(self.dir_survey, '5_ANES') self.fn_anes = os.path.join(self.dir_anes, '1_Data', 'cleaned.txt') self.dir_anes_figs = os.path.join(self.dir_anes, '3_Figs') self.dir_elections = os.path.join(self.dir_data, '2_PoliticalInstitutions') self.fn_elections = os.path.join(self.dir_elections, '2_Cleaned', 'ElectionMonth.dta') self.fn_publisher_slant = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'data', 'newspaper_quality_processed.txt') print(self.fn_twitter_db) def fn_twitter_user_api(self, username): return os.path.join(self.dir_twitter_api_cache, username + '.json')