implement more helper random changes with replace random.xxx
This commit is contained in:
parent
1ad321b08a
commit
6076e1832a
|
@ -1,6 +1,8 @@
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
from pyelliptic.openssl import OpenSSL
|
from pyelliptic.openssl import OpenSSL
|
||||||
|
NoneType = type(None)
|
||||||
|
|
||||||
|
|
||||||
def randomBytes(n):
|
def randomBytes(n):
|
||||||
"""Method randomBytes."""
|
"""Method randomBytes."""
|
||||||
|
@ -30,7 +32,7 @@ def randomsample(population, k):
|
||||||
return random.sample(population, k)
|
return random.sample(population, k)
|
||||||
|
|
||||||
|
|
||||||
def randomrandrange(x, y):
|
def randomrandrange(x, y=None):
|
||||||
"""Method randomRandrange.
|
"""Method randomRandrange.
|
||||||
|
|
||||||
return a randomly selected element from
|
return a randomly selected element from
|
||||||
|
@ -38,4 +40,7 @@ def randomrandrange(x, y):
|
||||||
choice(range(start, stop)),
|
choice(range(start, stop)),
|
||||||
but doesnt actually build a range object.
|
but doesnt actually build a range object.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(y, NoneType):
|
||||||
|
return random.randrange(x)
|
||||||
|
else:
|
||||||
return random.randrange(x, y)
|
return random.randrange(x, y)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from collections import deque
|
from collections import deque
|
||||||
import Queue
|
import Queue
|
||||||
import random
|
import random
|
||||||
|
import helper_random
|
||||||
|
|
||||||
class MultiQueue(Queue.Queue):
|
class MultiQueue(Queue.Queue):
|
||||||
defaultQueueCount = 10
|
defaultQueueCount = 10
|
||||||
|
@ -24,7 +25,7 @@ class MultiQueue(Queue.Queue):
|
||||||
# Put a new item in the queue
|
# Put a new item in the queue
|
||||||
def _put(self, item):
|
def _put(self, item):
|
||||||
#self.queue.append(item)
|
#self.queue.append(item)
|
||||||
self.queues[random.randrange(self.queueCount)].append((item))
|
self.queues[helper_random.randomrandrange(self.queueCount)].append((item))
|
||||||
|
|
||||||
# Get an item from the queue
|
# Get an item from the queue
|
||||||
def _get(self):
|
def _get(self):
|
||||||
|
|
Reference in New Issue
Block a user