Create prov entities and activities.
775824
def export(self, nidm_version, export_dir):
        
        # Create "Excursion set" entity
        self.add_attributes((
            (PROV['type'], self.type),
            (NIDM_IN_COORDINATE_SPACE, self.coord_space.id),
            (PROV['label'], self.label),
        ))

        if self.visu is not None:
            self.add_attributes((
                (DC['description'], self.visu.id),
            ))

        if self.clust_map is not None:
            self.add_attributes((
                (NIDM_HAS_CLUSTER_LABELS_MAP, self.clust_map.id),
            ))

        if self.mip is not None:
            self.add_attributes((
                (NIDM_HAS_MAXIMUM_INTENSITY_PROJECTION, self.mip.id),
            ))

        if self.num_clusters is not None:
            self.add_attributes((
                (NIDM_NUMBER_OF_CLUSTERS, self.num_clusters),
            ))

        if self.p_value is not None:
            self.add_attributes((
                (NIDM_P_VALUE, self.p_value),
            ))
51190
def createRepoObjects():
	""""""
	repositories = {}
	repodir = os.path.join(getScriptLocation())
	for importer, name, ispkg in pkgutil.iter_modules([repodir]):
		module = importer.find_module(name).load_module(name)
		repo_name = module.name
		if module.enabled:
			repositories[repo_name] = module.getRepository()
	
	return repositories
809829
def create_tables(args):
  """"""

  from bob.db.utils import create_engine_try_nolock
  engine = create_engine_try_nolock(args.type, args.files[0], echo=(args.verbose > 2))
  Base.metadata.create_all(engine)
548992
def create_action(self):
        """"""
        actions = {}

        act = QAction(QIcon(ICON['step_prev']), 'Previous Step', self)
        act.setShortcut('[')
        act.triggered.connect(self.step_prev)
        actions['step_prev'] = act

        act = QAction(QIcon(ICON['step_next']), 'Next Step', self)
        act.setShortcut(']')
        act.triggered.connect(self.step_next)
        actions['step_next'] = act

        act = QAction(QIcon(ICON['page_prev']), 'Previous Page', self)
        act.setShortcut(QKeySequence.MoveToPreviousChar)
        act.triggered.connect(self.page_prev)
        actions['page_prev'] = act

        act = QAction(QIcon(ICON['page_next']), 'Next Page', self)
        act.setShortcut(QKeySequence.MoveToNextChar)
        act.triggered.connect(self.page_next)
        actions['page_next'] = act

        act = QAction('Go to Epoch', self)
        act.setShortcut(QKeySequence.FindNext)
        act.triggered.connect(self.go_to_epoch)
        actions['go_to_epoch'] = act

        act = QAction('Line Up with Epoch', self)
        act.setShortcut('F4')
        act.triggered.connect(self.line_up_with_epoch)
        actions['line_up_with_epoch'] = act

        act = QAction(QIcon(ICON['zoomprev']), 'Wider Time Window', self)
        act.setShortcut(QKeySequence.ZoomIn)
        act.triggered.connect(self.X_more)
        actions['X_more'] = act

        act = QAction(QIcon(ICON['zoomnext']), 'Narrower Time Window', self)
        act.setShortcut(QKeySequence.ZoomOut)
        act.triggered.connect(self.X_less)
        actions['X_less'] = act

        act = QAction(QIcon(ICON['zoomin']), 'Larger Scaling', self)
        act.setShortcut(QKeySequence.MoveToPreviousLine)
        act.triggered.connect(self.Y_more)
        actions['Y_less'] = act

        act = QAction(QIcon(ICON['zoomout']), 'Smaller Scaling', self)
        act.setShortcut(QKeySequence.MoveToNextLine)
        act.triggered.connect(self.Y_less)
        actions['Y_more'] = act

        act = QAction(QIcon(ICON['ydist_more']), 'Larger Y Distance', self)
        act.triggered.connect(self.Y_wider)
        actions['Y_wider'] = act

        act = QAction(QIcon(ICON['ydist_less']), 'Smaller Y Distance', self)
        act.triggered.connect(self.Y_tighter)
        actions['Y_tighter'] = act

        act = QAction(QIcon(ICON['chronometer']), '6 Hours Earlier', self)
        act.triggered.connect(partial(self.add_time, -6 * 60 * 60))
        actions['addtime_-6h'] = act

        act = QAction(QIcon(ICON['chronometer']), '1 Hour Earlier', self)
        act.triggered.connect(partial(self.add_time, -60 * 60))
        actions['addtime_-1h'] = act

        act = QAction(QIcon(ICON['chronometer']), '10 Minutes Earlier', self)
        act.triggered.connect(partial(self.add_time, -10 * 60))
        actions['addtime_-10min'] = act

        act = QAction(QIcon(ICON['chronometer']), '10 Minutes Later', self)
        act.triggered.connect(partial(self.add_time, 10 * 60))
        actions['addtime_10min'] = act

        act = QAction(QIcon(ICON['chronometer']), '1 Hour Later', self)
        act.triggered.connect(partial(self.add_time, 60 * 60))
        actions['addtime_1h'] = act

        act = QAction(QIcon(ICON['chronometer']), '6 Hours Later', self)
        act.triggered.connect(partial(self.add_time, 6 * 60 * 60))
        actions['addtime_6h'] = act

        act = QAction('Go to Next Event', self)
        act.setShortcut('s')
        act.triggered.connect(self.next_event)
        actions['next_event'] = act
        
        act = QAction('Delete Event and Go to Next', self)
        act.setShortcut('d')
        act.triggered.connect(partial(self.next_event, True))
        actions['del_and_next_event'] = act
        
        act = QAction('Next Event of Same Type', self)
        act.setCheckable(True)
        act.setChecked(True)
        actions['next_of_same_type'] = act
        
        act = QAction('Change Event Type', self)
        act.setShortcut('e')
        act.triggered.connect(self.change_event_type)
        actions['change_event_type'] = act
        
        act = QAction('Centre Window Around Event', self)
        act.setCheckable(True)
        act.setChecked(True)
        actions['centre_event'] = act
        
        act = QAction('Full-length Markers', self)
        act.setCheckable(True)
        act.setChecked(True)
        act.triggered.connect(self.display_annotations)
        actions['cross_chan_mrk'] = act

        # Misc
        act = QAction('Export to svg...', self)
        act.triggered.connect(partial(export_graphics, MAIN=self.parent))
        actions['export_svg'] = act

        self.action = actions
