New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wizard: ged rid of eval() statements #2329

Closed
borysiasty opened this Issue Sep 4, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@borysiasty
Contributor

borysiasty commented Sep 4, 2015

As @timlinux suggested, getattr should be rather used for accessing dictionaries from definitions.py.
A helper method will be written to get a definition whose key matches a given key.

import safe.definitions

for item in dir(safe.definitions):
    if not item.startswith("__"):
        var = getattr(safe.definitions, item)
        if isinstance(var, dict):
            if var.has_key('name'):
                print var['name']

@borysiasty borysiasty self-assigned this Sep 4, 2015

@borysiasty borysiasty added this to the Version 3.3 milestone Sep 7, 2015

@borysiasty borysiasty added the Ready label Sep 7, 2015

@borysiasty

This comment has been minimized.

Show comment
Hide comment
@borysiasty

borysiasty Sep 7, 2015

Contributor

See also PR #2323.

Timlinux says: see https://github.com/AIFDR/inasafe/pull/2328/files#diff-844316bf2c24e3915be331fde33f5059R679 for the final (re-usable) method I made to get a definition given a key. I will go ahead and apply this PR.

Contributor

borysiasty commented Sep 7, 2015

See also PR #2323.

Timlinux says: see https://github.com/AIFDR/inasafe/pull/2328/files#diff-844316bf2c24e3915be331fde33f5059R679 for the final (re-usable) method I made to get a definition given a key. I will go ahead and apply this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment