Exemplo n.º 1
0
def get_random_profile(idMgr, seed = 12113):
	"""creates a random profile.
	"""
	r = random.Random()
	r.seed()
	yr = 1900 + r.randint(0, 99)
	month = r.randint(1, 12)
	day = r.randint(1, 28)
	surname = get_random_surname(seed)
	name = r.choice(["Anwyn", "Anna", "Beryl", "Betty", "Joelle","Sara", "Martin", "Andrew", "Patrick", "Jim", "Ben", "Ernest", "Diane", "John", "Lillian", "Sharon" ,"Jane", "Mary", "Susan", "Bob", "Tom", "Dick", "Harry" ])
	street_no = r.randint(1, 120)
	street = get_random_street(seed)
#	city = r.choice(["Sydney", "Hong Kong", "Amsterdam", "Istanbul"])
#	state = r.choice(["Victoria", "Wales", "Yorkshire"])
#	postcode = r.randint(1000, 9000)
#	country = r.choice(["Erewhon", "Ylevol", "Yglu", "Ecarf"])
	city, state, postcode, country = get_random_location()
	phone = r.randint(111111, 999999)
	code = r.randint(10, 90)
	map = SqlTraits.get_trait_map(idMgr, name, '', surname,'',  str(street_no) +' '+ street,  '', city, state, str(postcode), country,
dobDay=day, dobMonth=month, dobYear=yr, sex="?", phoneCountryCode=str(code), phoneNumber=str(phone) )
	profile = trait_map_to_profile(map)
	if debug:
		print "\n\n ** RANDOM PROFILE = \n\t",[ t.value.value() for t in profile], "\n"
	return profile
Exemplo n.º 2
0
def getTraitSelectorSeqFromProfile( profile, specifiedTraits, defaultWeight = 0.5 ):
	"converts a profile into a traitSelectorSequence based on the SpecifiedTraits"
	if specifiedTraits._d == PersonIdService.ALL_TRAITS:
		traitnames = SqlTraits.get_supported_trait_names()
	else:
		traitnames = specifiedTraits._v

	return [ PersonIdService.TraitSelector( trait, get_weight_for_trait(trait, defaultWeight, SqlTraits.default_weight_map) ) for trait in filter( lambda(t): t.name in traitnames and t.value.typecode().kind() == CORBA.tk_string and t.value.value().strip() <> '' , profile ) ]
Exemplo n.º 3
0
def getTraitSelectorSeqFromProfile( profile, specifiedTraits =PersonIdService.SpecifiedTraits(PersonIdService.ALL_TRAITS, []), defaultWeight = 0.2 ):
	"converts a profile into a traitSelectorSequence based on the SpecifiedTraits"
	if specifiedTraits._d == PersonIdService.ALL_TRAITS:
		traitnames = SqlTraits.get_supported_trait_names()
	else:
		traitnames = specifiedTraits._v

	tSelSeq = []
	for trait in filter( lambda(t): t.name in traitnames and t.value.typecode().kind() == CORBA.tk_string and t.value.value().strip() <> '' , profile ) :
		tSelSeq.append(PersonIdService.TraitSelector( trait, defaultWeight))
Exemplo n.º 4
0
def getTraitSelectorSeqFromProfile(
        profile,
        specifiedTraits=PersonIdService.SpecifiedTraits(
            PersonIdService.ALL_TRAITS, []),
        defaultWeight=0.2):
    "converts a profile into a traitSelectorSequence based on the SpecifiedTraits"
    if specifiedTraits._d == PersonIdService.ALL_TRAITS:
        traitnames = SqlTraits.get_supported_trait_names()
    else:
        traitnames = specifiedTraits._v

    tSelSeq = []
    for trait in filter(
            lambda (t): t.name in traitnames and t.value.typecode().kind() ==
            CORBA.tk_string and t.value.value().strip() <> '', profile):
        tSelSeq.append(PersonIdService.TraitSelector(trait, defaultWeight))
