this patch is only for to fix the error, not to refactor the code.<br><br>i tried to change the code as minimum as possible. <br><br>os.path.join(Path, Filename) is more appropriate, but if the code is working without using proper built-in function,<br>
<br>that is also fine for me.<br><br>volkan.<br><br><div class="gmail_quote">On Thu, Jun 4, 2009 at 1:55 PM, Barry Rowlingson <span dir="ltr"><<a href="mailto:b.rowlingson@lancaster.ac.uk">b.rowlingson@lancaster.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> srcPath += '/' + srcName<br>
<div class="im"><br>
> if self.writeToShp(tmpDir+'/'+srcName+'.shp', self.provider.encoding())<br>
<br>
</div><div class="im">> QgsVectorFileWriter.deleteShapeFile(tmpDir+'/'+srcName+'.shp')<br>
<br>
</div>> QFile(srcPath+'.dbf~').remove()<br>
<div class="im"><br>
> if not QFile(srcPath+'.dbf').rename(srcPath+'.dbf~'):<br>
<br>
</div><div class="im">> QgsVectorFileWriter.deleteShapeFile(tmpDir+'/'+srcName+'.shp')<br>
<br>
</div><div class="im">> shutil.copy(tmpDir+'/'+srcName+'.dbf', srcPath+'.dbf')<br>
> QFile(srcPath+'.dbf~').remove()<br>
<br>
</div> ouch ouch ouch!<br>
<br>
If you need to do file path manipulation in python then it's<br>
generally better to use functions from the os.path module - it handles<br>
OS-specific things like / and \, splitting dir/filename from paths,<br>
creating canonical paths, resolving symlinks (if your OS supports it)<br>
and all that.<br>
<br>
Note that os.path tends to fail if you feed it QStrings, so convert<br>
to python strings beforehand, or maybe use methods from QDir -<br>
actually, that's probably a better idea! QDir has methods for these<br>
sort of things too. Concatenating strings for files, especially adding<br>
slashes or backslashes, can get painful when you go across platforms.<br>
<font color="#888888"><br>
Barry<br>
</font></blockquote></div><br><br clear="all">