603523
def create(self):
        """"""
        required_nodes = self._get_required_nodes()
        self.lb_attrs = self.consul.create_lb(
                self.instance_name,
                protocol=self.protocol,
                port=self.port,
                nodes=required_nodes,
                node_port=str(self.backend_port),
                algorithm=getattr(self, 'algorithm', None)
                )
287269
def create(self):
        
        # Calls each of these methods in order.  _populate_from_lines and
        # _update_relations must be implemented in subclasses.
        self._init_tables()
        self._populate_from_lines(self.iterator)
        self._update_relations()
        self._finalize()
967370
def execute(self):
        """"""
        self.provider.authenticate()
        identifier = self.config.resolve('lexicon:identifier')
        record_type = self.config.resolve('lexicon:type')
        name = self.config.resolve('lexicon:name')
        content = self.config.resolve('lexicon:content')

        if self.action == 'create':
            return self.provider.create_record(record_type, name, content)

        if self.action == 'list':
            return self.provider.list_records(record_type, name, content)

        if self.action == 'update':
            return self.provider.update_record(identifier, record_type, name, content)

        if self.action == 'delete':
            return self.provider.delete_record(identifier, record_type, name, content)

        raise ValueError('Invalid action statement: {0}'.format(self.action))
898024
def create_loadfile(entities, f):
        """"""
        with open(f, 'w') as out:
            out.write(Entity.create_payload(entities))
