[Qgis-developer] Patch for Table Manager (ver.0.17) - python plugin

Volkan Kepoglu vkepoglu at gmail.com
Thu Jun 4 07:13:28 EDT 2009


this patch is only for to fix the error, not to refactor the code.

i tried to change the code as minimum as possible.

os.path.join(Path, Filename) is more appropriate, but if the code is working
without using proper built-in function,

that is also fine for me.

volkan.

On Thu, Jun 4, 2009 at 1:55 PM, Barry Rowlingson <
b.rowlingson at lancaster.ac.uk> wrote:

> >         srcPath += '/' + srcName
>
> >     if self.writeToShp(tmpDir+'/'+srcName+'.shp',
> self.provider.encoding())
>
> >       QgsVectorFileWriter.deleteShapeFile(tmpDir+'/'+srcName+'.shp')
>
> >     QFile(srcPath+'.dbf~').remove()
>
> >     if not QFile(srcPath+'.dbf').rename(srcPath+'.dbf~'):
>
> >       QgsVectorFileWriter.deleteShapeFile(tmpDir+'/'+srcName+'.shp')
>
> >     shutil.copy(tmpDir+'/'+srcName+'.dbf', srcPath+'.dbf')
> >     QFile(srcPath+'.dbf~').remove()
>
>  ouch ouch ouch!
>
>  If you need to do file path manipulation in python then it's
> generally better to use functions from the os.path module - it handles
> OS-specific things like / and \, splitting dir/filename from paths,
> creating canonical paths, resolving symlinks (if your OS supports it)
> and all that.
>
>  Note that os.path tends to fail if you feed it QStrings, so convert
> to python strings beforehand, or maybe use methods from QDir -
> actually, that's probably a better idea! QDir has methods for these
> sort of things too. Concatenating strings for files, especially adding
> slashes or backslashes, can get painful when you go across platforms.
>
> Barry
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090604/ea5a7dcd/attachment.html


More information about the Qgis-developer mailing list