Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python-uv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Managing Python Projects With `uv`: An All-in-One Solution

This folder provides the code examples for the Real Python tutorial [Managing Python Projects With `uv`: An All-in-One Solution](https://realpython.com/python-uv/).
58 changes: 58 additions & 0 deletions python-uv/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import argparse
import sys

import requests


def get_breeds_info():
response = requests.get("https://api.thecatapi.com/v1/breeds")
response.raise_for_status()
return response.json()


def find_breed_info(breed_name):
json_response = get_breeds_info()
for breed in json_response:
if breed["name"] == breed_name:
return breed
return {}
Comment thread
martin-martin marked this conversation as resolved.
Outdated


def display_breed_profile(breed):
print(f"\n{breed['name']:-^30s}")
print(f"Origin: {breed['origin']}")
print(f"Temperament: {breed['temperament']}")
print(f"Life Span: {breed['life_span']} years")
print(f"Weight: {breed['weight']['imperial']} lbs")
if breed.get("wikipedia_url"):
print(f"\nLearn more: {breed['wikipedia_url']}")


def parse_args():
parser = argparse.ArgumentParser(
description="Get information about cat breeds",
)
parser.add_argument(
"breed",
help="Name of cat breed (e.g., 'Siamese')",
)
return parser.parse_args()


def main():
args = parse_args()
try:
breed = find_breed_info(args.breed)
if not breed:
print("Breed not found. Try another breed name.")
return 0
display_breed_profile(breed)
except Exception as e:
print(f"Error: {e}")
return 1

return 0


if __name__ == "__main__":
sys.exit(main())
27 changes: 27 additions & 0 deletions python-uv/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "rpcats"
version = "0.1.0"
description = "Add your description here"
Comment thread
martin-martin marked this conversation as resolved.
Outdated
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"requests>=2.32.3",
]

[dependency-groups]
dev = [
"pytest>=8.3.5",
]

[project.scripts]
rpcats = "main:main"

[build-system]
requires = ["setuptools>=78.1.0", "wheel>=0.45.1"]
build-backend = "setuptools.build_meta"

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true
137 changes: 137 additions & 0 deletions python-uv/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.