1
1
2
2
3
+ import builtins
4
+
5
+
3
6
class ConfigValidator :
4
7
config = None
5
8
@@ -18,52 +21,52 @@ def validate(self):
18
21
# Start urls must be an array
19
22
if self .config .start_urls and not isinstance (self .config .start_urls ,
20
23
list ):
21
- raise Exception ('start_urls should be list' )
24
+ raise builtins . Exception ('start_urls should be list' )
22
25
23
26
# Stop urls must be an array
24
27
if self .config .stop_urls and not isinstance (self .config .stop_urls ,
25
28
list ):
26
- raise Exception ('stop_urls should be list' )
29
+ raise builtins . Exception ('stop_urls should be list' )
27
30
28
31
# Custom settings must be a dict
29
32
if self .config .custom_settings and not isinstance (self .config .custom_settings ,
30
33
dict ):
31
- raise Exception ('custom_settings must be a dictionary' )
34
+ raise builtins . Exception ('custom_settings must be a dictionary' )
32
35
33
36
if self .config .js_render and not isinstance (self .config .js_render ,
34
37
bool ):
35
- raise Exception ('js_render should be boolean' )
38
+ raise builtins . Exception ('js_render should be boolean' )
36
39
37
40
# `js_wait` is set to 0s by default unless it is specified
38
41
if self .config .js_wait and not isinstance (self .config .js_wait , int ):
39
- raise Exception ('js_wait should be integer' )
42
+ raise builtins . Exception ('js_wait should be integer' )
40
43
41
44
if self .config .use_anchors and not isinstance (self .config .use_anchors ,
42
45
bool ):
43
- raise Exception ('use_anchors should be boolean' )
46
+ raise builtins . Exception ('use_anchors should be boolean' )
44
47
45
48
if self .config .sitemap_alternate_links and not isinstance (
46
49
self .config .sitemap_alternate_links , bool ):
47
- raise Exception ('sitemap_alternate_links should be boolean' )
50
+ raise builtins . Exception ('sitemap_alternate_links should be boolean' )
48
51
49
52
if self .config .sitemap_urls_regexs and not self .config .sitemap_urls :
50
- raise Exception (
53
+ raise builtins . Exception (
51
54
'You gave an regex to parse sitemap but you didn\' t provide a sitemap url' )
52
55
53
56
if self .config .sitemap_urls_regexs and not self .config .sitemap_urls :
54
57
for regex in self .config .sitemap_urls_regex :
55
58
if not isinstance (regex , str ):
56
- raise Exception (
59
+ raise builtins . Exception (
57
60
'You gave an bad regex: ' + regex + ' must be a string' )
58
61
59
62
if self .config .force_sitemap_urls_crawling and not self .config .sitemap_urls :
60
- raise Exception (
63
+ raise builtins . Exception (
61
64
'You want to force the sitemap crawling but you didn\' t provide a sitemap url' )
62
65
63
66
if not self .config .scrape_start_urls and not self .config .scrap_start_urls :
64
- raise Exception (
67
+ raise builtins . Exception (
65
68
'Please use only the new variable name: scrape_start_urls' )
66
69
67
70
if self .config .nb_hits_max and not isinstance (self .config .nb_hits_max ,
68
71
int ):
69
- raise Exception ('nb_hits_max should be integer' )
72
+ raise builtins . Exception ('nb_hits_max should be integer' )
0 commit comments