Return the project to use.
169552
def get_project(conn, vm_):
    '''
    
    '''
    try:
        projects = conn.ex_list_projects()
    except AttributeError:
        # with versions <0.15 of libcloud this is causing an AttributeError.
        log.warning('Cannot get projects, you may need to update libcloud to 0.15 or later')
        return False
    projid = config.get_cloud_config_value('projectid', vm_, __opts__)

    if not projid:
        return False

    for project in projects:
        if six.text_type(projid) in (six.text_type(project.id), six.text_type(project.name)):
            return project

    log.warning("Couldn't find project %s in projects", projid)
    return False
1135028
def get(self, name, default=_MISSING):
        """"""
        name = self._convert_name(name)
        if name not in self._fields:
            if default is _MISSING:
                default = self._default_value(name)
            return default
        if name in _UNICODEFIELDS:
            value = self._fields[name]
            return value
        elif name in _LISTFIELDS:
            value = self._fields[name]
            if value is None:
                return []
            res = []
            for val in value:
                if name not in _LISTTUPLEFIELDS:
                    res.append(val)
                else:
                    # That's for Project-URL
                    res.append((val[0], val[1]))
            return res

        elif name in _ELEMENTSFIELD:
            value = self._fields[name]
            if isinstance(value, string_types):
                return value.split(',')
        return self._fields[name]
958639
def get_project_build(account_project):
    """"""
    url = make_url("/projects/{account_project}", account_project=account_project)
    response = requests.get(url, headers=make_auth_headers())
    return response.json()
1373979
public Request request(String name, Project project) {
        return request(name, project, null);
    }
1055032
def get_project(self, projectname):
        
        cmd = ["list", "accounts", "where", "name=%s" % projectname]
        results = self._read_output(cmd)

        if len(results) == 0:
            return None
        elif len(results) > 1:
            logger.error(
                "Command returned multiple results for '%s'." % projectname)
            raise RuntimeError(
                "Command returned multiple results for '%s'." % projectname)

        the_result = results[0]
        the_project = the_result["Account"]
        if projectname.lower() != the_project.lower():
            logger.error(
                "We expected projectname '%s' "
                "but got projectname '%s'." % (projectname, the_project))
            raise RuntimeError(
                "We expected projectname '%s' "
                "but got projectname '%s'." % (projectname, the_project))

        return the_result
661469
def __load_project_from_file_path(file_path):
    '''
    
    '''
    try:
        project = get_project(project_dir=os.path.dirname(file_path),
                              config_path=[os.path.basename(file_path)])
    except Exception as inst:
        return __handle_except(inst)
    return project
143173
function fetchProject(projectId) {
	return cocoonSDK.ProjectAPI.get(projectId)
	.catch((error) => {
		console.error("Project with ID: " + projectId + " couldn't be fetched.");
		console.trace(error);
		throw error;
	});
}
514011
def get_project(self, project_id):
        
        return youtrack.Project(self._get("/admin/project/" + urlquote(project_id)), self)
576736
def get_projects(self, **kwargs):
        

        _login = kwargs.get('login', self._login)
        search_url = SEARCH_URL.format(login=_login)
        return self._request_api(url=search_url).json()
199550
def _class(self):
        """"""
        try:
            self._project_name()
        except ValueError:
            return MalformedReq
        if self._is_satisfied():
            return SatisfiedReq
        if not self._expected_hashes():
            return MissingReq
        if self._actual_hash() not in self._expected_hashes():
            return MismatchedReq
        return InstallableReq
551107
def as_requirement(self):
        """"""
        if isinstance(self.parsed_version, packaging.version.Version):
            spec = "%s==%s" % (self.project_name, self.parsed_version)
        else:
            spec = "%s===%s" % (self.project_name, self.parsed_version)

        return Requirement.parse(spec)
655012
def project_path(cls, user, project):
        """"""
        return google.api_core.path_template.expand(
            "users/{user}/projects/{project}", user=user, project=project
        )
1147836
def get(self, id=None, title=None):
        
        # Make sure the kwargs are kosher
        if id and title:
            raise ValueError("You can only retrieve a Project by id or \
                title, not by both")
        elif not id and not title:
            raise ValueError("You must provide an id or a title to \
                make a request.")
        # Pull the hits
        if id:
            hit_list = [i for i in self.all() if str(i.id) == str(id)]
        elif title:
            hit_list = [
                i for i in self.all() if
                i.title.lower().strip() == title.lower().strip()
            ]
        # Throw an error if there's more than one hit.
        if len(hit_list) > 1:
            raise DuplicateObjectError("There is more than one project that \
                matches your request.")
        # Try to pull the first hit
        try:
            return hit_list[0]
        except IndexError:
            # If it's not there, you know to throw this error.
            raise DoesNotExistError("The resource you've requested does not \
                exist or is unavailable without the proper credentials.")
890241
def get_project(self, name):
        
        if self._cache is None:  # pragma: no cover
            result = self._get_project(name)
        elif name in self._cache:
            result = self._cache[name]
        else:
            self.clear_errors()
            result = self._get_project(name)
            self._cache[name] = result
        return result
709723
def get_project(username, project, machine_name=None):
    

    try:
        account = Account.objects.get(
            username=username,
            date_deleted__isnull=True)
    except Account.DoesNotExist:
        return "Account '%s' not found" % username

    if project is None:
        project = account.default_project
    else:
        try:
            project = Project.objects.get(pid=project)
        except Project.DoesNotExist:
            project = account.default_project

    if project is None:
        return "None"

    if account.person not in project.group.members.all():
        project = account.default_project

    if project is None:
        return "None"

    if account.person not in project.group.members.all():
        return "None"

    return project.pid
770844
def get_third_party(self, third_party):
        """"""
        actual_account = third_party.get_account()

        assert actual_account.get_bookset() == self.get_bookset()
        return ProjectAccount(actual_account, project=self, third_party=third_party)
526772
def to_project(project):
        
        from sevenbridges.models.project import Project
        if not project:
            raise SbgError('Project is required!')
        elif isinstance(project, Project):
            return project.id
        elif isinstance(project, six.string_types):
            return project
        else:
            raise SbgError('Invalid project parameter!')