#3009: Proposal to add the ability to load raw .py files as plugins
-------------------------+--------------------------------------------------
 Reporter:  athomas      |        Owner:  jonas
     Type:  enhancement  |       Status:  new  
 Priority:  low          |    Milestone:  0.10 
Component:  general      |      Version:  devel
 Severity:  minor        |   Resolution:       
 Keywords:  plugin       |  
-------------------------+--------------------------------------------------
Comment (by athomas):

 This patches WebAdmin to work with the .py plugins:

 {{{
 #!diff
 Index: webadmin/plugin.py
 ===================================================================
 --- webadmin/plugin.py  (revision 3116)
 +++ webadmin/plugin.py  (working copy)
 @@ -204,6 +204,7 @@
          path = module.__file__
          if path.endswith('.pyc') or path.endswith('.pyo'):
              path = path[:-1]
 +        file = path
          if os.path.basename(path) == '__init__.py':
              path = os.path.dirname(path)
          path = _find_base_path(path, module.__name__)
 @@ -214,7 +215,15 @@
          else:
              for dist in pkg_resources.find_distributions(path,
 only=True):
                  return dist
 +            plugins_dir = os.path.realpath(os.path.join(self.env.path,
 +                                                        'plugins'))
 +            if path == plugins_dir and file.endswith('.py'):
 +                module_name = os.path.basename(file[:-3])
 +                return
 pkg_resources.Distribution(project_name=module_name,
 +                                                  version='0.1',
 +                                                  location=path)

 +
      def _get_pkginfo(self, dist):
          attrs = ('author', 'author-email', 'license', 'home-page',
 'summary',
                   'description')
 }}}

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/3009>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets

Reply via email to