/[gentoo]/src/packages/gentoo.py
Gentoo

Diff of /src/packages/gentoo.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.16 Revision 1.16.2.2
1#!/usr/bin/python -O 1#!/usr/bin/python -O
2"""These functions mainly take ebuild info (grabbed from the database and 2"""These functions mainly take ebuild info (grabbed from the database and
3 convert it to HTML. See the "main" function at the bottom.""" 3 convert it to HTML. See the "main" function at the bottom."""
4 4
5__revision__ = "$Revision: 1.16 $" 5__revision__ = "$Revision: 1.16.2.2 $"
6# $Source: /var/cvsroot/gentoo/src/packages/gentoo.py,v $ 6# $Source: /var/cvsroot/gentoo/src/packages/gentoo.py,v $
7 7
8import config 8import config
9import os 9import os
10import time 10import time
58 if not license.strip(): return "?" 58 if not license.strip(): return "?"
59 license = license.replace('|',' ') 59 license = license.replace('|',' ')
60 license = license.replace('(', '') 60 license = license.replace('(', '')
61 license = license.replace(')', '') 61 license = license.replace(')', '')
62 pieces = license.split() 62 pieces = license.split()
63 html = ['<a href="http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/' 63 html = ['<a href="http://sources.gentoo.org/viewcvs.py/*checkout*/'
64 'licenses/%s">%s</a>' % (piece, piece) for piece in pieces] 64 'gentoo-x86/licenses/%s">%s</a>' % (piece, piece) for piece in pieces]
65 return '<br>\n'.join(html) 65 return '<br>\n'.join(html)
66 66
67def package_to_html(pkginfo, db, full=False): 67def package_to_html(pkginfo, db, full=False):
68 """This function needs a database (db) connection because it performs a 68 """This function needs a database (db) connection because it performs a
69 query_to_dict on the package""" 69 query_to_dict on the package"""
181 """This actually will (should) take either a package or ebuild dict 181 """This actually will (should) take either a package or ebuild dict
182 as an argument""" 182 as an argument"""
183 183
184 import forums 184 import forums
185 185
186 changelogurl = ('http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/' 186 changelogurl = ('http://sources.gentoo.org/viewcvs.py/*checkout*/'
187 '%s/%s/ChangeLog' % (pkg['category'],pkg['name'])) 187 'gentoo-x86/%s/%s/ChangeLog' % (pkg['category'],pkg['name']))
188 cat_header = '<th class="category">Category</th>' 188 cat_header = '<th class="category">Category</th>'
189 license_header = '<th class="license">License</th>' 189 license_header = '<th class="license">License</th>'
190 category = ('<td class="category">' 190 category = ('<td class="category">'
191 '<a href="%spackages/?category=%s">%s</a></td>' % (config.FEHOME, 191 '<a href="%spackages/?category=%s">%s</a></td>' % (config.FEHOME,
192 pkg['category'], pkg['category'])) 192 pkg['category'], pkg['category']))
220 '</table>']) 220 '</table>'])
221 221
222def create_similar_pkgs_link(pkg): 222def create_similar_pkgs_link(pkg):
223 """Create a link to similar packages""" 223 """Create a link to similar packages"""
224 224
225 def strip_chars(mystring): 225 return '<a href="/similar/?package=%(category)s/%(name)s">Similar</a>' % pkg
226 newstring = ''
227 for char in mystring:
228 if char not in string.punctuation:
229 newstring = newstring + char
230 else:
231 newstring = newstring + ' '
232 return newstring
233
234 description = strip_chars(pkg['description'].lower())
235
236 words = [word for word in description.split()
237 if word and len(word)>2 and word not in config.EXCLUDED_FROM_SIMILAR]
238 words = words[:config.SIMILAR_MAX_WORDS] + [pkg['name']]
239 #query = ['[[:<:]]%s[[:>:]].*' % word for word in words]
240 query = ['[[:<:]]%s.*' % word for word in words]
241 query = '(%s){%s,}' % ('|'.join(query), config.SIMILAR_MIN_MATCHES)
242 url = '%ssearch/?sstring=%s' % (config.FEHOME, escape(query))
243 return '<a href="%s">Similar</a>' % url
244 226
245def create_related_bugs_link(pkg): 227def create_related_bugs_link(pkg):
246 """Create a link to related bugs""" 228 """Create a link to related bugs"""
247 229
248 url = ('http://bugs.gentoo.org/buglist.cgi?query_format=' 230 url = ('http://bugs.gentoo.org/buglist.cgi?query_format='
297 extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra) 279 extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra)
298 280
299 if new: 281 if new:
300 extra = ('%s AND package.new=1 ' % extra) 282 extra = ('%s AND package.new=1 ' % extra)
301 283
302 query = """SELECT ebuild.category,ebuild.name,version,when_found,description, 284 query = """SELECT ebuild.category,ebuild.name,version,ebuild.when_found,description,
303 changelog,arch,homepage,license,is_masked FROM ebuild,package WHERE ebuild.name=\ 285 changelog,arch,homepage,license,is_masked FROM ebuild,package WHERE ebuild.name=\
304 package.name AND ebuild.category=package.category %s ORDER by when_found DESC \ 286 package.name AND ebuild.category=package.category %s ORDER by ebuild.when_found DESC \
305 LIMIT %s""" % (extra,max) 287 LIMIT %s""" % (extra,max)
306 c.execute(query) 288 c.execute(query)
307 results = c.fetchall() 289 results = c.fetchall()
308 return results 290 return results
309 291

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.16.2.2

  ViewVC Help
Powered by ViewVC 1.1.20