Example #1
0
def testB(sncfFileName):
	'''
Returns a boolean True if the dependency between routeIDs and Vehicle routeID are established.
Returns False, if it does not. 
	'''
	# Test B getattribs.getroute_routeID(sncfFileName)=getattribs.getveh_routeID(sncfFileName)
	# n_=normalised/without repetitions
	# s_=sorted list
	if filesanity.check_vTypeAttribs(sncfFileName)==True and filesanity.check_routeEntryAttribs(sncfFileName)==True and filesanity.check_vehicleAttribs(sncfFileName)==True:
		listRouteID=getattribs.getroute_routeID(sncfFileName)
		listvehRouteID=getattribs.getveh_routeID(sncfFileName)
		# Set Union operation to eliminate repetitions.
		n_listRouteID=setoper.setUnion(listRouteID,listRouteID)
		n_listvehRouteID=setoper.setUnion(listvehRouteID,listvehRouteID)
		# Sort the list alphabetically
		s_listRouteID=setoper.listSortAB(n_listRouteID)
		s_listvehRouteID=setoper.listSortAB(n_listvehRouteID)
		len_routeID=len(s_listRouteID)
		len_vrouteID=len(s_listvehRouteID)
		if len_routeID>len_vrouteID or len_routeID==len_vrouteID:
			return True
		else:
			return False
	else:
		print'''
[testB says]:Error!Illegal dependency check. Check the file %s for proper association of routeIDs of routeEntry attribute with the routeIDs of vehicle attribute.The routeIDs of vehicle attribute must contain the same routeIDs of vehicle attribute.[testB says]:Error!
		'''%(sncfFileName)
Example #2
0
def getroute_routeID(sncfFileName):
	'''
Function that returns a list of route id(s) from route entry attributes from the file sncfFileName.
	'''
	if filesanity.check_vTypeAttribs(sncfFileName) and filesanity.check_routeEntryAttribs(sncfFileName) and filesanity.check_vehicleAttribs(sncfFileName):
		rList=[]
		for i in range(0,len(getrouteEntryAttribs(sncfFileName))):
			rList.append(getrouteEntryAttribs(sncfFileName)[i][0])
		return rList
	else:
		print'''
[getroute_routeID says]:Error!The sncf file %s may be corrupted. Use a text editor to enclose each set of attributes inside a pair of curly brackets.Or, check if the field contains 3 attribute values.	
		'''%sncfFileName
Example #3
0
def depChecker(sncfFileName):
	'''
Function that checks the sanity of the sncf file by checking the dependency conditions in the route meta-data.
If the depChecker tests are all passed, then the *.rou.xml files are generated, else aborted.	
	'''
	if filesanity.check_vTypeAttribs(sncfFileName)==True and filesanity.check_routeEntryAttribs(sncfFileName)==True and filesanity.check_vehicleAttribs(sncfFileName)==True:
		if testA(sncfFileName)==True and testB(sncfFileName)==True and testC(sncfFileName)==True:
			return True
		else:
			return False
	else:
		print'''
[depChecker says]:Error!Dependency check failed. Please check the %s file again.
		'''%(sncfFileName)
Example #4
0
def testC(sncfFileName):
	'''
Returns a boolean True if the dependency between edgeIDs in M:*.edg.xml and route edges are established.
Returns False, if it does not.
	'''
	###################################################################################
	# [Test C] edg.xml.edgeList=route.edges
	# Get edge IDs from  sortedList(makeXML.getEdgeIDs) and sortedList(setUnion(getattribs.getvectEdgeNames))
	if filesanity.check_vTypeAttribs(sncfFileName)==True and filesanity.check_routeEntryAttribs(sncfFileName)==True and filesanity.check_vehicleAttribs(sncfFileName)==True:
		listM_edgeIDs=setoper.listSortAB(setoper.setUnion(makeXML.getEdgeIDs(sncfFileName),makeXML.getEdgeIDs(sncfFileName)))
		lenMEdgeIDs=len(listM_edgeIDs)
		listroute_edgeIDs=setoper.listSortAB(setoper.setUnion(getattribs.getvectEdgeNames(sncfFileName),getattribs.getvectEdgeNames(sncfFileName)))
		lenrouteEdgeIDs=len(listroute_edgeIDs)
		if lenMEdgeIDs>lenrouteEdgeIDs or lenMEdgeIDs==lenrouteEdgeIDs:
			return True
		else:
			return False
	else:
		print'''
[testC says]:Error!Illegal dependency check. Check the file %s for proper association of edgeIDs of M:Paradigm *.edg.xml file with the edgeIDs of routeEntry attribute.The edgeIDs of routeEntry attribute must contain the same edgeIDs of M:Paradigm *.edg.xml.[testC says]:Error!
		'''%(sncfFileName)
