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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
--- contrib/python/moto/py3/moto/cognitoidp/responses.py (index)
+++ contrib/python/moto/py3/moto/cognitoidp/responses.py (working tree)
@@ -624,10 +624,8 @@ class CognitoIdpResponse(BaseResponse):
class CognitoIdpJsonWebKeyResponse(BaseResponse):
def __init__(self):
- with open(
- os.path.join(os.path.dirname(__file__), "resources/jwks-public.json")
- ) as f:
- self.json_web_key = f.read()
+ import pkgutil
+ self.json_web_key = pkgutil.get_data(__package__, 'resources/jwks-public.json')
def serve_json_web_key(
self, request, full_url, headers
--- contrib/python/moto/py3/moto/s3/responses.py (index)
+++ contrib/python/moto/py3/moto/s3/responses.py (working tree)
@@ -288,6 +288,8 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
request.headers.get("Authorization", "")
)
region_name = region_name or DEFAULT_REGION_NAME
+ if region_name == "yandex":
+ region_name = DEFAULT_REGION_NAME
bucket_name = self.parse_bucket_name_from_url(request, full_url)
if not bucket_name:
--- contrib/python/moto/py3/moto/ec2/models/amis.py (index)
+++ contrib/python/moto/py3/moto/ec2/models/amis.py (working tree)
@@ -25,1 +25,1 @@ if "MOTO_AMIS_PATH" in environ:
- AMIS = load_resource(__name__, "../resources/amis.json")
+ AMIS = load_resource("moto.ec2", "resources/amis.json")
--- contrib/python/moto/py3/moto/ec2/models/instance_types.py (index)
+++ contrib/python/moto/py3/moto/ec2/models/instance_types.py (working tree)
@@ -5,19 +5,27 @@ from os import listdir
from moto.utilities.utils import load_resource
from ..exceptions import InvalidInstanceTypeError
-INSTANCE_TYPES = load_resource(__name__, "../resources/instance_types.json")
+import library.python.resource as _ya_res
+import os
+import json
+
+INSTANCE_TYPES = load_resource("moto.ec2", "resources/instance_types.json")
INSTANCE_FAMILIES = list(set([i.split(".")[0] for i in INSTANCE_TYPES.keys()]))
-root = pathlib.Path(__file__).parent
-offerings_path = "../resources/instance_type_offerings"
+root = pathlib.Path(__file__).parent.parent
+offerings_path = "resources/instance_type_offerings"
INSTANCE_TYPE_OFFERINGS = {}
-for location_type in listdir(root / offerings_path):
- INSTANCE_TYPE_OFFERINGS[location_type] = {}
- for _region in listdir(root / offerings_path / location_type):
- full_path = offerings_path + "/" + location_type + "/" + _region
- res = load_resource(__name__, full_path)
- for instance in res:
- instance["LocationType"] = location_type
+for entry in _ya_res.resfs_files(prefix=str(root / offerings_path)):
+ rel_path = os.path.relpath(entry, root / offerings_path)
+ path_parts = os.path.normpath(rel_path).split(os.path.sep)
+ if len(path_parts) != 2:
+ continue
+ location_type, _region = path_parts
+ if location_type not in INSTANCE_TYPE_OFFERINGS:
+ INSTANCE_TYPE_OFFERINGS[location_type] = {}
+ res = json.loads(_ya_res.find(f"resfs/file/{entry}"))
+ for instance in res:
+ instance["LocationType"] = location_type
INSTANCE_TYPE_OFFERINGS[location_type][_region.replace(".json", "")] = res
|