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

Commit

Permalink
Fixing incorrect 'list_resources' method.
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Feb 15, 2023
1 parent 99ed7d0 commit 8f4f169
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pytransifex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ def get_project(self, project_slug: str) -> None | Resource:
return None

@ensure_login
def list_resources(self, project_slug: str) -> list[Resource]:
def list_resources(self, project_slug: str) -> list[Any]:
"""List all resources for the project passed as argument"""
if self.projects:
res = self.projects.filter(slug=project_slug)
logging.info("Obtained these resources:")
return res
if project := self.get_project(project_slug=project_slug):
if resources := project.fetch("resources"):
return list(resources.all())
else:
return []

raise Exception(
f"Unable to find any project under this organization: '{self.organization}'"
)
Expand All @@ -109,8 +111,8 @@ def create_resource(
if project := self.get_project(project_slug=project_slug):
resource = tx_api.Resource.create(
project=project,
name=resource_name,
slug=resource_slug,
name=resource_name or resource_slug,
slug=resource_slug or resource_name,
i18n_format=tx_api.I18nFormat(id=self.i18n_type),
)

Expand Down Expand Up @@ -305,7 +307,7 @@ def push(
logging.info(f"Slug: {slug}. Resources: {resources}.")
if not slug in resources:
logging.info(
f"{project_slug} is missing {slug}. Created it from {path}."
f"{project_slug} is missing {slug}. Creating it from {path}."
)
self.create_resource(
project_slug=project_slug, path_to_file=path, resource_slug=slug
Expand Down

0 comments on commit 8f4f169

Please sign in to comment.