def get(img, cache_dir=CACHE_DIR, iterative=False):
if os.path.isfile(img):<EOL><INDENT>wal_img = img<EOL><DEDENT>elif os.path.isdir(img):<EOL><INDENT>if iterative:<EOL><INDENT>wal_img = get_next_image(img)<EOL><DEDENT>else:<EOL><INDENT>wal_img = get_random_image(img)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logging.error("<STR_LIT>")<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>wal_img = os.path.abspath(wal_img)<EOL>util.save_file(wal_img, os.path.join(cache_dir, "<STR_LIT>"))<EOL>logging.info("<STR_LIT>", os.path.basename(wal_img))<EOL>return wal_img<EOL>
Validate image input.