{"id":292633,"date":"2019-07-26T21:00:20","date_gmt":"2019-07-26T21:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=292633"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=292633","title":{"rendered":"\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 Python: \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/cd64d5e9-af9a-46cc-868b-c8873c98adb6.png\" alt=\"image\"\/><\/p>\n<p>  \u042f \u043f\u0438\u0448\u0443 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435 \u043b\u0435\u0442 \u043f\u044f\u0442\u044c, \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0442\u0440\u0438 \u0433\u043e\u0434\u0430 \u2014 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0411\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432 \u044d\u0442\u043e\u043c \u043c\u043e\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430. \u0418 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c, \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0444\u0438\u0447\u0435\u0439 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u0438\u043b\u0438\u0439 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u0441\u044f \u0432 \u043c\u0435\u0441\u0438\u0432\u043e \u0438\u0437 \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430; \u043c\u044b \u0431\u043e\u0440\u0435\u043c\u0441\u044f \u0441 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430\u043c\u0438, \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. <\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 Python-\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0442 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u00ab\u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b\u00bb, \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u00ab\u043f\u0438\u0442\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u0438\u00bb, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u0438\u043c. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u2014 \u043b\u043e\u043d\u0433\u0440\u0438\u0434 \u0441 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0438 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u2014 \u043e\u0431 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u043a Python.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h1>django.setup()<\/h1>\n<p>  \u041d\u0430\u0447\u043d\u0443 \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0434\u0436\u0430\u043d\u0433\u0438\u0441\u0442\u0430\u043c. \u0427\u0430\u0441\u0442\u043e \u043b\u0438 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0432\u043e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438?<\/p>\n<pre><code class=\"python\">import django django.setup() <\/code><\/pre>\n<p>  \u0421 \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 django, \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044f \u0441\u0430\u043c \u0432\u0435\u0431\u0441\u0435\u0440\u0432\u0435\u0440 django. \u042d\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c (<code><b>django.utils.timezone<\/b><\/code>), \u0438 \u0443\u0440\u043b\u043e\u0432 (<code><b>django.urls.reverse<\/b><\/code>), \u0438 \u043c\u043d\u043e\u0433\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"plaintext\">django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. <\/code><\/pre>\n<p>  \u042f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u0438\u0448\u0443 \u044d\u0442\u0438 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438. \u042f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044c \u043a\u043e\u0434\u0430 \u00ab\u043d\u0430 \u0432\u044b\u0431\u0440\u043e\u0441\u00bb; \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <code><b>.py<\/b><\/code>-\u0444\u0430\u0439\u043b, \u043f\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0432 \u043d\u0435\u043c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0432\u0435\u0449\u0438, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0438\u0445 \u2014 \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>  \u0418 \u043c\u0435\u043d\u044f \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 <code><b>django.setup()<\/b><\/code>. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0443\u0441\u0442\u0430\u0435\u0448\u044c \u044d\u0442\u043e \u0432\u0435\u0437\u0434\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c; \u0430, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f django \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 (\u0443 \u043d\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u043e\u043d\u043e\u043b\u0438\u0442), \u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0448\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0444\u0430\u0439\u043b 10, 20, 100 \u0440\u0430\u0437 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 <code><b>django.setup()<\/b><\/code>? \u041d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 django.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u043d\u0435\u043a\u0438\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e API, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043e\u0442 django:<\/p>\n<pre><code class=\"python\">from django.conf import settings   class APIClient:     def __init__(self):         self.api_key = settings.SOME_API_KEY  # \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435: client = APIClient() <\/code><\/pre>\n<p>  \u0430 \u043c\u043e\u0436\u043d\u043e \u2014 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043e\u0442 django:<\/p>\n<pre><code class=\"python\">class APIClient:     def __init__(self, api_key):         self.api_key = api_key  # \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435: client = APIClient(api_key='abc') <\/code><\/pre>\n<p>  \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u043e\u043b\u0435\u0435 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0439, \u0437\u0430\u0442\u043e \u043b\u044e\u0431\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u044d\u0442\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044f \u0432\u0441\u044e \u0434\u0436\u0430\u043d\u0433\u043e\u0432\u0441\u043a\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0435\u0440\u0438\u044e.<\/p>\n<p>  \u0422\u0435\u0441\u0442\u044b \u0442\u043e\u0436\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435. \u041a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a <code><b>django.conf.settings<\/b><\/code>? \u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u043e\u043a\u0430\u0432 \u0438\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c <code><b>@override_settings<\/b><\/code>. \u0410 \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0438 \u043e\u0442 \u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442, \u0442\u043e \u0438 \u043c\u043e\u043a\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0447\u0435\u0433\u043e: \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u2014 \u0438 \u043f\u043e\u0433\u043d\u0430\u043b\u0438.<\/p>\n<h1> \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438<\/h1>\n<p>  \u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043e\u0442 <code><b>django<\/b><\/code> \u2014 \u044d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044f\u0440\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c: \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 python \u2014 \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b python-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 Python-\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0435. \u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043b\u0430\u0433\u0435\u0440\u044f:<\/p>\n<ul>\n<li>\u041f\u0438\u0442\u043e\u043d \u2014 \u0433\u0438\u0431\u043a\u0438\u0439 \u044f\u0437\u044b\u043a. \u041f\u0438\u0448\u0435\u043c \u043a\u0430\u043a \u0445\u043e\u0442\u0438\u043c, \u0437\u0430\u0432\u0438\u0441\u0438\u043c \u043e\u0442 \u0447\u0435\u0433\u043e \u0445\u043e\u0442\u0438\u043c. \u041d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0435\u043c\u0441\u044f \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0438 \u0442.\u0434.\n<\/li>\n<li>\u041f\u0438\u0442\u043e\u043d \u2014 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a. \u0417\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0432\u0435\u0440\u0445 \u0438 \u0432\u043d\u0438\u0437 \u043f\u043e \u0441\u0442\u0435\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0445 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432.\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0430\u0441\u0441\u043d\u044b\u0439 \u0434\u043e\u043a\u043b\u0430\u0434 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">Brandon Rhodes, Dropbox: <a href=\"https:\/\/www.youtube.com\/watch?v=PBQN62oUnN8&amp;t=2s\">Hoist your IO<\/a>.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u043b\u0430\u0434\u0430:<\/p>\n<pre><code class=\"python\">def main():     &quot;&quot;&quot; \u041d\u0430 \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0441 \u0434\u0438\u0441\u043a\u0430 &quot;&quot;&quot;     with open(&quot;\/etc\/hosts&quot;) as file:         for line in parse_hosts(file):             print(line)   def parse_hosts(lines):     &quot;&quot;&quot; \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435 - \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 &quot;&quot;&quot;     for line in lines:         if line.startswith(&quot;#&quot;):             continue     yield line <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>   <\/li>\n<li>\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u043f\u0438\u0442\u043e\u043d\u0430 \u2014 \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0432 \u043d\u043e\u0433\u0443. \u041d\u0443\u0436\u0435\u043d \u0436\u0435\u0441\u0442\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438. \u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0440\u0443\u0441\u0441\u043a\u0438\u0435 \u0440\u0435\u0431\u044f\u0442\u0430 <a href=\"https:\/\/www.youtube.com\/watch?v=b-Ry_4wX9Q8\">dry-python<\/a>. \u0415\u0449\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u0445\u0430\u0440\u0434\u043a\u043e\u0440\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 <a href=\"https:\/\/www.youtube.com\/watch?v=yG3ZdxBb1oo\">Django structure for scale and longevity<\/a>, \u041d\u043e \u0438\u0434\u0435\u044f \u0437\u0434\u0435\u0441\u044c \u0442\u0430 \u0436\u0435.   <\/li>\n<\/ul>\n<p>  \u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0442\u0435\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 python (<a href=\"https:\/\/webdevblog.ru\/vnedrenie-zavisimostej-v-python\/\">\u043f\u0440\u0438\u043c\u0435\u0440 1<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/212217\/\">\u043f\u0440\u0438\u043c\u0435\u0440 2<\/a>), \u043d\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u0441\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043a \u0440\u0435\u043a\u043b\u0430\u043c\u0435 \u0447\u044c\u0438\u0445-\u0442\u043e Dependency Injection \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u043d\u043e\u0432\u044b\u0439 \u0437\u0430\u0445\u043e\u0434 \u043d\u0430 \u0442\u0443 \u0436\u0435 \u0442\u0435\u043c\u0443, \u043d\u043e \u043d\u0430 \u0441\u0435\u0439 \u0440\u0430\u0437 \u044d\u0442\u043e \u0447\u0438\u0441\u0442\u044b\u0439 \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0431\u0435\u0437 \u0440\u0435\u043a\u043b\u0430\u043c\u044b. \u042d\u0442\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043d\u0430\u0439\u0442\u0438 \u0431\u0430\u043b\u0430\u043d\u0441 \u043c\u0435\u0436\u0434\u0443 \u0442\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438 \u0432\u044b\u0448\u0435, \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u00ab\u043f\u0438\u0442\u043e\u043d\u0438\u0447\u043d\u043e\u00bb.<\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043f\u0440\u043e\u0447\u0435\u043b <a href=\"https:\/\/www.amazon.com\/Clean-Architecture-Craftsmans-Software-Structure\/dp\/0134494164\">Clean Architecture<\/a> \u2014 \u0438, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043f\u043e\u043d\u044f\u043b, \u0432 \u0447\u0435\u043c \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0438\u0442\u043e\u043d\u0435 \u0438 \u043a\u0430\u043a \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u042f \u0443\u0432\u0438\u0434\u0435\u043b \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u2014 \u044d\u0442\u043e <b>\u0437\u0430\u0449\u0438\u0442\u0430 \u043a\u043e\u0434\u0430 \u043e\u0442 \u043f\u043e\u043b\u043e\u043c\u043e\u043a \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/b>.<\/p>\n<h1>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>  \u0415\u0441\u0442\u044c API-\u043a\u043b\u0438\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441-\u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u0435\u043b\u044c:<\/p>\n<pre><code class=\"python\"># shortener_client.py  import requests   class ShortenerClient:      def __init__(self, api_key):         self.api_key = api_key      def shorten_link(self, url):         response = requests.post(             url='https:\/\/fstrk.cc\/short',             headers={'Authorization': self.api_key},             json={'url': url}         )         return response.json()['url']  <\/code><\/pre>\n<p>  \u0418 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 API-\u043a\u043b\u0438\u0435\u043d\u0442 \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code class=\"python\"># text_processor.py  import re from shortener_client import ShortenerClient   class TextProcessor:      def __init__(self, text):         self.text = text      def process(self):         changed_text = self.text         links = re.findall(             r'https?:\/\/[^\\r\\n\\t&quot;) ]*',             self.text,             flags=re.MULTILINE         )         api_client = ShortenerClient('abc')         for link in links:             shortened = api_client.shorten_link(link)             changed_text = changed_text.replace(link, shortened)         return changed_text <\/code><\/pre>\n<p>  \u041b\u043e\u0433\u0438\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0436\u0438\u0432\u0435\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u043c \u0444\u0430\u0439\u043b\u0435 (\u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c):<\/p>\n<pre><code class=\"python\"># controller.py  from text_processor import TextProcessor  processor = TextProcessor(&quot;&quot;&quot;     \u0421\u0441\u044b\u043b\u043a\u0430 1: https:\/\/ya.ru  \u0421\u0441\u044b\u043b\u043a\u0430 2: https:\/\/google.com     &quot;&quot;&quot;) print(processor.process()) <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043f\u0430\u0440\u0441\u0438\u0442 \u0442\u0435\u043a\u0441\u0442, \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/58d8aa1d-0024-42c6-918e-05b2d41f126d.png\" alt=\"image\"\/><\/p>\n<h1>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h1>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0442 \u043a\u0430\u043a\u0430\u044f: \u043a\u043b\u0430\u0441\u0441 <code><b>TextProcessor<\/b><\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code><b>ShortenerClient<\/b><\/code> \u2014 \u0438 <b>\u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430<\/b> <code><b>ShortenerClient<\/b><\/code>.<\/p>\n<p>  \u041a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438?<\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <code><b>shorten_link<\/b><\/code> \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code><b>callback_url<\/b><\/code>. \u042d\u0442\u043e\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043f\u043e \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code><b>ShortenerClient.shorten_link<\/b><\/code> \u0441\u0442\u0430\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def shorten_link(self, url, callback_url):     response = requests.post(         url='https:\/\/fstrk.cc\/short',         headers={'Authorization': self.api_key},         json={'url': url,               'callback_on_click': callback_url}     )     return response.json()['url'] <\/code><\/pre>\n<p>  \u0418 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f? \u0410 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"python\">TypeError: shorten_link() missing 1 required positional argument: 'callback_url' <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u0435\u043b\u044c, \u043d\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u0441\u044f \u043d\u0435 \u043e\u043d, \u0430 \u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/13e9dcd5-7866-4c82-b1d0-e56134650b62.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0443 \u0438 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0433\u043e? \u041d\u0443 \u0441\u043b\u043e\u043c\u0430\u043b\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b, \u043c\u044b \u043f\u043e\u0448\u043b\u0438 \u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0435\u0433\u043e. \u0412 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430-\u0442\u043e?<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u043c\u0438\u043d\u0443\u0442\u0443 \u2014 \u043f\u043e\u0448\u043b\u0438 \u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u2014 \u0442\u043e \u044d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438 \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0432\u0441\u0435. \u0415\u0441\u043b\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043c\u0430\u043b\u043e \u043a\u043e\u0434\u0430 \u0438 \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0435 \u0438\u0445 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e (\u044d\u0442\u043e \u0432\u0430\u0448 \u0441\u0430\u0439\u0434-\u043f\u0440\u043e\u0435\u043a\u0442, \u044d\u0442\u043e \u0434\u0432\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0442\u0434) \u2014 \u0442\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430;<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u043b\u044e\u0434\u0438\/\u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/li>\n<\/ul>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 <code><b>ShortenerClient<\/b><\/code>, \u0430 \u0432\u0430\u0448 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u043f\u0438\u0448\u0435\u0442 <code><b>TextProcessor<\/b><\/code>, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0438\u0434\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f: <b>\u043a\u043e\u0434 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u0432\u044b, \u0430 \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c \u0443 \u043d\u0435\u0433\u043e.<\/b> \u041f\u0440\u0438\u0447\u0435\u043c \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c \u0432 \u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0432 \u0436\u0438\u0437\u043d\u0438 \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0438, \u0438 \u0432\u0430\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u0430\u0434\u0438\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0447\u0443\u0436\u043e\u043c \u043a\u043e\u0434\u0435.<\/p>\n<p>  \u0415\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u2014 \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u0430 \u043d\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c; \u0438 \u0432\u0430\u0448\u0430 \u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e\u043b\u043e\u043c\u0430\u0435\u0442 \u043a\u043e\u0434 \u0432 \u043a\u0443\u0447\u0435 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a: \u043a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <code><b>ShortenerClient<\/b><\/code> <b>\u043b\u043e\u043c\u0430\u043b\u0441\u044f \u0441\u0430\u043c <code><b>ShortenerClient<\/b><\/code>, \u0430 \u043d\u0435 \u0435\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438<\/b> (\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e)?<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u043e\u0435:<\/p>\n<ul>\n<li>\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u043e\u0431 \u043e\u0431\u0449\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435. \u042d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0442\u0430\u0442\u044c \u0437\u0430\u043a\u043e\u043d\u043e\u043c.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0443\u0436\u0435 \u0435\u0433\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439.<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/dbb4d320-2683-4f2e-821e-dea621b54b53.png\" alt=\"image\"\/><\/p>\n<h1> \u0417\u0430\u043c\u043e\u0440\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/h1>\n<p>  \u041a\u0430\u043a \u0432 \u043f\u0438\u0442\u043e\u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430? \u042d\u0442\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"python\">from abc import ABC, abstractmethod  class AbstractClient(ABC):      @abstractmethod     def __init__(self, api_key):         pass      @abstractmethod     def shorten_link(self, link):         pass <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u0441\u044f \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u2014 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"python\">class ShortenerClient(AbstractClient):     def __ini__(self, api_key):         self.api_key = api_key  client = ShortenerClient('123')  &gt;&gt;&gt; TypeError: Can't instantiate abstract class ShortenerClient with abstract methods __init__, shorten_link <\/code><\/pre>\n<p>  \u041d\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043d\u043e \u043d\u0435 \u0438\u0445 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443.<\/p>\n<p>  \u041d\u0443\u0436\u0435\u043d \u0432\u0442\u043e\u0440\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u042d\u0442\u043e\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2014 <code><b>mypy<\/b><\/code>. \u041e\u043d \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\"># shortener_client.py  from abc import ABC, abstractmethod  class AbstractClient(ABC):      @abstractmethod     def __init__(self, api_key: str) -&gt; None:         pass      @abstractmethod     def shorten_link(self, link: str) -&gt; str:         pass  class ShortenerClient(AbstractClient):      def __init__(self, api_key: str) -&gt; None:         self.api_key = api_key      def shorten_link(self, link: str, callback_url: str) -&gt; str:         return 'xxx' <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code><b>mypy<\/b><\/code>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438\u0437-\u0437\u0430 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <code><b>callback_url<\/b><\/code>:<\/p>\n<pre><code class=\"plaintext\">mypy shortener_client.py  &gt;&gt;&gt; error: Signature of &quot;shorten_link&quot; incompatible with supertype &quot;AbstractClient&quot; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<h1> \u0418\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h1>\n<p>  \u041e\u0442\u043b\u0430\u0434\u0438\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u043e\u0442 \u0444\u0430\u0439\u043b\u0430 <code><b>shortener_client.py<\/b><\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u2014 \u0432 \u0444\u0430\u0439\u043b \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c <code><b>TextProcessor<\/b><\/code>:<\/p>\n<pre><code class=\"python\"># text_processor.py  import re from abc import ABC, abstractmethod  class AbstractClient(ABC):      @abstractmethod     def __init__(self, api_key: str) -&gt; None:         pass      @abstractmethod     def shorten_link(self, link: str) -&gt; str:         pass  class TextProcessor:      def __init__(self, text, shortener_client: AbstractClient) -&gt; None:         self.text = text         self.shortener_client = shortener_client      def process(self) -&gt; str:         changed_text = self.text          links = re.findall(             r'https?:\/\/[^\\r\\n\\t&quot;) ]*',             self.text,             flags=re.MULTILINE         )          for link in links:             shortened = self.shortener_client.shorten_link(link)             changed_text = changed_text.replace(link, shortened)          return changed_text <\/code><\/pre>\n<p>  \u0418 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438! \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u043b\u0430\u0434\u0435\u0435\u0442 <code><b>TextProcessor<\/b><\/code>, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 <code><b>ShortenerClient<\/b><\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0435\u0433\u043e, \u0430 \u043d\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/33f3c619-63bf-420d-99d0-67bed0dfa628.png\" alt=\"image\"\/><\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u043e\u0432\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0443\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a:<\/p>\n<ul>\n<li><code><b>TextProcessor<\/b><\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442: \u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u0438 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0430. \u042f \u043d\u0435 \u0445\u043e\u0447\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f: \u044d\u0442\u043e \u043d\u0435 \u043c\u043e\u0451 \u0434\u0435\u043b\u043e. \u042f \u0445\u043e\u0447\u0443 \u0434\u0435\u0440\u043d\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code><b>shorten_link<\/b><\/code>, \u0447\u0442\u043e\u0431 \u043e\u043d \u043c\u043d\u0435 \u0432\u0441\u0451 \u0443\u043a\u043e\u0440\u043e\u0442\u0438\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0440\u044b, \u043f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u043c\u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0433\u0440\u0430\u0435\u0442 \u043f\u043e \u043c\u043e\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c. \u0420\u0435\u0448\u0435\u043d\u0438\u044f \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e \u044f, \u0430 \u043d\u0435 \u043e\u043d.<\/li>\n<li><code><b>ShortenerClient<\/b><\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442: \u043f\u043e\u0445\u043e\u0436\u0435, \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0432\u0430\u043a\u0443\u0443\u043c\u0435, \u0438 \u043e\u0442 \u043c\u0435\u043d\u044f \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u041f\u043e\u0439\u0434\u0443 \u0441\u043f\u0440\u043e\u0448\u0443 \u0443 <code><b>TextProcessor<\/b><\/code>, \u0447\u0435\u043c\u0443 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043b\u043e\u043c\u0430\u0442\u044c\u0441\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<h1>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439<\/h1>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0441\u044b\u043b\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0435 \u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445, \u0430 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u00ab\u043d\u0430\u0434\u00bb \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u0432\u044b\u0448\u0435 \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/a81ef19a-45aa-4b23-b93a-e9a6b9094670.png\" alt=\"image\"\/><\/p>\n<h1> \u0423\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/h1>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442 <code><b>ShortenerClient<\/b><\/code>, \u0442\u043e \u043a\u0442\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0435\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430? \u042d\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u2014 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <code><b>controller.py<\/b><\/code>.<\/p>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u044d\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, Dependency Injection \u00ab\u0432 \u043b\u043e\u0431\u00bb. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439. \u041f\u0440\u043e\u0444\u0438\u0442.<\/p>\n<pre><code class=\"python\"># controller.py  import TextProcessor import ShortenerClient  processor = TextProcessor(     text='\u0421\u0441\u044b\u043b\u043a\u0430 1: https:\/\/ya.ru  \u0421\u0441\u044b\u043b\u043a\u0430 2: https:\/\/google.com',     shortener_client=ShortenerClient(api_key='123') )  print(processor.process()) <\/code><\/pre>\n<p>  <\/p>\n<h1> \u041f\u0438\u0442\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<\/h1>\n<p>  \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u00ab\u043f\u0438\u0442\u043e\u043d\u0438\u0447\u043d\u044b\u0439\u00bb \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u044d\u0442\u043e Dependency Injection \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Raymond Hettinger \u0432 \u0441\u0432\u043e\u0435\u043c \u0434\u043e\u043a\u043b\u0430\u0434\u0435 Super considered Super<\/b><\/p>\n<div class=\"spoiler_text\">\n<div class=\"oembed\"><a href=\"https:\/\/www.youtube.com\/watch?v=EiOglTERPEo\">https:\/\/www.youtube.com\/watch?v=EiOglTERPEo<\/a><\/div>\n<p>  <\/div>\n<\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u0434 \u044d\u0442\u043e\u0442 \u0441\u0442\u0438\u043b\u044c, \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c <code><b>TextProcessor<\/b><\/code>, \u0441\u0434\u0435\u043b\u0430\u0432 \u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u043c:<\/p>\n<pre><code class=\"python\"># text_processor.py  class TextProcessor:      def __init__(self, text: str) -&gt; None:         self.text = text         self.shortener_client: AbstractClient = self.get_shortener_client()      def get_shortener_client(self) -&gt; AbstractClient:         &quot;&quot;&quot; \u041c\u0435\u0442\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u0445 &quot;&quot;&quot;         raise NotImplementedError  <\/code><\/pre>\n<p>  \u0418 \u0437\u0430\u0442\u0435\u043c, \u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"python\"># controller.py  import TextProcessor import ShortenerClient  class ProcessorWithClient(TextProcessor):     &quot;&quot;&quot; \u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0438\u043d\u0434\u0436\u0435\u043a\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0443\u043a\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u0435\u043b\u044f &quot;&quot;&quot;  def get_shortener_client(self) -&gt; ShortenerClient:     return ShortenerClient(api_key='abc')  processor = ProcessorWithClient(     text='\u0421\u0441\u044b\u043b\u043a\u0430 1: https:\/\/ya.ru  \u0421\u0441\u044b\u043b\u043a\u0430 2: https:\/\/google.com' )  print(processor.process()) <\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445:<\/p>\n<ul>\n<li>\u0412 Django \u043c\u044b \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u0441\u044f. \u041c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b Class-based \u0432\u044c\u044e\u0445, \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0444\u043e\u0440\u043c; \u0438\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0438\u043d\u0434\u0436\u0435\u043a\u0442\u0438\u043c \u0441\u0432\u043e\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0443\u0436\u0435 \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430.<\/li>\n<li>\u0412 DRF \u2014 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435. \u041c\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u0432\u044c\u044e\u0441\u0435\u0442\u044b, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b, \u043f\u0435\u0440\u043c\u0438\u0448\u0435\u043d\u044b.<\/li>\n<li>\u0418 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u0430\u0441\u0441\u0430.<\/li>\n<\/ul>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u0435\u0435 \u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u0435\u0435, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043e\u0432\u044c\u0435\u043c \u0435\u0433\u043e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043b\u0438 \u044d\u0442\u0430 \u043a\u0440\u0430\u0441\u043e\u0442\u0430.<\/p>\n<h1> \u0420\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043f\u0438\u0442\u043e\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430<\/h1>\n<p>  \u0412 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 <code><b>TextProcessor<\/b><\/code>, \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0430 \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430 <code><b>TextPipeline<\/b><\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0448\u043b\u0435\u0442 \u0435\u0433\u043e \u043d\u0430 \u043f\u043e\u0447\u0442\u0443:<\/p>\n<pre><code class=\"python\">class TextPipeline:      def __init__(self, text, email):         self.text_processor = TextProcessor(text)         self.mailer = Mailer(email)      def process_and_mail(self) -&gt; None:         processed_text = self.text_processor.process()         self.mailer.send_text(text=processed_text) <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code><b>TextPipeline<\/b><\/code> \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u0447\u0442\u043e \u0438 \u0440\u0430\u043d\u044c\u0448\u0435:<\/p>\n<ul>\n<li>\u043a\u043b\u0430\u0441\u0441 <code><b>TextPipeline<\/b><\/code> \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432;<\/li>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c;<\/li>\n<li>\u043d\u0435\u043a\u0438\u0439 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c.<\/li>\n<\/ul>\n<p>  \u0421\u0445\u0435\u043c\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/35f207fa-3ad7-4779-92c3-ae8f63401b8e.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u043e \u043a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u043e\u0434 \u0441\u0431\u043e\u0440\u043a\u0438 \u044d\u0442\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439?<\/p>\n<pre><code class=\"python\">import TextProcessor import ShortenerClient import Mailer import TextPipeline  class ProcessorWithClient(TextProcessor):     def get_shortener_client(self) -&gt; ShortenerClient:         return ShortenerClient(api_key='123')  class PipelineWithDependencies(TextPipeline):     def get_text_processor(self, text: str) -&gt; ProcessorWithClient:         return ProcessorWithClient(text)      def get_mailer(self, email: str) -&gt; Mailer:         return Mailer(email)  pipeline = PipelineWithDependencies(     email='abc@def.com',     text='\u0421\u0441\u044b\u043b\u043a\u0430 1: https:\/\/ya.ru  \u0421\u0441\u044b\u043b\u043a\u0430 2: https:\/\/google.com' )  pipeline.process_and_mail() <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438? \u041c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code><b>TextProcessor<\/b><\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e <code><b>ShortenerClient<\/b><\/code>, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c <code><b>TextPipeline<\/b><\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043d\u0430\u0448 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 <code><b>TextProcessor<\/b><\/code> (\u0430 \u0442\u0430\u043a\u0436\u0435 <code><b>Mailer<\/b><\/code>). \u0423 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0423\u0436\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0432\u0430\u0442\u043e.<\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u0432\u0441\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c? <b>\u0414\u0430 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432.<\/b><\/p>\n<ul>\n<li>\u0412\u0441\u0435 \u0443\u0440\u043e\u0432\u043d\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0447\u0435\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b, \u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Django \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code><b>FormField<\/b><\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b <code><b>Form<\/b><\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0432 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 <code><b>View<\/b><\/code>. \u0412\u0441\u0451. \u0422\u0440\u0438 \u0443\u0440\u043e\u0432\u043d\u044f.<\/li>\n<li>\u041a\u0430\u0436\u0434\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0441\u043b\u0443\u0436\u0438\u0442 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435. \u042d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0447\u0435\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430.<\/li>\n<li>\u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u043e, \u043a\u0430\u043a \u0438 \u0447\u0442\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c; \u0447\u0442\u043e \u0438 \u0441 \u0447\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/li>\n<\/ul>\n<p>  \u041c\u043e\u0436\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u0442\u0430\u043a \u0436\u0435 \u0447\u0435\u0442\u043a\u043e \u0438 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438 \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443? \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u2014 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0443\u0440\u043e\u0432\u043d\u0435\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442? \u042f \u2014 \u043d\u0435\u0442. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e\u0434\u0445\u043e\u0434 \u0420\u0430\u0439\u043c\u043e\u043d\u0434\u0430 \u0425\u0435\u0442\u0442\u0438\u043d\u0433\u0435\u0440\u0430 \u043d\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<h1> \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u043e\u0434\u0445\u043e\u0434\u0443 \u00ab\u0432 \u043b\u043e\u0431\u00bb<\/h1>\n<p>  \u041d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u044f\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0449\u0435 \u2014 \u0438 \u0435\u0433\u043e \u043b\u0435\u0433\u0447\u0435 \u043c\u0435\u043d\u044f\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430.<\/p>\n<pre><code class=\"python\">import TextProcessor import ShortenerClient import Mailer import TextPipeline  pipeline = TextPipeline(     text_processor=TextProcessor(         text='\u0421\u0441\u044b\u043b\u043a\u0430 1: https:\/\/ya.ru  \u0421\u0441\u044b\u043b\u043a\u0430 2: https:\/\/google.com',         shortener_client=ShortenerClient(api_key='abc')     ),     mailer=Mailer('abc@def.com') )  pipeline.process_and_mail() <\/code><\/pre>\n<p>  \u041d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442, \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u041d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0443\u0447\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0438\u0445 \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0437\u0430\u0445\u043e\u0434.<\/p>\n<h1> \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432<\/h1>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u043d\u0443\u0436\u043d\u044b\u0445 \u043d\u0430\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0418 \u043f\u0443\u0441\u0442\u044c \u044d\u0442\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043e\u0441\u0442\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0430\u0440\u044e. <\/p>\n<p>  \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code><b>INSTANCE_DICT<\/b><\/code>:<\/p>\n<pre><code class=\"python\"># text_processor.py  import INSTANCE_DICT   class TextProcessor(AbstractTextProcessor):      def __init__(self, text) -&gt; None:         self.text = text      def process(self) -&gt; str:         shortener_client: AbstractClient = INSTANCE_DICT['Shortener']         # ... \u043f\u0440\u0435\u0436\u043d\u0438\u0439 \u043a\u043e\u0434  <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\"> # text_pipeline.py  import INSTANCE_DICT   class TextPipeline:      def __init__(self) -&gt; None:         self.text_processor: AbstractTextProcessor = INSTANCE_DICT[             'TextProcessor']         self.mailer: AbstractMailer = INSTANCE_DICT['Mailer']      def process_and_mail(self) -&gt; None:         processed_text = self.text_processor.process()         self.mailer.send_text(text=processed_text) <\/code><\/pre>\n<p>  \u0422\u0440\u044e\u043a \u2014 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b <b>\u043f\u043e\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043d\u0430\u0448\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a \u043d\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u044f\u0442\u0441\u044f<\/b>. \u042d\u0442\u043e \u043c\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0432 <code><b>controller.py<\/b><\/code>:<\/p>\n<pre><code class=\"python\"># controller.py  import INSTANCE_DICT import TextProcessor import ShortenerClient import Mailer import TextPipeline  INSTANCE_DICT['Shortener'] = ShortenerClient('123') INSTANCE_DICT['Mailer'] = Mailer('abc@def.com') INSTANCE_DICT['TextProcessor'] = TextProcessor(text='\u0412\u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0430: https:\/\/ya.ru')  pipeline = TextPipeline() pipeline.process_and_mail() <\/code><\/pre>\n<p>  \u041f\u043b\u044e\u0441\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c:<\/p>\n<ul>\n<li>\u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u043a\u0430\u043f\u043e\u0442\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u0438 \u043b\u0438\u0448\u043d\u0438\u0445 DI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432;<\/li>\n<li>\u043f\u043b\u043e\u0441\u043a\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e;<\/li>\n<li>\u0432\u0441\u0435 \u0431\u043e\u043d\u0443\u0441\u044b DI: \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u0437\u0430\u0449\u0438\u0442\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u043e\u043b\u043e\u043c\u043e\u043a \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/li>\n<\/ul>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e <code><b>INSTANCE_DICT<\/b><\/code>, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u0438\u043c-\u043d\u0438\u0431\u0443\u0434\u044c DI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c; \u043d\u043e \u0441\u0443\u0442\u044c \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f. \u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u0430\u0441\u0442 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u043c\u0438; \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u043e\u0432 \u0438\u043b\u0438 \u043f\u0430\u0447\u043a\u0430\u043c\u0438, \u043a\u0430\u043a \u0444\u0430\u0431\u0440\u0438\u043a\u0430; \u043d\u043e \u0438\u0434\u0435\u044f \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435.<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e, \u0438 \u044f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0432\u044b\u0431\u0435\u0440\u0443 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a.<\/p>\n<p>  \u0410, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0441\u0451 \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u0435\u0435, \u0438 \u043f\u0440\u043e\u0449\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e: \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u0438 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432.<\/p>\n<p>  \u0410 \u043a\u0430\u043a\u043e\u0439 \u0443 \u0432\u0430\u0441 \u043e\u043f\u044b\u0442 \u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 \u043f\u0438\u0442\u043e\u043d\u0435? \u0418 \u0432\u043e\u043e\u0431\u0449\u0435 \u2014 \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e, \u0438\u043b\u0438 \u044f \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0438\u0437 \u0432\u043e\u0437\u0434\u0443\u0445\u0430?<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/461511\/\"> https:\/\/habr.com\/ru\/post\/461511\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"http:\/\/ftcdn.pw\/cd64d5e9-af9a-46cc-868b-c8873c98adb6.png\" alt=\"image\"\/><\/p>\n<p>  \u042f \u043f\u0438\u0448\u0443 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435 \u043b\u0435\u0442 \u043f\u044f\u0442\u044c, \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0442\u0440\u0438 \u0433\u043e\u0434\u0430 \u2014 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u0411\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432 \u044d\u0442\u043e\u043c \u043c\u043e\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430. \u0418 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c, \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0444\u0438\u0447\u0435\u0439 \u0443 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u0438\u043b\u0438\u0439 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u0441\u044f \u0432 \u043c\u0435\u0441\u0438\u0432\u043e \u0438\u0437 \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430; \u043c\u044b \u0431\u043e\u0440\u0435\u043c\u0441\u044f \u0441 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430\u043c\u0438, \u0432\u0437\u0430\u0438\u043c\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. <\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 Python-\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0442 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u00ab\u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b\u00bb, \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u00ab\u043f\u0438\u0442\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u0438\u00bb, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u0438\u043c. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u2014 \u043b\u043e\u043d\u0433\u0440\u0438\u0434 \u0441 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0438 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u2014 \u043e\u0431 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u043a Python.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-292633","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=292633"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292633\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}