def __init__(self): # Bind 'wikicalendar' catalog to the specified locale directory. locale_dir = resource_filename(__name__, 'locale') add_domain(self.env.path, locale_dir) # Parse 'wikicalendar' configuration section for test instructions. # Valid options are written as check.<item>.<test name>, where item # is optional. The value must be a SQL query with arguments depending # on the item it applies to. self.checks = {} conf_section = self.config['wikicalendar'] for key, sql in conf_section.options(): if key.startswith('check.'): check_type = key.split('.') if len(check_type) in range(2, 4): self.checks[check_type[-1]] = {'test': sql} if len(check_type) == 3: # We've got test type information too. self.checks[check_type[-1]]['type'] = check_type[1] # Options in 'wikicalendar' configuration section take precedence over # those in old 'wikiticketcalendar' section. cfg = self.config if 'wikicalendar' in cfg.sections(): # Rewrite option name for easier plugin upgrade. if cfg.has_option('wikicalendar', 'ticket.due_field.name'): self.env.log.debug("Old 'wikiticketcalendar' option found.") cfg.set('wikicalendar', 'ticket.due_field', cfg.get('wikicalendar', 'ticket.due_field.name')) cfg.remove('wikicalendar', 'ticket.due_field.name') cfg.save() self.env.log.debug('Updated to new option: ticket.due_field') self.tkt_due_field = self.ticket_due self.tkt_due_format = self.ticket_due_fmt else: self.tkt_due_field = self.due_field_name self.tkt_due_format = self.due_field_fmt
def __init__(self): # Bind 'wikicalendar' catalog to the specified locale directory. locale_dir = resource_filename(__name__, "locale") add_domain(self.env.path, locale_dir) # Parse 'wikicalendar' configuration section for test instructions. # Valid options are written as check.<item>.<test name>, where item # is optional. The value must be a SQL query with arguments depending # on the item it applies to. self.checks = {} conf_section = self.config["wikicalendar"] for key, sql in conf_section.options(): if key.startswith("check."): check_type = key.split(".") if len(check_type) in range(2, 4): self.checks[check_type[-1]] = {"test": sql} if len(check_type) == 3: # We've got test type information too. self.checks[check_type[-1]]["type"] = check_type[1] # Options in 'wikicalendar' configuration section take precedence over # those in old 'wikiticketcalendar' section. cfg = self.config if "wikicalendar" in cfg.sections(): # Rewrite option name for easier plugin upgrade. if cfg.has_option("wikicalendar", "ticket.due_field.name"): self.env.log.debug("Old 'wikiticketcalendar' option found.") cfg.set("wikicalendar", "ticket.due_field", cfg.get("wikicalendar", "ticket.due_field.name")) cfg.remove("wikicalendar", "ticket.due_field.name") cfg.save() self.env.log.debug("Updated to new option: ticket.due_field") self.tkt_due_field = self.ticket_due self.tkt_due_format = self.ticket_due_fmt else: self.tkt_due_field = self.due_field_name self.tkt_due_format = self.due_field_fmt
def __init__(self): # bind 'wikicalendar' catalog to the specified locale directory locale_dir = resource_filename(__name__, 'locale') add_domain(self.env.path, locale_dir) # Parse 'wikicalendar' configuration section for test instructions. # Valid options are written as check.<item>.<test name>, where item # is optional. The value must be a SQL query with arguments depending # on the item it applies to. self.checks = {} conf_section = self.config['wikicalendar'] for key, sql in conf_section.options(): if key.startswith('check.'): check_type = key.split('.') if len(check_type) in range(2,4): self.checks[check_type[-1]] = {'test': sql} if len(check_type) == 3: # We've got test type information too. self.checks[check_type[-1]]['type'] = check_type[1] # Options in 'wikicalendar' configuration section take precedence over # those in old 'wikiticketcalendar' section. c = self.config if 'wikicalendar' in c.sections(): # Rewrite option name for easier plugin upgrade. if c.has_option('wikicalendar', 'ticket.due_field.name'): self.env.log.debug('Old wikiticketcalendar option found.') c.set('wikicalendar', 'ticket.due_field', c.get('wikicalendar', 'ticket.due_field.name')) c.remove('wikicalendar', 'ticket.due_field.name') c.save() self.env.log.debug('Updated to new option: ticket.due_field') self.tkt_due_field = self.ticket_due self.tkt_due_format = self.ticket_due_fmt else: self.tkt_due_field = self.due_field_name self.tkt_due_format = self.due_field_fmt # Read options from Trac configuration system, adjustable in trac.ini. # [wiki] section self.sanitize = True if self.config.getbool('wiki', 'render_unsafe_content') is True: self.sanitize = False # TRANSLATOR: Keep macro doc style formatting here, please. self.doc_calendar = _( """Inserts a small calendar where each day links to a wiki page whose name matches `wiki-page-format`. The current day is highlighted, and days with Milestones are marked in bold. This version makes heavy use of CSS for formatting. Usage: {{{ [[WikiCalendar([year, [month, [show-buttons, [wiki-page-format]]]])]] }}} Arguments: 1. `year` (4-digit year) - defaults to `*` (current year) 1. `month` (2-digit month) - defaults to `*` (current month) 1. `show-buttons` (boolean) - defaults to `true` 1. `wiki-page-format` (string) - defaults to `%Y-%m-%d` Examples: {{{ [[WikiCalendar(2006,07)]] [[WikiCalendar(2006,07,false)]] [[WikiCalendar(*,*,true,Meeting-%Y-%m-%d)]] [[WikiCalendar(2006,07,false,Meeting-%Y-%m-%d)]] }}} """) self.doc_ticketcalendar = _( """Display Milestones and Tickets in a calendar view. displays a calendar, the days link to: - milestones (day in bold) if there is one on that day - a wiki page that has wiki_page_format (if exist) - create that wiki page if it does not exist - use page template (if exist) for new wiki page """)
def __init__(self): # bind 'wikicalendar' catalog to the specified locale directory locale_dir = resource_filename(__name__, 'locale') add_domain(self.env.path, locale_dir) # Parse 'wikicalendar' configuration section for test instructions. # Valid options are written as check.<item>.<test name>, where item # is optional. The value must be a SQL query with arguments depending # on the item it applies to. self.checks = {} conf_section = self.config['wikicalendar'] for key, sql in conf_section.options(): if key.startswith('check.'): check_type = key.split('.') if len(check_type) in range(2, 4): self.checks[check_type[-1]] = {'test': sql} if len(check_type) == 3: # We've got test type information too. self.checks[check_type[-1]]['type'] = check_type[1] # Options in 'wikicalendar' configuration section take precedence over # those in old 'wikiticketcalendar' section. c = self.config if 'wikicalendar' in c.sections(): # Rewrite option name for easier plugin upgrade. if c.has_option('wikicalendar', 'ticket.due_field.name'): self.env.log.debug('Old wikiticketcalendar option found.') c.set('wikicalendar', 'ticket.due_field', c.get('wikicalendar', 'ticket.due_field.name')) c.remove('wikicalendar', 'ticket.due_field.name') c.save() self.env.log.debug('Updated to new option: ticket.due_field') self.tkt_due_field = self.ticket_due self.tkt_due_format = self.ticket_due_fmt else: self.tkt_due_field = self.due_field_name self.tkt_due_format = self.due_field_fmt # Read options from Trac configuration system, adjustable in trac.ini. # [wiki] section self.sanitize = True if self.config.getbool('wiki', 'render_unsafe_content') is True: self.sanitize = False # TRANSLATOR: Keep macro doc style formatting here, please. self.doc_calendar = _( """Inserts a small calendar where each day links to a wiki page whose name matches `wiki-page-format`. The current day is highlighted, and days with Milestones are marked in bold. This version makes heavy use of CSS for formatting. Usage: {{{ [[WikiCalendar([year, [month, [show-buttons, [wiki-page-format]]]])]] }}} Arguments: 1. `year` (4-digit year) - defaults to `*` (current year) 1. `month` (2-digit month) - defaults to `*` (current month) 1. `show-buttons` (boolean) - defaults to `true` 1. `wiki-page-format` (string) - defaults to `%Y-%m-%d` Examples: {{{ [[WikiCalendar(2006,07)]] [[WikiCalendar(2006,07,false)]] [[WikiCalendar(*,*,true,Meeting-%Y-%m-%d)]] [[WikiCalendar(2006,07,false,Meeting-%Y-%m-%d)]] }}} """) self.doc_ticketcalendar = _( """Display Milestones and Tickets in a calendar view. displays a calendar, the days link to: - milestones (day in bold) if there is one on that day - a wiki page that has wiki_page_format (if exist) - create that wiki page if it does not exist - use page template (if exist) for new wiki page """)