view py/inputChecking.py @ 2:8a739c944dbf draft

planemo upload commit e96b43f96afce6a7b7dfd4499933aad7d05c955e-dirty
author thondeboer
date Tue, 15 May 2018 16:22:08 -0400
parents 6e75a84e9338
children
line wrap: on
line source

import os
import sys

def requiredField(s,errString):
	if s == None:
		print '\n'+errString+'\n'
		exit(1)

def checkFileOpen(fn,errString,required=False):
	if required or fn != None:
		if fn == None:
			print '\n'+errString+'\n'
			exit(1)
		else:
			try:
				open(fn,'r')
			except:
				print '\n'+errString+'\n'
				exit(1)

def checkDir(dir,errString):
	if not os.path.isdir(dir):
		print '\n'+errString+'\n'
		exit(1)

def isInRange(val,lb,ub,errString):
	if val < lb or val > ub:
		print '\n'+errString+'\n'
		exit(1)