Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)

        def validateFile(game, fileName):
	if is_zipfile(fileName) == False: # file not a zip archive
		status('jeop', 'is not a zip archive')
		return False

	z = ZipFile(str(fileName), 'r')

	if z.testzip() != None: # corrupted file
		status('jeop', 'is corrupted')
		return False
	if 'rules.json' not in z.namelist(): # no game description
		status('jeop', 'does not contain a valid game description')
		return False

		game.rules = json.load(z.open('rules.json'))
	except ( AttributeError, ValueError ) as error:
		status('jeop', 'does not contain a valid JSON rule file', error)
		return False

	# print(game.rules)

	if validateRules(game, z) == False: # rule file not logical
		status('jeop', 'does not describe a valid game')
		return False
		if game.type == 'html' and not validateResources(z):
			return False
		game.resources = {}
		for resourceName in z.namelist():
			if resourceName != 'rules.json':
				game.resources[resourceName] = z.read(resourceName)
		#resources = [z.read(x) for x in z.namelist() if x != 'rules.json']

	game.tempPath = tempfile.mkdtemp()

	return True

src/j/e/Jeopy-HEAD/AdminGui.py   Jeopy(Download)
from PyQt4.QtGui import *
from RuleLoader import validateFile
from Gui import Gui
			# validateFile is the actual function from RuleLoader that is called
			if validateFile(self.game, fileName) == False:
				ans = QMessageBox.warning(self, '',
					'The selected game file is invalid.\n'