Remove extraneous dependency
The rstr library relies on the normal random.SystemRandom() and does not perform additional functionalites that would require a whole dependency to be added to pegleg. This patch set places in the logic into pegleg's crypto generation rather than using the whole rstr library. Change-Id: I20c0ceae8ac7d11468f325cd6a4cc035fc176b14 Signed-off-by: Tin Lam <tin@irrational.io>
This commit is contained in:
parent
e3e5683765
commit
cecaa73f57
@ -12,9 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import random
|
||||||
from random import SystemRandom
|
|
||||||
from rstr import Rstr
|
|
||||||
import string
|
import string
|
||||||
|
|
||||||
__all__ = ['CryptoString']
|
__all__ = ['CryptoString']
|
||||||
@ -24,14 +22,11 @@ class CryptoString(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._pool = string.ascii_letters + string.digits + string.punctuation
|
self._pool = string.ascii_letters + string.digits + string.punctuation
|
||||||
self._rs = Rstr(SystemRandom())
|
self._random = random.SystemRandom()
|
||||||
|
|
||||||
def get_crypto_string(self, len=24):
|
def get_crypto_string(self, length=24):
|
||||||
"""
|
"""
|
||||||
Create and return a random cryptographic string,
|
Create and return a random cryptographic string of length ``length``.
|
||||||
of the ``len`` length.
|
|
||||||
"""
|
"""
|
||||||
|
return ''.join(self._random.choice(self._pool)
|
||||||
if len < 24:
|
for _ in range(max(24, length)))
|
||||||
len = 24
|
|
||||||
return self._rs.rstr(self._pool, len)
|
|
||||||
|
@ -6,7 +6,6 @@ cryptography==2.3.1
|
|||||||
python-dateutil==2.7.3
|
python-dateutil==2.7.3
|
||||||
|
|
||||||
# External dependencies
|
# External dependencies
|
||||||
rstr==2.2.6
|
|
||||||
git+https://github.com/openstack/airship-deckhand.git@49ad9f38842f7f1ecb86d907d86d332f8186eb8c
|
git+https://github.com/openstack/airship-deckhand.git@49ad9f38842f7f1ecb86d907d86d332f8186eb8c
|
||||||
git+https://github.com/openstack/airship-shipyard.git@44f7022df6438de541501c2fdd5c46df198b82bf#egg=shipyard_client&subdirectory=src/bin/shipyard_client
|
git+https://github.com/openstack/airship-shipyard.git@44f7022df6438de541501c2fdd5c46df198b82bf#egg=shipyard_client&subdirectory=src/bin/shipyard_client
|
||||||
git+https://github.com/openstack/airship-promenade.git@a6e8fdbe22bd153c78a008b92cd5d1c245bc63e3
|
git+https://github.com/openstack/airship-promenade.git@a6e8fdbe22bd153c78a008b92cd5d1c245bc63e3
|
||||||
|
Loading…
Reference in New Issue
Block a user