File: latest.py

package info (click to toggle)
taskcoach 1.4.1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 32,496 kB
  • ctags: 17,810
  • sloc: python: 72,170; makefile: 254; ansic: 120; xml: 29; sh: 16
file content (104 lines) | stat: -rwxr-xr-x 3,361 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/python

'''
Task Coach - Your friendly task manager
Copyright (C) 2004-2014 Task Coach developers <developers@taskcoach.org>

Task Coach is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Task Coach 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

import os, re, sys

def findLatest(path, valid):
    rx = re.compile(r'(.*)(\d+\.\d+\.\d+\.\d+)(.*)')

    results = dict()

    for name in os.listdir(path):
        if name.lower().startswith('taskcoach') and valid(name):
            mt = rx.search(name)
            if mt:
                ls = results.get((mt.group(1), mt.group(3)), [])
                ls.append(map(int, mt.group(2).split('.')))
                results[(mt.group(1), mt.group(3))] = ls

    packages = []

    for (part1, part3), versions in results.items():
        versions.sort()
        packages.append('%s%s%s' % (part1, '.'.join(map(str, versions[-1])), part3))

    packages.sort()

    return packages


def listPath(path):
    def isSource(name):
        return name.endswith('.zip') or name.endswith('.tar.gz') or name.endswith('.src.rpm')

    print '<h2>Sources</h2>'
    print '<ul>'

    for pkgname in findLatest(path, isSource):
        if path == '.' or path == 'all':
            print '<li><a href="http://www.fraca7.net/TaskCoach-packages/%s">%s</a></li>' % (pkgname, pkgname)
        else:
            print '<li><a href="http://www.fraca7.net/TaskCoach-packages/%s/%s">%s</a></li>' % (path, pkgname, pkgname)

    print '</ul>'

    print '<h2>Binaries</h2>'
    print '<ul>'

    for pkgname in findLatest(path, lambda x: not isSource(x)):
        if path == '.' or path == 'all':
            print '<li><a href="http://www.fraca7.net/TaskCoach-packages/%s">%s</a></li>' % (pkgname, pkgname)
        else:
            print '<li><a href="http://www.fraca7.net/TaskCoach-packages/%s/%s">%s</a></li>' % (path, pkgname, pkgname)

    print '</ul>'

def main(path):
    print 'Content-type: text/html'
    print

    print '<html><head><title>Latest Task Coach builds</title>'
    print '<style type="text/css" media="screen">@import "default.css";</style>'
    print '</head></body>'

    if path == '.' or path == 'all':
        print '<h1>New developments (from trunk)</h1>'
        listPath('.')

    if path != '.':
        for name in os.listdir(path):
            if name.startswith('Release'):
                fname = os.path.join(path, name)
                if os.path.isdir(fname):
                    print '<h1>Bug fixes (from %s)</h1>' % name
                    listPath(fname)

    print '<a href="http://www.taskcoach.org/download.html>Back to Task Coach downloads</a>'

    print '</body></html>'

if __name__ == '__main__':
    if sys.argv[0].endswith('latest_features.py'):
        main('.')
    elif sys.argv[0].endswith('latest_bugfixes.py'):
        main('branches')
    else:
        main('all')