// check if there's a project.
320519
func (b *Bootstrapper) isProject() bool {
	_, err := os.Stat("project.json")
	return err == nil
}
128817
func IsGranted(scope string, c echo.Context) bool {
	parts := strings.Split(scope, ":")
	switch parts[0] {
	case "profile_messages", "project_messages":
		return IsGranted("messages:"+parts[1], c)

	case "profile_comments":
		return IsGranted("profile_messages:"+parts[1], c)

	case "project_comments":
		return IsGranted("project_messages:"+parts[1], c)
	}

	scopes := c.Get("scopes").([]string)
	i := sort.SearchStrings(scopes, scope)
	if i < len(scopes) && scopes[i] == scope {
		return true
	}

	scope = "base:" + parts[1]
	i = sort.SearchStrings(scopes, scope)
	return i < len(scopes) && scopes[i] == scope
}
538439
func IsProjectWriter(c context.Context, pcfg *svcconfig.ProjectConfig) error {
	return checkMember(c, pcfg.WriterAuthGroups...)
}
345204
func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, *Response, error) {
	u := fmt.Sprintf("projects/%v", id)
	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept headers when APIs fully launch.
	req.Header.Set("Accept", mediaTypeProjectsPreview)

	project := &Project{}
	resp, err := s.client.Do(ctx, req, project)
	if err != nil {
		return nil, resp, err
	}

	return project, resp, nil
}
594443
func IsAllowed(c context.Context, project string) (bool, error) {
	switch admin, err := IsAdmin(c); {
	case err != nil:
		return false, err
	case admin:
		return true, nil
	}

	// Get the project, because that's where the ACLs lie.
	err := access.Check(c, backend.AsUser, config.ProjectSet(project))
	innerError := errors.Unwrap(err)

	switch {
	case err == nil:
		return true, nil
	case err == access.ErrNoAccess:
		return false, nil
	case innerError == config.ErrNoConfig:
		return false, grpcutil.NotFoundTag.Apply(err)
	default:
		return false, err
	}
}
427176
func IsProjectReader(c context.Context, pcfg *svcconfig.ProjectConfig) error {
	return checkMember(c, pcfg.ReaderAuthGroups...)
}
1324178
func IsNotFound(err error) bool {
	switch {
	case err == nil:
		return false
	case strings.Contains(err.Error(), "does not exist"):
		return true
	case strings.Contains(err.Error(), "not found"):
		return true
	default:
		return false
	}
}
1102368
func (v *version) AppProjects() AppProjectInformer {
	return &appProjectInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
1074718
func isProjectNumber(idOrNumber string) bool {
	_, err := strconv.ParseUint(idOrNumber, 10, 64)
	return err == nil
}
789573
func (s *Service) GetProjects() *GetProjectsCall {
	c := &GetProjectsCall{s: s, urlParams_: make(gensupport.URLParams)}
	return c
}
592955
func (c *Client) SuspendProject(p *SuspendProjectParameter) (*Project, error) {
	obj, err := c.Request("suspendProject", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Project), err
}
301362
func (s *ProjectService) ActivateProject(p *ActivateProjectParams) (*ActivateProjectResponse, error) {
	resp, err := s.cs.newRequest("activateProject", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ActivateProjectResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
962029
func (c *ApiController) GetBuildsWithProjectName() {
	log.Info("Get builds with project name")

	projectName := c.GetString(":projectName")

	builds := models.GetBuildsWithProjectName(projectName)

	c.Data["json"] = builds
	c.ServeJson()
}
256173
func (c CloudstackClient) ListProjects(name string) (ListProjectsResponse, error) {
	var resp ListProjectsResponse
	params := url.Values{}

	if name != "" {
		params.Set("name", name)
	}
	response, err := NewRequest(c, "listProjects", params)
	if err != nil {
		return resp, err
	}

	resp = response.(ListProjectsResponse)
	return resp, err
}
1154251
func ProjectStop(p project.APIProject, c *cli.Context) error {
	err := p.Stop(context.Background(), c.Int("timeout"), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
380245
func GetAllProjects() []*Project {
	o := orm.NewOrm()

	var projects []*Project
	num, err := o.QueryTable("project").All(&projects)
	fmt.Printf("Returned Rows Num: %s, %s", num, err)
	return projects
}
103934
func (c *ApiController) GetProjectBadge() {
	log.Info("Get project badge")

	// TODO(tobe): need more svg images.
	success_svg := []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="104" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="104" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#4c1" d="M54 0h50v20H54z"/><path fill="url(#b)" d="M0 0h104v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="78" y="15" fill="#010101" fill-opacity=".3">correct</text><text x="78" y="14">correct</text></g></svg>`)
	fail_svg := []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="99" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#e05d44" d="M54 0h45v20H54z"/><path fill="url(#b)" d="M0 0h99v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="75.5" y="15" fill="#010101" fill-opacity=".3">wrong</text><text x="75.5" y="14">wrong</text></g></svg>`)

	var badge []byte

	projectId, _ := c.GetInt64(":projectId")
	project := models.GetProjectWithId(projectId)

	if project.Status == models.PROJECT_STATUS_NEED_TEST {
		badge = success_svg
	} else if project.Status == models.PROJECT_STATUS_TESTING {
		badge = success_svg
	} else if project.Status == models.PROJECT_STATUS_SUCCESS {
		badge = success_svg
	} else {
		badge = fail_svg
	}

	header := c.Ctx.ResponseWriter.Header()
	header.Set("Content-Type", "image/svg+xml")
	header.Set("Cache-Control", "no-cache, no-store, must-revalidate")

	c.Ctx.ResponseWriter.Write(badge)
}