Checks for messages in the ``new`` subdirectory, moving them to
        ``cur`` and returning their keys.
969585
def claim_new(self) -> Iterable[str]:
        
        new_subdir = self._paths['new']
        cur_subdir = self._paths['cur']
        for name in os.listdir(new_subdir):
            new_path = os.path.join(new_subdir, name)
            cur_path = os.path.join(cur_subdir, name)
            try:
                os.rename(new_path, cur_path)
            except FileNotFoundError:
                pass
            else:
                yield name.rsplit(self.colon, 1)[0]
1250652
def _compare_recursive(old, new):
    
    if isinstance(new, dict):
        for key in six.iterkeys(new):
            try:
                if _compare_recursive(old[key], new[key]):
                    return True
            except (KeyError, TypeError):
                return True

    elif isinstance(new, list) or isinstance(new, tuple):
        for i, item in enumerate(new):
            try:
                if _compare_recursive(old[i], item):
                    return True
            except (IndexError, TypeError):
                return True
    else:
        return old != new

    return False
689799
def find_new(self):
        
        print("\nSearch for .new configuration files:\n")
        for path, dirs, files in os.walk(self.etc):
            del dirs    # delete unsed
            for f in files:
                if f.endswith(".new"):
                    self.news.append(os.path.join(path, f))
        if not self.news:
            print("  No new configuration files\n")
            raise SystemExit()
575565
def from_data(cls, data):
        
        messages = []
        filename = data['checker']['filename']
        for m in data['messages']:
            for l in m['locations']:
                location = l['path']
                if not location.startswith(filename):
                    location = filename + '/' + location
                if l['line'] != -1:
                    location += ':{}'.format(l['line'])
                if l['column'] != -1:
                    location += ':{}'.format(l['column'])
                messages.append(
                    cls(m['ID'], m['severity'], location, m['message'], m['suggestion'])
                )
        return messages
84071
def messages(fp, key='@message'):
    
    for line in lines(fp):
        txt = line.rstrip('\n')
        yield {key: txt}
49805
def chdir(new_dir):
    
    # On busy filesystems can have issues accessing main directory. Allow retries
    num_tries = 0
    max_tries = 5
    cur_dir = None
    while cur_dir is None:
        try:
            cur_dir = os.getcwd()
        except OSError:
            if num_tries > max_tries:
                raise
            num_tries += 1
            time.sleep(2)
    safe_makedir(new_dir)
    os.chdir(new_dir)
    try:
        yield
    finally:
        os.chdir(cur_dir)
374150
function rmdirWalk( ls, done ) {
  if( ls.length === 0 ) return done()
  fs.rmdir( ls.shift().path, function( error ) {
    if( error ) log( error.message )
    rmdirWalk( ls, done )
  })
}
775314
function(key, replacements) {
        var message = messageMap[key];

        if (replacements) {
            message = util.replaceText(message, replacements);
        }

        return message;
    }
406574
function _recursiveMkDir(dir) {
  if (!fs.existsSync(dir)) {
    _recursiveMkDir(path.dirname(dir));
    fs.mkdirSync(dir);
  }
}
157506
def check_for_new_files_in_home(self):
        
        if not self._user:
            return None
        try:
            created_files = set(self._listdir(self._home_dir)).difference(self._home_dir_content)
        except (subprocess.CalledProcessError, IOError):
            # Probably home directory does not exist
            created_files = []
        if created_files:
            logging.warning('The tool created the following files in %s, '
                            'this may influence later runs:\n\t%s',
                            self._home_dir, '\n\t'.join(created_files))
        return created_files
224093
def get_subdirs(parent_path):
  
  entries = os.listdir(parent_path)
  subdirs = [(entry, os.path.join(parent_path, entry))
             for entry in entries
             if os.path.isdir(entry)]
  return subdirs
785142
def _enter_single_subdir(root_dir):
    """"""
    current_cwd = os.getcwd()
    try:
        dest_dir = root_dir
        dir_list = os.listdir(root_dir)
        if len(dir_list) == 1:
            first = os.path.join(root_dir, dir_list[0])
            if os.path.isdir(first):
                dest_dir = first
        else:
            dest_dir = root_dir
        os.chdir(dest_dir)
        yield dest_dir
    finally:
        os.chdir(current_cwd)
1299167
function dirsExist(dirs) {
  if (0 === dirs.length) {
    return new Promise((resolve) => {
      resolve({});
    });
  }

  // Group dirs by '/' count
  const dirsByDepth = dirs.reduce(function(prev, curItem) {
    const depth = curItem.split(path.sep).length;
    (prev[depth] = prev[depth] || []).push(curItem);

    return prev;
  }, {});

  // Extract min depth dirs
  const allDepths = Object.keys(dirsByDepth).map(Number);
  const currDepth = Math.min(...allDepths);
  const currDirs = dirsByDepth[currDepth];

  // Prepare result object
  const result = dirs.reduce(function(prev, item) {
    prev[item] = null;

    return prev;
  }, {});

  // Check if min depth dirs exist
  return stupidDirsExist(currDirs).then((localResult) => {
    Object.keys(result).forEach((dir) => {
      if (null !== result[dir]) {
        return;
      }

      Object.keys(localResult).forEach((localDir) => {
        // Transfer local check result to global "as is"
        result[localDir] = localResult[localDir];

        // Additionally check if we can mark more deeper directories
        // as non-existing
        if (false === localResult[localDir] &&
          dir.slice(0, localDir.length + 1) === localDir + path.sep) {
          result[dir] = false;
        }
      });
    });

    // Extract not checked dirs
    const restDirs = dirs.filter((dir) => {
      return null === result[dir];
    });

    return dirsExist(restDirs);
  }).then((finalResult) => {
    // Transfer local check result to global "as is"
    Object.keys(finalResult).forEach((finalDir) => {
      result[finalDir] = finalResult[finalDir];
    });

    return result;
  });
}
907476
function recursiveMkDir(dir) {
    if (!fs.existsSync(dir)) {
        recursiveMkDir(path.dirname(dir));
        fs.mkdirSync(dir);
    }
}
1045069
private void mkdirs(File directory, String message) throws IOException {
    try {
      FileUtils.mkdirs(directory);
    } catch (FileUtils.CreateDirectoryException cde) {
      mCacheErrorLogger.logError(
          CacheErrorLogger.CacheErrorCategory.WRITE_CREATE_DIR,
          TAG,
          message,
          cde);
      throw cde;
    }
  }
515786
def do_rm(self, subcmd, opts, message):
        
        maildir = self.maildir
        client = MdClient(maildir, filesystem=self.filesystem)
        try:
            client.remove(message)
        except KeyError:
            return 1
357659
def setup_directories(base_dir, subdirs):
  """"""
  base_dir = os.path.expanduser(base_dir)
  tf.gfile.MakeDirs(base_dir)

  all_dirs = {}
  for subdir in subdirs:
    if isinstance(subdir, six.string_types):
      subdir_tuple = (subdir,)
    else:
      subdir_tuple = subdir
    dir_name = os.path.join(base_dir, *subdir_tuple)
    tf.gfile.MakeDirs(dir_name)
    all_dirs[subdir] = dir_name
  return all_dirs