forked from OCA/edi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
26 lines (18 loc) · 770 Bytes
/
utils.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
# Copyright 2020 ACSONE SA
# @author Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
import hashlib
from odoo.addons.http_routing.models.ir_http import slugify
from odoo.addons.queue_job.job import identity_exact_hasher
def normalize_string(a_string, sep="_"):
"""Normalize given string, replace dashes with given separator."""
return slugify(a_string).replace("-", sep)
def get_checksum(filecontent):
return hashlib.md5(filecontent).hexdigest()
def exchange_record_job_identity_exact(job_):
hasher = identity_exact_hasher(job_)
# Include files checksum
hasher.update(
str(sorted(job_.recordset.mapped("exchange_filechecksum"))).encode("utf-8")
)
return hasher.hexdigest()