Re: Requiring DOAP instead of MAINTAINERS file



So let's bring this at some constructive level.

Attached is a script that converts files of this kind, I suggest the
name "PROJECT-INFO", into DOAP files. Attached there also is some
initial script for converting this file into DOAP.

------ >> snip >> ------ >> snip >> ------ >> snip >> ------
[Project]
name:        Clutter
short-name:  clutter

created:     2006-11-18
summary:     Clutter is an OpenGL based user interface library
categories:  library, graphics, embedded, clutter
license:     LGPL

description:
	Clutter is a GObject based library for creating fast, visually
	rich graphical user interfaces. It is intended for creating
	single window heavily stylised applications such as media box
	ui's, presentations or kiosk style programs in preference to
	regular 'desktop' style applications.

homepage:       http://www.clutter-project.org/
download-page:  http://www.clutter-project.org/sources/
bug-database:   http://bugzilla.o-hand.com/enter_bug.cgi?product=Clutter
mailing-list:   clutter+subscribe o-hand com

[Person: Matthew Allum]
email: mallum o-hand com
roles: maintainer, author

[Person: Emmanuele Bassi]
email: ebassi o-hand com
roles: author

[Repository: svn.o-hand.com]
type:      subversion
location:  https://svn.o-hand.com/repos/clutter
browser:   http://svn.o-hand.com/view/clutter
------ << snip << ------ << snip << ------ << snip << ------

I've omitted the OS and programming-language tags: Manually entered
information usually is bogus here - IMHO. Just an example: Firefox
describes itself as written in C++, whereas most of its code is
JavaScript and XML... But that's really just personal opinion, I would
not fight for leaving this information away.

I've also omitted release information: This should be extracted from our
file servers I guess.

Highly redundant is the author information: It's also is listed in the
AUTHORS file. How to keep that in sync?

Completely broken is DOAP's code repository support: Each kind of code
repository needs its own tag defined. Currently supported by DOAP: SVN,
Bitkeeper, CVS and Arch. Not supported by DOAP: git and bzr, for
instance.

Ciao,
Mathias
-- 
Mathias Hasselmann <mathias hasselmann gmx de>
Openismus GmbH: http://www.openismus.com/
Personal Site: http://taschenorakel.de/
#!/usr/bin/python
#
# Convert PROJECT-INFO files to DOAP
# Copyright - Have to check with Murray first: either Openismus or me
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# Author:
#       Mathias Hasselmann
#
from ConfigParser import SafeConfigParser
import sys, re

CC_LICENSES =   ('cc', 'cc-nd', 'cc-nc-nd', 'cc-nc', 'cc-nc-sa', 'cc-sa')
DOAP_LICENSES = ('asl10', 'asl11', 'asl20', 'artistic', 'bsd', 'mit', 'mpl', 'w3c')

FSF_LICENSES = {
    'gpl3':   'http://www.fsf.org/licensing/licenses/gpl.html',
    'gpl2':   'http://www.gnu.org/licenses/old-licenses/gpl-2.0.html',
    'lgpl3':  'http://www.fsf.org/licensing/licenses/lgpl.html',
    'lgpl21': 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html',
    'agpl3':  'http://www.fsf.org/licensing/licenses/agpl-3.0.html',
}

REPOSITORY_TYPES = {
    'subversion': 'SVNRepository',
    'bitkeeper':  'BKRepository',
    'cvs':        'CVSRepository',
    'arch':       'ArchRepository',
}

def normalize_uri(items, key):
    value = items[key]

    print value.split(':', 1)

    if not value.split(':', 1) in ('http', 'https', 'ftp', 'mailto'):
        items[key] = 'mailto:%s' % value

def tokenize(value):
    return re.split(r'\s*[;,]?\s*', value)

def convert_persons(parser, role):
    for sect in parser.sections():
        if not sect.startswith('Person:'):
            continue

        if not role in tokenize(parser.get(sect, 'roles')):
            continue

        name = sect[7:].strip()
        email = parser.get(sect, 'email')

        print """
 <%(role)s>
  <foaf:Person>
   <foaf:name>%(name)s</foaf:name>
   <foaf:mbox rdf:resource="mailto:%(email)s" />
  </foaf:Person>
 </%(role)s>""" % vars()

def convert_repositories(parser):
    first_repository = True

    for sect in parser.sections():
        if not sect.startswith('Repository:'):
            continue

        type = parser.get(sect, 'type')
        tag = REPOSITORY_TYPES.get(type.lower())
        location = parser.get(sect, 'location')
        browser = parser.get(sect, 'browser')

        if not tag or not (location or browser):
            continue

        print

        if first_repository:
            print ' <repository>'
            first_repository = False

        print '  <%s>' % tag

        if location:
            print '   <location rdf:resource="%s" />' % location
        if browser:
            print '   <browse rdf:resource="%s" />' % browser

        print '  </%s>' % tag

    if not first_repository:
        print ' </repository>'

