Create a new profile and return it
774782
def create_profile!
      cert = certificate_to_use
      bundle_id = Sigh.config[:app_identifier]
      name = Sigh.config[:provisioning_name] || [bundle_id, profile_type.pretty_type].join(' ')

      unless Sigh.config[:skip_fetch_profiles]
        if Spaceship.provisioning_profile.all.find { |p| p.name == name }
          UI.error("The name '#{name}' is already taken, using another one.")
          name += " #{Time.now.to_i}"
        end
      end

      UI.important("Creating new provisioning profile for '#{Sigh.config[:app_identifier]}' with name '#{name}' for '#{Sigh.config[:platform]}' platform")
      profile = profile_type.create!(name: name,
                                bundle_id: bundle_id,
                              certificate: cert,
                                      mac: Sigh.config[:platform].to_s == 'macos',
                             sub_platform: Sigh.config[:platform].to_s == 'tvos' ? 'tvOS' : nil,
                            template_name: Sigh.config[:template_name])
      profile
    end
1223028
def save_profile(self, profile):
        
        profile = profile.replace('.json', '')
        profile_path = os.path.join(
            self.root_directory,
            'minimum_needs',
            profile + '.json'
        )
        self.write_to_file(profile_path)
658075
def create_workshift_profile(sender, instance, created, **kwargs):
    '''
    
    '''
    if instance.user.username == ANONYMOUS_USERNAME or \
       instance.status != UserProfile.RESIDENT:
        return

    try:
        semester = Semester.objects.get(current=True)
    except (Semester.DoesNotExist, Semester.MultipleObjectsReturned):
        pass
    else:
        profile, created = WorkshiftProfile.objects.get_or_create(
            user=instance.user,
            semester=semester,
        )
        if created:
            utils.make_workshift_pool_hours(
                semester=semester,
                profiles=[profile],
            )
1177837
function (req, res, next) {
    var profile = req.profile;
    var filter = { or: [{ foursquare: profile.id }, { email: profile.email }] };

    User.find({ where: filter }, function(err, users) {
      var user = users[0];

      if (user) {
        if (!user.foursquare) {
          user.foursquare = profile.id;
          user.displayName = user.displayName || profile.firstName + ' ' + profile.lastName;
          user.save(function() {
            req.user = user;
            next();
          });
          return;
        }
        req.user = user;
        next();
        return;
      }

      User.create({
        displayName: profile.firstName + ' ' + profile.lastName,
        foursquare: profile.id,
        email: profile.email,
        password: profile.id
      }, function (err, user) {
        req.user = user;
        next();
      });
    });
  }
1233018
def create(name, profile="splunk", **kwargs):
    '''
    
    '''
    client = _get_splunk(profile)
    search = client.saved_searches.create(name, **kwargs)

    # use the REST API to set owner and permissions
    # this is hard-coded for now; all managed searches are app scope and
    # readable by all
    config = __salt__['config.option'](profile)
    url = "https://{0}:{1}".format(config.get('host'), config.get('port'))
    auth = (config.get('username'), config.get('password'))
    data = {
        "owner": config.get("username"),
        "sharing": "app",
        "perms.read": "*",
    }
    _req_url = "{0}/servicesNS/{1}/search/saved/searches/{2}/acl".format(
        url, config.get("username"), urllib.quote(name)
    )
    requests.post(_req_url, auth=auth, verify=True, data=data)
    return _get_splunk_search_props(search)
1154419
def after_create(record)
      Resque.enqueue(::Riaction::ProfileCreator, record.class.base_class.to_s, record.id) unless record.class.riactionless?
    end
1330824
def load(self, profile_args):
        
        for key, value in profile_args.items():
            self.add(key, value)
1332844
def merge_profile(mean_profile, new_profile):
  """"""
  for i in range(0, len(mean_profile)):
    if new_profile[i] is None:
      continue
    mean_profile[i].add(new_profile[i])
1197897
def load(
        cls, name=None, parent_name=None, profile_is_live=False, values=None, defaults=None
    ) -> "EnvvarProfile":
        
        instance = cls(
            name=name,
            parent_name=parent_name,
            profile_is_live=profile_is_live,
            values=values,
            defaults=defaults,
        )
        instance._do_load()
        return instance
546851
public function createAction()
    {
        if ($this->request->isPost()) {

            $profile = new Profiles([
                'name' => $this->request->getPost('name', 'striptags'),
                'active' => $this->request->getPost('active')
            ]);

            if (!$profile->save()) {
                $this->flash->error($profile->getMessages());
            } else {
                $this->flash->success("Profile was created successfully");
            }

            Tag::resetInput();
        }

        $this->view->form = new ProfilesForm(null);
    }
