Returns random string value with provided number of characters >>> random.seed(0) >>> randomStr(6) 'FUPGpY'
(length=4, lowercase=False, alphabet=None, seed=None)
| 1266 | return int("".join(choice(string.digits if _ != 0 else string.digits.replace('0', '')) for _ in xrange(0, length))) |
| 1267 | |
| 1268 | def randomStr(length=4, lowercase=False, alphabet=None, seed=None): |
| 1269 | """ |
| 1270 | Returns random string value with provided number of characters |
| 1271 | |
| 1272 | >>> random.seed(0) |
| 1273 | >>> randomStr(6) |
| 1274 | 'FUPGpY' |
| 1275 | """ |
| 1276 | |
| 1277 | if seed is not None: |
| 1278 | _random = getCurrentThreadData().random |
| 1279 | _random.seed(seed) |
| 1280 | choice = _random.choice |
| 1281 | else: |
| 1282 | choice = random.choice |
| 1283 | |
| 1284 | if alphabet: |
| 1285 | retVal = "".join(choice(alphabet) for _ in xrange(0, length)) |
| 1286 | elif lowercase: |
| 1287 | retVal = "".join(choice(string.ascii_lowercase) for _ in xrange(0, length)) |
| 1288 | else: |
| 1289 | retVal = "".join(choice(string.ascii_letters) for _ in xrange(0, length)) |
| 1290 | |
| 1291 | return retVal |
| 1292 | |
| 1293 | def sanitizeStr(value): |
| 1294 | """ |
searching dependent graphs…