From c71c880519c82df2fc49e6e607db7f49626ac977 Mon Sep 17 00:00:00 2001 From: Colin Morey Date: Wed, 1 Oct 2003 22:59:08 +0000 Subject: new version now handles < and > in homepage urls ?? fixes bug 30056 also fixes 6415 (order of package list has changes from horizontal to vertical ordering) --- admin/www.gentoo.org/scripts/pkgs.py | 91 ++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/admin/www.gentoo.org/scripts/pkgs.py b/admin/www.gentoo.org/scripts/pkgs.py index e7f1ee119d..80f2b8b4cb 100644 --- a/admin/www.gentoo.org/scripts/pkgs.py +++ b/admin/www.gentoo.org/scripts/pkgs.py @@ -1,13 +1,15 @@ #! /usr/bin/env python # genpkgxml-v2.py # Based upon the genpkgxml.py by Grant Goodyear, this script extends the fuctionality and general look and feel. +# original version by Colin Morey, modified by Daniel Robbins for the website reorganisation +# main index page output rewritten by Colin Morey. import portage, string, os, os.path, time, sys, re from stat import * if not os.environ["WEBROOT"]: - print "$WEBROOT not set; exiting" - sys.exit(1) + print "$WEBROOT not set; exiting" + sys.exit(1) ##################################### # prog start, and main variable, and compiled regex's @@ -167,6 +169,8 @@ def do_pkgentry(db,pkgname,category): if db[category][pkgname]["homepage"]: nice_homepage=string.replace(db[category][pkgname]["homepage"],'&','&') nice_homepage=string.replace(nice_homepage,' ',' , ') + nice_homepage=string.replace(nice_homepage,'<','<') + nice_homepage=string.replace(nice_homepage,'>','>') pkgentry += ""+nice_homepage+"" else: pkgentry += "(No homepage specified)" @@ -221,25 +225,84 @@ content="""

del db['totalnumberofpackages'] out.write(header) out.write(content) -side='1' +####################### +# produce the main index page +####################### + +# first we find out the size of each array, (left,middle,right) +totalcategories = len(db.keys()) +quotient = int(totalcategories/3) +remainder = totalcategories - (quotient *3) +if (remainder == 2): + left_length= quotient + 1 + middle_length = quotient + 1 + right_length = quotient +elif (remainder == 1): + left_length= quotient + 1 + middle_length = quotient + right_length = quotient +elif (remainder ==0): + left_length= quotient + middle_length = quotient + right_length = quotient +else: + + sys.stderr.write("managed to get a remainder greater than the devisor!!\n") + sys.stderr.write("remainder->") + sys.stderr.write(str(remainder)) + sys.stderr.write("\n") + sys.exit(1) + +# now we've set up the length of the columns, lets fill them + +currentcolumn = 'left' +position =1 +left_category = [] +middle_category = [] +right_category = [] for category in fsort(db.keys()): - if (side=='1'): - out.write('\n') - out.write(''+category+'\n') - side='2' - elif (side=='2'): - out.write(''+category+'\n') - side='3' - elif (side=='3'): - out.write(''+category+'\n') + if (currentcolumn =='left'): + left_category.append(category) + if (position == left_length ): + currentcolumn ='middle' + position=1 + else : + position = position +1 + elif (currentcolumn =='middle'): + middle_category.append(category) + if (position == middle_length): + currentcolumn ='right' + position =1 + else : + position = position + 1 + else : + right_category.append(category) + +#we now have our filled columns and we want to go through them and print out the table + + +# yeah, yeah there's probably easier ways of doing it :) +side='1' +for row in range(left_length) : + out.write('\n') + out.write('' + left_category[row] + '\n') + if (row < middle_length): + out.write('' + middle_category[row] + '\n') + if (row < right_length): + out.write(''+ right_category[row] +'\n') out.write('\n') - side='1' -if (side=='2') or (side=='3'): + +if (remainder > 0): out.write('\n') + out.write('

') footer=do_footer() out.write(footer) out.close() + + + + #################### # category index pages #################### -- cgit v1.2.3-65-gdbad