Example #5
0
def testA(sncfFileName):
	'''
Returns a boolean True if the dependency between vType IDs and Vehicle Types are established.
Returns False, if it does not. 
	'''
	# Test A getattribs.getvType_vTypeID(globFile)=getattribs.getveh_vTypeID(globFile)
	# n_=normalised/without repetitions
	# s_=sorted list
	if filesanity.check_vTypeAttribs(sncfFileName)==True and filesanity.check_routeEntryAttribs(sncfFileName)==True and filesanity.check_vehicleAttribs(sncfFileName)==True:
		listvType=getattribs.getvType_vTypeID(sncfFileName)
		listvehvType=getattribs.getveh_vTypeID(sncfFileName)
		# To eliminate repetitions, perform set union on both the lists.
		n_listvType=setoper.setUnion(listvType,listvType)
		n_listvehvType=setoper.setUnion(listvehvType,listvehvType)
		# To facilitate comparison, sort it alphabetically.
		s_listvType=setoper.listSortAB(n_listvType)
		s_listvehvType=setoper.listSortAB(n_listvehvType)
		if len(s_listvehvType)==len(s_listvType):
			# For every vTypeID there must be equal number of vTypeID in vehicleAttributes. Not only the number of 
			# vTypeIDs must be the same, but, also IDs must be the same to pass testA.
			tValue=True
			for itr in range(0,len(s_listvehvType)):
				if s_listvehvType[itr]==s_listvType[itr]:
					oValue=True
					tValue=oValue and tValue
				else:
					oValue=False
					tValue=oValue and tValue
			return tValue
		else:
			print'''
[testA says]:Error!Illegal dependency check. Check the file %s for proper association of vTypeID of vType attribute with the vTypeID of vehicle attribute.The vTypeID of vehicle attribute must contain the same vTypeID of vType attribute. 
			'''%(sncfFileName)
	else:
		print'''
[testA says]:Error!Illegal dependency check. Check the file %s for proper association of vTypeID of vType attribute with the vTypeID of vehicle attribute.The vTypeID of vehicle attribute must contain the same vTypeID of vType attribute.[testA says]:Error!
		'''%(sncfFileName)
Example #6
0
def getvTypeDefaults(sncfFileName):
	'''
Function that returns a list of vType attribute default values, if specified as 'default'. 
	'''
	try:
		if filesanity.check_vTypeAttribs(sncfFileName)==True:
			listGet=getvTypeAttribs(sncfFileName)
			for i in range(0,len(listGet)):
				if listGet[i][1]=='default':
					listGet[i][1]='2.60'
				else:
					pass
				if listGet[i][2]=='default':
					listGet[i][2]='4.50'
				else:
					pass
				if listGet[i][3]=='default':
					listGet[i][3]='0.5'
				else:
					pass
				if listGet[i][4]=='default':
					listGet[i][4]='1.0'
				else:
					pass
				if listGet[i][5]=='default':
					listGet[i][5]='5.0'
				else:
					pass
				if listGet[i][6]=='default':
					listGet[i][6]='2.50'
				else:
					pass
				if listGet[i][7]=='default':
					listGet[i][7]='70.0'
				else:
					pass
				if listGet[i][8]=='default':
					listGet[i][8]='1.0'
				else:
					pass
				if listGet[i][9]=='default':
					listGet[i][9]='0.0'
				else:
					pass
				if listGet[i][10]=='default':
					listGet[i][10]='[1 1 0]'
				else:
					pass
				if listGet[i][11]=='default':
					listGet[i][11]='unknown'
				else:
					pass
				if listGet[i][12]=='default':
					listGet[i][12]='P_7_7'
				else:
					pass
				if listGet[i][13]=='default':
					listGet[i][13]='unknown'
				else:
					pass
				if listGet[i][14]=='default':
					listGet[i][14]='2.0'
				else:
					pass
				if listGet[i][15]=='default':
					listGet[i][15]=''
				else:
					pass
				if listGet[i][16]=='default':
					listGet[i][16]='0.0'
				else:
					pass
				if listGet[i][17]=='default':
					listGet[i][17]='DK2008'
				else:
					pass
			return listGet
		else:
			return None	
	except TypeError:
		print'''
[getvTypeDefaults says]:Error! Unable to determine defaults. Check the sncf file %s and try again.
		'''%sncfFileName