File tree Expand file tree Collapse file tree 4 files changed +225
-0
lines changed Expand file tree Collapse file tree 4 files changed +225
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Managing Python Projects With ` uv ` : An All-in-One Solution
2
+
3
+ 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/ ) .
Original file line number Diff line number Diff line change
1
+ import argparse
2
+ import sys
3
+
4
+ import requests
5
+
6
+
7
+ def get_breeds_info ():
8
+ response = requests .get ("https://api.thecatapi.com/v1/breeds" )
9
+ response .raise_for_status ()
10
+ return response .json ()
11
+
12
+
13
+ def find_breed_info (breed_name ):
14
+ json_response = get_breeds_info ()
15
+ for breed in json_response :
16
+ if breed ["name" ] == breed_name :
17
+ return breed
18
+ return None
19
+
20
+
21
+ def display_breed_profile (breed ):
22
+ print (f"\n { breed ['name' ]:-^30s} " )
23
+ print (f"Origin: { breed ['origin' ]} " )
24
+ print (f"Temperament: { breed ['temperament' ]} " )
25
+ print (f"Life Span: { breed ['life_span' ]} years" )
26
+ print (f"Weight: { breed ['weight' ]['imperial' ]} lbs" )
27
+ if breed .get ("wikipedia_url" ):
28
+ print (f"\n Learn more: { breed ['wikipedia_url' ]} " )
29
+
30
+
31
+ def parse_args ():
32
+ parser = argparse .ArgumentParser (
33
+ description = "Get information about cat breeds" ,
34
+ )
35
+ parser .add_argument (
36
+ "breed" ,
37
+ help = "Name of cat breed (e.g., 'Siamese')" ,
38
+ )
39
+ return parser .parse_args ()
40
+
41
+
42
+ def main ():
43
+ args = parse_args ()
44
+ try :
45
+ breed = find_breed_info (args .breed )
46
+ if not breed :
47
+ print ("Breed not found. Try another breed name." )
48
+ return 0
49
+ display_breed_profile (breed )
50
+ except Exception as e :
51
+ print (f"Error: { e } " )
52
+ return 1
53
+
54
+ return 0
55
+
56
+
57
+ if __name__ == "__main__" :
58
+ sys .exit (main ())
Original file line number Diff line number Diff line change
1
+ [project ]
2
+ name = " rpcats"
3
+ version = " 0.1.0"
4
+ description = " Display cat information for the specified breed."
5
+ readme = " README.md"
6
+ requires-python = " >=3.13"
7
+ dependencies = [
8
+ " requests>=2.32.3" ,
9
+ ]
10
+
11
+ [dependency-groups ]
12
+ dev = [
13
+ " pytest>=8.3.5" ,
14
+ ]
15
+
16
+ [project .scripts ]
17
+ rpcats = " main:main"
18
+
19
+ [build-system ]
20
+ requires = [" setuptools>=78.1.0" , " wheel>=0.45.1" ]
21
+ build-backend = " setuptools.build_meta"
22
+
23
+ [[tool .uv .index ]]
24
+ name = " testpypi"
25
+ url = " https://test.pypi.org/simple/"
26
+ publish-url = " https://test.pypi.org/legacy/"
27
+ explicit = true
You can’t perform that action at this time.
0 commit comments