#!/usr/bin/python -OO
import config
import os
import time
import sys
import MySQLdb
import ebuilddb
import changelogs
from cgi import escape
from urllib import quote
def is_new(db,ebuild):
"""Check for newness. An ebuild is considered new if it is the
only ebuild with that category/name in ebuild and it has no prevarch"""
c = db.cursor()
query = """SELECT prevarch FROM ebuild WHERE category="%s" AND name="%s" """ \
% (ebuild['category'], ebuild['name'])
c.execute(query)
results = c.fetchall()
if len(results) == 1 and results[0][0] is None:
return 1
return 0
def changelog_to_html(s):
n = ""
for c in s:
if c == '\n':
n = "%s
" % n
else:
n = "%s%s" % (n,escape(c))
n = changelogs.bugs_to_html(n)
return n
def homepage_to_html(s):
if not s.strip(): return "?"
t = s.replace('|',' ')
if ' ' in t:
pieces = t.split()
return ' '.join([ homepage_to_html(piece) for piece in pieces ])
return ("""
""" % (s, config.ICONS))
def license_to_html(s):
if not s.strip(): return "?"
t = s.replace('|',' ')
if ' ' in t:
pieces = t.split()
return "
".join([ license_to_html(piece) for piece in pieces ])
return """%s""" % (s,s)
def package_to_html(pkginfo,db):
"""This function needs a database (db) connection because it performs a query_to_dict
on the package"""
#colspan = len(config.ARCHLIST) + 1
s = """
| %s | |||||||
Releases:
| |||||||
| '
'%s %s%s ' '%s \n' ' | |||
'
' '
' | '
' Description: %s \n' 'Changes: | ||
%s \n' ' | |||
| \n""") index.write('\n\n |
| ')
results = get_most_recent(db,arch=arch,branch=branch)
ebuilds = [ query_to_dict(i) for i in results ]
for ebuild in ebuilds:
new = is_new(db,ebuild)
pkgfilename = "%s/%s-%s.html" % (
config.EBUILD_FILES,ebuild['name'],ebuild['version'])
ebuild_html = ebuild_to_html(ebuild,new)
if arch == '' and branch == '': # and not os.path.exists(pkgfilename):
pkgfile = open(pkgfilename,'w')
pkgfile.write(ebuild_html)
pkgfile.close()
ebuildfilename = "%s/%s/%s/%s-%s.ebuild" % (ebuilddb.config.PORTAGE_DIR,
ebuild['category'],ebuild['name'],ebuild['name'],
ebuild['version'])
os.system('touch -r %s %s || touch -d "today -1 year" %s' % (ebuildfilename,pkgfilename,pkgfilename))
try:
index.write('%s \n\n\n' % (ebuild_html)) except IOError: pass #index.write(' \n\n\n' # % (config.WEBBASE,ebuild['name'],ebuild['version'])) #index.write(""" \n""") index.write(""" |