Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/misc/package.py: Improve source formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Dec 29, 2020
1 parent 64bde5f commit e9a7572
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sage/misc/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ def pip_installed_packages(normalization=None):
stderr=devnull,
)
stdout = proc.communicate()[0].decode()

def normalize(name):
if normalization is None:
return name
elif normalization == 'spkg':
return name.lower().replace('-', '_').replace('.', '_')
else:
raise NotImplementedError(f'normalization {normalization} is not implemented')

try:
return {normalize(package['name']): package['version']
for package in json.loads(stdout)}
Expand Down

0 comments on commit e9a7572

Please sign in to comment.