Exemplo n.º 1
0
 def DOCTORReplace(self, pattern, **kw):
     if pattern.isDoctorInitials:
         return _IDReplace(pattern.input)
     elif pattern.transcriberToks is not None:
         # Note I have to tell the category that it should use the pattern, because
         # the category isn't created by the replacer.
         return _IDReplace(pattern.transcriberToks[0]) + " / " + \
                pattern.replacer.transcriptionCache.Replace(PIIIDPattern(pattern.replacer,
                                                                         pattern.transcriberToks[1]))
     else:
         return self.PERSONReplace(pattern, **kw)
Exemplo n.º 2
0
 def EMAILReplace(self, pattern, **kw):
     hostList, pathSuffs = self.repository.loadURLs()
     host = random.choice(hostList)
     # Trim the www.
     if re.match("^www\.", host):
         host = host[4:]
     # So the email will either be a first initial plus
     # last name, a first.last, or a first name + some random digit.
     # I'm not sure what else to do here.
     # Actually, I should be able to mirror the email name
     # using IDReplace (below) if the seed is there.
     if pattern.name is None:
         nameResource = self.repository.loadNames()
         mDist = nameResource.maleFirstNameDist
         fDist = nameResource.femaleFirstNameDist
         nDist = nameResource.neutralFirstNameDist
         lastNameDist = nameResource.lastNameDist
         firstNameDist = random.choice([mDist, fDist, nDist])
         firstName = random.choice(firstNameDist.WeightedChoice(None))
         lastName = lastNameDist.WeightedChoice(None)
         choice = random.randint(0, 2)
         if choice == 0:
             name = firstName.lower()[0] + lastName.lower()
         elif choice == 1:
             name = firstName.lower() + "." + lastName.lower()
         else:
             name = firstName.lower() + str(random.randint(0, 9999))
     else:
         name = _IDReplace(pattern.name)
     return name + "@" + host
Exemplo n.º 3
0
 def IDReplace(self, pattern, **kw):
     if hasattr(pattern, "seed") and pattern.seed.has_key("id"):
         return pattern.seed["id"]
     # If we have nothing to go by, well, we have nothing to go by.
     elif pattern.template is None:
         return pattern.prefix + str(random.randint(10000, 99999))
     else:
         return _IDReplace(pattern.template)
Exemplo n.º 4
0
 def _getRSStreetNum(self, seed, numSeed=None):
     if seed["streetNum"] is None:
         if numSeed is not None:
             seed["streetNum"] = _IDReplace(numSeed)
             # We have to be sure that we don't end up with a
             # leading 0.
             if seed["streetNum"] and (seed["streetNum"][0] == "0"):
                 seed["streetNum"] = str(random.randint(
                     1, 9)) + seed["streetNum"][1:]
         else:
             # Hell, just pick some number.
             seed["streetNum"] = str(random.randint(1, 10000))
     return seed["streetNum"]
Exemplo n.º 5
0
 def Replace(self, pattern, **kw):
     return _IDReplace(pattern.input)
Exemplo n.º 6
0
 def HOSPITALReplace(self, pattern, **kw):
     if pattern.isRoomNumber:
         return _IDReplace(pattern.input)
     else:
         return ClearRenderingStrategy.HOSPITALReplace(self, pattern, **kw)
Exemplo n.º 7
0
 def INITIALSReplace(self, pattern, **kw):
     return _IDReplace("A" * random.randint(2, 3))