Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.0.8 #8

Merged
merged 3 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def startproject(project_name, project_dir, cwd="."):
sys.exit(1)


demo_item = """
example_item = """

class DemoItem(scrapy.Item):
class ExampleItem(scrapy.Item):
# auto generated by os-scrapy-cookiecutter
url = scrapy.Field()
status = scrapy.Field()
Expand All @@ -98,32 +98,32 @@ class DemoItem(scrapy.Item):
body = scrapy.Field()
"""

demo_item_file = os.path.join(project_dir, "{{cookiecutter.project_name}}", "items.py")
example_item_file = os.path.join(project_dir, "{{cookiecutter.project_name}}", "items.py")

with open(demo_item_file, "a+") as f:
f.write(demo_item)
with open(example_item_file, "a+") as f:
f.write(example_item)


demo_spider = """
example_spider = """
import scrapy

from {{cookiecutter.project_name}}.items import DemoItem
from {{cookiecutter.project_name}}.items import ExampleItem


class DemoSpider(scrapy.Spider):
\"\"\" DemoSpider
class ExampleSpider(scrapy.Spider):
\"\"\" ExampleSpider
Auto generated by os-scrapy-cookiecuter

Run:
scrapy crawl demo
scrapy crawl example
\"\"\"

name = "demo"
name = "example"

start_urls = ["http://example.com/"]

def parse(self, response):
yield DemoItem(
yield ExampleItem(
url=response.url,
status=response.status,
headers=response.headers,
Expand All @@ -132,9 +132,9 @@ def parse(self, response):
)
"""

demo_spider_file = os.path.join(
example_spider_file = os.path.join(
project_dir, "{{cookiecutter.project_name}}", "spiders", "__init__.py"
)

with open(demo_spider_file, "a+") as f:
f.write(demo_spider)
with open(example_spider_file, "a+") as f:
f.write(example_spider)
2 changes: 1 addition & 1 deletion src/os_scrapy_cookiecutter/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.7
0.0.8
12 changes: 9 additions & 3 deletions {{cookiecutter.project_dir}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ It is also a python package, the scaffolds can be used for formatting, testing,
python setup.py install
```

* demo
* example

You can run demo spider:
You can run example spider:

```
scrapy crawl demo
scrapy crawl example
```

* files
Expand Down Expand Up @@ -69,6 +69,12 @@ It is also a python package, the scaffolds can be used for formatting, testing,
└── tox.ini # tox config file
```

## Install

```
python setup.py install
```

## Usage

```
Expand Down