# xy_web_settings **Repository Path**: xy-opensource/xy_web_settings ## Basic Information - **Project Name**: xy_web_settings - **Description**: xy-web-service 服务设置模块 - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-12 - **Last Updated**: 2024-11-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xy_web_settings | [简体中文](./README.md) | [繁體中文](readme/README.zh-hant.md) | [English](readme/README.en.md) | | ----------- | -------------|---------------------------------------| ## 说明 xy-web-service服务设置模块. ## 源码仓库 | [Github](https://github.com/xy-web-service/xy_web_settings.git) | [Gitee](https://gitee.com/xy-opensource/xy_web_settings.git) | [GitCode](https://gitcode.com/xy-opensource/xy_web_settings.git) | | ----------- | -------------|---------------------------------------| ## 安装 ```bash # bash pip install xy_web_settings ``` ## 使用 ```python # main.py from xy_work.Settings.Section.Project import Project as xyProject class Project(xyProject): def get_name(self) -> str | None: return "xy_web_project" from xy_work.Settings.Section.Runner import Runner as xyWorkRunner class Runner(xyWorkRunner): def get_name(self) -> str | None: return "xy_web_runner" from pathlib import Path from xy_web_settings.Settings import Settings as xySettings class Settings(xySettings): project: Project | None runner: Runner | None def reload(self, settings_cfg_path: Path): super().reload(settings_cfg_path) self.project = self.make_section(Project) self.runner = self.make_section(Runner) if __name__ == "__main__": settings = Settings() settings.reload(Path("./xy_web.toml")) print(f"project ===> {settings.project}") print(f"project.name ===> {settings.project.name}") print(f"project.identifier ===> {settings.project.identifier}") ``` ```toml # xy_web.toml # ######################## xy_web_work配置 ########################### # 默认配置文件位置为 当前工作目录下的 config/xy_web.toml # ######################## xy_web_work项目配置 ########################### [xy_web_project] # 项目名称, 仅支持英文 name = "xy_web_demo" # 项目标识 identifier = "d842087be5204c85a8bef764815348b5" # 项目名称, 支持中英文 verbose_name = "xy-web-service Demo" # 项目说明, 支持中英文 description = "xy-web-service Demo" # 项目路径 path = "/home/helios/workspace/beachstudio/development/xy_web_demo" # ######################## xy_web_work运行配置 ########################### [xy_web_runner] # 服务源码目录自动添加到sys.path # 默认 当前工作目录下的 source/Runner path = "../source/Runner" # 服务入口类,根据上文的path寻找对应的类初始化即为启动,字符串,若包含模块使用module.class根据importlib引入 # 默认 Runner.Runner runner = "Runner.Runner" ``` ```bash # bash python main.py # project ===> {'path': '/home/helios/workspace/beachstudio/development/xy_web_demo', 'name': 'xy_web_demo', 'verbose_name': 'xy-web-service Demo', 'identifier': 'd842087be5204c85a8bef764815348b5', 'description': 'xy-web-service Demo'} # project.name ===> xy_web_demo # project.identifier ===> d842087be5204c85a8bef764815348b5 ``` ## 许可证 xy_web_settings 根据 <木兰宽松许可证, 第2版> 获得许可。有关详细信息,请参阅 [LICENSE](LICENSE) 文件。 ## 捐赠 如果小伙伴们觉得这些工具还不错的话,能否请咱喝一杯咖啡呢? ![Pay-Total](./readme/Pay-Total.png) ## 联系方式 ``` 微信: yuyangiit 邮箱: yuyangit.0515@qq.com ```