def rand_host(min_hn=3, max_hn=10, min_depth=2, max_depth=4, prefix=[], suffix=[]): # choose one suffix from HOST_SUFFIX to make the host seems reasonable if suffix is None or len(suffix) == 0: suffix = HOST_SUFFIX _rand_host = lambda: rand_str(min_hn, max_hn, string.lowercase) parts = utils.rand_list(_rand_host, min_depth, max_depth, prefix, suffix) return '.'.join(parts)
def rand_path(min_fn=1, max_fn=10, min_depth=1, max_depth=5, prefix=[], suffix=[], abs=True): _rand_path = lambda: rand_str(minlen=min_fn, maxlen=max_fn, chrset=PATH_CHRSET) parts = utils.rand_list(_rand_path, minlen=min_depth, maxlen=max_depth, prefix=prefix, suffix=suffix) p = PATH_SEP.join(parts) if abs and p[0:1] != PATH_SEP: p = PATH_SEP + p return p