Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
with open
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Feb 15, 2023
1 parent aeb0c27 commit fd6d949
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pytransifex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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}'"
Expand Down

0 comments on commit fd6d949

Please sign in to comment.