[GRASS-dev] [GRASS-SVN] r64850 - in grass-addons/grass7/gui/wxpython: . wx.mwprecip

Vaclav Petras wenzeslaus at gmail.com
Fri Mar 13 18:50:15 PDT 2015


Well, this is interesting, I'm looking forward how this will develop.

Here is code review of some minor issues.

On Fri, Mar 13, 2015 at 1:24 PM, <svn_grass at osgeo.org> wrote:
>
> +    def loadSettings(self, sett=None):
> +        if sett:
> +            self.settings = sett
> +
> +        try:
> +            self.database.SetValue(self.settings['database'])
> +        except:
> +            print 'err'
> +            pass
> +        try:
> +            self.schema.SetValue(self.settings['schema'])
> +        except:
> +            pass
> +        try:
> +            self.host.SetValue(self.settings['host'])
> +        except:
> +            pass
> +        try:
> +            self.user.SetValue(self.settings['user'])
> +        except:
> +            pass
> +        try:
> +            self.port.SetValue(self.settings['port'])
> +        except:
> +            pass
> +        try:
> +            self.passwd.SetValue(self.settings['passwd'])
> +        except:
> +            pass

This should be one big try-except. Also, `except:` is a bad practice, this
will catch everything including perhaps even SyntaxError. You should
specify the error/exception type. You should also specify in the comment
why it is OK to ignore the error. What you should use in case of `eval`
that's a questions, more checks with `eval` is always a good idea.

Also, please use

if __name__ == '__main__':

for consistency with other modules. This will allow you to import the files
and avoid code duplication between wx.*.py file and g.gui.*.py in case the
wx.*.py file is needed.

Try to check your files with pep8 before submitting.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20150313/3c342fce/attachment.html>


More information about the grass-dev mailing list