File tree 4 files changed +40
-0
lines changed
4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1
1
from . import processor
2
2
from . import processor_xml
3
3
from . import processor_json
4
+ from . import processor_txt
4
5
from . import splitter
5
6
from . import splitter_json
6
7
from . import splitter_xml
8
+ from . import splitter_txt
Original file line number Diff line number Diff line change
1
+ # Copyright 2021 Akretion (https://www.akretion.com).
2
+ # @author Sébastien BEAU <[email protected] >
3
+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4
+
5
+ import base64
6
+
7
+ from odoo .addons .component .core import AbstractComponent
8
+
9
+
10
+ class ChunkProcessorTxt (AbstractComponent ):
11
+ _name = "chunk.importer.txt"
12
+ _inherit = "chunk.processor"
13
+ _collection = "chunk.item"
14
+ _end_of_line = b"\n "
15
+
16
+ def _parse_data (self ):
17
+ return base64 .b64decode (self .collection .data ).split (self ._end_of_line )
Original file line number Diff line number Diff line change
1
+ # Copyright 2021 Akretion (https://www.akretion.com).
2
+ # @author Sébastien BEAU <[email protected] >
3
+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4
+
5
+ from odoo .addons .component .core import Component
6
+
7
+
8
+ class ChunkSplitterTxt (Component ):
9
+ _inherit = "chunk.splitter"
10
+ _name = "chunk.splitter.txt"
11
+ _usage = "txt"
12
+ _end_of_line = b"\n "
13
+
14
+ def _parse_data (self , data ):
15
+ for idx , item in enumerate (data .split (self ._end_of_line )):
16
+ if item :
17
+ yield idx + 1 , item
18
+
19
+ def _convert_items_to_data (self , items ):
20
+ return self ._end_of_line .join ([x [1 ] for x in items ])
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class ChunkGroup(models.Model):
20
20
[
21
21
("json" , "Json" ),
22
22
("xml" , "XML" ),
23
+ ("txt" , "Txt" ),
23
24
]
24
25
)
25
26
xml_split_xpath = fields .Char ()
You can’t perform that action at this time.
0 commit comments