def sorted(self, wantdirs=False):
def add_dir(dirs, d):<EOL><INDENT>dirs.add(d)<EOL>logger.debug('<STR_LIT>', d)<EOL>if d != self.base:<EOL><INDENT>parent, _ = os.path.split(d)<EOL>assert parent not in ('<STR_LIT>', '<STR_LIT:/>')<EOL>add_dir(dirs, parent)<EOL><DEDENT><DEDENT>result = set(self.files)    <EOL>if wantdirs:<EOL><INDENT>dirs = set()<EOL>for f in result:<EOL><INDENT>add_dir(dirs, os.path.dirname(f))<EOL><DEDENT>result |= dirs<EOL><DEDENT>return [os.path.join(*path_tuple) for path_tuple in<EOL>sorted(os.path.split(path) for path in result)]<EOL>
Return sorted files in directory order