Create an evdev style object.
17041
def create_event_object(self,
                            event_type,
                            code,
                            value,
                            timeval=None):
        """"""
        if not timeval:
            timeval = self.__get_timeval()
        try:
            event_code = self.manager.codes['type_codes'][event_type]
        except KeyError:
            raise UnknownEventType(
                "We don't know what kind of event a %s is." % event_type)
        event = struct.pack(EVENT_FORMAT,
                            timeval[0],
                            timeval[1],
                            event_code,
                            code,
                            value)
        return event
337391
function(point,ev){
    var _self = this,
      shape = ev.target.shape;
    return Util.mix({shape : shape},point);
  }
331155
def create(game, normalize_returns=False, settings=None, presets=None):
    
    return MujocoEnv(
        envname=game,
        normalize_returns=normalize_returns,
        settings=settings,
        presets=presets
    )
505521
def create(doc=None, error_text=None, exception_handlers=empty.dict, extend=Type, chain=True, auto_instance=True,
           accept_context=False):
    """"""
    extend = extend if type(extend) == type else type(extend)

    def new_type_handler(function):
        class NewType(extend):
            __slots__ = ()
            _accept_context = accept_context

            if chain and extend != Type:
                if error_text or exception_handlers:
                    if not accept_context:
                        def __call__(self, value):
                            try:
                                value = super(NewType, self).__call__(value)
                                return function(value)
                            except Exception as exception:
                                for take_exception, rewrite in exception_handlers.items():
                                    if isinstance(exception, take_exception):
                                        if isinstance(rewrite, str):
                                            raise ValueError(rewrite)
                                        else:
                                            raise rewrite(value)
                                if error_text:
                                    raise ValueError(error_text)
                                raise exception
                    else:
                        if extend._accept_context:
                            def __call__(self, value, context):
                                try:
                                    value = super(NewType, self).__call__(value, context)
                                    return function(value, context)
                                except Exception as exception:
                                    for take_exception, rewrite in exception_handlers.items():
                                        if isinstance(exception, take_exception):
                                            if isinstance(rewrite, str):
                                                raise ValueError(rewrite)
                                            else:
                                                raise rewrite(value)
                                    if error_text:
                                        raise ValueError(error_text)
                                    raise exception
                        else:
                            def __call__(self, value, context):
                                try:
                                    value = super(NewType, self).__call__(value)
                                    return function(value, context)
                                except Exception as exception:
                                    for take_exception, rewrite in exception_handlers.items():
                                        if isinstance(exception, take_exception):
                                            if isinstance(rewrite, str):
                                                raise ValueError(rewrite)
                                            else:
                                                raise rewrite(value)
                                    if error_text:
                                        raise ValueError(error_text)
                                    raise exception
                else:
                    if not accept_context:
                        def __call__(self, value):
                            value = super(NewType, self).__call__(value)
                            return function(value)
                    else:
                        if extend._accept_context:
                            def __call__(self, value, context):
                                value = super(NewType, self).__call__(value, context)
                                return function(value, context)
                        else:
                            def __call__(self, value, context):
                                value = super(NewType, self).__call__(value)
                                return function(value, context)
            else:
                if not accept_context:
                    if error_text or exception_handlers:
                        def __call__(self, value):
                            try:
                                return function(value)
                            except Exception as exception:
                                for take_exception, rewrite in exception_handlers.items():
                                    if isinstance(exception, take_exception):
                                        if isinstance(rewrite, str):
                                            raise ValueError(rewrite)
                                        else:
                                            raise rewrite(value)
                                if error_text:
                                    raise ValueError(error_text)
                                raise exception
                    else:
                        def __call__(self, value):
                            return function(value)
                else:
                    if error_text or exception_handlers:
                        def __call__(self, value, context):
                            try:
                                return function(value, context)
                            except Exception as exception:
                                for take_exception, rewrite in exception_handlers.items():
                                    if isinstance(exception, take_exception):
                                        if isinstance(rewrite, str):
                                            raise ValueError(rewrite)
                                        else:
                                            raise rewrite(value)
                                if error_text:
                                    raise ValueError(error_text)
                                raise exception
                    else:
                        def __call__(self, value, context):
                            return function(value, context)

        NewType.__doc__ = function.__doc__ if doc is None else doc
        if auto_instance and not (introspect.arguments(NewType.__init__, -1) or
                                  introspect.takes_kwargs(NewType.__init__) or
                                  introspect.takes_args(NewType.__init__)):
            return NewType()
        return NewType

    return new_type_handler
