the command line now uses the crayons Python library in order to have colored strings in the terminal.

This commit is contained in:
Cédric Bonhomme 2017-02-20 14:16:41 +01:00
parent 263e287559
commit 6215c03939
No known key found for this signature in database
GPG key ID: A1CB94DE57B7A70D
4 changed files with 25 additions and 26 deletions

View file

@ -1,6 +1,12 @@
Release History
===============
0.6.6 (2017-02-20)
------------------
* improved docstrings for the desciption of the generators;
* improved the command which displays the list of generators.
0.6.5 (2017-02-16)
------------------

View file

@ -25,6 +25,8 @@ __date__ = "$Date: 2016/03/18 $"
__revision__ = "$Date: 2016/08/04 $"
__license__ = "GPLv3"
import crayons
try:
from stegano import lsbset
from stegano.lsbset import generators
@ -120,4 +122,7 @@ elif arguments.command == 'list-generators':
import inspect
all_generators = inspect.getmembers(generators, inspect.isfunction)
for generator in all_generators:
print(generator[0], generator[1].__doc__)
print('Generator id:\n {}\nDesciption:\n {}'.format(
crayons.green(generator[0]),
generator[1].__doc__))
print('')

View file

@ -36,7 +36,7 @@ with open('CHANGELOG.rst', 'r') as f:
setup(
name='Stegano',
version='0.6.5',
version='0.6.6',
author='Cédric Bonhomme',
author_email='cedric@cedricbonhomme.org',
packages=packages,

View file

@ -29,8 +29,7 @@ import math
import itertools
def identity():
"""
f(x) = x
"""f(x) = x
"""
n = 0
while True:
@ -38,8 +37,7 @@ def identity():
n += 1
def Dead_Man_Walking():
"""
Dead Man Walking.
"""Dead Man Walking.
"""
n = 0
while True:
@ -47,8 +45,7 @@ def Dead_Man_Walking():
n += 2
def OEIS_A000217():
"""
http://oeis.org/A000217
"""http://oeis.org/A000217
Triangular numbers: a(n) = C(n+1,2) = n(n+1)/2 = 0+1+2+...+n.
"""
n = 0
@ -57,8 +54,7 @@ def OEIS_A000217():
n += 1
def fermat():
"""
Generate the n-th Fermat Number.
"""Generate the n-th Fermat Number.
"""
y = 5
while True:
@ -66,8 +62,7 @@ def fermat():
y = pow(y-1,2)+1
def mersenne():
"""
Generate 2^n-1.
"""Generate 2^n-1.
"""
y = 1
while True:
@ -75,8 +70,7 @@ def mersenne():
y = 2*y + 1
def eratosthenes():
"""
Generate the prime numbers with the sieve of Eratosthenes.
"""Generate the prime numbers with the sieve of Eratosthenes.
"""
d = {}
for i in itertools.count(2):
@ -89,8 +83,7 @@ def eratosthenes():
yield i
def eratosthenes_composite():
"""
Generate the composite numbers with the sieve of Eratosthenes.
"""Generate the composite numbers with the sieve of Eratosthenes.
"""
p1 = 3
for p2 in eratosthenes():
@ -99,8 +92,7 @@ def eratosthenes_composite():
p1 = p2
def carmichael():
"""
https://oeis.org/A002997
"""https://oeis.org/A002997
Composite numbers n such that a^(n-1) == 1 (mod n) for every a coprime to n.
"""
for m in eratosthenes_composite():
@ -111,8 +103,7 @@ def carmichael():
yield m
def ackermann(m, n):
"""
Ackermann number.
"""Ackermann number.
"""
if m == 0:
return n + 1
@ -122,8 +113,7 @@ def ackermann(m, n):
return ackermann(m - 1, ackermann(m, n - 1))
def fibonacci():
"""
https://oeis.org/A000045
"""https://oeis.org/A000045
A generator for Fibonacci numbers, goes to next number in series on each call.
This generator start at 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, ...
"""
@ -133,8 +123,7 @@ def fibonacci():
a, b = b, a + b
def syracuse(l=15):
"""
Generate the sequence of Syracuse.
"""Generate the sequence of Syracuse.
"""
y = l
while True:
@ -146,8 +135,7 @@ def syracuse(l=15):
y = 3*y + 1
def log_gen():
"""
Logarithmic generator.
"""Logarithmic generator.
"""
y = 1
while True: