-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move away from setup.py (#1623)
- Loading branch information
1 parent
241db14
commit 7b04d01
Showing
15 changed files
with
137 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import sys | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-p", "--path", help="Path to the project source code.", type=str) | ||
if len(sys.argv) == 1: | ||
parser.print_help(sys.stderr) | ||
sys.exit(1) | ||
args = parser.parse_args() | ||
|
||
header = ( | ||
"# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" | ||
"#\n" | ||
"# *** DO NOT EDIT THIS FILE ***\n" | ||
"#\n" | ||
"# 1) Modify slack_sdk/web/client.py\n" | ||
"# 2) Run `python scripts/codegen.py`\n" | ||
"# 3) Run `black slack_sdk/`\n" | ||
"#\n" | ||
"# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" | ||
"\n" | ||
) | ||
|
||
with open(f"{args.path}/slack_sdk/web/client.py", "r") as original: | ||
source = original.read() | ||
import re | ||
|
||
async_source = header + source | ||
async_source = re.sub(" def ", " async def ", async_source) | ||
async_source = re.sub("from asyncio import Future\n", "", async_source) | ||
async_source = re.sub(r"return self.api_call\(", "return await self.api_call(", async_source) | ||
async_source = re.sub("-> SlackResponse", "-> AsyncSlackResponse", async_source) | ||
async_source = re.sub( | ||
"from .base_client import BaseClient, SlackResponse", | ||
"from .async_base_client import AsyncBaseClient, AsyncSlackResponse", | ||
async_source, | ||
) | ||
# from slack_sdk import WebClient | ||
async_source = re.sub( | ||
r"class WebClient\(BaseClient\):", | ||
"class AsyncWebClient(AsyncBaseClient):", | ||
async_source, | ||
) | ||
async_source = re.sub( | ||
"from slack_sdk import WebClient", | ||
"from slack_sdk.web.async_client import AsyncWebClient", | ||
async_source, | ||
) | ||
async_source = re.sub(r"= WebClient\(", "= AsyncWebClient(", async_source) | ||
async_source = re.sub( | ||
r" self.files_getUploadURLExternal\(", | ||
" await self.files_getUploadURLExternal(", | ||
async_source, | ||
) | ||
async_source = re.sub( | ||
r" self._upload_file\(", | ||
" await self._upload_file(", | ||
async_source, | ||
) | ||
async_source = re.sub( | ||
r" self.files_completeUploadExternal\(", | ||
" await self.files_completeUploadExternal(", | ||
async_source, | ||
) | ||
async_source = re.sub( | ||
r" self.files_info\(", | ||
" await self.files_info(", | ||
async_source, | ||
) | ||
async_source = re.sub( | ||
"_attach_full_file_metadata", | ||
"_attach_full_file_metadata_async", | ||
async_source, | ||
) | ||
async_source = re.sub( | ||
r" _attach_full_file_metadata_async\(", | ||
" await _attach_full_file_metadata_async(", | ||
async_source, | ||
) | ||
with open(f"{args.path}/slack_sdk/web/async_client.py", "w") as output: | ||
output.write(async_source) | ||
|
||
legacy_source = header + "from asyncio import Future\n" + source | ||
legacy_source = re.sub("-> SlackResponse", "-> Union[Future, SlackResponse]", legacy_source) | ||
legacy_source = re.sub( | ||
"from .base_client import BaseClient, SlackResponse", | ||
"from .legacy_base_client import LegacyBaseClient, SlackResponse", | ||
legacy_source, | ||
) | ||
legacy_source = re.sub( | ||
r"class WebClient\(BaseClient\):", | ||
"class LegacyWebClient(LegacyBaseClient):", | ||
legacy_source, | ||
) | ||
legacy_source = re.sub( | ||
"from slack_sdk import WebClient", | ||
"from slack_sdk.web.legacy_client import LegacyWebClient", | ||
legacy_source, | ||
) | ||
legacy_source = re.sub(r"= WebClient\(", "= LegacyWebClient(", legacy_source) | ||
with open(f"{args.path}/slack_sdk/web/legacy_client.py", "w") as output: | ||
output.write(legacy_source) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.