Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions autorest/codegen/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ def serialize(self, code_model: CodeModel) -> None:
)

# if there was a patch file before, we keep it
if self._autorestapi.read_file(namespace_path / "_patch.py"):
self._autorestapi.write_file(
namespace_path / Path("_patch.py"),
self._autorestapi.read_file(namespace_path / "_patch.py")
)
self._keep_patch_file(namespace_path / Path("_patch.py"))
self._keep_patch_file(namespace_path / Path("aio") / Path("_patch.py"))

self._serialize_and_write_top_level_folder(code_model=code_model, env=env, namespace_path=namespace_path)

Expand All @@ -72,6 +69,12 @@ def serialize(self, code_model: CodeModel) -> None:
self._serialize_and_write_models_folder(code_model=code_model, env=env, namespace_path=namespace_path)



def _keep_patch_file(self, path_file: Path):
if self._autorestapi.read_file(path_file):
self._autorestapi.write_file(path_file, self._autorestapi.read_file(path_file))


def _serialize_and_write_models_folder(self, code_model: CodeModel, env: Environment, namespace_path: Path) -> None:
# Write the models folder
models_path = namespace_path / Path("models")
Expand Down
2 changes: 0 additions & 2 deletions autorest/codegen/templates/init.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ from ._version import VERSION
__version__ = VERSION
{% endif %}
__all__ = ['{{ code_model.class_name }}']
{% if not async_mode %}

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._auto_rest_head_test_service import AutoRestHeadTestService
__all__ = ['AutoRestHeadTestService']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._auto_rest_head_test_service import AutoRestHeadTestService
__all__ = ['AutoRestHeadTestService']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._polling_paging_example import PollingPagingExample
__all__ = ['PollingPagingExample']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._auto_rest_head_test_service import AutoRestHeadTestService
__all__ = ['AutoRestHeadTestService']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._multiapi_service_client import MultiapiServiceClient
__all__ = ['MultiapiServiceClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._multiapi_service_client import MultiapiServiceClient
__all__ = ['MultiapiServiceClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._multiapi_service_client import MultiapiServiceClient
__all__ = ['MultiapiServiceClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_duration_test_service import AutoRestDurationTestService

__all__ = ["AutoRestDurationTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_parameter_grouping_test_service import AutoRestParameterGroupingTestService

__all__ = ["AutoRestParameterGroupingTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_report_service_for_azure import AutoRestReportServiceForAzure

__all__ = ["AutoRestReportServiceForAzure"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_azure_special_parameters_test_client import AutoRestAzureSpecialParametersTestClient

__all__ = ["AutoRestAzureSpecialParametersTestClient"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient

__all__ = ["AutoRestParameterizedHostTestClient"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

from ._auto_rest_paging_test_service import AutoRestPagingTestService
__all__ = ['AutoRestPagingTestService']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_parameterized_host_test_paging_client import AutoRestParameterizedHostTestPagingClient

__all__ = ["AutoRestParameterizedHostTestPagingClient"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_head_test_service import AutoRestHeadTestService

__all__ = ["AutoRestHeadTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_head_exception_test_service import AutoRestHeadExceptionTestService

__all__ = ["AutoRestHeadExceptionTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_head_test_service import AutoRestHeadTestService

__all__ = ["AutoRestHeadTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_long_running_operation_test_service import AutoRestLongRunningOperationTestService

__all__ = ["AutoRestLongRunningOperationTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._lro_with_paramaterized_endpoints import LROWithParamaterizedEndpoints

__all__ = ["LROWithParamaterizedEndpoints"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_paging_test_service import AutoRestPagingTestService

__all__ = ["AutoRestPagingTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._storage_management_client import StorageManagementClient

__all__ = ["StorageManagementClient"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._microsoft_azure_test_url import MicrosoftAzureTestUrl

__all__ = ["MicrosoftAzureTestUrl"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_duration_test_service import AutoRestDurationTestService

__all__ = ["AutoRestDurationTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_parameter_grouping_test_service import AutoRestParameterGroupingTestService

__all__ = ["AutoRestParameterGroupingTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_report_service_for_azure import AutoRestReportServiceForAzure

__all__ = ["AutoRestReportServiceForAzure"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_azure_special_parameters_test_client import AutoRestAzureSpecialParametersTestClient

__all__ = ["AutoRestAzureSpecialParametersTestClient"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient

__all__ = ["AutoRestParameterizedHostTestClient"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_parameterized_host_test_paging_client import AutoRestParameterizedHostTestPagingClient

__all__ = ["AutoRestParameterizedHostTestPagingClient"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_head_exception_test_service import AutoRestHeadExceptionTestService

__all__ = ["AutoRestHeadExceptionTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_head_test_service import AutoRestHeadTestService

__all__ = ["AutoRestHeadTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_long_running_operation_test_service import AutoRestLongRunningOperationTestService

__all__ = ["AutoRestLongRunningOperationTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._lro_with_paramaterized_endpoints import LROWithParamaterizedEndpoints

__all__ = ["LROWithParamaterizedEndpoints"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
from ._auto_rest_paging_test_service import AutoRestPagingTestService

__all__ = ["AutoRestPagingTestService"]

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Loading