def _get_projects(self, project_ids=None, by_internal_id=False):
        if by_internal_id:
            by = 'by_iid'
        else:
            by = 'by_pid'
        if self._projects is None:
            self._projects = {'by_iid': {}, 'by_pid': {}}
        if project_ids:
            new_projects = [pid for pid in project_ids
                            if pid not in self._projects[by]]
        else:
            new_projects = None
        if new_projects is None or new_projects:
            for project in self._source.get_projects(new_projects):
                project.identifier = re.sub('\W', '', project.identifier)
                self._projects['by_iid'][project.id] = project
                self._projects['by_pid'][project.identifier] = project
        if project_ids:
            result = {}
            for pid in [re.sub('\W', '', p) for p in project_ids]:
                try:
                    result[pid] = self._projects[by][pid]
                except __HOLE__:
                    raise redmine.RedmineException(
                        "Project '%s' doesn't exist in Redmine" % pid)
        return self._projects[by]
dataset/ETHPy150Open JetBrains/youtrack-rest-python-library/python/redmine2youtrack.py/RedmineImporter._get_projects