def create_config(vdirs, dateformat, timeformat): config = ['[calendars]'] for name, path, type_ in sorted(vdirs or ()): config.append('\n[[{name}]]'.format(name=name)) config.append('path = {path}'.format(path=path)) config.append('type = {type}'.format(type=type_)) config.append('\n[locale]') config.append('timeformat = {timeformat}\n' 'dateformat = {dateformat}\n' 'longdateformat = {longdateformat}\n' 'datetimeformat = {dateformat} {timeformat}\n' 'longdatetimeformat = {longdateformat} {timeformat}\n' .format(timeformat=timeformat, dateformat=dateformat, longdateformat=dateformat)) config = '\n'.join(config) return config
def create_config(vdirs, dateformat, timeformat, default_calendar=None): config = ['[calendars]'] for name, path, type_ in sorted(vdirs or ()): config.append(f'\n[[{name}]]') config.append(f'path = {path}') config.append(f'type = {type_}') config.append('\n[locale]') config.append('timeformat = {timeformat}\n' 'dateformat = {dateformat}\n' 'longdateformat = {longdateformat}\n' 'datetimeformat = {dateformat} {timeformat}\n' 'longdatetimeformat = {longdateformat} {timeformat}\n' .format(timeformat=timeformat, dateformat=dateformat, longdateformat=dateformat)) if default_calendar: config.append('[default]') config.append(f'default_calendar = {default_calendar}\n') config = '\n'.join(config) return config