PK!kHHscrmbl/__init__.pyfrom scrmbl.main import echo __all__ = ['echo'] __version__ = '1.0.0' PK!-0 scrmbl/cli.pyimport re import sys import click import scrmbl @click.command() @click.argument('message', default='') @click.option('-s', '--speed', type=click.FLOAT, default=0.05, help='Time in seconds between prints. Default: 0.05') @click.option('-i', '--iterations', type=click.INT, default=2, help='Number of iterations per character. Default: 2') @click.option('-c', '--charset', type=click.Path(exists=True, allow_dash=True, dir_okay=False), help='Set of chars to scramble.') @click.version_option(version=scrmbl.__version__) def cli(message: str, speed: float, iterations: int, charset: str) -> None: """Scrmbl print the given message.""" # no text input if not message: # if no stdin or just '-c -' if sys.stdin.isatty() or charset == '-': raise click.UsageError('"MESSAGE" is empty. No argument or stdin.') for line in sys.stdin: message += line message = _strip_ansi_colors(message) if charset: with click.open_file(charset) as f: charset_content = f.read() charset_content = charset_content.replace('\n', '') else: charset_content = None scrmbl.echo(message, charset=charset_content, speed=speed, iterations=iterations) def _strip_ansi_colors(message: str) -> str: """Strip ANSI color codes""" escape_codes = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]') return escape_codes.sub('', message) PK!SJLscrmbl/main.pyimport random import string import time import click random.seed() ALL_CHARS = string.digits + string.ascii_letters + string.punctuation COLS, _ = click.get_terminal_size() def echo(message: str, charset: str = ALL_CHARS, speed: float = 0.05, iterations: int = 2) -> None: """Scrmbl print the given message.""" if not charset: charset = ALL_CHARS for line in message.split('\n'): echoed = '' for char in line: for _ in range(iterations): if char != ' ': ran_char = random.choice(charset) click.echo('\r{}{}'.format(echoed, ran_char), nl=False) else: click.echo('\r{}'.format(echoed), nl=False) time.sleep(speed) echoed += char # wrap if line longer than console cols if len(echoed) >= COLS - 1: click.echo('\r' + echoed) echoed = '' if echoed: click.echo('\r' + echoed) PK!H+k$)'scrmbl-1.0.0.dist-info/entry_points.txtN+I/N.,()2rrl!^rNsqPK!ʒ22scrmbl-1.0.0.dist-info/LICENSEMIT License Copyright (c) 2018 Etienne Napoleone Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HW"TTscrmbl-1.0.0.dist-info/WHEEL A н#J."jm)Afb~ ڡ5 G7hiޅF4+-3ڦ/̖?XPK!H7% scrmbl-1.0.0.dist-info/METADATAVaS8_fb'BIP2Gһ:S*哔fJIp$kw߮vrGpTZ<}- Сʦ){[~Y}C1UT֕/FP( r02 SٌIS?Y'ohZX~eQB'Vא9Aϰ{%eq֟ 55h#]z7H>7E^s<ͰAzRͱ[~r9V>A$LgqVUZ߱7S׭dx9 OI*4נORl-i4O[ToE Sy];!dY^s| PK!kHHscrmbl/__init__.pyPK!-0 xscrmbl/cli.pyPK!SJLtscrmbl/main.pyPK!H+k$)' scrmbl-1.0.0.dist-info/entry_points.txtPK!ʒ22 scrmbl-1.0.0.dist-info/LICENSEPK!HW"TT{scrmbl-1.0.0.dist-info/WHEELPK!H7%  scrmbl-1.0.0.dist-info/METADATAPK!HuqVscrmbl-1.0.0.dist-info/RECORDPK: