From 6215c0393988893e674f57a4c9938ec85d96e852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Mon, 20 Feb 2017 14:16:41 +0100 Subject: [PATCH] the command line now uses the crayons Python library in order to have colored strings in the terminal. --- CHANGELOG.rst | 6 ++++++ bin/lsb-set | 7 ++++++- setup.py | 2 +- stegano/lsbset/generators.py | 36 ++++++++++++------------------------ 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9e1a946..428ac79 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) ------------------ diff --git a/bin/lsb-set b/bin/lsb-set index fc3d4ca..f6b17bb 100755 --- a/bin/lsb-set +++ b/bin/lsb-set @@ -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('') diff --git a/setup.py b/setup.py index 4aa15f7..50af05d 100644 --- a/setup.py +++ b/setup.py @@ -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, diff --git a/stegano/lsbset/generators.py b/stegano/lsbset/generators.py index 5205d49..53bf645 100644 --- a/stegano/lsbset/generators.py +++ b/stegano/lsbset/generators.py @@ -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: