Automatically exported from code.google.com/p/planningalerts
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

30 行
810 B

  1. #!/usr/bin/python
  2. list_of_sites_filename = "PublicAccessSites.csv"
  3. template_filename = "CGITemplate"
  4. python_location = "/usr/bin/python"
  5. import csv
  6. from os import chmod
  7. list_of_sites_file = open(list_of_sites_filename)
  8. csv_reader = csv.DictReader(list_of_sites_file, quoting=csv.QUOTE_ALL, skipinitialspace=True)
  9. template_contents = open(template_filename).read()
  10. template = "#!" + python_location +"\n\n" + template_contents
  11. for site_dict in csv_reader:
  12. filename = "%s.cgi" %site_dict["authority_short_name"]
  13. contents = template %site_dict
  14. this_file = open(filename, "w")
  15. print "Writing %s" %filename
  16. this_file.write(contents)
  17. this_file.close()
  18. chmod(filename, 0755)
  19. # need to look at:
  20. # "Perth and Kinross Council", "Perthshire", "http://193.63.61.22/publicaccess/"