restructure

This commit is contained in:
wataru 2023-01-01 01:59:01 +09:00
parent 9c4a7d5e49
commit a2a12f54ad
6 changed files with 28 additions and 28 deletions

View File

@ -1,7 +1,7 @@
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
from trainer_mods.files import get_file_list
from restapi.utils.files import get_file_list
import os
def mod_get_models():

View File

@ -1,6 +1,6 @@
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
from trainer_mods.files import get_file_list
from restapi.utils.files import get_file_list
import os
def mod_get_speaker_voices(speaker:str):

View File

@ -1,6 +1,6 @@
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
from trainer_mods.files import get_dir_list
from restapi.utils.files import get_dir_list
import os
# CreateはFileUploaderで実装。

View File

@ -1,5 +1,5 @@
import subprocess,os
from trainer_mods.files import get_file_list
from restapi.utils.files import get_file_list
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder

24
server/restapi/utils/files.py Executable file
View File

@ -0,0 +1,24 @@
import os,glob
# def get_file_list(top_dir):
# for root, dirs, files in os.walk(top_dir):
# for dir in dirs:
# dirPath = os.path.join(root, dir)
# print(f'dirPath = {dirPath}')
# for file in files:
# filePath = os.path.join(root, file)
# print(f'filePath = {filePath}')
def get_dir_list(top_dir):
dirlist = []
files = os.listdir(top_dir)
for filename in files:
if os.path.isdir(os.path.join(top_dir, filename)):
dirlist.append(filename)
return dirlist
def get_file_list(top_dir):
return glob.glob(top_dir)

View File

@ -1,24 +0,0 @@
import os,glob
def get_file_list(top_dir):
for root, dirs, files in os.walk(top_dir):
for dir in dirs:
dirPath = os.path.join(root, dir)
print(f'dirPath = {dirPath}')
for file in files:
filePath = os.path.join(root, file)
print(f'filePath = {filePath}')
def get_dir_list(top_dir):
dirlist = []
files = os.listdir(top_dir)
for filename in files:
if os.path.isdir(os.path.join(top_dir, filename)):
dirlist.append(filename)
return dirlist
def get_file_list(top_dir):
return glob.glob(top_dir)