My impression was that Mike had a whole lot of files such as leave_empty1.text, leave_empty2.txt, leave_empty3.txt, which should all match the pattern leave_empty*.*<div><br></div><div><br></div><div>Cheers,</div><div>-T<br>
<br><div class="gmail_quote">On Thu, Oct 15, 2009 at 8:06 PM, raf <span dir="ltr"><<a href="mailto:raf@raf.org">raf@raf.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Mike Dewhirst wrote:<br>
<br>
> The problem I find is that Python seems to be using the wrong default<br>
> path separator here ...<br>
><br>
> 'C:\\users\\miked\\py\\chemdata\\src\\getmsds\\testlinks\\leave_empty/*.*'<br>
><br>
> ... and which line can be seen below in context as part of the traceback.<br>
><br>
> I'm sure Windows did not add the /*.* and I certainly didn't. That<br>
> leaves Python as the obvious suspect.<br>
><br>
> Any clues appreciated<br>
><br>
> Thanks<br>
> Mike<br>
<br>
</div>hi,<br>
<br>
forward slash works fine on windows.<br>
i don't think that's the problem.<br>
does the leave_empty directory actually exist?<br>
that might be the problem. i can't see mkdir<br>
anywhere in the code.<br>
<br>
cheers,<br>
<font color="#888888">raf<br>
</font><div><div></div><div class="h5"><br>
> --- code being tested on Windows XP with Python 2.6 ---<br>
><br>
> class GetBase(object):<br>
><br>
> def __init__(self, basedir=basedir, ext=ext):<br>
> self.basedir = basedir<br>
> self.ext = ext<br>
><br>
> def filelist(self):<br>
> # return list of (ccode, filename) tuples<br>
> filelist = os.listdir(self.basedir)<br>
> retlist = []<br>
> for item in filelist:<br>
> if self.ext in item:<br>
> (ccode, toss) = item.split("_", 1)<br>
> retlist.append((ccode, item))<br>
> return retlist<br>
><br>
><br>
> --- tests.py excerpt ---<br>
><br>
> import os, unittest<br>
> import sds<br>
><br>
> emptydir = 'leave_empty'<br>
> testdir = os.getcwd() + os.path.sep + 'testlinks'<br>
><br>
> class test_sds(unittest.TestCase):<br>
><br>
> def test_files_not_exist(self):<br>
> """ 1 """<br>
> filesdir = testdir + os.path.sep + emptydir<br>
> print(filesdir)<br>
> tsto = sds.GetBase(filesdir)<br>
> numf = len(tsto.filelist())<br>
> print('%s' % numf)<br>
> self.assertEqual(numf == 0, True)<br>
><br>
> --- error ---<br>
><br>
> Traceback (most recent call last):<br>
> File "tests.py", line 85, in test_files_not_exist<br>
> numf = len(tsto.filelist())<br>
> File "C:\users\miked\py\chemdata\src\getmsds\sds.py", line 39, in<br>
> filelist<br>
> filelist = os.listdir(self.basedir)<br>
> WindowsError: [Error 3] The system cannot find the path specified:<br>
> 'C:\\users\\miked\\py\\chemdata\\src\\getmsds\\testlinks\\leave_empty/*.*'<br>
><br>
><br>
><br>
> _______________________________________________<br>
> python-au maillist - <a href="mailto:python-au@starship.python.net">python-au@starship.python.net</a><br>
> <a href="http://starship.python.net/mailman/listinfo/python-au" target="_blank">http://starship.python.net/mailman/listinfo/python-au</a><br>
<br>
_______________________________________________<br>
python-au maillist - <a href="mailto:python-au@starship.python.net">python-au@starship.python.net</a><br>
<a href="http://starship.python.net/mailman/listinfo/python-au" target="_blank">http://starship.python.net/mailman/listinfo/python-au</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>--------------------------------------------------<br>Tennessee Leeuwenburg<br><a href="http://myownhat.blogspot.com/">http://myownhat.blogspot.com/</a><br>"Don't believe everything you think"<br>
</div>