Cambio en métido join de utilidades
This commit is contained in:
parent
2f30bba8b4
commit
63c08d3a42
|
@ -10,10 +10,10 @@ def main(args):
|
|||
return
|
||||
|
||||
if args.dir_trabajo:
|
||||
entrada = util.join(args.dir_trabajo, 'entrada')
|
||||
generados = util.join(args.dir_trabajo, 'generados')
|
||||
por_timbrar = util.join(args.dir_trabajo, 'por_timbrar')
|
||||
timbrados = util.join(args.dir_trabajo, 'timbrados')
|
||||
entrada = util.validar_dir(args.dir_trabajo, 'entrada')
|
||||
generados = util.validar_dir(args.dir_trabajo, 'generados')
|
||||
por_timbrar = util.validar_dir(args.dir_trabajo, 'por_timbrar')
|
||||
timbrados = util.validar_dir(args.dir_trabajo, 'timbrados')
|
||||
else:
|
||||
entrada = args.dir_entrada
|
||||
generados = args.dir_generados
|
||||
|
|
|
@ -34,13 +34,20 @@ NS_CFDI = {
|
|||
}
|
||||
|
||||
|
||||
def validar_dir(base, name):
|
||||
path = _join(base, name)
|
||||
if not _exists(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
|
||||
def _exists(path):
|
||||
if not path:
|
||||
return False
|
||||
return Path(path).exists()
|
||||
|
||||
|
||||
def join(*paths):
|
||||
def _join(*paths):
|
||||
return str(Path(paths[0]).joinpath(*paths[1:]))
|
||||
|
||||
|
||||
|
@ -349,9 +356,9 @@ def _validate_args_validar_cert(args):
|
|||
log.error(msg)
|
||||
return False, data
|
||||
|
||||
path_cer = join(path_cert, f'{name}.cer')
|
||||
path_key = join(path_cert, f'{name}.key')
|
||||
path_enc = join(path_cert, f'{name}.enc')
|
||||
path_cer = _join(path_cert, f'{name}.cer')
|
||||
path_key = _join(path_cert, f'{name}.key')
|
||||
path_enc = _join(path_cert, f'{name}.enc')
|
||||
|
||||
if not _exists(path_cer):
|
||||
msg = f'No se encontró el archivo CER en: {path_cer}'
|
||||
|
@ -428,14 +435,14 @@ def make(source, target):
|
|||
|
||||
def _stamp(path, target):
|
||||
current_path = os.path.dirname(__file__)
|
||||
path_cer = join(current_path, 'certificados')
|
||||
path_xslt = join(current_path, 'xslt', 'cadena.xslt')
|
||||
path_cer = _join(current_path, 'certificados')
|
||||
path_xslt = _join(current_path, 'xslt', 'cadena.xslt')
|
||||
doc = ET.parse(path)
|
||||
|
||||
for pac in PACs.keys():
|
||||
xslt = open(path_xslt, 'rb')
|
||||
cer = read_file(join(path_cer, f'{pac}.cer'))
|
||||
key = read_file(join(path_cer, f'{pac}.enc'))
|
||||
cer = read_file(_join(path_cer, f'{pac}.cer'))
|
||||
key = read_file(_join(path_cer, f'{pac}.enc'))
|
||||
cert = SATCertificate(cer, key)
|
||||
# ~ print(cert)
|
||||
|
||||
|
@ -512,17 +519,13 @@ def read_file(path):
|
|||
return data
|
||||
|
||||
|
||||
|
||||
|
||||
def get_files(path, ext='xml'):
|
||||
docs = []
|
||||
for folder, _, files in os.walk(path):
|
||||
pattern = re.compile('\.{}'.format(ext), re.IGNORECASE)
|
||||
docs += [join(folder,f) for f in files if pattern.search(f)]
|
||||
docs += [_join(folder,f) for f in files if pattern.search(f)]
|
||||
return tuple(docs)
|
||||
|
||||
|
||||
|
||||
|
||||
def _replace_ext(path, ext):
|
||||
return str(Path(path).with_suffix(ext))
|
||||
|
|
Loading…
Reference in New Issue