Skip to content

Commit

Permalink
Extract function for constructing the session.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 29, 2024
1 parent 9aa28c1 commit e628e46
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions jaraco/develop/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,21 @@ def checkout(project, target: path.Path = path.Path(), **kwargs):
return repo


def projects():
@functools.lru_cache()
def _session():
"""
Load projects from PROJECTS_LIST_URL.
Return a requests session capable of opening files.
"""
session = requests.Session()
session.mount('file://', requests_file.FileAdapter())
text = session.get(os.environ['PROJECTS_LIST_URL']).text
return session


def projects():
"""
Load projects from PROJECTS_LIST_URL.
"""
text = _session().get(os.environ['PROJECTS_LIST_URL']).text
return set(map(Project.parse, text.splitlines()))


Expand Down

0 comments on commit e628e46

Please sign in to comment.