22158
def __create_object_body(kind,
                         obj_class,
                         spec_creator,
                         name,
                         namespace,
                         metadata,
                         spec,
                         source,
                         template,
                         saltenv):
    '''
    
    '''
    if source:
        src_obj = __read_and_render_yaml_file(source, template, saltenv)
        if (
                not isinstance(src_obj, dict) or
                'kind' not in src_obj or
                src_obj['kind'] != kind):
            raise CommandExecutionError(
                'The source file should define only '
                'a {0} object'.format(kind))

        if 'metadata' in src_obj:
            metadata = src_obj['metadata']
        if 'spec' in src_obj:
            spec = src_obj['spec']

    return obj_class(
        metadata=__dict_to_object_meta(name, namespace, metadata),
        spec=spec_creator(spec))
458549
def _generate_vdev(self, base, offset):
        
        vdev = hex(int(base, 16) + offset)[2:]
        return vdev.rjust(4, '0')
528420
def create(client, _type, **kwargs):
    """"""
    obj = client.factory.create("ns0:%s" % _type)
    for key, value in kwargs.items():
        setattr(obj, key, value)
    return obj
808556
def from_config(cls, pyvlx, item):
        """"""
        name = item['name']
        ident = item['id']
        return cls(pyvlx, ident, name)
1128384
def init(cls, obj, context):
    """"""
    addr = statsId(obj)
    if addr not in cls.containerMap:
      cls.containerMap[addr] = cls.__getStatContainer(context)
    return cls.containerMap[addr]
1051507
function (evt) {
      var evh = this.evtHandlers, et = evt.type;
      if (evh) {
          for (var i = 0, sz = evh.length; sz > i; i++) {
              if (evh[i].evtType === et) {
                  evh[i].executeCb(evt, this.eh, this.parent.vscope);
                  break;
              }
          }
      }
  }
690558
function createModelObject() {
  var key, method,
      self = this,
      generator = this;
  
  /**
    Model Object Class. Generated by the Model.
  
    @private
    @class ModelObject
    @constructor
   */
  
  function ModelObject() {
    this.className = generator.className + 'Object';
  }
  
  /**
    Model Generator
   */

  ModelObject.prototype.generator = this;
  
  var gen = this;
  
  
  /**
    Get Changed Values

    @returns {object} Object with the fields updated
   */
 
  ModelObject.prototype.getUpdatedFields = function() {
    var diff = 0,
        update = {},
        currentState = gen.createCurrentState(this),
        origState = this.__currentState;
    for (var key in currentState) {
      if (currentState[key] !== origState[key]) {
        update[key] = currentState[key];
        diff++;
      }
    }
    return (diff > 0) ? update : null;
  }
  
  /**
    Save model data
  
    Provides [err]
  
    @param {function} callback
   */
  
  ModelObject.prototype.save = function(callback) {
    
    var self = this;
    
    // Emit before_save event
    generator.emit('before_save', self);
    
    // Get updated fields after the before_save event
    var update = this.getUpdatedFields();
    
    // No changes
    if (update == null) { 
      callback.call(self, null); 
      return; 
    }
    
    update.id = this.id;
    
    // Perform driver save.
    // NOTE: data is validated by the model
    generator.save(update, function(err) {
      generator.emit('after_save', err, self);
      callback.call(self, err);
    });
  }
  
  /**
    Alias of `ModelObject::save`
  
    @method update
   */
  
  ModelObject.prototype.update = ModelObject.prototype.save; // alias
  
  /**
    Alias of `ModelObject::save`
   */

  ModelObject.prototype.sync = ModelObject.prototype.save; // alias
  
  /**
    Delete model data
  
    Provides: [err]
  
    @param {function} callback
   */
  
  ModelObject.prototype.delete = function(callback) {
    var self = this;
    var generator = this.generator;
    generator.delete(this.id, function(err) {
      generator.emit('delete', err, self);
      callback.call(self, err);
    });
  }
  
  /**
    Alias of `ModelObject::delete`
   */
  
  ModelObject.prototype.remove = ModelObject.prototype.delete; // alias
  
  /**
    Alias of `ModelObject::delete`
   */
 
  ModelObject.prototype.destroy = ModelObject.prototype.delete; // alias

  /**
    Creates a Multi object
  
    @private
    @param {object} options Multi Configuration
   */
  
  ModelObject.prototype.createMulti = function(options) {
    return new Multi(this, options);
  }
  
  /**
    Provides caching capabilities. Alias of `Driver::queryCached`
   */
 
  ModelObject.prototype.queryCached = function(cdata) {
    var args = slice.call(arguments, 0),
        driver = this.generator.driver;
    cdata.storage = driver.storage;
    driver.queryCached.apply(this, args);
  }
  
  return ModelObject;
  
}
684933
def generate(env):
    """"""
    SCons.Tool.CreateJarBuilder(env)

    SCons.Tool.CreateJavaFileBuilder(env)
    SCons.Tool.CreateJavaClassFileBuilder(env)
    SCons.Tool.CreateJavaClassDirBuilder(env)

    env.AddMethod(Jar)

    env['JAR']        = 'jar'
    env['JARFLAGS']   = SCons.Util.CLVar('cf')
    env['_JARFLAGS']  = jarFlags
    env['_JARMANIFEST'] = jarManifest
    env['_JARSOURCES'] = jarSources
    env['_JARCOM']    = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARSOURCES'
    env['JARCOM']     = "${TEMPFILE('$_JARCOM','$JARCOMSTR')}"
    env['JARSUFFIX']  = '.jar'
