Skip to content

Commit

Permalink
Support PPA list pagination
Browse files Browse the repository at this point in the history
The PPA lists are paginated. To correctly fetch the list of PPAs, we
need to keep iterating over the paginated lists.
  • Loading branch information
athos-ribeiro committed Apr 5, 2024
1 parent e10e5fd commit bb1ad3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lppa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def delete(args):


def list(args):
ppas = lppa.utils.ppa_list()
for ppa_name in ppas:
for ppa_name in lppa.utils.ppa_list():
print(ppa_name)


Expand Down
10 changes: 6 additions & 4 deletions lppa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def ppa_list():
session = Session().get_session()
me = session.me
ppas_url = me.ppas_collection_link
r = requests.get(ppas_url)
ppas = r.json()
ppa_names = [ppa['name'] for ppa in ppas['entries']]
return sorted(ppa_names)
while ppas_url:
r = requests.get(ppas_url)
ppas = r.json()
ppas_url = ppas.get('next_collection_link')
for ppa in ppas['entries']:
yield ppa['name']

0 comments on commit bb1ad3d

Please sign in to comment.