Commits

Olemis Lang committed 0c97a46

TracBasicMacros: Changing package name

Comments (0)

Files changed (26)

trac-dev/tracbm/CHANGES

-
-What's new in version 1.0.0
----------------------------
-
-- XXX

trac-dev/tracbm/COPYRIGHT

-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed 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.

trac-dev/tracbm/MANIFEST.in

-
-include CHANGES COPYRIGHT NOTICE README TODO

trac-dev/tracbm/NOTICE

-
-Below you will find an example NOTICE file. Modify its contents as 
-needed.
-
-This package includes a verbatim copy of `gviz_api` module 
-(version 1.0.0). This has been done so as to ease the installation 
-process and provide the means to fall-back to this implementation if 
-`gviz_api` is not installed in the target deployment environment.
-Herinafter you will also find a verbatim copy of the contents of the 
-README file distributed with the aformentioned module.
-
-==============================
-Copyright (C) 2008 Google Inc.
-
-Licensed 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.
-
-Installing the library:
-  python ./setup.py install
-  (You might need root privileges to do this)
-
-Testing the library:
-  python ./setup.py test
-
-==============================
-
-By installing TracGViz plugin, you will have a completely functional 
-instance of `gviz_api` (version 1.0.0) module. The maintainers of 
-this package ARE NOT RESPONSIBLE of providing the latest version 
-of this module in newer versions, since this has been done as 
-a last recourse alternative. If a newer (or any other) version is 
-already installed in your system, it will be used instead. However 
-the authors and maintainers WILL NOT ensure that the current plugin 
-implementation will be compatible with successive versions of 
-`gviz_api` and ARE NOT responsible if future contributions included 
-in the aforementioned module turn out to be incompatible with the 
-current implementation.
-
-Google Visualization API, and iGoogle Gadgets  are technologies 
-offered by Google Inc. in the form of a Software as a Service (SaaS) 
-platform. If you are using TracGViz plugin, make sure you have 
-already read and agreed the related Terms of Use of these services 
-and/or End-User License Agreement (EULA).
-
-Youtube is a registered trademark owned by Google Inc.
-
-All other trademarks and labels are a property of their respective 
-owners. The authors and maintainers of TracGViz plugin 
-ARE NOT RESPONSIBLE if the usage given to this package violates any 
-of the aformentioned statements, or if any end-user violates 
-any other COPYRIGHT statements.

trac-dev/tracbm/README

