2021-11-01 11:00:59 -03:00
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
|
|
|
|
import contabilidad.pdf as pdf
|
2021-11-02 15:37:36 -03:00
|
|
|
import contabilidad.text_handler as th
|
2021-11-01 11:00:59 -03:00
|
|
|
|
|
|
|
|
|
|
|
def main(args):
|
|
|
|
filename = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data', args.filename))
|
2021-11-02 22:12:25 -03:00
|
|
|
temp = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data', args.temp_filename))
|
|
|
|
pdf.remove_encryption(filename, args.password, temp)
|
|
|
|
obj = pdf.get_data(temp)
|
2021-11-02 15:37:36 -03:00
|
|
|
obj = pdf.get_text(filename, args.password)
|
|
|
|
text = th.text_cleanup(obj, filename=str(args.filename))
|
2021-11-02 22:12:25 -03:00
|
|
|
os.remove(temp)
|
2021-11-01 11:00:59 -03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('-f', '--filename', type=str)
|
|
|
|
parser.add_argument('-p', '--password', type=str, default='')
|
2021-11-02 22:12:25 -03:00
|
|
|
parser.add_argument('-t', '--temp_filename', type=str)
|
2021-11-01 11:00:59 -03:00
|
|
|
_args = parser.parse_args()
|
|
|
|
main(_args)
|