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