-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathexample_data_provider.py
More file actions
25 lines (20 loc) · 887 Bytes
/
example_data_provider.py
File metadata and controls
25 lines (20 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#
# GoogleFindMyTools - A set of tools to interact with the Google Find My API
# Copyright © 2024 Leon Böttger. All rights reserved.
#
import json
import os
def get_example_data(identifier: str) -> str:
try:
with open(_get_example_file(), 'r') as file:
data = json.load(file)
value = data.get(identifier)
if value is not None:
return value
else:
raise ValueError("The requested value was not found in the example data file (example_data.json).")
except Exception:
raise ValueError("The requested value was not found in the example data file (example_data.json). Please make sure the file is present and correctly formatted.")
def _get_example_file() -> str:
script_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.join(script_dir, 'example_data.json')