Skip to content

Commit

Permalink
chore: del some project templates
Browse files Browse the repository at this point in the history
  • Loading branch information
shengchenyang committed Mar 19, 2024
1 parent bb0adf3 commit 2a02faa
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 39 deletions.
29 changes: 0 additions & 29 deletions ayugespidertools/commands/startproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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():
Expand Down Expand Up @@ -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:"
Expand Down
1 change: 0 additions & 1 deletion ayugespidertools/scraper/pipelines/oracle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion ayugespidertools/templates/project/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions ayugespidertools/templates/project/module/run.py.tmpl

This file was deleted.

4 changes: 0 additions & 4 deletions ayugespidertools/templates/project/module/run.sh.tmpl

This file was deleted.

Empty file.

0 comments on commit 2a02faa

Please sign in to comment.