1329327
def creator(entry, config):
        """"""
        script = render(config.script, model=config.model, env=config.env, item=config.item)

        temp = tempfile.NamedTemporaryFile(prefix="script-", suffix=".py", mode='w+t', delete=False)
        temp.writelines(script)
        temp.close()

        language = 'python' if 'type' not in entry else entry['type']
        template_file = os.path.join(os.path.dirname(__file__), 'templates/%s-script.sh.j2' % language)

        with open(template_file) as handle:
            template = handle.read()
            config.script = render(template, script=temp.name)

        return Script(config)
995451
def generate_id(self, obj):
        """"""
        object_type = type(obj).__name__.lower()
        return '{}_{}'.format(object_type, self.get_object_id(obj))
607617
def create(cls, data=None, *args, **kwargs):
        """"""
        cls.validate(data)
        # otherwise endpoint should contain the service path too
        getattr(Entity, 'create').__func__(cls, data=data, *args, **kwargs)
578223
def create_object(
        request, model=None, template_name=None,
        template_loader=loader, extra_context=None, post_save_redirect=None,
        login_required=False, context_processors=None, form_class=None):
    
    if extra_context is None:
        extra_context = {}
    if login_required and not request.user.is_authenticated:
        return redirect_to_login(request.path)

    model, form_class = get_model_and_form_class(model, form_class)
    if request.method == 'POST':
        form = form_class(request.POST, request.FILES)
        if form.is_valid():
            new_object = form.save()

            msg = ugettext("The %(verbose_name)s was created successfully.") %\
                {"verbose_name": model._meta.verbose_name}
            messages.success(request, msg, fail_silently=True)
            return redirect(post_save_redirect, new_object)
    else:
        form = form_class()

    # Create the template, context, response
    if not template_name:
        template_name = "%s/%s_form.html" % (
            model._meta.app_label, model._meta.object_name.lower())
    t = template_loader.get_template(template_name)
    c = {
        'form': form,
    }
    apply_extra_context(extra_context, c)
    return HttpResponse(t.render(context=c, request=request))
1324269
def create(cls, parent=None, **kwargs):
        """"""

        if parent is None:
            raise Exception("Parent class is required")

        route = copy(parent.route)
        if cls.ID_NAME is not None:
            route[cls.ID_NAME] = ""

        obj = cls(key=parent.key, route=route, config=parent.config)

        start = datetime.now()
        response = requests.post(obj._url(), auth=(obj.key, ""), data=kwargs)
        cls._delay_for_ratelimits(start)

        if response.status_code not in cls.TRUTHY_CODES:
            return cls._handle_request_exception(response)

        # No envelope on post requests
        data = response.json()
        obj.route[obj.ID_NAME] = data.get("id", data.get(obj.ID_NAME))
        obj.data = data

        return obj