def upload_dir(self, user, tempdir):
        if tempdir is None:
            return

        _session = os.path.basename(tempdir)
        index = 0
        failed = False

        # compile each file one by one
        for _file in glob.glob(os.path.join(tempdir, '*.yang')):
            self.stdout.write("Compiling : user: %s, file: %s " % (user, _file))
            success, response = sync_file(user, _session, _file, str(index))
            if not success:
                self.stdout.write("Compilation Failed: " + ET.tostring(response))
                failed = True
                break
            else:
                self.stdout.write("Compiled: " + _file)
            index += 1

        # if compiled sucessfully, commit to user profile
        if not failed:
            success, modules = commit_files(user, _session)
            self.stdout.write("Uploaded %d files " % index)

        return not failed
Upload directory contents, complie and commit
dataset/ETHPy150Open CiscoDevNet/yang-explorer/server/explorer/management/commands/bulkupload.py/Command.upload_dir