-
-= Simple but useful Trac macros =
-
-Expand Trac capabilities by embedding simple snippets in wiki pages using simple macros.
-
-== !ToDo ==
-
-Outstanding tasks are :
-
-[[TicketQuery(component=trac-basic-macros&priority=major, format=list, rows=id|summary)]]
-
-== Dependencies ==
-
-This plugin depends on the following components to be installed:
-
-  - None yet.
-
-== Installation ==
-
-This plugin has been tested with 
-[http://trac.edgewall.org/ Trac]  [http://trac.edgewall.org/wiki/0.11 0.11] . 
-
-The first step to make it work is to [wiki:TracPlugins install this plugin] 
-either for a particular environment or otherwise make it available to
-all the environments:
-
-{{{
-$ easy_install /path/to/unpacked/TracBasicMacros-x.y.z.zip
-}}}
-
-,, where ''x.y.z'' is the version of the plugin,,
-
-... or alternately ...
-
-{{{
-$ easy_install TracBasicMacros
-}}}
-
-In case of having internet connection and access to 
-[http://pypi.python.org/pypi PyPI] or a simlar repository, both these 
-methods '''should''' automatically retrieve the [#Dependencies external 
-dependencies] from there.
-
-== Configuration ==
-
-In order to enable [wiki:/En/Devel/TracBasicMacros TracBasicMacros] plugin, 
-the only thing to do is to add the following lines to [wiki:TracIni trac.ini].
-
-{{{
-[components]
-tracbm.* = enabled
-}}}
-
-== Bug / feature requests ==
-
-Existing bugs and feature requests for [wiki:/En/Devel/TracBasicMacros TracBasicMacros] are
-[query:status=new|assigned|reopened&component=trac-basic-macros here].
-If you have any issues, please create a [/newticket?component=trac-basic-macros new ticket].
-
-

trac-dev/tracbm/TODO

-
-Outstanding tasks
------------------
-
-- XXX

trac-dev/tracbm/setup.cfg

-[egg_info]
-tag_build = 
-tag_date = 0
-tag_svn_revision = 0
-
-[sdist]
-formats = gztar,bztar,ztar,tar,zip

trac-dev/tracbm/setup.py

-#!/usr/bin/env python
-
-# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-#
-#   Licensed 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.
-
-
-try:
-    from setuptools import setup
-except ImportError:
-    from distutils.core import setup
-
-from tracbm.__init__ import __doc__ as DESC
-
-versions = [
-    (1, 0, 0),
-    (1, 0, 1),
-    ]
-    
-latest = '.'.join(str(x) for x in versions[-1])
-
-status = {
-            'planning' :  "Development Status :: 1 - Planning",
-            'pre-alpha' : "Development Status :: 2 - Pre-Alpha",
-            'alpha' :     "Development Status :: 3 - Alpha",
-            'beta' :      "Development Status :: 4 - Beta",
-            'stable' :    "Development Status :: 5 - Production/Stable",
-            'mature' :    "Development Status :: 6 - Mature",
-            'inactive' :  "Development Status :: 7 - Inactive"
-         }
-dev_status = status["alpha"]
-
-cats = [
-    dev_status,
-    
-      "Environment :: Plugins", 
-      "Environment :: Web Environment", 
-      "Framework :: Trac", 
-      "Intended Audience :: Developers", 
-      "Intended Audience :: Information Technology", 
-      "Intended Audience :: Other Audience", 
-      "Intended Audience :: System Administrators", 
-      "License :: OSI Approved :: Apache Software License", 
-      "Operating System :: OS Independent", 
-      "Programming Language :: Python", 
-      "Programming Language :: Python :: 2.5", 
-      "Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries", 
-      "Topic :: Internet :: WWW/HTTP :: HTTP Servers", 
-      "Topic :: Internet :: WWW/HTTP :: WSGI", 
-      "Topic :: Software Development :: Bug Tracking", 
-      "Topic :: Software Development :: Libraries :: Application Frameworks", 
-      "Topic :: Software Development :: Libraries :: Python Modules", 
-    ]
-
-# Be compatible with older versions of Python
-from sys import version
-if version < '2.2.3':
-    from distutils.dist import DistributionMetadata
-    DistributionMetadata.classifiers = None
-    DistributionMetadata.download_url = None
-
-# Add the change log to the package description.
-chglog = None
-try:
-    from os.path import dirname, join
-    chglog = open(join(dirname(__file__), "CHANGES"))
-    DESC+= ('\n\n' + chglog.read())
-finally:
-    if chglog:
-        chglog.close()
-
-DIST_NM = 'TracBasicMacros'
-PKG_INFO = {'tracbm' : ('tracbm',                     # Package dir
-                            # Package data
-                            ['../CHANGES', '../TODO', '../COPYRIGHT', 
-                              '../NOTICE', '../README'],
-                          ), 
-            }
-
-ENTRY_POINTS = r"""
-               [trac.plugins]
-               tracbm = tracbm
-               """
-
-setup(
-	name=DIST_NM,
-	version=latest,
-	description=DESC.split('\n', 1)[0],
-	author='Olemis Lang',
-	author_email='olemis+trac@gmail.com',
-	maintainer='Olemis Lang',
-	maintainer_email='olemis+trac@gmail.com',
-	url='https://opensvn.csie.org/traccgi/swlcu/wiki/En/Devel/%s' % (DIST_NM,),
-	download_url='http://pypi.python.org/packages/2.5/%s/%s/%s-%s-py2.5.egg' % \
-	                              (DIST_NM[0], DIST_NM, DIST_NM, latest,),
-	requires = ['trac',  'trac', ],
-  install_requires = [
-      'setuptools>=0.6b1',
-      'Trac>=0.11',
-  ],
-	package_dir = dict([p, i[0]] for p, i in PKG_INFO.iteritems()),
-	packages = PKG_INFO.keys(),
-	package_data = dict([p, i[1]] for p, i in PKG_INFO.iteritems()),
-	include_package_data=True,
-	provides = ['%s (%s)' % (p, latest) for p in PKG_INFO.keys()],
-	obsoletes = ['%s (>=%s.0.0, <%s)' % (p, versions[-1][0], latest) \
-	              for p in PKG_INFO.keys()],
-	entry_points = ENTRY_POINTS,
-	classifiers = cats,
-	long_description= DESC
-	)

trac-dev/tracbm/tracbm/__init__.py

-#!/usr/bin/env python
-# -*- coding: UTF-8 -*-
-
-# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-#
-#   Licensed 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"""Simple but useful Trac macros
-
-Expand Trac capabilities by embed simple snippets in wiki pages using simple macros.
-
-Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-Licensed under the Apache License
-"""
-__author__ = 'Olemis Lang'
-
-# Ignore errors to avoid Internal Server Errors
-from trac.core import TracError
-TracError.__str__ = lambda self: unicode(self).encode('ascii', 'ignore')
-
-try:
-    from tracbm.config import *
-    from tracbm.wiki import *
-    msg = 'Ok'
-except Exception, exc:
-#    raise
-    msg = "Exception %s raised: '%s'" % (exc.__class__.__name__, str(exc))

trac-dev/tracbm/tracbm/config.py

-
-# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-#
-#   Licensed 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"""Insert configuration options in wiki pages
-
-Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-Licensed under the Apache License
-"""
-__author__ = 'Olemis Lang'
-
-from trac.core import TracError, Interface
-from trac.config import *
-from trac.config import _TRUE_VALUES
-from trac.util.compat import all
-from trac.util.text import to_unicode
-from trac.util.translation import _
-from trac.wiki.api import parse_args
-from trac.wiki.macros import WikiMacroBase
-
-from tracbm.util import load_interface
-
-from genshi.builder import tag
-
-class ConfigOptionMacro(WikiMacroBase):
-    r"""Insert configuration options in Wiki pages
-    
-    Usage is as follows.
-    
-    `[[ConfigOption(section, name, type=option_type, sep=char)]]`
-    
-    ''section'' :           the section in trac.ini (mandatory).
-    ''name'' :              option name (mandatory).
-    ''type'' :              if this keyword argument is present then 
-                            the value will be rendered using an
-                            appropriate format according to the option 
-                            type. Supported values are `text`,
-                            `bool`, `int`, `list`, `path`, `extension`,
-                            `extension_list`. Default behavior is `auto` which 
-                            means using the information stored in the global 
-                            options cache.
-    ''sep'' :               list separator (optional, ignored if 
-                            `type`! = `list`).
-    ''keep_empty'':         include empty list items (optional, ignored if 
-                            `type`! = `list`).
-    ''interface'' :         components should implement this interface. Value 
-                            should be of the form `some.module:some.attribute`
-                            (e.g. `trac.web:IRequestHandler`). If missing and 
-                            `type` is set to `extension` or `extension_list`) 
-                            then the interface type will be looked up in the 
-                            options cache. If it can't be found an error is 
-                            raised.
-    ''include_missing'' :   if true (the default) all components implementing 
-                            the interface are returned, with those specified 
-                            by the option ordered first (optional if type is 
-                            `extension_list`).
-    
-    Note: In order to render the target information the approprioate permission 
-            have to be granted by specifying a (comma-separated) list of 
-            permission names in options of the form `section.option`, 
-            `section.*` or , `*` in `config-perm` section. For instance the 
-            following configuration
-            
-            {{{
-            [config-perm]
-            * = WIKI_ADMIN, TICKET_ADMIN
-            project.* = WIKI_VIEW
-            project.name = *
-            }}}
-            
-            allows users having `WIKI_ADMIN` and `TICKET_ADMIN` permissions to view 
-            all configuration options, in addition all those having `WIKI_VIEW` 
-            permission may see all options under `project` section, and finally 
-            option `project.name` may be seen by everybody.
-    """
-    OPTION_MAP = {Option: 'text',
-                    BoolOption: 'bool',
-                    IntOption: 'int',
-                    ListOption: 'list',
-                    PathOption: 'path',
-                    ExtensionOption: 'extension',
-                    OrderedExtensionsOption: 'extension_list',
-                    }
-    
-    def expand_macro(self, formatter, name, content):
-        # TODO: Permissions for sections and individual options
-        args, kw = parse_args(content)
-        try :
-            s, o = args
-        except IndexError :
-            raise TracError(_('Specify both section and option name, and nothing else'))
-        else :
-            s = s.strip() ; o = o.strip()
-            perm_options = tuple(('%s.%s,%s.*,*' % (s, o, s)).split(','))
-            req = formatter.context.req
-            getlist = self.config.getlist
-            if 'TRAC_ADMIN' not in req.perm and \
-                    all(p != '*' and p not in req.perm for _o in perm_options \
-                                            for p in getlist('config-perm', _o, \
-                                                            keep_empty=False)):
-                self.log.warning('Preventing user `%s` from reading option '
-                                    '`%s` in `%s`', req.authname, o, s)
-                raise TracError(_('Insufficient privileges '
-                                    'to perform this operation.') + 
-                                    _(' Check %s, %s, %s in trac.ini') % perm_options)
-            opt_type = kw.get('type', 'auto')
-            self.log.debug('Rendering config option %s in %s using %s', 
-                            o, s, opt_type)
-            return getattr(self, '_render_' + opt_type, 
-                                self._do_render_unknown) (s, o, kw)
-    
-    # Rendering methods
-    def _render_auto(self, s, o, opts):
-        opt = Option.registry.get((s, o))
-        if opt is not None :
-            opt_type = self.OPTION_MAP.get(opt.__class__, 'unknown')
-            if opt_type in ('extension', 'extension_list'):
-                opts.setdefault('interface', opt.xtnpt.interface)
-                cond = getattr(opt, 'include_missing', None) in _TRUE_VALUES
-                opts.setdefault('include_missing', cond and 'true' or '')
-            if opt_type in ('list', 'extension_list'):
-                opts.setdefault('sep', opt.sep)
-                opts.setdefault('keep_empty', opt.keep_empty and 'true' or '')
-            opts['default'] = opt.default
-            return getattr(self, '_render_' + opt_type, 
-                                self._do_render_unknown) (s, o, opts)
-    
-    def _render_text(self, s, o, opts):
-        value = self.config.get(s, o, opts.get('default'))
-        if value :
-            return to_unicode(value)
-        else :
-            return self._do_render_none(s, o, opts)
-    
-    def _render_bool(self, s, o, opts):
-        value = self.config.getbool(s, o, opts.get('default'))
-        return tag.input(type="radio", 
-                        checked=value in _TRUE_VALUES and "true" or None, 
-                        disabled="true")
-    
-    def _render_int(self, s, o, opts):
-        value = self.config.getint(s, o, opts.get('default'))
-        return tag.tt(str(value))
-    
-    def _render_list(self, s, o, opts):
-        value = self.config.getlist(s, o, None, opts.get('sep', ','), 
-                                        opts.get('keep_empty', 'true').lower() in _TRUE_VALUES)
-        if value :
-            return tag.o([tag.li(item) for item in value])
-        else :
-            return tag.strike('Empty list')
-    
-    _render_path = _render_text
-    
-    def _render_extension(self, s, o, opts):
-        try :
-            interface = opts.get('interface') or \
-                        Option.registry.get((s, o)).xtnpt.interface
-        except :
-            raise TracError(_('Keyword argument `interface` is required'))
-        if not issubclass(interface, Interface):
-            interface = load_interface(interface)
-        self.log.debug("Rendering extension implementing %s", interface)
-        try :
-            if s is not None :
-                value = ExtensionOption(s, o, interface, None).__get__(self, self.__class__)
-            else :
-                # A component is supplied instead of option name
-                value = o
-        except AttributeError :
-            value = self.env.config.get(s, o, None)
-            if value is not None :
-                return tag.span(tag.strike(value), 
-                                tag.span(_('missing ?'), style="color: red;"))
-            else :
-                return tag.strike(_('Value not found'))
-        else :
-            value = value.__class__
-            return tag.span(tag.tt(value.__name__), ' at ', tag.i(value.__module__))
-    
-    def _render_extension_list(self, s, o, opts):
-        include_missing = opts.get('include_missing', 'true').lower()  in _TRUE_VALUES
-        try :
-            interface = opts.get('interface') or \
-                        Option.registry.get((s, o)).xtnpt.interface
-        except :
-            raise TracError(_('Keyword argument `interface` is required'))
-        if not issubclass(interface, Interface):
-            interface = load_interface(interface)
-        opts['interface'] = interface
-        self.log.debug("Listing extensions for %s", interface)
-        option = OrderedExtensionsOption(s, o, interface, include_missing=include_missing)
-        components = option.__get__(self, self.__class__)
-        if components :
-            return tag.ol([tag.li(self._render_extension(None, c, opts))] \
-                            for c in components)
-        else :
-            return tag.strike(_('Empty list'))
-    
-    def _do_render_none(self, s, o, opts):
-        return tag.strike(_('Missing ?'))
-    
-    def _do_render_unknown(self, s, o, opts):
-        raise TracError(_('Invalid configuration option type'))
-    
-    _render_unknown = _do_render_unknown

trac-dev/tracbm/tracbm/util.py

-
-# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-#
-#   Licensed 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"""Helper classes and functions
-
-Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-Licensed under the Apache License
-"""
-__author__ = 'Olemis Lang'
-
-from trac.core import TracError, Interface
-
-from pkg_resources import EntryPoint
-
-def load_object(objpath):
-    r"""Dynamically load an object at a given global object path
-    following `pkg_resources` syntax.
-    """
-    ep = EntryPoint.parse("x=" + objpath)
-    return ep.load(require=False)
-
-def load_interface(objpath):
-    r"""Dynamically load a Trac interface. Raise `TracError` if path 
-    leads to an invalid object.
-    """
-    intf = load_object(objpath)
-    if not isinstance(intf, Interface):
-        raise TracError('Trac interface expected at `%s`' % (objpath,), 
-                        'Invalid object')
-    else :
-        return intf

trac-dev/tracbm/tracbm/wiki.py

-
-# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-#
-#   Licensed 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"""Display information about wiki pages
-
-Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
-Licensed under the Apache License
-"""
-__author__ = 'Olemis Lang'
-
-from trac.core import TracError
-from trac.config import ListOption, Option
-from trac.resource import Resource
-from trac.util.datefmt import format_datetime, localtz
-from trac.util.text import to_unicode
-from trac.util.translation import _
-from trac.wiki.api import parse_args
-from trac.wiki.macros import WikiMacroBase
-from trac.wiki.model import WikiPage
-
-from genshi.builder import tag
-
-class WikiHistoryMacro(WikiMacroBase):
-    r"""Embed information about wiki changelog in wiki pages.
-    If invoked without keyword arguments then full 
-    changelog is shown inside a table with columns 
-    `Fecha`, `Version`, `Descripcion, `Autor`. Column labels 
-    may be customized using `chgtable_titles` option in `wiki` 
-    section. CSS class used to render the table may be specified 
-    through `chgtable_class` option in `wiki` section 
-    (see TracIni if you need help). Please read below for further 
-    details.
-    
-    Usage is as follows (all fields are optional).
-    
-    `[[WikiHistory(pagename, version, attr=attr_name, cols=columns)]]`
-    
-    ''pagename'' : the name of target Wiki page. If missing or empty 
-                   and a wiki page is being rendered then it defaults to 
-                   the current wiki page. If the page being rendered 
-                   doesn't belong in the Wiki then 'WikiStart' is used instead.
-    ''version'' :  consider changes prior to (and including) this version
-    ''attr'' :     if this keyword argument is present then only the value 
-                   of the version attribute identified by `attr_name` is 
-                   rendered in textual form (and `cols` argument is ignored)
-                   Supported values are `time`, `version`, 
-                   `comment`, and `author`
-    ''cols'' :     colon separated list of identifiers used to select 
-                   specific columns (order matters). Identifiers are 
-                   the same supported for `attr` parameter.
-    """
-    
-    table_class = Option('wiki', 'chgtable_class', 'listing', 
-                                doc=_("""CSS class to render wiki history table"""))
-    labels = ListOption('wiki', 'chgtable_titles', u'Version, Date, Author, Comment', 
-                                keep_empty=True,
-                                doc=_("""Comma separated list of column labels for """
-                                """version, time, author, and comment (in that order)"""),
-                                )
-    
-    def expand_macro(self, formatter, name, content):
-        args, kw = parse_args(content)
-        attr, cols = [kw.get(k) for k in ('attr', 'cols')]
-        resource = formatter.context.resource
-        is_wiki = isinstance(resource, Resource) and resource.realm == 'wiki'
-        try :
-            pagename = args[0]
-        except IndexError :
-            if not is_wiki :
-                raise TracError(_('You must specify page name in this context'))
-            page = WikiPage(self.env, resource, version=resource.version)
-        else :
-            pagename = pagename or (is_wiki and resource.id or 'WikiStart')
-            version = (args[1:2] or [None])[0]
-            page = WikiPage(self.env, pagename, version=version)
-        ALL_ATTRS = ['version', 'time', 'author', 'comment']
-        ATTR_LABELS = self.labels
-        ATTR_LABELS = (len(ATTR_LABELS) == len(ALL_ATTRS)) and \
-                        ATTR_LABELS or [_('Version'), _('Date'), _('Author'), _('Comment')]
-        
-        def format_verinfo(value, attridx):
-            return {
-                       1 : lambda x : tag.i(format_datetime(x, '%d/%m/%Y %H:%M:%S', tzinfo=localtz)), 
-                       0 : lambda x : tag.b(to_unicode(x, 'utf-8')), 
-                       3 : lambda x : to_unicode(x or _('(No comments)'), 'utf-8'),
-                       2 : lambda x : tag.i(to_unicode(x, 'utf-8')),
-                   }.get(attridx, lambda x : tag.i(_('Atributo desconocido')) ) (value)
-        
-        if attr is None :
-            if cols :
-                cols = [ALL_ATTRS.index(x) for x in cols.split(':') if x in ALL_ATTRS ]
-            else :
-                cols = xrange(len(ALL_ATTRS))
-            def ver_row(verinfo):
-                return tag.tr([verinfo[c] for c in cols])
-            return tag.table(
-                            tag.thead([tag.tr(
-                                        [tag.th(tag.i(h or ''))
-                                            for h in (ATTR_LABELS[c] for c in cols)]
-                                   )]),
-                            tag.tbody([tag.tr(
-                                        [tag.td(format_verinfo(x[c], c))
-                                                for c in cols]
-                                    ) for x in page.get_history()]), 
-                            class_=self.table_class, align='center')
-        else :
-            try :
-                attridx = ALL_ATTRS.index(attr)
-            except ValueError :
-                raise TracError(_('Invalid attribute name %s') % (attr,))
-            else :
-                return format_verinfo(getattr(page, attr, None), attridx)
-
Add a comment to this file

trac-dev/tracbm/void/__init__.py

Empty file removed.

trac-dev/tracbmacros/CHANGES

+
+What's new in version 1.0.0
+---------------------------
+
+- XXX

trac-dev/tracbmacros/COPYRIGHT

+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

trac-dev/tracbmacros/MANIFEST.in

+
+include CHANGES COPYRIGHT NOTICE README TODO

trac-dev/tracbmacros/NOTICE

+
+Below you will find an example NOTICE file. Modify its contents as 
+needed.
+
+This package includes a verbatim copy of `gviz_api` module 
+(version 1.0.0). This has been done so as to ease the installation 
+process and provide the means to fall-back to this implementation if 
+`gviz_api` is not installed in the target deployment environment.
+Herinafter you will also find a verbatim copy of the contents of the 
+README file distributed with the aformentioned module.
+
+==============================
+Copyright (C) 2008 Google Inc.
+
+Licensed 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.
+
+Installing the library:
+  python ./setup.py install
+  (You might need root privileges to do this)
+
+Testing the library:
+  python ./setup.py test
+
+==============================
+
+By installing TracGViz plugin, you will have a completely functional 
+instance of `gviz_api` (version 1.0.0) module. The maintainers of 
+this package ARE NOT RESPONSIBLE of providing the latest version 
+of this module in newer versions, since this has been done as 
+a last recourse alternative. If a newer (or any other) version is 
+already installed in your system, it will be used instead. However 
+the authors and maintainers WILL NOT ensure that the current plugin 
+implementation will be compatible with successive versions of 
+`gviz_api` and ARE NOT responsible if future contributions included 
+in the aforementioned module turn out to be incompatible with the 
+current implementation.
+
+Google Visualization API, and iGoogle Gadgets  are technologies 
+offered by Google Inc. in the form of a Software as a Service (SaaS) 
+platform. If you are using TracGViz plugin, make sure you have 
+already read and agreed the related Terms of Use of these services 
+and/or End-User License Agreement (EULA).
+
+Youtube is a registered trademark owned by Google Inc.
+
+All other trademarks and labels are a property of their respective 
+owners. The authors and maintainers of TracGViz plugin 
+ARE NOT RESPONSIBLE if the usage given to this package violates any 
+of the aformentioned statements, or if any end-user violates 
+any other COPYRIGHT statements.

trac-dev/tracbmacros/README

+
+= Simple but useful Trac macros =
+
+Expand Trac capabilities by embedding simple snippets in wiki pages using simple macros.
+
+== !ToDo ==
+
+Outstanding tasks are :
+
+[[TicketQuery(component=trac-basic-macros&priority=major, format=list, rows=id|summary)]]
+
+== Dependencies ==
+
+This plugin depends on the following components to be installed:
+
+  - None yet.
+
+== Installation ==
+
+This plugin has been tested with 
+[http://trac.edgewall.org/ Trac]  [http://trac.edgewall.org/wiki/0.11 0.11] . 
+
+The first step to make it work is to [wiki:TracPlugins install this plugin] 
+either for a particular environment or otherwise make it available to
+all the environments:
+
+{{{
+$ easy_install /path/to/unpacked/TracBasicMacros-x.y.z.zip
+}}}
+
+,, where ''x.y.z'' is the version of the plugin,,
+
+... or alternately ...
+
+{{{
+$ easy_install TracBasicMacros
+}}}
+
+In case of having internet connection and access to 
+[http://pypi.python.org/pypi PyPI] or a simlar repository, both these 
+methods '''should''' automatically retrieve the [#Dependencies external 
+dependencies] from there.
+
+== Configuration ==
+
+In order to enable [wiki:/En/Devel/TracBasicMacros TracBasicMacros] plugin, 
+the only thing to do is to add the following lines to [wiki:TracIni trac.ini].
+
+{{{
+[components]
+tracbmacros.* = enabled
+}}}
+
+== Bug / feature requests ==
+
+Existing bugs and feature requests for [wiki:/En/Devel/TracBasicMacros TracBasicMacros] are
+[query:status=new|assigned|reopened&component=trac-basic-macros here].
+If you have any issues, please create a [/newticket?component=trac-basic-macros new ticket].
+
+

trac-dev/tracbmacros/TODO

+
+Outstanding tasks
+-----------------
+
+- XXX

trac-dev/tracbmacros/setup.cfg

+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
+[sdist]
+formats = gztar,bztar,ztar,tar,zip

trac-dev/tracbmacros/setup.py

+#!/usr/bin/env python
+
+# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+#
+#   Licensed 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.
+
+
+try:
+    from setuptools import setup
+except ImportError:
+    from distutils.core import setup
+
+from tracbmacros.__init__ import __doc__ as DESC
+
+versions = [
+    (1, 0, 0),
+    (1, 0, 1),
+    (1, 0, 2),
+    ]
+    
+latest = '.'.join(str(x) for x in versions[-1])
+
+status = {
+            'planning' :  "Development Status :: 1 - Planning",
+            'pre-alpha' : "Development Status :: 2 - Pre-Alpha",
+            'alpha' :     "Development Status :: 3 - Alpha",
+            'beta' :      "Development Status :: 4 - Beta",
+            'stable' :    "Development Status :: 5 - Production/Stable",
+            'mature' :    "Development Status :: 6 - Mature",
+            'inactive' :  "Development Status :: 7 - Inactive"
+         }
+dev_status = status["alpha"]
+
+cats = [
+    dev_status,
+    
+      "Environment :: Plugins", 
+      "Environment :: Web Environment", 
+      "Framework :: Trac", 
+      "Intended Audience :: Developers", 
+      "Intended Audience :: Information Technology", 
+      "Intended Audience :: Other Audience", 
+      "Intended Audience :: System Administrators", 
+      "License :: OSI Approved :: Apache Software License", 
+      "Operating System :: OS Independent", 
+      "Programming Language :: Python", 
+      "Programming Language :: Python :: 2.5", 
+      "Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries", 
+      "Topic :: Internet :: WWW/HTTP :: HTTP Servers", 
+      "Topic :: Internet :: WWW/HTTP :: WSGI", 
+      "Topic :: Software Development :: Bug Tracking", 
+      "Topic :: Software Development :: Libraries :: Application Frameworks", 
+      "Topic :: Software Development :: Libraries :: Python Modules", 
+    ]
+
+# Be compatible with older versions of Python
+from sys import version
+if version < '2.2.3':
+    from distutils.dist import DistributionMetadata
+    DistributionMetadata.classifiers = None
+    DistributionMetadata.download_url = None
+
+# Add the change log to the package description.
+chglog = None
+try:
+    from os.path import dirname, join
+    chglog = open(join(dirname(__file__), "CHANGES"))
+    DESC+= ('\n\n' + chglog.read())
+finally:
+    if chglog:
+        chglog.close()
+
+DIST_NM = 'TracBasicMacros'
+PKG_INFO = {'tracbmacros' : ('tracbmacros',                     # Package dir
+                            # Package data
+                            ['../CHANGES', '../TODO', '../COPYRIGHT', 
+                              '../NOTICE', '../README'],
+                          ), 
+            }
+
+ENTRY_POINTS = r"""
+               [trac.plugins]
+               tracbmacros = tracbmacros
+               """
+
+setup(
+	name=DIST_NM,
+	version=latest,
+	description=DESC.split('\n', 1)[0],
+	author='Olemis Lang',
+	author_email='olemis+trac@gmail.com',
+	maintainer='Olemis Lang',
+	maintainer_email='olemis+trac@gmail.com',
+	url='https://opensvn.csie.org/traccgi/swlcu/wiki/En/Devel/%s' % (DIST_NM,),
+	download_url='http://pypi.python.org/packages/2.5/%s/%s/%s-%s-py2.5.egg' % \
+	                              (DIST_NM[0], DIST_NM, DIST_NM, latest,),
+	requires = ['trac',  'trac', ],
+  install_requires = [
+      'setuptools>=0.6b1',
+      'Trac>=0.11',
+  ],
+	package_dir = dict([p, i[0]] for p, i in PKG_INFO.iteritems()),
+	packages = PKG_INFO.keys(),
+	package_data = dict([p, i[1]] for p, i in PKG_INFO.iteritems()),
+	include_package_data=True,
+	provides = ['%s (%s)' % (p, latest) for p in PKG_INFO.keys()],
+	obsoletes = ['%s (>=%s.0.0, <%s)' % (p, versions[-1][0], latest) \
+	              for p in PKG_INFO.keys()],
+	entry_points = ENTRY_POINTS,
+	classifiers = cats,
+	long_description= DESC
+	)

trac-dev/tracbmacros/tracbmacros/__init__.py

+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+#
+#   Licensed 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"""Simple but useful Trac macros
+
+Expand Trac capabilities by embed simple snippets in wiki pages using simple macros.
+
+Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+Licensed under the Apache License
+"""
+__author__ = 'Olemis Lang'
+
+# Ignore errors to avoid Internal Server Errors
+from trac.core import TracError
+TracError.__str__ = lambda self: unicode(self).encode('ascii', 'ignore')
+
+try:
+    from tracbmacros.config import *
+    from tracbmacros.wiki import *
+    msg = 'Ok'
+except Exception, exc:
+#    raise
+    msg = "Exception %s raised: '%s'" % (exc.__class__.__name__, str(exc))

trac-dev/tracbmacros/tracbmacros/config.py

+
+# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+#
+#   Licensed 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"""Insert configuration options in wiki pages
+
+Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+Licensed under the Apache License
+"""
+__author__ = 'Olemis Lang'
+
+from trac.core import TracError, Interface
+from trac.config import *
+from trac.config import _TRUE_VALUES
+from trac.util.compat import all
+from trac.util.text import to_unicode
+from trac.util.translation import _
+from trac.wiki.api import parse_args
+from trac.wiki.macros import WikiMacroBase
+
+from tracbm.util import load_interface
+
+from genshi.builder import tag
+
+class ConfigOptionMacro(WikiMacroBase):
+    r"""Insert configuration options in Wiki pages
+    
+    Usage is as follows.
+    
+    `[[ConfigOption(section, name, type=option_type, sep=char)]]`
+    
+    ''section'' :           the section in trac.ini (mandatory).
+    ''name'' :              option name (mandatory).
+    ''type'' :              if this keyword argument is present then 
+                            the value will be rendered using an
+                            appropriate format according to the option 
+                            type. Supported values are `text`,
+                            `bool`, `int`, `list`, `path`, `extension`,
+                            `extension_list`. Default behavior is `auto` which 
+                            means using the information stored in the global 
+                            options cache.
+    ''sep'' :               list separator (optional, ignored if 
+                            `type`! = `list`).
+    ''keep_empty'':         include empty list items (optional, ignored if 
+                            `type`! = `list`).
+    ''interface'' :         components should implement this interface. Value 
+                            should be of the form `some.module:some.attribute`
+                            (e.g. `trac.web:IRequestHandler`). If missing and 
+                            `type` is set to `extension` or `extension_list`) 
+                            then the interface type will be looked up in the 
+                            options cache. If it can't be found an error is 
+                            raised.
+    ''include_missing'' :   if true (the default) all components implementing 
+                            the interface are returned, with those specified 
+                            by the option ordered first (optional if type is 
+                            `extension_list`).
+    
+    Note: In order to render the target information the approprioate permission 
+            have to be granted by specifying a (comma-separated) list of 
+            permission names in options of the form `section.option`, 
+            `section.*` or , `*` in `config-perm` section. For instance the 
+            following configuration
+            
+            {{{
+            [config-perm]
+            * = WIKI_ADMIN, TICKET_ADMIN
+            project.* = WIKI_VIEW
+            project.name = *
+            }}}
+            
+            allows users having `WIKI_ADMIN` and `TICKET_ADMIN` permissions to view 
+            all configuration options, in addition all those having `WIKI_VIEW` 
+            permission may see all options under `project` section, and finally 
+            option `project.name` may be seen by everybody.
+    """
+    OPTION_MAP = {Option: 'text',
+                    BoolOption: 'bool',
+                    IntOption: 'int',
+                    ListOption: 'list',
+                    PathOption: 'path',
+                    ExtensionOption: 'extension',
+                    OrderedExtensionsOption: 'extension_list',
+                    }
+    
+    def expand_macro(self, formatter, name, content):
+        # TODO: Permissions for sections and individual options
+        args, kw = parse_args(content)
+        try :
+            s, o = args
+        except IndexError :
+            raise TracError(_('Specify both section and option name, and nothing else'))
+        else :
+            s = s.strip() ; o = o.strip()
+            perm_options = tuple(('%s.%s,%s.*,*' % (s, o, s)).split(','))
+            req = formatter.context.req
+            getlist = self.config.getlist
+            if 'TRAC_ADMIN' not in req.perm and \
+                    all(p != '*' and p not in req.perm for _o in perm_options \
+                                            for p in getlist('config-perm', _o, \
+                                                            keep_empty=False)):
+                self.log.warning('Preventing user `%s` from reading option '
+                                    '`%s` in `%s`', req.authname, o, s)
+                raise TracError(_('Insufficient privileges '
+                                    'to perform this operation.') + 
+                                    _(' Check %s, %s, %s in trac.ini') % perm_options)
+            opt_type = kw.get('type', 'auto')
+            self.log.debug('Rendering config option %s in %s using %s', 
+                            o, s, opt_type)
+            return getattr(self, '_render_' + opt_type, 
+                                self._do_render_unknown) (s, o, kw)
+    
+    # Rendering methods
+    def _render_auto(self, s, o, opts):
+        opt = Option.registry.get((s, o))
+        if opt is not None :
+            opt_type = self.OPTION_MAP.get(opt.__class__, 'unknown')
+            if opt_type in ('extension', 'extension_list'):
+                opts.setdefault('interface', opt.xtnpt.interface)
+                cond = getattr(opt, 'include_missing', None) in _TRUE_VALUES
+                opts.setdefault('include_missing', cond and 'true' or '')
+            if opt_type in ('list', 'extension_list'):
+                opts.setdefault('sep', opt.sep)
+                opts.setdefault('keep_empty', opt.keep_empty and 'true' or '')
+            opts['default'] = opt.default
+            return getattr(self, '_render_' + opt_type, 
+                                self._do_render_unknown) (s, o, opts)
+    
+    def _render_text(self, s, o, opts):
+        value = self.config.get(s, o, opts.get('default'))
+        if value :
+            return to_unicode(value)
+        else :
+            return self._do_render_none(s, o, opts)
+    
+    def _render_bool(self, s, o, opts):
+        value = self.config.getbool(s, o, opts.get('default'))
+        return tag.input(type="radio", 
+                        checked=value in _TRUE_VALUES and "true" or None, 
+                        disabled="true")
+    
+    def _render_int(self, s, o, opts):
+        value = self.config.getint(s, o, opts.get('default'))
+        return tag.tt(str(value))
+    
+    def _render_list(self, s, o, opts):
+        value = self.config.getlist(s, o, None, opts.get('sep', ','), 
+                                        opts.get('keep_empty', 'true').lower() in _TRUE_VALUES)
+        if value :
+            return tag.o([tag.li(item) for item in value])
+        else :
+            return tag.strike('Empty list')
+    
+    _render_path = _render_text
+    
+    def _render_extension(self, s, o, opts):
+        try :
+            interface = opts.get('interface') or \
+                        Option.registry.get((s, o)).xtnpt.interface
+        except :
+            raise TracError(_('Keyword argument `interface` is required'))
+        if not issubclass(interface, Interface):
+            interface = load_interface(interface)
+        self.log.debug("Rendering extension implementing %s", interface)
+        try :
+            if s is not None :
+                value = ExtensionOption(s, o, interface, None).__get__(self, self.__class__)
+            else :
+                # A component is supplied instead of option name
+                value = o
+        except AttributeError :
+            value = self.env.config.get(s, o, None)
+            if value is not None :
+                return tag.span(tag.strike(value), 
+                                tag.span(_('missing ?'), style="color: red;"))
+            else :
+                return tag.strike(_('Value not found'))
+        else :
+            value = value.__class__
+            return tag.span(tag.tt(value.__name__), ' at ', tag.i(value.__module__))
+    
+    def _render_extension_list(self, s, o, opts):
+        include_missing = opts.get('include_missing', 'true').lower()  in _TRUE_VALUES
+        try :
+            interface = opts.get('interface') or \
+                        Option.registry.get((s, o)).xtnpt.interface
+        except :
+            raise TracError(_('Keyword argument `interface` is required'))
+        if not issubclass(interface, Interface):
+            interface = load_interface(interface)
+        opts['interface'] = interface
+        self.log.debug("Listing extensions for %s", interface)
+        option = OrderedExtensionsOption(s, o, interface, include_missing=include_missing)
+        components = option.__get__(self, self.__class__)
+        if components :
+            return tag.ol([tag.li(self._render_extension(None, c, opts))] \
+                            for c in components)
+        else :
+            return tag.strike(_('Empty list'))
+    
+    def _do_render_none(self, s, o, opts):
+        return tag.strike(_('Missing ?'))
+    
+    def _do_render_unknown(self, s, o, opts):
+        raise TracError(_('Invalid configuration option type'))
+    
+    _render_unknown = _do_render_unknown

trac-dev/tracbmacros/tracbmacros/util.py

+
+# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+#
+#   Licensed 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"""Helper classes and functions
+
+Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+Licensed under the Apache License
+"""
+__author__ = 'Olemis Lang'
+
+from trac.core import TracError, Interface
+
+from pkg_resources import EntryPoint
+
+def load_object(objpath):
+    r"""Dynamically load an object at a given global object path
+    following `pkg_resources` syntax.
+    """
+    ep = EntryPoint.parse("x=" + objpath)
+    return ep.load(require=False)
+
+def load_interface(objpath):
+    r"""Dynamically load a Trac interface. Raise `TracError` if path 
+    leads to an invalid object.
+    """
+    intf = load_object(objpath)
+    if not isinstance(intf, Interface):
+        raise TracError('Trac interface expected at `%s`' % (objpath,), 
+                        'Invalid object')
+    else :
+        return intf

trac-dev/tracbmacros/tracbmacros/wiki.py

+
+# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+#
+#   Licensed 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"""Display information about wiki pages
+
+Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+Licensed under the Apache License
+"""
+__author__ = 'Olemis Lang'
+
+from trac.core import TracError
+from trac.config import ListOption, Option
+from trac.resource import Resource
+from trac.util.datefmt import format_datetime, localtz
+from trac.util.text import to_unicode
+from trac.util.translation import _
+from trac.wiki.api import parse_args
+from trac.wiki.macros import WikiMacroBase
+from trac.wiki.model import WikiPage
+
+from genshi.builder import tag
+
+class WikiHistoryMacro(WikiMacroBase):
+    r"""Embed information about wiki changelog in wiki pages.
+    If invoked without keyword arguments then full 
+    changelog is shown inside a table with columns 
+    `Fecha`, `Version`, `Descripcion, `Autor`. Column labels 
+    may be customized using `chgtable_titles` option in `wiki` 
+    section. CSS class used to render the table may be specified 
+    through `chgtable_class` option in `wiki` section 
+    (see TracIni if you need help). Please read below for further 
+    details.
+    
+    Usage is as follows (all fields are optional).
+    
+    `[[WikiHistory(pagename, version, attr=attr_name, cols=columns)]]`
+    
+    ''pagename'' : the name of target Wiki page. If missing or empty 
+                   and a wiki page is being rendered then it defaults to 
+                   the current wiki page. If the page being rendered 
+                   doesn't belong in the Wiki then 'WikiStart' is used instead.
+    ''version'' :  consider changes prior to (and including) this version
+    ''attr'' :     if this keyword argument is present then only the value 
+                   of the version attribute identified by `attr_name` is 
+                   rendered in textual form (and `cols` argument is ignored)
+                   Supported values are `time`, `version`, 
+                   `comment`, and `author`
+    ''cols'' :     colon separated list of identifiers used to select 
+                   specific columns (order matters). Identifiers are 
+                   the same supported for `attr` parameter.
+    """
+    
+    table_class = Option('wiki', 'chgtable_class', 'listing', 
+                                doc=_("""CSS class to render wiki history table"""))
+    labels = ListOption('wiki', 'chgtable_titles', u'Version, Date, Author, Comment', 
+                                keep_empty=True,
+                                doc=_("""Comma separated list of column labels for """
+                                """version, time, author, and comment (in that order)"""),
+                                )
+    
+    def expand_macro(self, formatter, name, content):
+        args, kw = parse_args(content)
+        attr, cols = [kw.get(k) for k in ('attr', 'cols')]
+        resource = formatter.context.resource
+        is_wiki = isinstance(resource, Resource) and resource.realm == 'wiki'
+        try :
+            pagename = args[0]
+        except IndexError :
+            if not is_wiki :
+                raise TracError(_('You must specify page name in this context'))
+            page = WikiPage(self.env, resource, version=resource.version)
+        else :
+            pagename = pagename or (is_wiki and resource.id or 'WikiStart')
+            version = (args[1:2] or [None])[0]
+            page = WikiPage(self.env, pagename, version=version)
+        ALL_ATTRS = ['version', 'time', 'author', 'comment']
+        ATTR_LABELS = self.labels
+        ATTR_LABELS = (len(ATTR_LABELS) == len(ALL_ATTRS)) and \
+                        ATTR_LABELS or [_('Version'), _('Date'), _('Author'), _('Comment')]
+        
+        def format_verinfo(value, attridx):
+            return {
+                       1 : lambda x : tag.i(format_datetime(x, '%d/%m/%Y %H:%M:%S', tzinfo=localtz)), 
+                       0 : lambda x : tag.b(to_unicode(x, 'utf-8')), 
+                       3 : lambda x : to_unicode(x or _('(No comments)'), 'utf-8'),
+                       2 : lambda x : tag.i(to_unicode(x, 'utf-8')),
+                   }.get(attridx, lambda x : tag.i(_('Atributo desconocido')) ) (value)
+        
+        if attr is None :
+            if cols :
+                cols = [ALL_ATTRS.index(x) for x in cols.split(':') if x in ALL_ATTRS ]
+            else :
+                cols = xrange(len(ALL_ATTRS))
+            def ver_row(verinfo):
+                return tag.tr([verinfo[c] for c in cols])
+            return tag.table(
+                            tag.thead([tag.tr(
+                                        [tag.th(tag.i(h or ''))
+                                            for h in (ATTR_LABELS[c] for c in cols)]
+                                   )]),
+                            tag.tbody([tag.tr(
+                                        [tag.td(format_verinfo(x[c], c))
+                                                for c in cols]
+                                    ) for x in page.get_history()]), 
+                            class_=self.table_class, align='center')
+        else :
+            try :
+                attridx = ALL_ATTRS.index(attr)
+            except ValueError :
+                raise TracError(_('Invalid attribute name %s') % (attr,))
+            else :
+                return format_verinfo(getattr(page, attr, None), attridx)
+
Add a comment to this file

trac-dev/tracbmacros/void/__init__.py

Empty file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.