From fd6d9496c371dcd647c8747b0ba36dde44e31600 Mon Sep 17 00:00:00 2001 From: why-not-try-calmer Date: Wed, 15 Feb 2023 10:49:02 +0100 Subject: [PATCH] with open --- pytransifex/api.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pytransifex/api.py b/pytransifex/api.py index be09c1b..21fe50a 100644 --- a/pytransifex/api.py +++ b/pytransifex/api.py @@ -116,8 +116,10 @@ def create_resource( with open(path_to_file, "r") as fh: content = fh.read() - tx_api.ResourceStringsAsyncUpload.upload(content, resource=resource) - logging.info(f"Resource created: {resource_slug or resource_name}") + + tx_api.ResourceStringsAsyncUpload.upload(content, resource=resource) + logging.info(f"Resource created: {resource_slug or resource_name}") + else: raise Exception( f"Not project could be found wiht the slug '{project_slug}'. Please create a project first." @@ -141,11 +143,12 @@ def update_source_translation( if resource := resources.get(slug=resource_slug): with open(path_to_file, "r") as fh: content = fh.read() - tx_api.ResourceStringsAsyncUpload.upload( - content, resource=resource - ) - logging.info(f"Source updated for resource: {resource_slug}") - return + + tx_api.ResourceStringsAsyncUpload.upload( + content, resource=resource + ) + logging.info(f"Source updated for resource: {resource_slug}") + return raise Exception( f"Unable to find resource '{resource_slug}' in project '{project_slug}'"