690536
public function build() {

        // If we have decided not to backup activities, prevent anything to be built
        if (!$this->get_setting_value('activities')) {
            $this->built = true;
            return;
        }

        // Add some extra settings that related processors are going to need
        $this->add_setting(new backup_activity_generic_setting(backup::VAR_MODID, base_setting::IS_INTEGER, $this->moduleid));
        $this->add_setting(new backup_activity_generic_setting(backup::VAR_COURSEID, base_setting::IS_INTEGER, $this->get_courseid()));
        $this->add_setting(new backup_activity_generic_setting(backup::VAR_SECTIONID, base_setting::IS_INTEGER, $this->sectionid));
        $this->add_setting(new backup_activity_generic_setting(backup::VAR_MODNAME, base_setting::IS_FILENAME, $this->modulename));
        $this->add_setting(new backup_activity_generic_setting(backup::VAR_ACTIVITYID, base_setting::IS_INTEGER, $this->activityid));
        $this->add_setting(new backup_activity_generic_setting(backup::VAR_CONTEXTID, base_setting::IS_INTEGER, $this->contextid));

        // Create the activity directory
        $this->add_step(new create_taskbasepath_directory('create_activity_directory'));

        // Generate the module.xml file, containing general information for the
        // activity and from its related course_modules record and availability
        $this->add_step(new backup_module_structure_step('module_info', 'module.xml'));

        // Annotate the groups used in already annotated groupings if groups are to be backed up.
        if ($this->get_setting_value('groups')) {
            $this->add_step(new backup_annotate_groups_from_groupings('annotate_groups'));
        }

        // Here we add all the common steps for any activity and, in the point of interest
        // we call to define_my_steps() is order to get the particular ones inserted in place.
        $this->define_my_steps();

        // Generate the roles file (optionally role assignments and always role overrides)
        $this->add_step(new backup_roles_structure_step('activity_roles', 'roles.xml'));

        // Generate the filter file (conditionally)
        if ($this->get_setting_value('filters')) {
            $this->add_step(new backup_filters_structure_step('activity_filters', 'filters.xml'));
        }

        // Generate the comments file (conditionally)
        if ($this->get_setting_value('comments')) {
            $this->add_step(new backup_comments_structure_step('activity_comments', 'comments.xml'));
        }

        // Generate the userscompletion file (conditionally)
        if ($this->get_setting_value('userscompletion')) {
            $this->add_step(new backup_userscompletion_structure_step('activity_userscompletion', 'completion.xml'));
        }

        // Generate the logs file (conditionally)
        if ($this->get_setting_value('logs')) {
            // Legacy logs.
            $this->add_step(new backup_activity_logs_structure_step('activity_logs', 'logs.xml'));
            // New log stores.
            $this->add_step(new backup_activity_logstores_structure_step('activity_logstores', 'logstores.xml'));
        }

        // Generate the calendar events file (conditionally)
        if ($this->get_setting_value('calendarevents')) {
            $this->add_step(new backup_calendarevents_structure_step('activity_calendar', 'calendar.xml'));
        }

        // Fetch all the activity grade items and put them to backup_ids
        $this->add_step(new backup_activity_grade_items_to_ids('fetch_activity_grade_items'));

        // Generate the grades file
        $this->add_step(new backup_activity_grades_structure_step('activity_grades', 'grades.xml'));

        // Generate the grading file (conditionally)
        $this->add_step(new backup_activity_grading_structure_step('activity_grading', 'grading.xml'));

        // Generate the grade history file. The setting 'grade_histories' is handled in the step.
        $this->add_step(new backup_activity_grade_history_structure_step('activity_grade_history', 'grade_history.xml'));

        // Generate the competency file.
        $this->add_step(new backup_activity_competencies_structure_step('activity_competencies', 'competencies.xml'));

        // Annotate the scales used in already annotated outcomes
        $this->add_step(new backup_annotate_scales_from_outcomes('annotate_scales'));

        // NOTE: Historical grade information is saved completely at course level only (see 1.9)
        // not per activity nor per selected activities (all or nothing).

        // Generate the inforef file (must be after ALL steps gathering annotations of ANY type)
        $this->add_step(new backup_inforef_structure_step('activity_inforef', 'inforef.xml'));

        // Migrate the already exported inforef entries to final ones
        $this->add_step(new move_inforef_annotations_to_final('migrate_inforef'));

        // At the end, mark it as built
        $this->built = true;
    }
656868
def create_activity(self, *args, **kwargs):
        
        if self._client.match_app_version(label='wim', version='<2.0.0', default=True):
            return self._client.create_activity(self.process, *args, **kwargs)
        else:
            return self._client.create_activity(self.workflow_root, *args, **kwargs)
1125647
protected function createEach() {
        foreach ($this->providers as $class => &$data) {
            if ( ! array_get($data, 'instance')) {
                $instance = $this->getProviderInvoker()
                    ->create($class, $this->getSharedArguments());
                array_set($data, 'instance', $instance);

                $this->create();
                break;
            }
        }
    }
1060817
def create_action(self):
        """"""
        actions = {}

        act = QAction('Load Montage...', self)
        act.triggered.connect(self.load_channels)
        act.setEnabled(False)
        actions['load_channels'] = act

        act = QAction('Save Montage...', self)
        act.triggered.connect(self.save_channels)
        act.setEnabled(False)
        actions['save_channels'] = act

        self.action = actions
