add listdirs
This commit is contained in:
@@ -4,8 +4,8 @@ try:
|
||||
except Exception:
|
||||
from yaml import SafeLoader
|
||||
from os.path import join, relpath
|
||||
from os import listdir
|
||||
from typing import List
|
||||
from game_backuper.file import listdirs
|
||||
|
||||
|
||||
class Program:
|
||||
@@ -46,12 +46,9 @@ class Program:
|
||||
t = i['type']
|
||||
if t == 'path':
|
||||
bp = join(b, i['path'])
|
||||
ll = listdir(bp)
|
||||
ll = listdirs(bp)
|
||||
for ii in ll:
|
||||
if ii.startswith('.'):
|
||||
continue
|
||||
pa = join(bp, ii)
|
||||
r.append((relpath(pa, b), pa))
|
||||
r.append((relpath(ii, b), ii))
|
||||
return r
|
||||
|
||||
@property
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections import namedtuple
|
||||
from os.path import exists, dirname, abspath
|
||||
from os import stat, makedirs
|
||||
from os.path import exists, dirname, abspath, isfile, isdir, join
|
||||
from os import stat, makedirs, listdir
|
||||
from game_backuper.hashl import sha512
|
||||
from shutil import copy2
|
||||
|
||||
@@ -16,6 +16,20 @@ def copy_file(loc: str, dest: str, name: str, prog: str):
|
||||
print(f'{prog}: Copyed {loc}({name}) -> {r}')
|
||||
|
||||
|
||||
def listdirs(loc: str):
|
||||
bl = listdir(loc)
|
||||
r = []
|
||||
for i in bl:
|
||||
if i.startswith('.'):
|
||||
continue
|
||||
p = join(loc, i)
|
||||
if isfile(p):
|
||||
r.append(p)
|
||||
elif isdir(p):
|
||||
r += listdirs(p)
|
||||
return r
|
||||
|
||||
|
||||
def new_file(loc: str, name: str, prog: str) -> File:
|
||||
if exists(loc):
|
||||
fs = stat(loc).st_size
|
||||
|
||||
Reference in New Issue
Block a user