From 2a02faa385069ac3a93194296c326dc31228c47b Mon Sep 17 00:00:00 2001 From: shengchenyang <15538221825@163.com> Date: Tue, 19 Mar 2024 10:41:45 +0800 Subject: [PATCH] chore: del some project templates --- ayugespidertools/commands/startproject.py | 29 ------------------- .../scraper/pipelines/oracle/__init__.py | 1 - ayugespidertools/templates/project/README.md | 1 - .../templates/project/module/run.py.tmpl | 4 --- .../templates/project/module/run.sh.tmpl | 4 --- .../templates/project/requirements.txt | 0 6 files changed, 39 deletions(-) delete mode 100644 ayugespidertools/templates/project/README.md delete mode 100644 ayugespidertools/templates/project/module/run.py.tmpl delete mode 100644 ayugespidertools/templates/project/module/run.sh.tmpl delete mode 100644 ayugespidertools/templates/project/requirements.txt diff --git a/ayugespidertools/commands/startproject.py b/ayugespidertools/commands/startproject.py index b0a77f8..e0049a9 100644 --- a/ayugespidertools/commands/startproject.py +++ b/ayugespidertools/commands/startproject.py @@ -7,19 +7,14 @@ from scrapy.utils.template import render_templatefile, string_camelcase import ayugespidertools -from ayugespidertools.common.params import Param # 添加需要的自定义配置文件 TEMPLATES_TO_RENDER = ( - ("README.md",), - ("requirements.txt",), ("scrapy.cfg",), ("${project_name}", "settings.py.tmpl"), ("${project_name}", "items.py.tmpl"), ("${project_name}", "pipelines.py.tmpl"), ("${project_name}", "middlewares.py.tmpl"), - # 添加 run.py 总运行文件 - ("${project_name}", "run.py.tmpl"), ) IGNORE = ignore_patterns("*.pyc", "__pycache__", ".svn") @@ -33,10 +28,8 @@ def run(self, args, opts): project_name = args[0] if len(args) == 2: - _has_project_dir_args = True project_dir = Path(args[1]) else: - _has_project_dir_args = False project_dir = Path(args[0]) if (project_dir / "scrapy.cfg").exists(): @@ -64,28 +57,6 @@ def run(self, args, opts): ProjectName=string_camelcase(project_name), ) - # 添加执行 shell 文件 run.sh 的生成 - if _has_project_dir_args: - run_shell_path = f"{project_dir}/{project_name}/run.sh.tmpl" - else: - run_shell_path = f"{project_dir}/{project_dir}/run.sh.tmpl" - run_shell_abspath = Path(project_dir).resolve() - # 如果是 windows 环境的话,就不生成 shell 文件了,没啥必要 - if Param.IS_WINDOWS: - print("Info: The run.sh file is no longer generated under windows.") - del_file = Path(run_shell_path) - if Path.exists(del_file): - del_file.unlink() - - else: - render_templatefile( - run_shell_path, - project_startup_dir=run_shell_abspath, - ProjectStartupDir=string_camelcase(str(run_shell_abspath)), - project_name=project_name, - ProjectName=string_camelcase(project_name), - ) - print( f"New Scrapy project '{project_name}', using template directory " f"'{self.templates_dir}', created in:" diff --git a/ayugespidertools/scraper/pipelines/oracle/__init__.py b/ayugespidertools/scraper/pipelines/oracle/__init__.py index de61dbd..1bb230f 100644 --- a/ayugespidertools/scraper/pipelines/oracle/__init__.py +++ b/ayugespidertools/scraper/pipelines/oracle/__init__.py @@ -38,7 +38,6 @@ def insert_item(self, alter_item: "AlterItem") -> None: return sql = self._get_sql_by_item(table=alter_item.table.name, item=new_item) - # no err handing self.cursor.execute(sql, tuple(new_item.values())) self.conn.commit() diff --git a/ayugespidertools/templates/project/README.md b/ayugespidertools/templates/project/README.md deleted file mode 100644 index 611383e..0000000 --- a/ayugespidertools/templates/project/README.md +++ /dev/null @@ -1 +0,0 @@ -# ${project_name} 项目说明文档 diff --git a/ayugespidertools/templates/project/module/run.py.tmpl b/ayugespidertools/templates/project/module/run.py.tmpl deleted file mode 100644 index fad238b..0000000 --- a/ayugespidertools/templates/project/module/run.py.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -# Define your startup file here -import os - -os.system("scrapy crawl ") diff --git a/ayugespidertools/templates/project/module/run.sh.tmpl b/ayugespidertools/templates/project/module/run.sh.tmpl deleted file mode 100644 index d49df22..0000000 --- a/ayugespidertools/templates/project/module/run.sh.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/bash -source ${project_startup_dir}/${project_name}_venv/bin/activate -cd ${project_startup_dir}/${project_name} && nohup python ./run.py & -deactivate diff --git a/ayugespidertools/templates/project/requirements.txt b/ayugespidertools/templates/project/requirements.txt deleted file mode 100644 index e69de29..0000000