def loadTemplates(injectSection = None): global TEMPLATES TEMPLATES = {} parser = ConfigParser() parser.read('templates.conf') for sectionName in parser.sections(): TEMPLATES[sectionName] = Configlet(sectionName, dict(parser.items(sectionName)), injectSection)
def _read_config(self): """Reads the config file with the Rebrandly API key""" import os file_path = os.path.join(os.path.dirname(__file__), './config.ini') config = ConfigParser() config.read(file_path) self._apikey = config.get('Rebrandly', 'apikey')
def _read_config(self): """Reads the config file with the API keys which should be placed where aliexpress_api.py is""" import os file_path = os.path.join(os.path.dirname(__file__), './config.ini') config = ConfigParser() config.read(file_path) self._appkey = config.get('AliExpress', 'appkey') self._tracking_id = config.get('AliExpress', 'trackingId')
def config(filename='database.ini', section='postgresql'): # create a parser parser = ConfigParser() # read config file parser.read(filename) # get section, default to postgresql db = {} if parser.has_section(section): params = parser.items(section) for param in params: db[param[0]] = param[1] else: raise Exception('Section {0} not found in the {1} file'.format( section, filename)) return db
def main(): # Import api key parser = ConfigParser() parser.read('config.ini') bot_token = parser.get('Telegram', 'token') # Create the Updater and pass it your bot's token. updater = Updater(bot_token) # todo: build a menu and conversation handler updater.dispatcher.add_handler(CommandHandler('promo', promo)) updater.dispatcher.add_handler( CommandHandler('search', search, pass_args=True)) updater.dispatcher.add_handler(CommandHandler('link', link, pass_args=True)) updater.dispatcher.add_error_handler(error) # Start the Bot updater.start_polling() # Run the bot until the user presses Ctrl-C or the process receives SIGINT, # SIGTERM or SIGABRT updater.idle()
def loadConfig(): global CONFIG CONFIG = {} CONFIG = ConfigParser() CONFIG.read('global.conf')