introduce validate method in plugin.py

Convenience method to get directory or file name from a directory or a
file name.
We can use this method to ensure the plugin will work even the user
provides a directory instead of a file and vice-versa