MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / create_class

Method create_class

scripts/openapi.py:2830–3006  ·  view source on GitHub ↗
(
        self,
        github_path: str,
        spec_file: str,
        index_filename: str,
        class_name: str,
        parent_name: str,
        docs_url: str,
        schemas: list[str],
        dry_run: bool,
        tests: bool,
        handle_new_schemas: HandleNewSchemas,
    )

Source from the content-addressed store, hash-verified

2828 return schemas_suggested > 0
2829
2830 def create_class(
2831 self,
2832 github_path: str,
2833 spec_file: str,
2834 index_filename: str,
2835 class_name: str,
2836 parent_name: str,
2837 docs_url: str,
2838 schemas: list[str],
2839 dry_run: bool,
2840 tests: bool,
2841 handle_new_schemas: HandleNewSchemas,
2842 ) -> bool:
2843 with open(index_filename) as r:
2844 index = json.load(r)
2845
2846 github_parent_path = str(Path(github_path).parent)
2847 clazz = GithubClass.from_class_name(class_name, github_parent_path=github_parent_path)
2848 parent_class = GithubClass.from_class_name(parent_name, index)
2849 print(f"Creating class {clazz.full_class_name} with parent {parent_class.full_class_name} in {clazz.filename}")
2850 if os.path.exists(clazz.filename):
2851 raise ValueError(f"File exists already: {clazz.filename}")
2852 if tests and os.path.exists(clazz.test_filename):
2853 raise ValueError(f"File exists already: {clazz.test_filename}")
2854
2855 source = (
2856 f"############################ Copyrights and license ############################\n"
2857 f"# #\n"
2858 f"# #\n"
2859 f"# This file is part of PyGithub. #\n"
2860 f"# http://pygithub.readthedocs.io/ #\n"
2861 f"# #\n"
2862 f"# PyGithub is free software: you can redistribute it and/or modify it under #\n"
2863 f"# the terms of the GNU Lesser General Public License as published by the Free #\n"
2864 f"# Software Foundation, either version 3 of the License, or (at your option) #\n"
2865 f"# any later version. #\n"
2866 f"# #\n"
2867 f"# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #\n"
2868 f"# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #\n"
2869 f"# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #\n"
2870 f"# details. #\n"
2871 f"# #\n"
2872 f"# You should have received a copy of the GNU Lesser General Public License #\n"
2873 f"# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #\n"
2874 f"# #\n"
2875 f"################################################################################\n"
2876 f"\n"
2877 f"from __future__ import annotations\n"
2878 f"\n"
2879 f"from typing import Any, TYPE_CHECKING\n"
2880 f"\n"
2881 f"from {parent_class.package}.{parent_class.module} import {parent_class.name}\n"
2882 f"from github.GithubObject import Attribute, NotSet\n"
2883 f"\n"
2884 f"if TYPE_CHECKING:\n"
2885 f" from {parent_class.package}.{parent_class.module} import {parent_class.name}\n"
2886 f"\n"
2887 f"\n"

Callers 2

mainMethod · 0.95

Calls 7

write_codeMethod · 0.95
indexMethod · 0.95
applyMethod · 0.95
PathClass · 0.85
loadMethod · 0.80
from_class_nameMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected