/[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.2.5 Revision 1.16.2.6
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.2.5 $" 5__revision__ = "$Revision: 1.16.2.6 $"
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
324 """Compare two ebuilds""" 324 """Compare two ebuilds"""
325 fields_a = pkgsplit('%s-%s' % (a['name'], a['version'])) 325 fields_a = pkgsplit('%s-%s' % (a['name'], a['version']))
326 fields_b = pkgsplit('%s-%s' % (b['name'], b['version'])) 326 fields_b = pkgsplit('%s-%s' % (b['name'], b['version']))
327 return pkgcmp(fields_a, fields_b) 327 return pkgcmp(fields_a, fields_b)
328 328
329def ebuilds_to_rss(fp, ebuilds, simple=False, subtitle=""): 329def ebuilds_to_rss(fp, ebuilds, simple=False, subtitle='', arch='', branch=''):
330 """write out ebuild info to RSS file (fp)""" 330 """write out ebuild info to RSS file (fp)"""
331 331
332 # web link for RSS feed 332 # web link for RSS feed
333 link = config.FEHOME
334 subtitle = subtitle
335 if arch != '':
336 link = '%sarchs/%s/' % (link, arch)
337 subtitle = '%s' % arch
338 if branch != '':
339 link = '%s%s/' % (link, branch)
340 subtitle = '%s %s' % (subtitle, branch)
341
342 title = 'packages.gentoo.org'
333 if subtitle: 343 if subtitle:
334 link = '%s/%s' % (config.FEHOME, subtitle.replace(' ','/',1)) 344 title = '%s [ %s ]' % (title, subtitle)
335 else:
336 link = config.FEHOME
337 345
338 pubDate = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) 346 pubDate = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
339 fp.write("""<?xml version="1.0" encoding="UTF-8"?> 347 fp.write("""<rss version="2.0">
340 <rss version="2.0">
341 <channel> 348 <channel>
342 <title>packages.gentoo.org [ %s ]</title> 349 <title>%s</title>
343 <link>%s</link> 350 <link>%s</link>
344 <description>Latest ebuilds from the Gentoo Linux portage tree</description> 351 <description>Latest ebuilds from the Gentoo Linux portage tree</description>
345 <webMaster>www@gentoo.org</webMaster> 352 <webMaster>www@gentoo.org</webMaster>
346 353
347 <image> 354 <image>
349 <url>%s</url> 356 <url>%s</url>
350 <link>%s</link> 357 <link>%s</link>
351 </image> 358 </image>
352 359
353 <managingEditor>marduk@gentoo.org</managingEditor> 360 <managingEditor>marduk@gentoo.org</managingEditor>
354 <pubDate>%s</pubDate>""" % (subtitle, link, config.RSS_IMAGE, 361 <pubDate>%s</pubDate>""" % (title, link, config.RSS_IMAGE,
355 config.FEHOME, pubDate)) 362 config.FEHOME, pubDate))
356 363
357 for ebuild in ebuilds: 364 for ebuild in ebuilds:
358 if simple: 365 if simple:
359 description = escape(ebuild['description']) 366 description = escape(ebuild['description'])
438 continue 445 continue
439 index.write("""</table>\n""") 446 index.write("""</table>\n""")
440 index.close() 447 index.close()
441 448
442 subtitle = ' %s %s' % (arch, branch) 449 subtitle = ' %s %s' % (arch, branch)
443 rss = open(os.path.join(config.LOCALHOME, "archs", arch, branch, 450 rss = open(
451 os.path.join(
452 config.LOCALHOME,
453 "archs",
454 arch,
455 branch,
444 config.RSS), 'w') 456 config.RSS
445 ebuilds_to_rss(rss, ebuilds, simple=False, subtitle=subtitle) 457 ),
458 'w'
459 )
460 ebuilds_to_rss(
461 rss,
462 ebuilds,
463 simple=False,
464 arch=arch,
465 branch=branch
466 )
446 rss.close() 467 rss.close()
447 468
448 rss2 = open(os.path.join(config.LOCALHOME, "archs", arch, branch, 469 rss2 = open(
470 os.path.join(
471 config.LOCALHOME,
472 "archs",
473 arch,
474 branch,
449 config.RSS2), 'w') 475 config.RSS2
450 ebuilds_to_rss(rss2, ebuilds, simple=True, subtitle=subtitle) 476 ),
477 'w'
478 )
479 ebuilds_to_rss(
480 rss2,
481 ebuilds,
482 simple=True,
483 arch=arch,
484 branch=branch
485 )
451 rss.close() 486 rss.close()
452 487
453if __name__ == '__main__': 488if __name__ == '__main__':
454 sys.exit(main()) 489 sys.exit(main())

Legend:
Removed from v.1.16.2.5  
changed lines
  Added in v.1.16.2.6

  ViewVC Help
Powered by ViewVC 1.1.20