car: Optional reference to car. If omitted, creates a blank car
329091
function createCar(car) {
    var back = createCardBack(assets.carBack);
    var front = new CarFront(car);
    var flippable = new FlippableCard(back, front);
    flippable.x = flippable.regX;
    flippable.y = flippable.regY;
    return flippable;
}
152689
def assign(A, attr, B, lock=False):
    '''
    '''
    class NoAttr(object): pass

    context = threading.Lock if lock else null_context
    with context():
        if not hasattr(A, attr):
            tmp = NoAttr
        else:
            tmp = getattr(A, attr)

        setattr(A, attr, B)

        try:
            yield B

        finally:
            if tmp is NoAttr:
                delattr(A, attr)
            else:
                setattr(A, attr, tmp)
1000336
def save(self, data, xparent=None):
        
        if xparent is not None:
            elem = ElementTree.SubElement(xparent, 'bool')
        else:
            elem = ElementTree.Element('bool')

        elem.text = nstr(data)
        return elem
26696
def assignrepr(self, prefix):
        """"""
        caller = 'Timegrids('
        blanks = ' ' * (len(prefix) + len(caller))
        prefix = f'{prefix}{caller}'
        lines = [f'{self.init.assignrepr(prefix)},']
        if self.sim != self.init:
            lines.append(f'{self.sim.assignrepr(blanks)},')
        lines[-1] = lines[-1][:-1] + ')'
        return '\n'.join(lines)
684214
def emptyElement(self, name, attrs):
        """"""
        attr = ' '.join('%s=%s' % (n, quoteattr(scientificformat(v)))
                        for n, v in sorted(attrs.items()))
        self._write('<%s %s/>' % (name, attr))
736480
function UnknownReference(id, prop, missing) {
                this._id = id;
                this._prop = prop;
                this._missing = missing;
            }
1194208
function(type, args, obj) {
        var close = args[0],
            title = this.cfg.getProperty(DEF_CFG.TITLE.key);
    
        if (close) {
            if (!title) {
                this.createTitleBar("&#160;");
            }
            this.createCloseButton();
        } else {
            this.removeCloseButton();
            if (!title) {
                this.removeTitleBar();
            }
        }
    }
873676
def main(car_factory, extra_engine):
    """"""
    car1 = car_factory(serial_number=1)
    car2 = car_factory(serial_number=2, engine=extra_engine)

    assert car1.serial_number == 1 and car2.serial_number == 2
    assert car1.engine is not car2.engine
    assert car2.engine is extra_engine
1076899
function omit(obj, blackList) {
  var newObj = {};
  Object.keys(obj || {}).forEach(function (key) {
    if (blackList.indexOf(key) === -1) {
      newObj[key] = obj[key];
    }
  });
  return newObj;
}
521450
protected function fillDataForEmpty()
    {
        // Fill list references if they are empty
        $fields = [];

        // Add fields for attributes
        foreach ($this->info->attributes as $attribute) {

            if ($attribute->hidden || ! $this->shouldAttributeBeDisplayedByDefault($attribute, $this->info)) {
                continue;
            }

            $fields[ $attribute->name ] = $this->makeModelShowFieldDataForAttributeData($attribute, $this->info);
        }

        // Add fields for relations?
        // Perhaps, though it may be fine to leave this up to manual configuration.
        // todo: consider


        $this->info->show->fields = $fields;
    }
339318
def _create(self):
        

        if 'name' in self._data:
            obj_ref = self.api.add(self.obj_parent(), self.obj_type(), name=self.obj_name())
        else:
            obj_ref = self.api.add(self.obj_parent(), self.obj_type())
        self.api.commit()
        return self.api.remapIds(obj_ref)
1278133
def _requirement_element(self, parent_element, req_data):
        """"""
        req_data = self._transform_result(req_data)
        if not req_data:
            return

        title = req_data.get("title")
        if not title:
            logger.warning("Skipping requirement, title is missing")
            return
        req_id = req_data.get("id")

        if not self._check_lookup_prop(req_id):
            logger.warning(
                "Skipping requirement `%s`, data missing for selected lookup method", title
            )
            return

        attrs, custom_fields = self._classify_data(req_data)
        attrs, custom_fields = self._fill_defaults(attrs, custom_fields)

        # For testing purposes, the order of fields in resulting XML
        # needs to be always the same.
        attrs = OrderedDict(sorted(attrs.items()))
        custom_fields = OrderedDict(sorted(custom_fields.items()))

        requirement = etree.SubElement(parent_element, "requirement", attrs)

        title_el = etree.SubElement(requirement, "title")
        title_el.text = title

        description = req_data.get("description")
        if description:
            description_el = etree.SubElement(requirement, "description")
            description_el.text = description

        self._fill_custom_fields(requirement, custom_fields)
1123973
public static Map<String, Object> replaceDataReferences(final Map<String, Object> input,
                                                             final Map<String, Map<String, String>> data,
                                                            Converter<String, String> converter,
                                                            boolean failIfUnexpanded,
                                                            boolean blankIfUnexpanded
    )
    {
        final HashMap<String, Object> output = new HashMap<>();
        for (final String s : input.keySet()) {
            Object o = input.get(s);
            output.put(s, replaceDataReferencesInObject(o, data, converter, failIfUnexpanded, blankIfUnexpanded));
        }
        return output;
    }
451932
function _createElementsIfNotExist()
    {
        if (empty($this->_elements)) {
            $this->_createElements();
            if ($this->_flagFrozen) {
                $this->freeze();
            }
        }
    }
996285
def blank?(str)
      str.nil? or (str.is_a? String and str.strip.empty?)
    end
25847
def create_empty_annotations(xml_file, dataset):
    
    xml_file = Path(xml_file)
    root = Element('annotations')
    root.set('version', VERSION)

    info = SubElement(root, 'dataset')
    x = SubElement(info, 'filename')
    x.text = str(dataset.filename)
    x = SubElement(info, 'path')  # not to be relied on
    x.text = str(dataset.filename)
    x = SubElement(info, 'start_time')
    start_time = dataset.header['start_time'].replace(tzinfo=None)
    x.text = start_time.isoformat()

    first_sec = 0
    last_sec = int(dataset.header['n_samples'] /
                   dataset.header['s_freq'])  # in s

    x = SubElement(info, 'first_second')
    x.text = str(first_sec)
    x = SubElement(info, 'last_second')
    x.text = str(last_sec)

    xml = parseString(tostring(root))
    with xml_file.open('w') as f:
        f.write(xml.toxml())
490751
def create_distant_reference(self, ref_data):
        """"""
        self.validate_reference_data(ref_data)
        creation_status = self._zotero_lib.create_items([ref_data])
        try:
            created_item = creation_status["successful"]["0"]
            return created_item
        except KeyError as e:
            print(creation_status)
            raise CreateZoteroItemError from e