schubergphilis / towerlib

A python library to interface with ansible tower's (awx) api.
MIT License
43 stars 39 forks source link

Get changes done by spirit21 #79

Closed inazir closed 3 years ago

inazir commented 3 years ago

We at spirit21 have been using this towerlib repo for some time now. We have made some changes so that it helps us better. We have also added some more methods in the towerlib.py file. We hope if this pull request is merged with the upstream schubergphilis/towerlib repo, then it will ease our maintenance step a lot.

costastf commented 3 years ago

Hi @inazir , thanks for your contribution! I have blocked some time on Monday to go over this MR but i can tell you from now that anything that is not functional for the code will have to be removed so if you do that already and make the MR only have the relevant functional changes (no changes that have to do with version files and release process) it will make my life easier and I will appreciate it. Thanks in advance and enjoy your weekend!

costastf commented 3 years ago

It is exactly the same as the list comprehension, but instead of using [] you use ().

On Wed, Jun 23, 2021, 16:13 Iqbal Nazir @.***> wrote:

@.**** commented on this pull request.

In towerlib/towerlib.py https://github.com/schubergphilis/towerlib/pull/79#discussion_r657143007 :

  • dict: dict of response of api request as json on success, None otherwise.
  • """
  • project = self.get_organization_project_by_name(organization, project_name)
  • return project.update
  • def update_organization_projects_by_scm_url(self, scm_url, organization_name):
  • """Send update request to update project for a given git repository (scm_url) withing an organization.
  • Args:
  • scm_url: the http url of the required repository.
  • """
  • organization = self.get_organization_by_name(organization_name)
  • matching_projects = [project for project in organization.projects if project.scm_url == scm_url]

I understood the making safe part. But I don't know how I can do a generator comprehension.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/schubergphilis/towerlib/pull/79#discussion_r657143007, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDMK222JGM2UIIY7IUDWM3TUHTXFANCNFSM43MQ2XGQ .

costastf commented 3 years ago

Sorry for being so frugal, replying from my phone. [something for something in other] returns a list, (something for something in other) returns a generator which will only start running upon iteration. I hope this makes it a bit clearer.

On Wed, Jun 23, 2021, 16:32 phospi @.***> wrote:

@.**** commented on this pull request.

In towerlib/towerlib.py https://github.com/schubergphilis/towerlib/pull/79#discussion_r657162088 :

  • dict: dict of response of api request as json on success, None otherwise.
  • """
  • project = self.get_organization_project_by_name(organization, project_name)
  • return project.update
  • def update_organization_projects_by_scm_url(self, scm_url, organization_name):
  • """Send update request to update project for a given git repository (scm_url) withing an organization.
  • Args:
  • scm_url: the http url of the required repository.
  • """
  • organization = self.get_organization_by_name(organization_name)
  • matching_projects = [project for project in organization.projects if project.scm_url == scm_url]

This should help: https://www.pythonlikeyoumeanit.com/Module2_EssentialsOfPython/Generators_and_Comprehensions.html

I think Costas means that the result of the generator is not a list but a generator.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/schubergphilis/towerlib/pull/79#discussion_r657162088, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDMK24T6F6AGYVAS36XVXDTUHV6XANCNFSM43MQ2XGQ .