All pastes #160587 Raw Edit

fever

public text v1 · immutable
·published 2006-09-04 14:14 UTC
rendered paste body
#!/usr/bin/python
from ConfigParser import ConfigParser
from urllib import FancyURLopener
import os
import re
def checkConfig():
	config=ConfigParser()
	if config.read(os.path.expanduser('~/.fever')) == []:
		print "Config file does not exist.\nPlease create it."
		raise SystemExit, 1
	for section in config.sections():
		if 'site' and 'filename' not in config.options(section):
			print '%s section is incorrect.\nYou have to add "site" or "filename" option."' % section
			raise SystemExit, 1
		print 'Checking %s' % section
		file=download(config.get(section,'site'))
		reg=re.compile(config.get(section,'filename'))
		search=reg.findall(file)
		search.sort()
		print 'The newest version of %s is %s' % (section,search[search.__len__()-1])
		
def download(address):
	url=FancyURLopener()
	file=url.open(address).read()
	return file
if __name__ == "__main__":
	checkConfig()