#!/usr/bin/env python # -*- mode: python; coding: utf-8 -*- # Copyright © 2007 Translation Project. # Benno Schulenberg , 2007. """\ Regenerate the indicated domain and team pages. Usage: generate-static-pages [ -idt | DOMAINNAME... | TEAMCODE... ] -i regenerate the two index pages -d regenerate all domain pages -t regenerate all team pages """ import sys, getopt sys.path.insert(0, sys.path[0]+'/../lib') import localweb, registry def main(*arguments): domains = index = teams = False options, arguments = getopt.getopt(arguments, 'dit') for option, value in options: if option == '-d': domains = True if option == '-i': index = True elif option == '-t': teams = True if not domains and not teams and not index and not arguments: sys.stdout.write(__doc__) sys.exit(2) if arguments and (domains or teams): print "*** Options -d and -t cannot be combined with arguments" sys.exit(2) domain_names = [] for domain in registry.domain_list(): domain_names.append(domain.name) team_names = [] for team in registry.team_list(): team_names.append(team.name) if index: localweb.generate_domain_page("index") localweb.generate_team_page("index") if domains: for domain in domain_names: localweb.generate_domain_page("%s" % domain) if teams: for team in team_names: localweb.generate_team_page("%s" % team) for argument in arguments: if argument in domain_names: localweb.generate_domain_page("%s" % argument) elif argument in team_names: localweb.generate_team_page("%s" % argument) else: print " *** No such team or domain: '%s'" % argument if __name__ == '__main__': apply(main, tuple(sys.argv[1:]))