Skip to content

Commit ece9de3

Browse files
committed
feat: added fullyQualifiedClassName to spider metadata
1 parent d35d456 commit ece9de3

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1414
then the name of the package containing the spider is assumed to be the
1515
category name - only place that categories are current used is in the API
1616
as a means to group spiders
17-
* added ```absoluteFilename``` property to spider metadata
17+
* added ```absoluteFilename``` property to spider metadata - this value is
18+
generated by Cloudfeaster
19+
* added ```fullyQualifiedClassName``` property to spider metadata - this value is
20+
generated by Cloudfeaster
1821

1922
### Changed
2023

cloudfeaster/jsonschemas/spider_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"absoluteFilename": {
3535
"type": "string"
3636
},
37+
"fullyQualifiedClassName": {
38+
"type": "string"
39+
},
3740
"paranoiaLevel": {
3841
"type": "string",
3942
"enum": [

cloudfeaster/spider.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ def get_validated_metadata(cls):
138138
metadata['categories'] = [category]
139139

140140
metadata['absoluteFilename'] = sys.modules[cls.__module__].__file__
141+
metadata['fullyQualifiedClassName'] = '{module}.{cls}'.format(
142+
module=cls.__module__,
143+
cls=cls.__name__)
141144

142145
crawl_method_arg_names = cls._get_crawl_method_arg_names_for_use_as_factors()
143146
if crawl_method_arg_names is None:

cloudfeaster/tests/spider_tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ class MySpider(spider.Spider):
475475

476476
@classmethod
477477
def get_metadata(cls):
478+
cls.metadata["fullyQualifiedClassName"] = "{module}.{cls}".format(
479+
module=cls.__module__,
480+
cls=cls.__name__)
478481
return cls.metadata
479482

480483
def crawl(self, browser, member_id, password):
@@ -520,6 +523,9 @@ class MySpider(spider.Spider):
520523

521524
@classmethod
522525
def get_metadata(cls):
526+
cls.metadata["fullyQualifiedClassName"] = "{module}.{cls}".format(
527+
module=cls.__module__,
528+
cls=cls.__name__)
523529
return cls.metadata
524530

525531
def crawl(self, browser, member_id, password):

0 commit comments

Comments
 (0)