[Qgis-developer] Python Plugin Repository - plugins app draft

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Nov 22 14:14:21 EST 2010


Hi guys,

 I just had a quick look at the plugin repo spec. Cool.

 It mentions putting plugin metadata in a config file rather than
having it executable in __init__.py - I've been doing that for a while
with my plugins. I have config.ini which looks like:

[general]
name: autosave
version: 0.21
description: save qgis projects as we go...
author: Barry Rowlingson <b.rowlingson at lancaster.ac.uk>
qgisMinimumVersion: 1.0

and then __init__.py looks like this:

import ConfigParser
import os.path
p = ConfigParser.ConfigParser()
here = os.path.join(os.path.dirname(__file__),"config.ini")
p.read(here)

def name():
  return p.get('general','name')

[and so on for the other methods]

The advantage here is that it only uses standard python modules, the
config file is easy for a human to edit (please no XML!), it's
flexible (can have more than just the [general] section) and so on.

 Eventually I hope some kind of config.ini is mandated and I can
delete the methods in __init__.py - but at the moment I can do either!

 A useful thing might be some python code to produce a config.ini from
an existing __init__.py methods... Are there plugins with complex code
in the __init__.py methods? I've just grepped all the __init__.py that
I have in the qgis plugins I've installed and I can't find anything
more complex than returning a string (except in my config.ini-driven
plugins!).

Barry


More information about the Qgis-developer mailing list