1315057
def create(cls, *args, **kwargs) -> 'Entity':
        
        logger.debug(
            f'Creating new `{cls.__name__}` object using data {kwargs}')

        model_cls = repo_factory.get_model(cls)
        repository = repo_factory.get_repository(cls)

        try:
            # Build the entity from the input arguments
            # Raises validation errors, if any, at this point
            entity = cls(*args, **kwargs)

            # Do unique checks, create this object and return it
            entity._validate_unique()

            # Perform Pre-Save Actions
            entity.pre_save()

            # Build the model object and create it
            model_obj = repository.create(model_cls.from_entity(entity))

            # Update the auto fields of the entity
            for field_name, field_obj in entity.meta_.declared_fields.items():
                if isinstance(field_obj, Auto):
                    if isinstance(model_obj, dict):
                        field_val = model_obj[field_name]
                    else:
                        field_val = getattr(model_obj, field_name)
                    setattr(entity, field_name, field_val)

            # Set Entity status to saved
            entity.state_.mark_saved()

            # Perform Post-Save Actions
            entity.post_save()

            return entity
        except ValidationError:
            # FIXME Log Exception
            raise
166241
def MakeProto():
  """"""
  # Start running from one directory above the grr directory which is found by
  # this scripts's location as __file__.
  cwd = os.path.dirname(os.path.abspath(__file__))

  # Find all the .proto files.
  protos_to_compile = []
  for (root, _, files) in os.walk(cwd):
    for filename in files:
      full_filename = os.path.join(root, filename)
      if full_filename.endswith(".proto"):
        proto_stat = os.stat(full_filename)

        pb2_path = full_filename.rsplit(".", 1)[0] + "_pb2.py"
        try:
          pb2_stat = os.stat(pb2_path)
          if pb2_stat.st_mtime >= proto_stat.st_mtime:
            continue

        except (OSError, IOError):
          pass

        protos_to_compile.append(full_filename)

  if protos_to_compile:
    # Find the protoc compiler.
    protoc = os.environ.get("PROTOC", "protoc")
    try:
      output = subprocess.check_output([protoc, "--version"])
    except (IOError, OSError):
      raise RuntimeError("Unable to launch %s protoc compiler. Please "
                         "set the PROTOC environment variable.", protoc)

    if b"3.6.1" not in output:
      raise RuntimeError("Incompatible protoc compiler detected. "
                         "We need 3.6.1 not %s" % output)

    for proto in protos_to_compile:
      command = [
          protoc,
          # Write the python files next to the .proto files.
          "--python_out",
          ROOT,
          "--proto_path=%s" % ROOT,
          proto
      ]
      print(
          "Compiling %s with (cwd: %s): %s" % (proto, ROOT, " ".join(command)))
      # The protoc compiler is too dumb to deal with full paths - it expects a
      # relative path from the current working directory.
      subprocess.check_call(command, cwd=ROOT)
813420
private function createActionProcess() {
        /** @var CreateObject[] $createObjects */
        $createObjects = [];
        try {
            $params = new Params($this->request);
        } catch(Exception $e) {
            $this->handleError($e);
            return $createObjects;
        }
        $postParams = $params->getParams();
        if(!is_array($postParams)) {
            $postParams = [$postParams];
        }
        foreach($postParams as $postParam) {
            $createObject = new CreateObject($postParam);
            try {
                $entity = $this->createActionInternal($postParam);
                $createObject->setEntity($entity);

            } catch(Exception $e) {
                $this->handleError($e);
            } catch(ValidationException $e) {
                $this->handleValidationError($e);
            } catch(AclException $e) {
                $this->handleAclError($e);
            } catch(CatchableException $e) {
                $this->handleCatchableError($e);
            }
            $createObject->setStatusCode($this->getStatusCode());
            $createObject->setErrors($this->getErrors());
            $this->setErrors([]);
            $createObjects[] = $createObject;
        }
        return $createObjects;
    }
1197000
def _init_proc(self):
        """"""
        if not self.proc:
            self.proc = [
                mp.Process(target=self._proc_loop, args=(i, self.alive, self.queue, self.fn))
                for i in range(self.num_proc)
            ]
            self.alive.value = True
            for p in self.proc:
                p.start()
716903
public function create()
    {
        event(new BeforeCreate($this));

        $this->beforeCreate();

        $this->doCreate();

        $this->afterCreate();

        event(new AfterCreate($this));
    }