Return the project as `foo` or `user/foo` if the project is a
    fork.
965725
def _get_project(msg, key='project'):
    ''' 
    '''
    project = msg[key]['name']
    ns = msg[key].get('namespace')
    if ns:
        project = '/'.join([ns, project])
    if msg[key]['parent']:
        user = msg[key]['user']['name']
        project = '/'.join(['fork', user, project])
    return project
1356482
def create_fork(self, repo):
        
        assert isinstance(repo, github.Repository.Repository), repo
        url_parameters = {
            "org": self.login,
        }
        headers, data = self._requester.requestJsonAndCheck(
            "POST",
            "/repos/" + repo.owner.login + "/" + repo.name + "/forks",
            parameters=url_parameters
        )
        return github.Repository.Repository(self._requester, headers, data, completed=True)
510067
def _get_parent(self):
        """"""
        _dir = os.path.dirname(self.path)
        if is_repo(_dir):
            return Local(_dir)
        else:
            return None
304946
def different_forks(self, lnode, rnode):
        """"""
        ancestor = self.get_common_ancestor(lnode, rnode)
        if isinstance(ancestor, ast.If):
            for fork in (ancestor.body, ancestor.orelse):
                if self.on_fork(ancestor, lnode, rnode, fork):
                    return True
        elif isinstance(ancestor, ast.Try):
            body = ancestor.body + ancestor.orelse
            for fork in [body] + [[hdl] for hdl in ancestor.handlers]:
                if self.on_fork(ancestor, lnode, rnode, fork):
                    return True
        elif isinstance(ancestor, ast.TryFinally):
            if self.on_fork(ancestor, lnode, rnode, ancestor.body):
                return True
        return False
198926
def patched_fork(self):
        """"""
        pid = self.original_os_fork()
        if not pid:
            _LOG('Fork detected. Reinstalling Manhole.')
            self.reinstall()
        return pid
79881
def patched_forkpty(self):
        """"""
        pid, master_fd = self.original_os_forkpty()
        if not pid:
            _LOG('Fork detected. Reinstalling Manhole.')
            self.reinstall()
        return pid, master_fd
