def generate_paths(paths):
    """
    Iterates over `paths` (which may consist of files and/or directories)
    and return list of files.
    """
    import os
    import subprocess
    files = []
    for path in paths:
        if os.path.isdir(path):
            files += sorted(subprocess.check_output(['find', path, '-type',
                'f', '-readable', '-writable', '!', '-empty', '(', '-name',
                '*.conf', '-o', '-name', '*.txt', ')', '-print0'], stderr=
                subprocess.DEVNULL, universal_newlines=True).rstrip('\x00')
                .split('\x00'))
        else:
            files.append(path)
    return files
