Created
September 23, 2016 22:51
-
-
Save JuniorPolegato/2a459e6d1808b46c34d47a4469e61ce9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import random | |
def quebra(dados, espacos = 0, tamanho = 79): | |
saida = [''] | |
limite = tamanho - espacos | |
for d in dados: | |
r = '\'\\"\'' if d == '"' else repr(d) | |
if len(saida[-1]) + len(r) > limite: | |
saida[-1] = ' ' * espacos + '"' + saida[-1] + '"' | |
saida.append(r[1:-1]) | |
else: | |
saida[-1] += r[1:-1] | |
saida[-1] = ' ' * espacos + '"' + saida[-1] + '"' | |
return saida | |
x = ''.join(chr(random.randint(0, 255)) for i in range(1000)) | |
print repr(x) | |
print '\n'.join(quebra(x, 16)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment