Last active
December 31, 2024 15:04
-
-
Save ryonagana/b256d8b22e9d8b3139980f815535e74f to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
import sys | |
import base64 | |
from stat import S_ISREG | |
import itertools | |
if __name__ == "__main__": | |
if len(sys.argv) < 3: | |
print("Erro paramentos Incorretos") | |
sys.exit(1) | |
try: | |
arquivo=sys.argv[1] | |
except IndexError as ie: | |
print("Arquivo nao Encontrado") | |
sys.exit(1) | |
try: | |
mode = os.lstat(arquivo).st_mode | |
if not S_ISREG(mode): | |
print("Nao e um Arquivo!") | |
sys.exit(1) | |
except FileNotFoundError as ex: | |
print(ex) | |
exit(1) | |
try: | |
linhas=int(sys.argv[2]) | |
except IndexError as ie: | |
print("Linhas nao definidas!") | |
sys.exit(1) | |
try: | |
saida=str(sys.argv[3]) | |
except IndexError as ie: | |
print("Saida nao definidas!") | |
sys.exit(1) | |
with open(arquivo,"r") as f: | |
out = open(saida,"wb") | |
for line in itertools.islice(f,linhas,None): | |
if not line: | |
break | |
out.write(base64.b64decode(line)) | |
out.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment