From 61b0722fb012ab7de8502b7e369901e68a6103a1 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Mon, 18 Sep 2006 11:05:59 -0400 Subject: [PATCH] Win32 fixes --- planet/__init__.py | 7 ++++++- planet/shell/tmpl.py | 2 +- tests/test_rlists.py | 4 ++-- tests/test_spider.py | 22 ++++++++++++---------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/planet/__init__.py b/planet/__init__.py index e24473c..ceb4b61 100644 --- a/planet/__init__.py +++ b/planet/__init__.py @@ -85,7 +85,12 @@ def downloadReadingList(list, orig_config, callback, use_cache=True, re_read=Tru cached_config.set(list, key, value) # read list - base = urljoin('file:', os.path.abspath(os.path.curdir)) + if sys.platform.find('win') < 0: + base = urljoin('file:', os.path.abspath(os.path.curdir)) + else: + path = os.path.abspath(os.path.curdir) + base = urljoin('file:///', path.replace(':','|').replace('\\','/')) + request = urllib2.Request(urljoin(base + '/', list)) if options.has_key("etag"): request.add_header('If-None-Match', options['etag']) diff --git a/planet/shell/tmpl.py b/planet/shell/tmpl.py index 81a79d5..6187bd8 100644 --- a/planet/shell/tmpl.py +++ b/planet/shell/tmpl.py @@ -225,7 +225,7 @@ def template_info(source): def run(script, doc, output_file=None, options={}): """ process an HTMLTMPL file """ - manager = htmltmpl.TemplateManager() + manager = htmltmpl.TemplateManager(precompile=(sys.platform.find('win')<0)) template = manager.prepare(script) tp = htmltmpl.TemplateProcessor(html_escape=0) for key,value in template_info(doc).items(): diff --git a/tests/test_rlists.py b/tests/test_rlists.py index 02285d5..5cb25ce 100644 --- a/tests/test_rlists.py +++ b/tests/test_rlists.py @@ -6,7 +6,7 @@ from os.path import split from glob import glob from ConfigParser import ConfigParser -workdir = 'tests/work/config/cache' +workdir = os.path.join('tests', 'work', 'config', 'cache') class ReadingListTest(unittest.TestCase): def setUp(self): @@ -38,7 +38,7 @@ class ReadingListTest(unittest.TestCase): def test_cache(self): cache = glob(os.path.join(workdir,'lists','*')) - self.assertTrue(1,len(cache)) + self.assertEqual(1,len(cache)) parser = ConfigParser() parser.read(cache[0]) diff --git a/tests/test_spider.py b/tests/test_spider.py index 9f819d6..aa0a6c1 100644 --- a/tests/test_spider.py +++ b/tests/test_spider.py @@ -26,11 +26,13 @@ class SpiderTest(unittest.TestCase): os.removedirs(os.path.split(workdir)[0]) def test_filename(self): - self.assertEqual('./example.com,index.html', + self.assertEqual(os.path.join('.', 'example.com,index.html'), filename('.', 'http://example.com/index.html')) - self.assertEqual('./planet.intertwingly.net,2006,testfeed1,1', + self.assertEqual(os.path.join('.', + 'planet.intertwingly.net,2006,testfeed1,1'), filename('.', u'tag:planet.intertwingly.net,2006:testfeed1,1')) - self.assertEqual('./00000000-0000-0000-0000-000000000000', + self.assertEqual(os.path.join('.', + '00000000-0000-0000-0000-000000000000'), filename('.', u'urn:uuid:00000000-0000-0000-0000-000000000000')) # Requires Python 2.3 @@ -38,7 +40,7 @@ class SpiderTest(unittest.TestCase): import encodings.idna except: return - self.assertEqual('./xn--8ws00zhy3a.com', + self.assertEqual(os.path.join('.', 'xn--8ws00zhy3a.com'), filename('.', u'http://www.\u8a79\u59c6\u65af.com/')) def test_spiderFeed(self): @@ -51,8 +53,8 @@ class SpiderTest(unittest.TestCase): self.assertEqual(5, len(files)) # verify that the file names are as expected - self.assertTrue(workdir + - '/planet.intertwingly.net,2006,testfeed1,1' in files) + self.assertTrue(os.path.join(workdir, + 'planet.intertwingly.net,2006,testfeed1,1') in files) # verify that the file timestamps match atom:updated data = feedparser.parse(files[2]) @@ -73,10 +75,10 @@ class SpiderTest(unittest.TestCase): self.assertEqual(13, len(files)) # verify that the file names are as expected - self.assertTrue(workdir + - '/planet.intertwingly.net,2006,testfeed1,1' in files) - self.assertTrue(workdir + - '/planet.intertwingly.net,2006,testfeed2,1' in files) + self.assertTrue(os.path.join(workdir, + 'planet.intertwingly.net,2006,testfeed1,1') in files) + self.assertTrue(os.path.join(workdir, + 'planet.intertwingly.net,2006,testfeed2,1') in files) data = feedparser.parse(workdir + '/planet.intertwingly.net,2006,testfeed3,1')