Exemplo n.º 5
0
def get_random_profile(idMgr, seed=12113):
    """creates a random profile.
	"""
    r = random.Random()
    r.seed()
    yr = 1900 + r.randint(0, 99)
    month = r.randint(1, 12)
    day = r.randint(1, 28)
    surname = get_random_surname(seed)
    name = r.choice([
        "Anwyn", "Anna", "Beryl", "Betty", "Joelle", "Sara", "Martin",
        "Andrew", "Patrick", "Jim", "Ben", "Ernest", "Diane", "John",
        "Lillian", "Sharon", "Jane", "Mary", "Susan", "Bob", "Tom", "Dick",
        "Harry"
    ])
    street_no = r.randint(1, 120)
    street = get_random_street(seed)
    #	city = r.choice(["Sydney", "Hong Kong", "Amsterdam", "Istanbul"])
    #	state = r.choice(["Victoria", "Wales", "Yorkshire"])
    #	postcode = r.randint(1000, 9000)
    #	country = r.choice(["Erewhon", "Ylevol", "Yglu", "Ecarf"])
    city, state, postcode, country = get_random_location()
    phone = r.randint(111111, 999999)
    code = r.randint(10, 90)
    map = SqlTraits.get_trait_map(idMgr,
                                  name,
                                  '',
                                  surname,
                                  '',
                                  str(street_no) + ' ' + street,
                                  '',
                                  city,
                                  state,
                                  str(postcode),
                                  country,
                                  dobDay=day,
                                  dobMonth=month,
                                  dobYear=yr,
                                  sex="?",
                                  phoneCountryCode=str(code),
                                  phoneNumber=str(phone))
    profile = trait_map_to_profile(map)
    if debug:
        print "\n\n ** RANDOM PROFILE = \n\t", [
            t.value.value() for t in profile
        ], "\n"
    return profile
Exemplo n.º 6
0
def getTraitSelectorSeqFromProfile(profile,
                                   specifiedTraits,
                                   defaultWeight=0.5):
    "converts a profile into a traitSelectorSequence based on the SpecifiedTraits"
    if specifiedTraits._d == PersonIdService.ALL_TRAITS:
        traitnames = SqlTraits.get_supported_trait_names()
    else:
        traitnames = specifiedTraits._v

    return [
        PersonIdService.TraitSelector(
            trait,
            get_weight_for_trait(trait, defaultWeight,
                                 SqlTraits.default_weight_map))
        for trait in filter(
            lambda (t): t.name in traitnames and t.value.typecode().kind() ==
            CORBA.tk_string and t.value.value().strip() <> '', profile)
    ]
Exemplo n.º 7
0
def __getTestProfiles(idMgr):
	# lastName^firstname^middlename^suffix
	n = "Smith^John^Harold^^^"

	# street^otherDesignation^city^state^postcode^country^_^_
	#  ( _ is space)
	a = "123 Black Rd^^BLACKTOWN^NSW^2148^AU^"

	#    yyyymmddhhmmss
	b = "19650227123000"

	s = "M"

	# phoneCountry^phoneNumber

	p = "65^034542222"

	return SqlTraits.get_trait_map_nabsp( idMgr, n, a, b, s, p)
Exemplo n.º 8
0
def _test_find_or_register_id(idMgr):
	global profile, profile2
	profile = trait_map_to_profile( __getTestProfiles(idMgr))
	print "\n\nTesting inserting single profile twice"
	idList = idMgr.find_or_register_ids([profile])
	idList2 = idMgr.find_or_register_ids([profile])
	print idList == idList2, " if 1 then find_or_create_ids() twice returns same id"
	if idList == idList2:
		print "PASS: find_or_create_ids() doesn't duplicate id"

	map = SqlTraits.get_trait_map(idMgr, firstname='Paulle', middle='', lastname='Smithy',suffix='',  street='22 Victor Rd', otherDesignation='', city='Vermont South', state='Vic', postcode='3133', country='Au',
	dobDay=20, dobMonth=11, dobYear=1952, sex='M', phoneCountryCode='65', phoneNumber='0394445555')

	profile2 = trait_map_to_profile(map)

	idList3 = idMgr.find_or_register_ids([profile, profile2])
	global profile_id, profile2_id
	profile_id = idList3[0]
	profile2_id = idList3[1]

	idList4 = idMgr.find_or_register_ids([profile, profile2])
	#print idList3
	#print idList4
	idList3.sort()


	idList4.sort()
	for label, list in [ ("first", idList3), ("second", idList4) ]:
		print "id list returned by ", label, " call of find_or_register_ids(profile, profile2) is", list

	if ( idList3==idList4):
		print "PASS: find_or_create_ids() is repeatable for a sequence of 2 profiles, returning the same id set"
	if idList3 > 2:
		print "INTEGRITY problem: there are ", max(len(idList3), len(idList4) ) , " identities with the same traits"
	else:
		if  idList3 <> idList4:
			print "Different id set returned after repeating call to find_or_create_ids()"
			print "idList3 = ", idList3
			print "idList4 = ", idList4
		print "FAIL** repeated operation of find_or_create_ids() failed"
		ask_continue()