Skip to content

Commit b7c790a

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

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

boto3/docs/service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
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
1617
from botocore.docs.service import ServiceDocumenter as BaseServiceDocumenter
1718
from botocore.exceptions import DataNotFoundError
1819

19-
import boto3
2020
from boto3.docs.client import Boto3ClientDocumenter
2121
from boto3.docs.resource import ResourceDocumenter, ServiceResourceDocumenter
2222
from boto3.utils import ServiceContext
2323

2424

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

2929
def __init__(self, service_name, session, root_docs_path):
3030
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)