Fixed change and property

This commit is contained in:
shekhar-cis 2023-01-13 12:30:22 +05:30
parent ab6d1083ec
commit 8091be197d
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7

View File

@ -66,16 +66,18 @@ class TransifexHandler(BaseHookHandler):
def process_translation_completed(self, payload, codebase):
changes = []
translated_request = self._transform_variables(payload['project'], payload['resource'])
ts = int(time.time())
change = {
'author': "buildbot-transifex",
'author': author,
'branch': translated_request["branch"],
'branch': translated_request["repository"],
'project': translated_request["project"],
'properties': {
"transifex_language": payload.get("language", "None"),
"transifex_event": payload.get("event", "None"),
"transifex_project": payload.get("project", "None"),
"transifex_resource": payload.get("resource", "None"),
"transifex_branch": "v0.6"
"transifex_branch": "translate_" + payload['language'] + "_" + str(ts)
}
}
if codebase is not None:
@ -83,10 +85,10 @@ class TransifexHandler(BaseHookHandler):
changes.insert(0, change)
return changes
def _transform_variables(self, transifex_project, transifex_resource):
def _transform_variables(self, transifex_project):
if transifex_project is None:
raise ValueError("Unknown project %s from transifex".format(transifex_project))
key = "{}/{}".format(transifex_project, transifex_resource)
key = transifex_project
_map = self.map[key]
repository = _map["repository"]
project = re.sub(r'^.*/(.*?)(\.git)?$', r'\1', repository)
@ -122,16 +124,6 @@ class TransifexHandler(BaseHookHandler):
request.getHeader(_HEADER_SIGNATURE))
self._verifyTransifexSignature(request, content, rendered_secret, signature, header_signature)
event_type = payload.get("event", "None")
mapped_request = self._transform_variables(payload['project'], payload['resource'])
change["changes"] = {
"author": author,
"repository": mapped_request["repository"],
"project": mapped_request["project"],
"branch": mapped_request["branch"]
}
log.msg("Received event '{}' from transifex".format(event_type))
codebase = ""