547307
function checkProjectCompilationsWithId(projectId) {
	return fetchProject(projectId)
	.then((project) => {
		return checkProjectCompilations(project);
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
1114197
def project_path(*names):
    """"""
    return os.path.join(os.path.dirname(__file__), *names)
1249210
def createfork(self, project_id):
        

        request = requests.post(
            '{0}/fork/{1}'.format(self.projects_url, project_id),
            timeout=self.timeout, verify=self.verify_ssl)

        if request.status_code == 200:
            return True
        else:
            return False
1121433
def project_admin?(project = nil)
      return false unless project.is_a?(Array)
      # => parse_auth.include?(user) && parse_auth[user]['roles'].any? { |r| ['admin', project].include? r.to_s.downcase }
      auth['roles'].any? { |r| ['admin', project].include? r.to_s.downcase }
    end
360492
def forkexec_pty(argv, env=None, size=None):
    """"""
    child_pid, child_fd = pty.fork()
    if child_pid == 0:
        os.closerange(3, MAXFD)
        environ = os.environ.copy()
        if env is not None:
            environ.update(env)
        os.execve(argv[0], argv, environ)
    if size is None:
        try:
            size = get_terminal_size(1)
        except Exception:
            size = (80, 24)
    set_terminal_size(child_fd, size)
    return child_pid, child_fd
1311547
protected Project filterProjectByPermission(final Project project, final User user,
      final Permission.Type type) {
    return filterProjectByPermission(project, user, type, null);
  }
1058730
function(isEmpty, isDefault) {
			var context = this.switchContext;

			if (!context.hasCase) {
				return;
			}

			/*
			 * Merge forks.
			 * The parent fork context has two segments.
			 * Those are from the current case and the body of the previous case.
			 */
			var parentForkContext = this.forkContext;
			var forkContext = this.pushForkContext();

			forkContext.add(parentForkContext.makeNext(0, -1));

			/*
			 * Save `default` chunk info.
			 * If the `default` label is not at the last, we must make a path from
			 * the last `case` to the `default` chunk.
			 */
			if (isDefault) {
				context.defaultSegments = parentForkContext.head;
				if (isEmpty) {
					context.foundDefault = true;
				} else {
					context.defaultBodySegments = forkContext.head;
				}
			} else {
				if (!isEmpty && context.foundDefault) {
					context.foundDefault = false;
					context.defaultBodySegments = forkContext.head;
				}
			}

			context.lastIsDefault = isDefault;
			context.countForks += 1;
		}
655012
def project_path(cls, user, project):
        """"""
        return google.api_core.path_template.expand(
            "users/{user}/projects/{project}", user=user, project=project
        )
1261102
def fork():
    """"""

    try:
        pid, fd = os.forkpty()
    except (AttributeError, OSError):
        pass
    else:
        if pid == CHILD:
            try:
                os.setsid()
            except OSError:
                # os.forkpty() already set us session leader
                pass
        return pid, fd

    master_fd, slave_fd = openpty()
    pid = os.fork()
    if pid == CHILD:
        # Establish a new session.
        os.setsid()
        os.close(master_fd)

        # Slave becomes stdin/stdout/stderr of child.
        os.dup2(slave_fd, STDIN_FILENO)
        os.dup2(slave_fd, STDOUT_FILENO)
        os.dup2(slave_fd, STDERR_FILENO)
        if (slave_fd > STDERR_FILENO):
            os.close (slave_fd)

        # Explicitly open the tty to make it become a controlling tty.
        tmp_fd = os.open(os.ttyname(STDOUT_FILENO), os.O_RDWR)
        os.close(tmp_fd)
    else:
        os.close(slave_fd)

    # Parent and child process.
    return pid, master_fd
352412
def _double_fork(self):
        
        try:

            pid = os.fork()
            if pid > 0:

                # Exit first parent.
                sys.exit(0)
                return None

        except OSError as err:

            LOG.exception(
                "Fork #1 failed: {0} ({1})".format(
                    err.errno,
                    err.strerror,
                ),
            )
            sys.exit(exit.DAEMONIZE_FAILED)
            return None

        # Decouple from parent environment.
        os.chdir("/")
        os.setsid()
        os.umask(0)

        # Do second fork.
        try:

            pid = os.fork()
            if pid > 0:

                # Exit from second parent.
                sys.exit(0)

        except OSError as err:

            LOG.exception(
                "Fork #2 failed: {0} ({1})".format(
                    err.errno,
                    err.strerror,
                ),
            )
            sys.exit(exit.DAEMONIZE_FAILED)
            return None
629437
def get(project, credentials=None):
        """"""
        user, oauth_access_token = parsecredentials(credentials)
        if not Project.exists(project, user):
            return withheaders(flask.make_response("Project " + project + " was not found for user " + user,404) ,headers={'allow_origin': settings.ALLOW_ORIGIN})#404
        else:
            #if user and not Project.access(project, user) and not user in settings.ADMINS:
            #    return flask.make_response("Access denied to project " +  project + " for user " + user, 401) #401
            datafile = os.path.join(Project.path(project,credentials),'clam.xml')
            statuscode, statusmsg, statuslog, completion = Project.status(project, user) #pylint: disable=unused-variable
            if statuscode == clam.common.status.DONE and os.path.exists(datafile):
                f = io.open(datafile,'r',encoding='utf-8')
                xmldata = f.read(os.path.getsize(datafile))
                f.close()
                data = clam.common.data.CLAMData(xmldata, None,False, Project.path(project,credentials), loadmetadata=False)
                return Project.response(user, project, settings.PARAMETERS,"",False,oauth_access_token,','.join([str(x) for x in data.program.matchedprofiles]) if data.program else "", data.program) #200
            else:
                #HTTP request parameters may be used to pre-set global parameters when starting a project (issue #66)
                for parametergroup, parameterlist in settings.PARAMETERS: #pylint: disable=unused-variable
                    for parameter in parameterlist:
                        value = parameter.valuefrompostdata(flask.request.values)
                        if value is not None:
                            parameter.set(value)
                return Project.response(user, project, settings.PARAMETERS,"",False,oauth_access_token)