1051527
def profile():
    """"""
    # Create forms
    verification_form = VerificationForm(formdata=None, prefix="verification")
    profile_form = profile_form_factory()

    # Process forms
    form = request.form.get('submit', None)
    if form == 'profile':
        handle_profile_form(profile_form)
    elif form == 'verification':
        handle_verification_form(verification_form)

    return render_template(
        current_app.config['USERPROFILES_PROFILE_TEMPLATE'],
        profile_form=profile_form,
        verification_form=verification_form,)
1277461
def get_profile(profile, caller, runner):
    '''
    
    '''
    profiles = profile.split(',')
    data = {}
    for profile in profiles:
        if os.path.basename(profile) == profile:
            profile = profile.split('.')[0]  # Trim extension if someone added it
            profile_path = os.path.join(os.path.dirname(__file__), 'profiles', profile + '.yml')
        else:
            profile_path = profile
        if os.path.exists(profile_path):
            try:
                rendered_template = _render_profile(profile_path, caller, runner)
                line = '-' * 80
                log.debug('\n%s\n%s\n%s\n', line, rendered_template, line)
                data.update(yaml.load(rendered_template))
            except Exception as ex:
                log.debug(ex, exc_info=True)
                raise salt.exceptions.SaltException('Rendering profile failed: {}'.format(ex))
        else:
            raise salt.exceptions.SaltException('Profile "{}" is not found.'.format(profile))

    return data
77421
def new_profile(self):
        
        # noinspection PyCallByClass,PyTypeChecker
        dir = os.path.join(QgsApplication.qgisSettingsDirPath(),
                           'inasafe', 'minimum_needs')
        file_name, __ = QFileDialog.getSaveFileName(
            self,
            self.tr('Create a minimum needs profile'),
            expanduser(dir),
            self.tr('JSON files (*.json *.JSON)'),
            options=QFileDialog.DontUseNativeDialog)
        if not file_name:
            return
        file_name = basename(file_name)
        if self.profile_combo.findText(file_name) == -1:
            minimum_needs = {
                'resources': [], 'provenance': '', 'profile': file_name}
            self.minimum_needs.update_minimum_needs(minimum_needs)
            self.minimum_needs.save_profile(file_name)
            self.profile_combo.addItem(file_name)
            self.clear_resource_list()
            self.profile_combo.setCurrentIndex(
                self.profile_combo.findText(file_name))
        else:
            self.profile_combo.setCurrentIndex(
                self.profile_combo.findText(file_name))
            self.select_profile_by_name(file_name)
790845
def create_new_profile(project_root, profile_name, profile_base_path)
      # Clean the profile_path to make it a valid path
      profile_base_path = Bebox::Profile.cleanpath(profile_base_path)
      # Check if the profile name is valid
      return unless name_valid?(profile_name, profile_base_path)
      # Check if the profile exist
      profile_path = profile_base_path.empty? ? profile_name : profile_complete_path(profile_base_path, profile_name)
      return error(_('wizard.profile.name_exist')%{profile: profile_path}) if profile_exists?(project_root, profile_path)
      # Profile creation
      profile = Bebox::Profile.new(profile_name, project_root, profile_base_path)
      output = profile.create
      ok _('wizard.profile.creation_success')%{profile: profile_path}
      return output
    end
249305
def create_profiles(self, prefix, weeks, ip_user=False):
        """"""
        # Future: Add a time range in weeks for how long a user is considered
        #         as the same user.

        # Count accessed records
        record_counter = {}
        for year, week in weeks:
            file = self.storage.get(prefix, year, week)
            self.count_records(record_counter, file)

        # TODO: Statistics, count records
        print("Records read all: {}".format(self.stat))

        # Filter records with to less/much views.
        records_valid = self.filter_counter(record_counter)

        # Create user profiles
        profiles = defaultdict(list)
        for year, week in weeks:
            file = self.storage.get(prefix, year, week)
            self._create_user_profiles(profiles, file, records_valid, ip_user,
                                       year, week)

        return profiles
863609
def create_user_profile(sender, instance, created, **kwargs):
    """"""
    if created:
        profile = UserProfile.objects.get_or_create(user=instance)[0]
        profile.hash_pass = create_htpasswd(instance.hash_pass)
        profile.save()
    else:
        # update password
        try:
            up = UserProfile.objects.get(user=instance.id)
            up.hash_pass = create_htpasswd(instance.hash_pass)
            up.save()
        except AttributeError:
            pass
150398
def get_or_create_profile(self, user, save=False, **kwargs):
        
        try:
            profile = self.get_model().objects.get(user=user, **kwargs)
            return profile, False
        except self.get_model().DoesNotExist:
            profile = self.create_profile(user, save=save, **kwargs)
            return profile, True