def convert(source, target = None):
    parser = SafeConfigParser()
    parser.read(source)

    project = dict(parser.items('Project'))
    license = project['license']

    if license in CC_LICENSES:
        license = 'http://creativecommons.org/licenses/by%s/3.0/' % license[2:]
    elif license in DOAP_LICENSES:
        license = 'http://usefulinc.com/doap/licenses/%s' % license
    elif license in FSF_LICENSES.keys():
        license = FSF_LICENSES[license]

    project['license'] = license

    normalize_uri(project, 'bug-database')
    normalize_uri(project, 'mailing-list')

    if not project.has_key('short-name'):
        project['short-name'] = project['name'].lower()
    if not project.has_key('summary'):
        description = project['description'].strip()
        project['summary'] = description.split('\n')[0]

    print """\
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
         xmlns:foaf="http://xmlns.com/foaf/0.1/";
         xmlns="http://usefulinc.com/ns/doap#";>

 <name>%(name)s</name>
 <shortname>%(short-name)s</shortname>
 <created>%(created)s</created>

 <license rdf:resource="%(license)s" />
 <shortdesc xml:lang="en">%(summary)s</shortdesc>
 <description xml:lang="en">%(description)s</description>

 <homepage rdf:resource="%(homepage)s" />
 <download-page rdf:resource="%(download-page)s" />

 <bug-database rdf:resource="%(bug-database)s"/>
 <mailing-list rdf:resource="%(mailing-list)s" />
""" % project

    for name in tokenize(project['categories']):
        print ' <category rdf:resource="http://labs.o-hand.com/doap/category/%s"; />' % name

    convert_persons(parser, 'maintainer')
    convert_persons(parser, 'author')
    convert_repositories(parser)

    print '</Project>'

if '__main__' == __name__:
    files = len(sys.argv) > 1 and sys.argv[1:] or ['PROJECT-INFO']
    apply(convert, files)

['http', '//bugzilla.o-hand.com/enter_bug.cgi?product=Clutter']
['clutter+subscribe o-hand com']
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
         xmlns:foaf="http://xmlns.com/foaf/0.1/";
         xmlns="http://usefulinc.com/ns/doap#";>

 <name>Clutter</name>
 <shortname>clutter</shortname>
 <created>2006-11-18</created>

 <license rdf:resource="LGPL" />
 <shortdesc xml:lang="en">Clutter is an OpenGL based user interface library</shortdesc>
 <description xml:lang="en">
Clutter is a GObject based library for creating fast, visually
rich graphical user interfaces. It is intended for creating
single window heavily stylised applications such as media box
ui's, presentations or kiosk style programs in preference to
regular 'desktop' style applications.</description>

 <homepage rdf:resource="http://www.clutter-project.org/"; />
 <download-page rdf:resource="http://www.clutter-project.org/sources/"; />

 <bug-database rdf:resource="mailto:http://bugzilla.o-hand.com/enter_bug.cgi?product=Clutter"/>
 <mailing-list rdf:resource="mailto:clutter+subscribe o-hand com" />

 <category rdf:resource="http://labs.o-hand.com/doap/category/library"; />
 <category rdf:resource="http://labs.o-hand.com/doap/category/graphics"; />
 <category rdf:resource="http://labs.o-hand.com/doap/category/embedded"; />
 <category rdf:resource="http://labs.o-hand.com/doap/category/clutter"; />

 <maintainer>
  <foaf:Person>
   <foaf:name>Matthew Allum</foaf:name>
   <foaf:mbox rdf:resource="mailto:mallum o-hand com" />
  </foaf:Person>
 </maintainer>

 <author>
  <foaf:Person>
   <foaf:name>Emmanuele Bassi</foaf:name>
   <foaf:mbox rdf:resource="mailto:ebassi o-hand com" />
  </foaf:Person>
 </author>

 <author>
  <foaf:Person>
   <foaf:name>Matthew Allum</foaf:name>
   <foaf:mbox rdf:resource="mailto:mallum o-hand com" />
  </foaf:Person>
 </author>

 <repository>
  <SVNRepository>
   <location rdf:resource="https://svn.o-hand.com/repos/clutter"; />
   <browse rdf:resource="http://svn.o-hand.com/view/clutter"; />
  </SVNRepository>
 </repository>
</Project>
[Project]
name:        Clutter
short-name:  clutter

created:     2006-11-18
summary:     Clutter is an OpenGL based user interface library
categories:  library, graphics, embedded, clutter
license:     LGPL

description:
	Clutter is a GObject based library for creating fast, visually
	rich graphical user interfaces. It is intended for creating
	single window heavily stylised applications such as media box
	ui's, presentations or kiosk style programs in preference to
	regular 'desktop' style applications.

homepage:       http://www.clutter-project.org/
download-page:  http://www.clutter-project.org/sources/
bug-database:   http://bugzilla.o-hand.com/enter_bug.cgi?product=Clutter
mailing-list:   clutter+subscribe o-hand com

[Person: Matthew Allum]
email: mallum o-hand com
roles: maintainer, author

[Person: Emmanuele Bassi]
email: ebassi o-hand com
roles: author

[Repository: svn.o-hand.com]
type:      subversion
location:  https://svn.o-hand.com/repos/clutter
browser:   http://svn.o-hand.com/view/clutter

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]