File tree Expand file tree Collapse file tree 7 files changed +18
-15
lines changed Expand file tree Collapse file tree 7 files changed +18
-15
lines changed Original file line number Diff line number Diff line change 41
41
else :
42
42
config_file = arg
43
43
44
+ from planet import config
45
+ config .load (config_file )
46
+
44
47
if verbose :
45
48
import planet
46
49
planet .getLogger ('DEBUG' )
47
50
48
51
if not offline :
49
52
from planet import spider
50
- spider .spiderPlanet (config_file )
53
+ spider .spiderPlanet ()
51
54
52
55
from planet import splice
53
- doc = splice .splice (config_file )
56
+ doc = splice .splice ()
54
57
splice .apply (doc .toxml ('utf-8' ))
Original file line number Diff line number Diff line change @@ -180,9 +180,8 @@ def spiderFeed(feed):
180
180
write (output , cache_file )
181
181
os .utime (cache_file , (mtime , mtime ))
182
182
183
- def spiderPlanet (configFile ):
183
+ def spiderPlanet ():
184
184
""" Spider (fetch) an entire planet """
185
- config .load (configFile )
186
185
log = planet .getLogger (config .log_level ())
187
186
planet .setTimeout (config .feed_timeout ())
188
187
Original file line number Diff line number Diff line change 5
5
from reconstitute import createTextElement , date
6
6
from spider import filename
7
7
8
- def splice (configFile ):
8
+ def splice ():
9
9
""" Splice together a planet from a cache of entries """
10
10
import planet
11
- config .load (configFile )
12
11
log = planet .getLogger (config .log_level ())
13
12
14
13
log .info ("Loading cached data" )
Original file line number Diff line number Diff line change 8
8
9
9
if __name__ == '__main__' :
10
10
11
+ config .load (sys .argv [1 ])
12
+
11
13
if len (sys .argv ) == 2 :
12
14
# spider all feeds
13
- spider .spiderPlanet (sys . argv [ 1 ] )
15
+ spider .spiderPlanet ()
14
16
elif len (sys .argv ) > 2 :
15
17
# spider selected feeds
16
- config .load (sys .argv [1 ])
17
18
for feed in sys .argv [2 :]:
18
19
spider .spiderFeed (feed )
19
20
else :
Original file line number Diff line number Diff line change 5
5
6
6
import os .path
7
7
import sys
8
- from planet import splice
8
+ from planet import splice , config
9
9
10
10
if __name__ == '__main__' :
11
11
12
12
if len (sys .argv ) == 2 and os .path .isfile (sys .argv [1 ]):
13
- # at the moment, we don't have template support, so we cheat and
14
- # simply insert a XSLT processing instruction
15
- doc = splice .splice (sys .argv [1 ])
13
+ config .load (sys .argv [1 ])
14
+ doc = splice .splice ()
16
15
splice .apply (doc .toxml ('utf-8' ))
17
16
else :
18
17
print "Usage:"
Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ def test_spiderUpdate(self):
66
66
self .test_spiderFeed ()
67
67
68
68
def test_spiderPlanet (self ):
69
- spiderPlanet (configfile )
69
+ config .load (configfile )
70
+ spiderPlanet ()
70
71
files = glob .glob (workdir + "/*" )
71
72
72
73
# verify that exactly eight files + 1 source dir were produced
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
3
3
import unittest
4
- from planet .splice import splice
4
+ from planet .splice import splice , config
5
5
6
6
configfile = 'tests/data/splice/config.ini'
7
7
8
8
class SpliceTest (unittest .TestCase ):
9
9
10
10
def test_splice (self ):
11
- doc = splice (configfile )
11
+ config .load (configfile )
12
+ doc = splice ()
12
13
self .assertEqual (12 ,len (doc .getElementsByTagName ('entry' )))
13
14
self .assertEqual (4 ,len (doc .getElementsByTagName ('planet:source' )))
14
15
self .assertEqual (16 ,len (doc .getElementsByTagName ('planet:name' )))
You can’t perform that action at this time.
0 commit comments