From 86fe199988801232f209b7e39a2910065bf5db5f Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 21 Jul 2012 20:20:37 +1200 Subject: pathoc: add a flag to dump request information. --- libpathod/rparse.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'libpathod/rparse.py') diff --git a/libpathod/rparse.py b/libpathod/rparse.py index 9d0f7e79..6eb7d5a4 100644 --- a/libpathod/rparse.py +++ b/libpathod/rparse.py @@ -130,21 +130,28 @@ class LiteralGenerator: def __getslice__(self, a, b): return self.s.__getslice__(a, b) + def __repr__(self): + return '"%s"'%self.s + class RandomGenerator: - def __init__(self, chars, length): - self.chars = chars + def __init__(self, dtype, length): + self.dtype = dtype self.length = length def __len__(self): return self.length def __getitem__(self, x): - return random.choice(self.chars) + return random.choice(DATATYPES[self.dtype]) def __getslice__(self, a, b): b = min(b, self.length) - return "".join(random.choice(self.chars) for x in range(a, b)) + chars = DATATYPES[self.dtype] + return "".join(random.choice(chars) for x in range(a, b)) + + def __repr__(self): + return "%s random from %s"%(self.length, self.dtype) class FileGenerator: @@ -205,7 +212,7 @@ class ValueGenerate: return self.usize * self.UNITS[self.unit] def get_generator(self, settings): - return RandomGenerator(DATATYPES[self.datatype], self.bytes()) + return RandomGenerator(self.datatype, self.bytes()) @classmethod def expr(klass): -- cgit v1.2.3