Skip to content

Commit 168285d

Browse files
committed
Move __file__ references to use importlib.resources.files
1 parent e84865b commit 168285d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

boto3/docs/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
13+
import importlib.resources
1314
import os
1415

1516
from botocore.docs.bcdoc.restdoc import DocumentStructure
@@ -24,7 +25,7 @@
2425

2526
class ServiceDocumenter(BaseServiceDocumenter):
2627
# The path used to find examples
27-
EXAMPLE_PATH = os.path.join(os.path.dirname(boto3.__file__), 'examples')
28+
EXAMPLE_PATH = str(importlib.resources.files('boto3') / 'examples')
2829

2930
def __init__(self, service_name, session, root_docs_path):
3031
super().__init__(

boto3/session.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313

1414
import copy
15-
import os
15+
import importlib.resources
1616

1717
import botocore.session
1818
from botocore.client import Config
@@ -147,9 +147,8 @@ def _setup_loader(self):
147147
Setup loader paths so that we can load resources.
148148
"""
149149
self._loader = self._session.get_component('data_loader')
150-
self._loader.search_paths.append(
151-
os.path.join(os.path.dirname(__file__), 'data')
152-
)
150+
data_path = str(importlib.resources.files('boto3') / 'data')
151+
self._loader.search_paths.append(data_path)
153152

154153
def get_available_services(self):
155154
"""

0 commit comments

Comments
 (0)