-
Notifications
You must be signed in to change notification settings - Fork 149
/
odoo_convert_url_to_image.py
executable file
·42 lines (34 loc) · 1.55 KB
/
odoo_convert_url_to_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''
Copyright (C) Thibault Francois
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Lesser Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import argparse
import os
from odoo_csv_tools.lib import mapper
from odoo_csv_tools.lib.transform import Processor
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Convert csv column Image URL into base64')
parser.add_argument('file', metavar='F', help='file to convert')
parser.add_argument('--out', dest='out', help='name of the result file, default out.csv', default="out.csv")
parser.add_argument('-f', dest='fields', help='Fields to convert from path to base64, comma separated', required = True)
args = parser.parse_args()
file_csv = args.file
out_csv = args.out
fields = args.fields
processor = Processor(file_csv)
mapping = processor.get_o2o_mapping()
for f in fields.split(','):
f = f.strip()
mapping[f] = mapper.binary_url(f, verbose=True)
processor.process(mapping, out_csv, {}, 'list')
processor.write_to_file("")