def __getattribute__(self, name): if name == '__class__': return Option value = Option.__getattribute__(self, name) if name == '__doc__': value = dgettext(doc_domain, value) return value return OptionTx if len(options) == 1: return _option_with_tx(options[0], domain) else: return map(lambda option: _option_with_tx(option, domain), options) _, N_, gettext, ngettext, add_domain = domain_functions( 'tracexceldownload', '_', 'N_', 'gettext', 'ngettext', 'add_domain') ChoiceOption = domain_options('tracexceldownload', ChoiceOption) class TranslationModule(Component): implements(IEnvironmentSetupParticipant) def __init__(self, *args, **kwargs): Component.__init__(self, *args, **kwargs) add_domain(self.env.path, resource_filename(__name__, 'locale')) # IEnvironmentSetupParticipant methods def environment_created(self): pass def environment_needs_upgrade(self, db):
from trac.core import Component, implements from trac.admin import IAdminPanelProvider from trac.config import Configuration, Option, BoolOption, ListOption, \ FloatOption, ChoiceOption from trac.env import IEnvironmentSetupParticipant from trac.perm import PermissionSystem from trac.util import arity from trac.util.compat import md5, any from trac.util.text import to_unicode, exception_to_unicode from trac.util.translation import dgettext, domain_functions from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script, \ add_script_data _, N_, add_domain = domain_functions('tracworkflowadmin', '_', 'N_', 'add_domain') if arity(Option.__init__) <= 5: def _option_with_tx(Base): # Trac 0.12.x class Option(Base): def __getattribute__(self, name): val = Base.__getattribute__(self, name) if name == '__doc__': val = dgettext('tracworkflowadmin', val) return val return Option else: def _option_with_tx(Base): # Trac 1.0 or later class Option(Base): def __init__(self, *args, **kwargs):
# -*- coding: utf-8 -*- #---------------------------------------------------------------------------- # Name: i18n_domain.py # Purpose: The TracTicketChangelogPlugin Trac plugin i18n_domain module # # Author: Richard Liao <*****@*****.**> # #---------------------------------------------------------------------------- try: from trac.util.translation import domain_functions gettext, _, tag_, N_, add_domain = domain_functions( 'ticketlog', 'gettext', '_', 'tag_', 'N_', 'add_domain') except ImportError: # ignore domain functions def add_domain(*args, **kwargs): pass try: from trac.util.translation import _, tag_, N_, gettext except ImportError: # skip support i18n, to work in trac 0.11 def gettext(string, **kwargs): return string def _(string, **kwargs): return string def tag_(string, **kwargs): return string
# Created by Denis Yeldandi on 2011-02-21. # Copyright (c) 2011 Denis Yeldandi. All rights reserved. import itertools from trac.core import * from trac.web.api import ITemplateStreamFilter from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script, add_script_data from trac.config import Option, OrderedExtensionsOption from genshi.builder import tag from genshi.filters.transform import Transformer from pkg_resources import resource_filename from trac.util.translation import domain_functions import pkg_resources _, tag_, N_, add_domain = domain_functions('Translate', ('_', 'tag_', 'N_', 'add_domain')) class TranslateModule(Component): """A stream filter to add translate buttons.""" implements(ITemplateStreamFilter, ITemplateProvider) googleApiKey = Option('translate', 'google_api_key', default='', doc='Google api key to use') def __init__(self): locale_dir = pkg_resources.resource_filename(__name__, 'locale') add_domain(self.env.path, locale_dir)
from genshi.builder import tag from pkg_resources import resource_filename from urllib import unquote_plus from trac.core import Component, ExtensionPoint, Interface, implements from trac.perm import IPermissionRequestor from trac.resource import IResourceManager, Resource, ResourceNotFound, \ get_resource_name, get_resource_shortname, \ get_resource_url # Import i18n methods. Fallback modules maintain compatibility to Trac 0.11 # by keeping Babel optional here. try: from trac.util.translation import domain_functions add_domain, _, ngettext, tag_ = \ domain_functions('tracforms', ('add_domain', '_', 'ngettext', 'tag_')) except ImportError: from genshi.builder import tag as tag_ from trac.util.translation import gettext _ = gettext ngettext = _ def add_domain(a,b,c=None): pass from trac.web import IRequestHandler from trac.web.api import HTTPBadRequest, HTTPUnauthorized # Import AccountManagerPlugin methods, if plugin is installed. try: from acct_mgr.api import IPasswordStore can_check_user = True
License: BSD (c) 2005-2012 ::: www.CodeResort.com - BV Network AS ([email protected]) """ import re from pkg_resources import resource_filename from trac.core import * from trac.ticket.api import TicketSystem try: from trac.util.translation import domain_functions add_domain, _, tag_ = \ domain_functions('customfieldadmin', ('add_domain', '_', 'tag_')) except: # fall back to 0.11 behavior, i18n functions are no-ops then from genshi.builder import tag as tag_ from trac.util.translation import gettext as _ def add_domain(*args, **kwargs): pass __all__ = ['CustomFields'] class CustomFields(Component): """ These methods should be part of TicketSystem API/Data Model. Adds update_custom_field and delete_custom_field methods.
from trac.config import BoolOption, ListOption, Option from trac.core import Component, ExtensionPoint, Interface, TracError from trac.core import implements from trac.perm import IPermissionPolicy, IPermissionRequestor from trac.perm import PermissionError, PermissionSystem from trac.resource import IResourceManager, get_resource_url from trac.resource import get_resource_description from trac.util import get_reporter_id from trac.util.text import to_unicode from trac.util.translation import domain_functions from trac.wiki.model import WikiPage # Import translation functions. add_domain, _, N_, gettext, ngettext, tag_, tagn_ = \ domain_functions('tractags', ('add_domain', '_', 'N_', 'gettext', 'ngettext', 'tag_', 'tagn_')) dgettext = None from tractags.model import resource_tags, tag_frequency, tag_resource from tractags.model import tagged_resources # Now call module importing i18n methods from here. from tractags.query import * REALM_RE = re.compile('realm:(\w+)', re.U | re.I) class InvalidTagRealm(TracError): pass class ITagProvider(Interface):
import re import copy from pkg_resources import resource_filename from trac.core import * from trac.config import ConfigSection, Option, ListOption, ExtensionOption, _TRUE_VALUES from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script, \ add_script_data, add_notice, add_warning from trac.admin.api import IAdminPanelProvider from trac.util.translation import dgettext, domain_functions from inieditorpanel.api import * _, tag_, N_, add_domain, gettext = domain_functions( 'inieditorpanel', ('_', 'tag_', 'N_', 'add_domain', 'gettext')) class TracIniAdminPanel(Component): """ An editor panel for trac.ini. """ implements(IAdminPanelProvider, ITemplateProvider) valid_section_name_chars = Option( 'ini-editor', 'valid-section-name-chars', '^[a-zA-Z0-9\\-_\\:]+$', doc="""Defines the valid characters for a section name or option name in `trac.ini`. Must be a valid regular expression. You only need to change these if you have plugins that use some strange section or option names. """,
from trac.core import Component, implements from trac.web.api import IRequestFilter, ITemplateStreamFilter from trac.util.translation import domain_functions from trac.web.chrome import ITemplateProvider, add_stylesheet, Chrome,\ add_warning from trac.config import ChoiceOption, Option from genshi.filters import Transformer from genshi import HTML from pkg_resources import resource_filename #@UnresolvedImport from genshi.builder import tag from trac.wiki.api import WikiSystem from genshi.core import Markup from trac.util import as_int _, tag_, N_, add_domain = \ domain_functions('navigationplugin', '_', 'tag_', 'N_', 'add_domain') SESSION_KEYS = {'nav': 'display_nav', 'wiki': 'wiki.href', 'tickets': 'tickets.href'} DISPLAY_CHOICES = ['normal', 'buttom_ctx_menu', 'fixed_menu'] CHOICES_DOC = {'normal': _("Trac default"), 'buttom_ctx_menu': _("Display another context menu at the buttom of page"), 'fixed_menu': _("Display banner and menu fixed on top of page " "(under development)")} class Navigation(Component):
# -*- coding: utf-8 -*- import pkg_resources from trac.util.translation import domain_functions _, tag_, N_, add_tracpor_domain = \ domain_functions('penelope.trac', ('_', 'tag_', 'N_', 'add_domain')) def add_domains(env_path): locale_dir = pkg_resources.resource_filename(__name__, 'locale') add_tracpor_domain(env_path, locale_dir)
from trac.mimeview import Context from trac.util.html import html from trac.util.text import pretty_size from trac.util.translation import domain_functions # Trac interfaces. from trac.web.main import IRequestHandler from trac.web.chrome import INavigationContributor, ITemplateProvider from trac.resource import IResourceManager from trac.perm import IPermissionRequestor # Local imports. from tracdownloads.api import * # Bring in dedicated Trac plugin i18n helper. add_domain, _, tag_ = domain_functions('tracdownloads', ('add_domain', '_', 'tag_')) class DownloadsCore(Component): """ The core module implements plugin's ability to download files, provides permissions and templates. """ implements(IRequestHandler, ITemplateProvider, IPermissionRequestor, IResourceManager) # IPermissionRequestor methods. def get_permission_actions(self): view = 'DOWNLOADS_VIEW' add = ('DOWNLOADS_ADD', ['DOWNLOADS_VIEW']) admin = ('DOWNLOADS_ADMIN', ['DOWNLOADS_VIEW', 'DOWNLOADS_ADD'])
from genshi.filters import Transformer from genshi.path import Path from trac.admin.api import IAdminPanelProvider from trac.core import Component, implements from trac.perm import IPermissionRequestor, PermissionSystem from trac.ticket.api import ITicketChangeListener from trac.util.translation import domain_functions from trac.web.api import IRequestFilter from trac.web.chrome import ITemplateProvider, add_stylesheet _, tag_, N_, add_domain = domain_functions('projectplugin', '_', 'tag_', 'N_', 'add_domain') class ProjectAdmin(Component): """Adds project number to ticket. User which have right `CONTROLLER_ADMIN` (or `TRAC_ADMIN`) can edit list of default project numbers in admin pane. Editing project number manually: - when creating a ticket, manually typed project numbers will be '''skipped''' ! """ implements(IAdminPanelProvider, ITemplateProvider, ITicketChangeListener, IPermissionRequestor, IRequestFilter) # ITemplateStreamFilter , IRequestHandler, ITicketManipulator changed_fields = ['type', 'milestone'] #=========================================================================== # TODO: maybe using class CustomField from settings.py #===========================================================================
# Created by Denis Yeldandi on 2011-02-21. # Copyright (c) 2011 Denis Yeldandi. All rights reserved. import itertools from trac.core import * from trac.web.api import ITemplateStreamFilter from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script, add_script_data from trac.config import Option, OrderedExtensionsOption from genshi.builder import tag from genshi.filters.transform import Transformer from pkg_resources import resource_filename from trac.util.translation import domain_functions import pkg_resources _, tag_, N_, add_domain = domain_functions('Translate', ('_', 'tag_', 'N_', 'add_domain')) class TranslateModule(Component): """A stream filter to add translate buttons.""" implements(ITemplateStreamFilter, ITemplateProvider) googleApiKey = Option('translate', 'google_api_key', default='', doc='Google api key to use') def __init__(self): locale_dir = pkg_resources.resource_filename(__name__, 'locale') add_domain(self.env.path, locale_dir) # ITemplateStreamFilter methods def filter_stream(self, req, method, filename, stream, data):
import re, sys from pkg_resources import resource_filename from genshi.builder import tag from trac.core import Component, implements from trac.util.translation import domain_functions from trac.web import IRequestFilter from trac.web.chrome import add_script, add_stylesheet, add_ctxtnav, \ ITemplateProvider add_domain, _ = \ domain_functions('datasaver', ('add_domain', '_')) class DataSaverModule(Component): implements(IRequestFilter, ITemplateProvider) def __init__(self): # bind the 'datasaver' catalog to the specified locale directory locale_dir = resource_filename(__name__, 'locale') add_domain(self.env.path, locale_dir) def pre_process_request(self, req, handler): return handler def post_process_request(self, req, template, data, content_type): add_script(req, 'datasaver/datasaver.js') if req.locale is not None: add_script(req, 'datasaver/lang_js/%s.js' % req.locale)
# """Translation functions and classes.""" from pkg_resources import parse_version from trac import __version__ as trac_version #------------------------------------------------------ # Internationalization #------------------------------------------------------ try: from trac.util.translation import domain_functions _, ngettext, tag_, tagn_, gettext, N_, add_domain = \ domain_functions('themeengine', ('_', 'ngettext', 'tag_', 'tagn_', 'gettext', 'N_', 'add_domain')) dgettext = None except ImportError: from genshi.builder import tag as tag_ from trac.util.translation import gettext _ = gettext N_ = lambda text: text def add_domain(a,b,c=None): pass def dgettext(domain, string, **kwargs): return safefmt(string, kwargs) def ngettext(singular, plural, num, **kwargs): string = num == 1 and singular or plural kwargs.setdefault('num', num) return safefmt(string, kwargs) def safefmt(string, kwargs):
# # Author: Franz Mayer <*****@*****.**> import re from operator import attrgetter from pkg_resources import resource_filename # @UnresolvedImport from genshi.filters import Transformer from trac.core import Component, implements from trac.ticket.roadmap import RoadmapModule from trac.util.html import html as tag from trac.util.translation import domain_functions from trac.web.api import IRequestFilter, ITemplateStreamFilter _, tag_, N_, add_domain = domain_functions( 'roadmapplugin', '_', 'tag_', 'N_', 'add_domain') keys = [u'noduedate', u'completed'] showkeys = {'noduedate': 'hidenoduedate', 'completed': 'showcompleted'} # returns the name of the attribute plus the prefix roadmap.filter def _get_session_key_name(name): return "roadmap.filter.%s" % name # saves a single attribute as a session key def _set_session_attrib(req, name, value): req.session[_get_session_key_name(name)] = value
from trac.env import ISystemInfoProvider from trac.perm import IPermissionGroupProvider from acct_mgr.api import IPasswordStore from gdata.apps.service import AppsService from gdata.apps.groups.service import GroupsService from gdata.service import BadAuthentication, CaptchaRequired from gdata.apps.service import AppsForYourDomainException from base64 import b64encode, b64decode # i18n from pkg_resources import resource_filename #@UnresolvedImport from trac.util.translation import domain_functions _, add_domain = domain_functions('googleappsauth', ('_', 'add_domain')) class GoogleAppsPasswordStore(Component): """TracAccountManager Password Store which authenticates against a Google Apps domain""" implements(IPasswordStore, IPermissionGroupProvider, ISystemInfoProvider) # Plugin Options opt_key = 'google_apps' gapps_domain = Option(opt_key, 'domain', doc=_("Domain name of the Google Apps domain")) gapps_admin_username = Option(opt_key, 'admin_username', doc=_("Username or email with Google Apps admin access")) gapps_admin_secret = Option(opt_key, 'admin_secret', doc=_("Password for Google Apps admin account; this is magically encrypted to make storage slightly more secure")) gapps_group_access = Option(opt_key, 'group_access', doc=_("Optional Google Apps Group which is exclusively granted access to this Trac site")) #enable_multiple_stores = BoolOption(opt_key, 'enable_multiple_stores', False, """Optional flag to enable use of this plugin alongside other PasswordStore implementations (will slightly increase network overhead)""")
import trac from pkg_resources import resource_filename from trac.config import BoolOption, Option from trac.core import * from trac.perm import PermissionSystem from trac.web.api import IRequestFilter, IRequestHandler from trac.web.chrome import add_script, ITemplateProvider # Import i18n methods. Fallback modules maintain compatibility to Trac 0.11 # by keeping Babel optional here. try: from trac.util.translation import domain_functions add_domain, _ = \ domain_functions('cc_selector', ('add_domain', '_')) except ImportError: from trac.util.translation import gettext _ = gettext def add_domain(a,b,c=None): pass class TicketWebUiAddon(Component): implements(IRequestFilter, ITemplateProvider, IRequestHandler) show_fullname = BoolOption( 'cc_selector', 'show_fullname', False, doc="Display full names instead of usernames if available.") username_blacklist = Option( 'cc_selector', 'username_blacklist', '',
from pkg_resources import resource_filename from trac.config import BoolOption, Configuration, ExtensionOption from trac.config import Option, OrderedExtensionsOption from trac.core import Component, ExtensionPoint, Interface, TracError from trac.core import implements from trac.perm import IPermissionRequestor, PermissionCache from trac.web.chrome import ITemplateProvider from trac.web.main import IRequestFilter # Import i18n methods. Fallback modules maintain compatibility to Trac 0.11 # by keeping Babel optional here. try: from trac.util.translation import dgettext, domain_functions add_domain, _, N_, gettext, ngettext, tag_ = \ domain_functions('acct_mgr', ('add_domain', '_', 'N_', 'gettext', 'ngettext', 'tag_')) except ImportError: from genshi.builder import tag as tag_ from trac.util.translation import gettext _ = gettext N_ = lambda text: text def add_domain(a, b, c=None): pass def dgettext(domain, string, **kwargs): return safefmt(string, kwargs) def ngettext(singular, plural, num, **kwargs): string = num == 1 and singular or plural kwargs.setdefault('num', num)
# All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # from trac.config import Option, ListOption, IntOption from trac.util import arity from trac.util.translation import domain_functions, dgettext TEXTDOMAIN = 'ticketcalendar' _, tag_, N_, gettext, add_domain = domain_functions( TEXTDOMAIN, ('_', 'tag_', 'N_', 'gettext', 'add_domain')) if arity(Option.__init__) <= 5: def _option_with_tx(Base): # Trac 0.12.x class Option(Base): def __getattribute__(self, name): val = Base.__getattribute__(self, name) if name == '__doc__': val = dgettext(TEXTDOMAIN, val) return val return Option else: def _option_with_tx(Base): # Trac 1.0 or later class Option(Base):
#!/usr/bin/env python # -*- coding: utf-8 -*- import re from genshi.builder import tag from trac.core import * from trac.web.api import ITemplateStreamFilter from genshi.filters.transform import Transformer from genshi.template import MarkupTemplate from trac.util.translation import domain_functions _, tag_, N_, add_domain = domain_functions('TicketLastCommentJump', ('_', 'tag_', 'N_', 'add_domain')) class TicketLastCommentJump(Component): implements(ITemplateStreamFilter) def __init__(self): from pkg_resources import resource_filename locale_dir = resource_filename(__name__, 'locale') add_domain(self.env.path, locale_dir) # ITemplateStreamFilter methods """Filter a Genshi event stream prior to rendering.""" def filter_stream(self, req, method, filename, stream, data): if filename != 'ticket.html': return stream
# -*- coding: utf-8 -*- # Copyright (C) 2010, 2012 Steffen Hoffmann <*****@*****.**> # from trac.core import Component # Import i18n methods. Fallback modules maintain compatibility to Trac 0.11 # by keeping Babel optional here. try: from trac.util.translation import domain_functions add_domain, _, tag_ = \ domain_functions('wikicalendar', ('add_domain', '_', 'tag_')) except ImportError: from genshi.builder import tag as tag_ from trac.util.translation import gettext _ = gettext def add_domain(a,b,c=None): pass __all__ = ['WikiCalendarBuilder'] class WikiCalendarBuilder(Component): """Base class for Components providing content for wiki calendar. """ def declare(self): """Returns an iterable of supported operations. Common values are pre-set here.
# deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # ---------------------------------------------------------------------------- from trac.util.translation import domain_functions # i18n support _, tag_, N_, add_domain = domain_functions('tracticketchangesetsplugin', '_', 'tag_', 'N_', 'add_domain') def init_translation(envpath): #Bind the language catalogs to the locale directory import pkg_resources locale_dir = pkg_resources.resource_filename(__name__, 'locale') add_domain(envpath, locale_dir)
from trac.util.translation import domain_functions try: TicketNotifyEmail = None from trac.notification.api import NotificationSystem from trac.ticket.notification import TicketChangeEvent except ImportError: NotificationSystem = TicketChangeEvent = None from trac.ticket.notification import TicketNotifyEmail import db_default NUMBERS_RE = re.compile(r'\d+', re.U) # i18n support for plugins, available since Trac r7705 # use _, tag_ and N_ as usual, e.g. _("this is a message text") _, tag_, N_, add_domain = domain_functions('tracsubtickets', '_', 'tag_', 'N_', 'add_domain') class SubTicketsSystem(Component): implements(IEnvironmentSetupParticipant, ITicketChangeListener, ITicketManipulator) opt_no_modif_w_p_c = BoolOption( 'subtickets', 'no_modif_when_parent_closed', default='false', doc=_( """If `True`, any modification of a child whose parent is `closed` will be blocked. If `False`, status changes will be blocked as controlled by the setting of `skip_closure_validation`.
from trac.core import * from genshi.filters import Transformer from genshi.builder import tag from genshi import HTML from trac.web.api import IRequestFilter, ITemplateStreamFilter from operator import attrgetter from trac.util.translation import domain_functions import pkg_resources import re # from trac.ticket.model import * _, tag_, N_, add_domain = domain_functions("roadmapplugin", "_", "tag_", "N_", "add_domain") # copied from RoadmapFilterPlugin.py, see https://trac-hacks.org/wiki/RoadmapFilterPlugin def get_session_key(name): return "roadmap.filter.%s" % name # copied from RoadmapFilterPlugin.py, see https://trac-hacks.org/wiki/RoadmapFilterPlugin class FilterRoadmap(Component): """Filters roadmap milestones. Mainly copied from [https://trac-hacks.org/wiki/RoadmapFilterPlugin RoadmapFilterPlugin] and modified a bit. Thanks to daveappendix """ implements(IRequestFilter, ITemplateStreamFilter)
from trac.config import Configuration from trac.core import implements from trac.ticket.query import Query from trac.util.datefmt import format_date, to_utimestamp from trac.util.text import to_unicode from trac.util.translation import domain_functions from trac.web.href import Href from trac.web.chrome import add_stylesheet, ITemplateProvider from trac.wiki.api import parse_args, IWikiMacroProvider, \ WikiSystem from trac.wiki.formatter import format_to_html from trac.wiki.macros import WikiMacroBase _, tag_, N_, add_domain = \ domain_functions('wikiticketcalendar', '_', 'tag_', 'N_', 'add_domain') __all__ = ['WikiTicketCalendarMacro', ] class WikiTicketCalendarMacro(WikiMacroBase): """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 """
from genshi.builder import tag from genshi import HTML, XML from trac.web.chrome import ITemplateProvider, add_script, add_script_data from trac.ticket.api import ITicketManipulator from string import upper from genshi.filters.transform import StreamBuffer from trac.db.schema import Table, Column, Index from trac.db.api import DatabaseManager from trac.config import Option from trac.ticket.model import Ticket import __init__ from trac.perm import PermissionSystem from compiler.ast import Printnl _, tag_, N_, add_domain = domain_functions('ticketbudgeting', '_', 'tag_', 'N_', 'add_domain') """ budgeting table object \ see trac/db_default.py for samples and trac/db/schema.py for implementation of objects """ BUDGETING_TABLE = Table('budgeting', key=('ticket', 'position'))[Column('ticket', type='int'), Column('position', type='int'), Column('username'), Column('type'), Column('estimation', type='int64'), Column('cost', type='int64'), Column('status', type='int'), Column('comment')] BUDGET_REPORT_ALL_ID = 90
from subprocess import call from trac.core import implements, Component from trac.notification.api import NotificationSystem from trac.ticket import model from trac.ticket.api import ITicketActionController, TicketSystem from trac.ticket.default_workflow import ConfigurableTicketWorkflow from trac.ticket.notification import TicketChangeEvent from trac.resource import ResourceNotFound from trac.util.datefmt import utc from trac.util.html import html from trac.util.text import to_unicode from trac.util.translation import domain_functions from trac.web.chrome import Chrome, add_warning _, tag_, add_domain = domain_functions('advancedworkflow', '_', 'tag_', 'add_domain') class TicketWorkflowOpBase(Component): """Abstract base class for 'simple' ticket workflow operations.""" implements(ITicketActionController) abstract = True _op_name = None # Must be specified. def __init__(self): try: locale_dir = resource_filename(__name__, 'locale') except: pass
from trac.web.api import ITemplateStreamFilter from genshi.builder import tag from genshi.filters import Transformer from trac.util.translation import domain_functions from trac.config import Option from pkg_resources import resource_filename #@UnresolvedImport from trac.core import Component, implements _, tag_, N_, add_domain = domain_functions('ticketnav', '_', 'tag_', 'N_', 'add_domain') class SimpleTicketCloneButton(Component): """Add a 'Clone' button to the ticket box. ~~This button is located next to the 'Reply' to description button, and~~ pressing it will send a request for creating a new ticket which will be based on the cloned one. Copied from both `trac-0.12.2/sample-plugins/ticket_clone.py` and from `TRAC/tracopt/ticket/clone.py`. Adjusted position of Clone-Button and translated text. """ implements(ITemplateStreamFilter) # ITemplateStreamFilter methods xpathToPosition = Option('trac', 'clone_xpath', '//h1[@id="trac-ticket-title"]', """xpath to postion of clone button""") def __init__(self): # bind the 'tracnav' catalog to the locale directory
import re from trac.core import Component, implements from trac.perm import IPermissionRequestor from trac.resource import IResourceManager from trac.util.html import html from trac.util.text import pretty_size from trac.util.translation import domain_functions from trac.web.chrome import INavigationContributor, ITemplateProvider, \ web_context from trac.web.main import IRequestHandler from tracdownloads.api import DownloadsApi # Bring in dedicated Trac plugin i18n helper. add_domain, _, tag_ = domain_functions('tracdownloads', ('add_domain', '_', 'tag_')) class DownloadsCore(Component): """ The core module implements plugin's ability to download files, provides permissions and templates. """ implements(INavigationContributor, IPermissionRequestor, IRequestHandler, IResourceManager, ITemplateProvider) # INavigationContributor methods. def get_active_navigation_item(self, req): return 'downloads'
from trac.config import Option from trac.core import * from trac.resource import ResourceNotFound from trac.util import get_reporter_id from trac.util.datefmt import format_date, localtz, parse_date, user_time from trac.util.translation import cleandoc_, domain_functions from trac.wiki.api import WikiSystem from trac.wiki.formatter import format_to_oneliner from trac.wiki.model import WikiPage from trac.wiki.macros import WikiMacroBase from trac.web.api import IRequestHandler from trac.web.chrome import INavigationContributor _, N_, add_domain, gettext = \ domain_functions('mypage', ('_', 'N_', 'add_domain', 'gettext')) class MyPageModule(Component): """Very simple personal journal-in-a-wiki tool. For now, only authenticated users can use it, and they must have all the appropriate wiki permissions (`WIKI_VIEW` and `WIKI_CREATE`). The `PageTemplates/MyPage` wiki page or the more specific `PageTemplates/MyPage/<user>` page will be used to prefill the content of the //page of the day// when creating it using the ''MyPage'' main navigation entry. Such template pages can even contain special tokens that will get substituted with some content. Use the [[MyPageHelp]] macro to
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. r"""Project dashboard for Apache(TM) Bloodhound Translation functions and classes. """ from trac.util.translation import domain_functions #------------------------------------------------------ # Internationalization #------------------------------------------------------ _, ngettext, tag_, tagn_, gettext, N_, add_domain = \ domain_functions('multiproduct', ('_', 'ngettext', 'tag_', 'tagn_', 'gettext', 'N_', 'add_domain'))
return (self.realm, self.category) def get_session_terms(self, session_id): return tuple() _TRUE_VALUES = ('yes', 'true', 'enabled', 'on', 'aye', '1', 1, True) def istrue(value, otherwise=False): return True and (value in _TRUE_VALUES) or otherwise try: from trac.util.translation import domain_functions _, tag_, N_, add_domain = \ domain_functions('announcer', ('_', 'tag_', 'N_', 'add_domain')) except ImportError: # fall back to 0.11 behavior, i18n functions are no-ops then def add_domain(): pass _ = N_ = tag_ = _noop = lambda string: string pass class AnnouncementSystem(Component): """AnnouncementSystem represents the entry-point into the announcement system, and is also the central controller that handles passing notices around.
# # Copyright (C) 2010-2013 Steffen Hoffmann <*****@*****.**> # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # # Author: Steffen Hoffmann from trac.core import Component # Import i18n methods. Fallback modules maintain compatibility to Trac 0.11 # by keeping Babel optional here. try: from trac.util.translation import domain_functions add_domain, _, gettext, tag_ = \ domain_functions('wikicalendar', ('add_domain', '_', 'gettext', 'tag_')) except ImportError: from genshi.builder import tag as tag_ from trac.util.translation import gettext _ = gettext def add_domain(a, b, c=None): pass from wikicalendar.compat import cleandoc cleandoc_ = cleandoc __all__ = ['WikiCalendarBuilder']
from trac.config import BoolOption, ListOption, Option from trac.core import Component, ExtensionPoint, Interface, TracError from trac.core import implements from trac.perm import IPermissionPolicy, IPermissionRequestor from trac.perm import PermissionError, PermissionSystem from trac.resource import IResourceManager, get_resource_url from trac.resource import get_resource_description from trac.util import get_reporter_id from trac.util.text import to_unicode from trac.util.translation import domain_functions from trac.wiki.model import WikiPage # Import translation functions. add_domain, _, N_, gettext, ngettext, tag_, tagn_ = \ domain_functions('tractags', ('add_domain', '_', 'N_', 'gettext', 'ngettext', 'tag_', 'tagn_')) dgettext = None from tractags.model import resource_tags, tag_frequency, tag_resource from tractags.model import tagged_resources # Now call module importing i18n methods from here. from tractags.query import * REALM_RE = re.compile('realm:(\w+)', re.U | re.I) class Counter(dict): """Dict subclass for counting hashable objects. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values.
# distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. r"""Project dashboard for Apache(TM) Bloodhound Translation functions and classes. """ from trac.util.translation import domain_functions #------------------------------------------------------ # Internationalization #------------------------------------------------------ _, ngettext, tag_, tagn_, gettext, N_, add_domain = \ domain_functions('bhdashboard', ('_', 'ngettext', 'tag_', 'tagn_', 'gettext', 'N_', 'add_domain'))
from trac.perm import IPermissionRequestor, PermissionError from trac.resource import ( Resource, ResourceNotFound, get_resource_description, get_resource_name, get_resource_shortname, get_resource_summary, ) from trac.util import get_reporter_id from trac.web.api import IRequestFilter, IRequestHandler from trac.web.chrome import (ITemplateProvider, add_ctxtnav, add_notice, add_script, add_stylesheet) from trac.util.translation import domain_functions _, add_domain = domain_functions('tracbookmark', ('_', 'add_domain')) try: from trac.web.api import arg_list_to_args, parse_arg_list except ImportError: from compat import arg_list_to_args, parse_arg_list try: from trac.resource import resource_exists # Trac > 0.11.7 except ImportError: from compat import resource_exists from trac.versioncontrol.api import NoSuchChangeset, RepositoryManager class BookmarkSystem(Component): """Bookmark Trac resources."""
from trac.web.chrome import Chrome, ITemplateProvider, add_stylesheet, \ add_script, add_script_data from trac.util.text import to_unicode, unicode_unquote from trac.util.translation import domain_functions try: from trac.web.chrome import web_context except ImportError: from trac.mimeview.api import Context def web_context(*args, **kwargs): return Context.from_request(*args, **kwargs) __all__ = ['TracDragDropModule'] add_domain, _ = domain_functions('tracdragdrop', 'add_domain', '_') def _list_message_files(dir): if not os.path.isdir(dir): return set() return set(file[0:-3] for file in os.listdir(dir) if file.endswith('.js')) class TracDragDropModule(Component): implements(ITemplateProvider, IRequestFilter, IRequestHandler, ITemplateStreamFilter, IEnvironmentSetupParticipant) htdocs_dir = resource_filename(__name__, 'htdocs') templates_dir = resource_filename(__name__, 'templates') messages_files = _list_message_files(os.path.join(htdocs_dir, 'messages'))
class OptionTx(Option): def __getattribute__(self, name): if name == '__class__': return Option value = Option.__getattribute__(self, name) if name == '__doc__': value = dgettext(doc_domain, value) return value return OptionTx if len(options) == 1: return _option_with_tx(options[0], domain) else: return map(lambda option: _option_with_tx(option, domain), options) _, N_, gettext, ngettext, add_domain = domain_functions( 'tracexceldownload', '_', 'N_', 'gettext', 'ngettext', 'add_domain') ChoiceOption = domain_options('tracexceldownload', ChoiceOption) class TranslationModule(Component): implements(IEnvironmentSetupParticipant) def __init__(self, *args, **kwargs): Component.__init__(self, *args, **kwargs) add_domain(self.env.path, resource_filename(__name__, 'locale')) # IEnvironmentSetupParticipant methods def environment_created(self): pass
# # Copyright (C) 2012-2013 MATOBA Akihiro <*****@*****.**> # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. from genshi.builder import tag from genshi.filters.transform import Transformer from pkg_resources import ResourceManager from trac.core import Component, implements from trac.util.translation import domain_functions from trac.web.api import IRequestFilter, ITemplateStreamFilter from trac.web.chrome import ITemplateProvider, add_script _, tag_, N_, add_domain = domain_functions('HideFieldChanges', ('_', 'tag_', 'N_', 'add_domain')) # functionality that implemented: # - hide specified fields # - add hide field button # - undone hiding fields class HideFieldChanges(Component): implements(IRequestFilter, ITemplateProvider, ITemplateStreamFilter) # IRequestFilter methods def pre_process_request(self, req, handler): # when show a ticket, add script for 'hide customfield' buttons if req.path_info.startswith('/ticket'): add_script(req, 'hidefieldchanges/js/hidefieldchanges.js')
# this stuff is worth it, you can buy me a beer in return. Matthew Good # # Author: Matthew Good <*****@*****.**> from pkg_resources import resource_filename from trac.config import BoolOption, Configuration, ExtensionOption, \ Option, OrderedExtensionsOption from trac.core import * # Import i18n methods. Fallback modules maintain compatibility to Trac 0.11 # by keeping Babel optional here. try: from trac.util.translation import domain_functions add_domain, _, N_, gettext, ngettext, tag_ = \ domain_functions('acct_mgr', ('add_domain', '_', 'N_', 'gettext', 'ngettext', 'tag_')) dgettext = None except ImportError: from genshi.builder import tag as tag_ from trac.util.translation import gettext _ = gettext N_ = lambda text: text def add_domain(a,b,c=None): pass def dgettext(domain, string, **kwargs): return safefmt(string, kwargs) def ngettext(singular, plural, num, **kwargs): string = num == 1 and singular or plural kwargs.setdefault('num', num) return safefmt(string, kwargs) def safefmt(string, kwargs):
# Trac interfaces. from trac.web.main import IRequestHandler from trac.web.chrome import INavigationContributor, ITemplateProvider from trac.resource import IResourceManager from trac.perm import IPermissionRequestor # CQDE from multiproject.core.configuration import conf # Local imports. from api import DownloadsApi, IDownloadListener # Bring in dedicated Trac plugin i18n helper. from multiproject.core.db import safe_int add_domain, _, tag_ = domain_functions("tracdownloads", ("add_domain", "_", "tag_")) class DownloadsCore(Component): """ The core module implements plugin's ability to download files, provides permissions and templates. """ implements(IRequestHandler, ITemplateProvider, IPermissionRequestor, IResourceManager) # IPermissionRequestor methods. def get_permission_actions(self): view = "DOWNLOADS_VIEW" add = ("DOWNLOADS_ADD", ["DOWNLOADS_VIEW"])
from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet,\ add_script from trac.util.translation import domain_functions from xmail.XMailFilterObject import FilterObject, XMAIL_TABLE, create_table,\ get_col_list from xmail.XMailEMailModule import XMailEventHandler from trac.util import datefmt from trac.util.datefmt import get_date_format_hint, get_datetime_format_hint, to_datetime, format_datetime from trac.ticket.api import TicketSystem import XMailPermissions #from trac.db.api import DatabaseManager # i18n support for plugins, available since Trac r7705 # use _, tag_ and N_ as usual, e.g. _("this is a message text") _, tag_, N_, add_domain = domain_functions('xmail', '_', 'tag_', 'N_', 'add_domain') INTERVAL_LIST = {0: _('immediately'), 86400: _('daily'), 604800: _('weekly')} #=============================================================================== # # TODO[fm]: implement also IEnvironmentSetupParticipant, since there could be checked, # if this plugin needs an upgrade #=============================================================================== class XMailMainView(Component): implements(INavigationContributor, IRequestHandler, ITemplateProvider) # path to xmail view MY_PATH = 'xmail' _CONFIG_SECTION = 'xmail-plugin'
format_date as babel_format_date) except ImportError: Locale = None LOCALE_ALIASES = {} UnknownLocaleError = None babel_get_day_names = None babel_get_month_names = None babel_format_date = None from trac.config import Option, ListOption, IntOption from trac.util import arity from trac.util.translation import domain_functions, dgettext TEXTDOMAIN = 'ticketcalendar' _, tag_, N_, gettext, add_domain = domain_functions( TEXTDOMAIN, ('_', 'tag_', 'N_', 'gettext', 'add_domain')) if arity(Option.__init__) <= 5: def _option_with_tx(Base): # Trac 0.12.x class Option(Base): def __getattribute__(self, name): val = Base.__getattribute__(self, name) if name == '__doc__': val = dgettext(TEXTDOMAIN, val) return val return Option else: def _option_with_tx(Base): # Trac 1.0 or later
# -*- coding: utf-8 -*- import os import re from pkg_resources import resource_filename from trac.admin import IAdminPanelProvider from trac.core import Component, implements from trac.ticket import TicketSystem from trac.util import translation from trac.web.chrome import add_notice, add_warning, add_stylesheet, add_script_data, ITemplateProvider, Chrome _, tag_, N_, add_domain = translation.domain_functions('ticket_template', '_', 'tag_', 'N_', 'add_domain') class TicketTemplateAdmin(Component): implements(IAdminPanelProvider, ITemplateProvider) # IAdminPanelProvider methods def get_admin_panels(self, req): self.log.debug('access to ticket_template admin panel. %s', req) if req.perm.has_permission('TRAC_ADMIN'): yield ('ticket', _("Ticket System"), 'templates', _("Ticket Templates")) def render_admin_panel(self, req, category, page, path_info): data = { 'id': req.args.get('id', ''), 'name': req.args.get('name', ''),
def get_session_terms(self, session_id): return tuple() _TRUE_VALUES = ('yes', 'true', 'enabled', 'on', 'aye', '1', 1, True) def istrue(value, otherwise=False): return True and (value in _TRUE_VALUES) or otherwise try: from trac.util.translation import domain_functions _, tag_, N_, add_domain = \ domain_functions('announcer', ('_', 'tag_', 'N_', 'add_domain')) except ImportError: # fall back to 0.11 behavior, i18n functions are no-ops then def add_domain(): pass _ = N_ = tag_ = _noop = lambda string: string pass class AnnouncementSystem(Component): """AnnouncementSystem represents the entry-point into the announcement system, and is also the central controller that handles passing notices around.
# -*- coding: utf-8 -*- from pkg_resources import resource_filename from trac.core import Component, implements from trac.env import IEnvironmentSetupParticipant from trac.ticket.api import ITicketChangeListener, ITicketManipulator from trac.ticket.model import Ticket from trac.util.translation import domain_functions from model import CUSTOM_FIELDS, TICKETREF, TicketLinks from utils import cnv_sorted_refs _, add_domain = domain_functions("ticketref", ("_", "add_domain")) class TicketRefsPlugin(Component): """ Extend custom field for ticket cross-reference """ implements(IEnvironmentSetupParticipant, ITicketChangeListener, ITicketManipulator) def __init__(self): add_domain(self.env.path, resource_filename(__name__, "locale")) # IEnvironmentSetupParticipant methods def environment_created(self): self.upgrade_environment(self.env.get_db_cnx()) def environment_needs_upgrade(self, db): for field in CUSTOM_FIELDS: if field["name"] not in self.config["ticket-custom"]:
from genshi.builder import tag from pkg_resources import resource_filename from urllib import unquote_plus from trac.core import Component, ExtensionPoint, Interface, implements from trac.perm import IPermissionRequestor from trac.resource import IResourceManager, Resource, ResourceNotFound, \ get_resource_name, get_resource_shortname, \ get_resource_url # Import i18n methods. Fallback modules maintain compatibility to Trac 0.11 # by keeping Babel optional here. try: from trac.util.translation import domain_functions add_domain, _, ngettext, tag_ = \ domain_functions('tracforms', ('add_domain', '_', 'ngettext', 'tag_')) except ImportError: from genshi.builder import tag as tag_ from trac.util.translation import gettext _ = gettext ngettext = _ def add_domain(a, b, c=None): pass from trac.web import IRequestHandler from trac.web.api import HTTPBadRequest, HTTPUnauthorized # Import AccountManagerPlugin methods, if plugin is installed. try:
from trac.util.datefmt import to_timestamp from trac.util.text import to_unicode from trac.util.translation import domain_functions from trac.web.chrome import add_script, add_stylesheet, format_to_oneliner, \ pretty_timedelta # Trac interfaces. from trac.perm import IPermissionRequestor from trac.web.main import IRequestHandler from trac.web.chrome import INavigationContributor, ITemplateProvider # Local imports. from tracscreenshots.api import * # Bring in dedicated Trac plugin i18n helper. add_domain, _, tag_ = domain_functions('tracscreenshots', ('add_domain', '_', 'tag_')) class ScreenshotsCore(Component): """ The core module implements plugin's main page and mainnav button, provides permissions and templates. """ implements(INavigationContributor, IRequestHandler, ITemplateProvider, IPermissionRequestor) # Screenshots renderers. renderers = ExtensionPoint(IScreenshotsRenderer) # Screenshot change listeners. change_listeners = ExtensionPoint(IScreenshotChangeListener)
from trac.core import Component, implements from trac.db.api import DatabaseManager from trac.db.schema import Table, Column from trac.perm import IPermissionRequestor from trac.ticket.api import ITicketManipulator from trac.ticket.model import Ticket from trac.util.translation import domain_functions from trac.web.api import ITemplateStreamFilter, IRequestFilter from trac.web.chrome import ITemplateProvider, add_script import locale import re import time _, tag_, N_, add_domain = domain_functions('ticketbudgeting', '_', 'tag_', 'N_', 'add_domain') """ budgeting table object \ see trac/db_default.py for samples and trac/db/schema.py for implementation of objects """ BUDGETING_TABLE = Table('budgeting', key=('ticket', 'position'))[ Column('ticket', type='int'), Column('position', type='int'), Column('username'), Column('type'), Column('estimation', type='int64'), Column('cost', type='int64'), Column('status', type='int'), Column('comment') ] BUDGET_REPORT_ALL_ID = 90
# -*- coding: utf-8 -*- #---------------------------------------------------------------------------- # Name: i18n_domain.py # Purpose: The TracReportInplaceEditPlugin Trac plugin i18n_domain module # # Author: Richard Liao <*****@*****.**> # #---------------------------------------------------------------------------- try: from trac.util.translation import domain_functions gettext, _, tag_, N_, add_domain = domain_functions('ripe', 'gettext', '_', 'tag_', 'N_', 'add_domain') except ImportError: # ignore domain functions def add_domain(*args, **kwargs): pass try: from trac.util.translation import _, tag_, N_, gettext except ImportError: # skip support i18n, to work in trac 0.11 def gettext(string, **kwargs): return string def _(string, **kwargs): return string def tag_(string, **kwargs): return string def N_(string, **kwargs): return string
# -*- coding: utf-8 -*- #---------------------------------------------------------------------------- # Name: i18n_domain.py # Purpose: The TracTicketChangelogPlugin Trac plugin i18n_domain module # # Author: Richard Liao <*****@*****.**> # #---------------------------------------------------------------------------- try: from trac.util.translation import domain_functions gettext, _, tag_, N_, add_domain = domain_functions('ticketlog', 'gettext', '_', 'tag_', 'N_', 'add_domain') except ImportError: # ignore domain functions def add_domain(*args, **kwargs): pass try: from trac.util.translation import _, tag_, N_, gettext except ImportError: # skip support i18n, to work in trac 0.11 def gettext(string, **kwargs): return string def _(string, **kwargs): return string def tag_(string, **kwargs): return string def N_(string, **kwargs): return string
import pkg_resources from pkg_resources import resource_filename from operator import attrgetter from genshi.filters import Transformer from genshi.path import Path from trac.core import * from trac.admin.api import IAdminPanelProvider from trac.web.chrome import ITemplateProvider, add_stylesheet from trac.web.api import IRequestHandler, ITemplateStreamFilter, IRequestFilter from trac.config import Option from trac.ticket.api import ITicketChangeListener, ITicketManipulator from trac.perm import IPermissionRequestor, PermissionSystem from trac.util.translation import domain_functions _, tag_, N_, add_domain = domain_functions('projectplugin', '_', 'tag_', 'N_', 'add_domain') class ProjectAdmin(Component): """Adds project number to ticket. User which have right `CONTROLLER_ADMIN` (or `TRAC_ADMIN`) can edit list of default project numbers in admin pane. Editing project number manually: - when creating a ticket, manually typed project numbers will be '''skipped''' ! """ implements(IAdminPanelProvider, ITemplateProvider, ITicketChangeListener, IPermissionRequestor, IRequestFilter) #ITemplateStreamFilter , IRequestHandler, ITicketManipulator changed_fields = ['type', 'milestone'] #===========================================================================