Commit 57785647 authored by Gilberto Astolfi's avatar Gilberto Astolfi
Browse files

Adicionando FileUtils para tranferir arquivos entre diretórios

parent 36a9975b
import os
from shutil import copyfile, make_archive
class FileUtils:
def __init__(self):
pass
def createDirectory(self, directory):
if not os.path.exists(directory):
os.makedirs(directory)
def transfereFilesTfrecordSet(self, fold_src_set, fold_dst_set):
for f in os.listdir(fold_src_set):
name, extension = os.path.splitext(f)
if extension.lower() == '.pbtxt'.lower():
file_src = fold_src_set + '/' + f
file_dst = fold_dst_set + '/' + f
copyfile(file_src, file_dst)
if extension.lower() == '.tfrecord'.lower():
file_src = fold_src_set + '/' + f
file_dst = fold_dst_set + '/' + f
copyfile(file_src, file_dst)
def transfereFilesTfrecord(self, path_tfrecords, repositorio_dst):
for fold in os.listdir(path_tfrecords):
fold_src = path_tfrecords + '/' + fold #origem
fold_dst = repositorio_dst + '/' + fold #destino
for set_ in os.listdir(fold_src):
fold_src_set = fold_src + '/' + set_ #origem
fold_dst_set = fold_dst + '/' + set_ #destino
if set_ != 'test':
self.transfereFilesTfrecordSet(fold_src_set, fold_dst_set)
def transfereFilesDrive(self, path_origem, path_dst):
self.createDirectory(path_dst)
sample_name_zip = path_dst + '/' + tipo_amostragem
make_archive(sample_name_zip, 'zip', path_origem)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment