(self)
| 1060 | return self.module.__name__.split(".")[-1] |
| 1061 | |
| 1062 | def write(self): |
| 1063 | with DirectoryWalkerGuard(self.short_name + self.stub_suffix): |
| 1064 | with open("__init__.pyi", "w", encoding="utf-8") as init_pyi: |
| 1065 | init_pyi.write("\n".join(self.to_lines())) |
| 1066 | for m in self.submodules: |
| 1067 | m.write() |
| 1068 | |
| 1069 | if self.write_setup_py: |
| 1070 | with open("setup.py", "w", encoding="utf-8") as setuppy: |
| 1071 | setuppy.write( |
| 1072 | """from setuptools import setup |
| 1073 | import os |
| 1074 | |
| 1075 | |
| 1076 | def find_stubs(package): |
| 1077 | stubs = [] |
| 1078 | for root, dirs, files in os.walk(package): |
| 1079 | for file in files: |
| 1080 | path = os.path.join(root, file).replace(package + os.sep, '', 1) |
| 1081 | stubs.append(path) |
| 1082 | return dict(package=stubs) |
| 1083 | |
| 1084 | |
| 1085 | setup( |
| 1086 | name='{package_name}-stubs', |
| 1087 | maintainer="{package_name} Developers", |
| 1088 | maintainer_email="example@python.org", |
| 1089 | description="PEP 561 type stubs for {package_name}", |
| 1090 | version='1.0', |
| 1091 | packages=['{package_name}-stubs'], |
| 1092 | # PEP 561 requires these |
| 1093 | install_requires=['{package_name}'], |
| 1094 | package_data=find_stubs('{package_name}-stubs'), |
| 1095 | )""".format( |
| 1096 | package_name=self.short_name |
| 1097 | ) |
| 1098 | ) |
| 1099 | |
| 1100 | |
| 1101 | def main(args=None): |
no test coverage detected