Skip to content

Instantly share code, notes, and snippets.

@JuniorPolegato
Created September 23, 2016 22:51
Show Gist options
  • Save JuniorPolegato/2a459e6d1808b46c34d47a4469e61ce9 to your computer and use it in GitHub Desktop.
Save JuniorPolegato/2a459e6d1808b46c34d47a4469e61ce9 to your computer and use it in GitHub Desktop.
#!/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