Setup virtual properties for the document
480952
function setVirtuals(schema, paths) {
  paths.forEach(path => {
    const props = path.options.virtual.properties;

    if (props[path.path]) {
      schema.virtual(props[path.path]).get(function() {
        return path.enumValues;
      });
    }
  });
}
304669
function applyPropDoclets(props, propName) {
  let prop = props[propName];
  let doclets = prop.doclets;
  let value;

  // the @type doclet to provide a prop type
  // Also allows enums (oneOf) if string literals are provided
  // ex: @type {("optionA"|"optionB")}
  if (doclets.type) {
    value = cleanDocletValue(doclets.type);
    prop.type.name = value;

    if (value[0] === '(') {
      value = value.substring(1, value.length - 1).split('|');

      prop.type.value = value;
      prop.type.name = value.every(isLiteral) ? 'enum' : 'union';
    }
  }

  // Use @required to mark a prop as required
  // useful for custom propTypes where there isn't a `.isRequired` addon
  if (doclets.required) {
    prop.required = true;
  }

  // Use @defaultValue to provide a prop's default value
  if (doclets.defaultValue) {
    prop.defaultValue = cleanDocletValue(doclets.defaultValue);
  }
}
1085461
def SetProperties(has_props_cls, input_dict, include_immutable=True):
    """"""
    props = has_props_cls()
    if not isinstance(input_dict, (dict, collections.OrderedDict)):
        raise RuntimeError('input_dict invalid: ', input_dict)
    for k, v in iter(input_dict.items()):
        if (k in has_props_cls._props and (
                include_immutable or
                any(hasattr(has_props_cls._props[k], att) for att in ('required', 'new_name'))
                )
           ):
            p = props._props.get(k)
            if isinstance(p, properties.HasProperties):
                props._set(k, SetProperties(p, v, include_immutable=include_immutable))
            elif isinstance(p, properties.Instance):
                props._set(k, SetProperties(p.instance_class, v, include_immutable=include_immutable))
            elif isinstance(p, properties.List):
                if not isinstance(v, list):
                    raise RuntimeError('property value mismatch', p, v)
                if not isinstance(v[0], properties.HasProperties):
                    prop = p.prop.instance_class
                    newlist = []
                    for i in v:
                        value = SetProperties(prop, i, include_immutable=include_immutable)
                        newlist.append(value)
                    props._set(k, newlist)
                else:
                    props._set(k, v)
            else:
                props._set(k, p.from_json(v))

    # Return others as well
    # others_dict = {k: v for k, v in iter(input_dict.items())
    #                if k not in has_props_cls._props}
    return props
1209675
def setProperty(self, prop, *args, **kwargs):
        
        f = self.__setAttrs.get(prop)
        if not f:
            raise KeyError('Unknown writable property: %s' % prop)
        f(self, *args, **kwargs)
1108133
function() {

            var that = this;
            var propertiesParams = that.__getPropertiesParam();

            _.each(propertiesParams, function(params, property) {

                var value = that.__getPropertyValue(property);

                if (_.isUndefined(value) && 'default' in params) {

                    var defaultValue = params.default;

                    if (_.isFunction(defaultValue)) {
                        defaultValue = defaultValue.call(that);
                    }

                    if (defaultValue) {
                        if ((_.isSimpleObject(defaultValue)) || _.isArray(defaultValue)) {
                            defaultValue = _.clone(defaultValue)
                        }
                    }

                    that.__setPropertyValue(property, defaultValue, false);
                }
            });
        }
1354923
def _add_properties(self, **kwargs):
        
        for k,v in kwargs.items():
            if k=='parallax':
                self.obs.add_parallax(v)
            elif k in ['Teff', 'logg', 'feh', 'density']:
                par = {k:v}
                self.obs.add_spectroscopy(**par)
            elif re.search('_', k):
                m = re.search('^(\w+)_(\w+)$', k)
                prop = m.group(1)
                tag = m.group(2)
                self.obs.add_spectroscopy(**{prop:v, 'label':'0_{}'.format(tag)})
761399
def add_property(self, prop):
        """"""
        if _debug: Object._debug("add_property %r", prop)

        # make a copy of the properties dictionary
        self._properties = _copy(self._properties)

        # save the property reference and default value (usually None)
        self._properties[prop.identifier] = prop
        self._values[prop.identifier] = prop.default
281335
function(e) {
		var win = null,
			doc = null,
			target = e.target,
			type = target.nodeType;
		if (gui.Type.isDefined(type)) {
			doc = (type === Node.DOCUMENT_NODE ? target : target.ownerDocument);
			win = doc.defaultView;
		} else {
			win = target;
			doc = win.document;
		}
		this.event = e;
		this.window = win;
		this.document = doc;
		this.documentspirit = doc.documentElement.spirit;
	}
1079968
void setup(final Map<String, Object> properties) {
        final List<SetupAction> successfulActions = new ArrayList<SetupAction>();
        for (final SetupAction action : setupActions) {
            try {
                action.setup(properties);
                successfulActions.add(action);
            } catch (final Throwable e) {
                for (SetupAction s : successfulActions) {
                    try {
                        s.teardown(properties);
                    } catch (final Throwable t) {
                        // we ignore these, and just propagate the exception that caused the setup to fail
                    }
                }
                throw new RuntimeException(e);
            }
        }
    }
978974
public function setDocumentValue($document, $property, $value)
    {
        $setter = \Closure::bind(function ($document, $property, $value) {
                $document->$property = $value;
            }, null, $document
        );
        $setter($document, $property, $value);
    }
673942
def setup_output_document(input_doc, tmp_input_doc, metadata_info,
                                                    copy_document_catalog=True):
    """"""
    # NOTE: Inserting pages from a PdfFileReader into multiple PdfFileWriters
    # seems to cause problems (writer can hang on write), so only one is used.
    # This is why the tmp_input_doc file was created earlier, to get copies of
    # the page objects which are independent of those in input_doc.  An ugly
    # hack for a nasty bug to track down.

    # NOTE: You can get the _root_object attribute (dict for the document
    # catalog) from the output document after calling cloneReaderDocumentRoot
    # or else you can just directly get it from the input_doc.trailer dict, as
    # below (which is from the code for cloneReaderDocumentRoot), but you
    # CANNOT set the full _root_object to be the _root_object attribute for the
    # actual output_doc or else only blank pages show up in acroread (whether
    # or not there is any attempt to explicitly copy the pages over).  The same
    # is true for using cloneDocumentFromReader (which just calls
    # cloneReaderDocumentRoot followed by appendPagesFromReader).  At least the
    # '/Pages' key and value in _root_object cause problems, so they are
    # skipped in the partial copy.  Probably a bug in PyPDF2.  See the original
    # code for the routines on the github pages below.
    #
    # https://github.com/mstamy2/PyPDF2/blob/master/PyPDF2/pdf.py
    # https://github.com/mstamy2/PyPDF2/blob/master/PyPDF2/generic.py
    #
    # Files still can change zoom mode on clicking outline links, but that is
    # an Adobe implementation problem, and happens even in the uncropped files:
    # https://superuser.com/questions/278302/

    output_doc = PdfFileWriter()

    def root_objects_not_indirect(input_doc, root_object):
        """This can expand some of the `IndirectObject` objects in  a root object to
        see the actual values.  Currently only used for debugging.  May mess up the
        input doc and require a temporary one."""
        if isinstance(root_object, dict):
            return {root_objects_not_indirect(input_doc, key):
                    root_objects_not_indirect(input_doc, value) for
                                                  key, value in root_object.items()}
        elif isinstance(root_object, list):
            return [root_objects_not_indirect(input_doc, item) for item in root_object]
        elif isinstance(root_object, IndirectObject):
            return input_doc.getObject(root_object)
        else:
            return root_object

    doc_cat_whitelist = args.docCatWhitelist.split()
    if "ALL" in doc_cat_whitelist:
        doc_cat_whitelist = ["ALL"]

    doc_cat_blacklist = args.docCatBlacklist.split()
    if "ALL" in doc_cat_blacklist:
        doc_cat_blacklist = ["ALL"]

    # Partially copy over document catalog data from input_doc to output_doc.
    if not copy_document_catalog or (
            not doc_cat_whitelist and doc_cat_blacklist == ["ALL"]):
        # Check this first, to completely skip the possibly problematic code getting
        # document catalog items when possible.  Does not print a skipped list, though.
        if args.verbose:
            print("\nNot copying any document catalog items to the cropped document.")
    else:
        try:
            root_object = input_doc.trailer["/Root"]

            copied_items = []
            skipped_items = []
            for key, value in root_object.items():
                # Some possible keys can be:
                #
                # /Type -- required, must have value /Catalog
                # /Pages -- required, indirect ref to page tree; skip, will change
                # /PageMode -- set to /UseNone, /UseOutlines, /UseThumbs, /Fullscreen,
                #              /UseOC, or /UseAttachments, with /UseNone default.
                # /OpenAction -- action to take when document is opened, like zooming
                # /PageLayout -- set to /SinglePage, /OneColumn, /TwoColumnLeft,
                #                /TwoColumnRight, /TwoPageLeft, /TwoPageRight
                # /Names -- a name dictionary to avoid having to use object numbers
                # /Outlines -- indirect ref to document outline, i.e., bookmarks
                # /Dests -- a dict of destinations in the PDF
                # /ViewerPreferences -- a viewer preferences dict
                # /MetaData -- XMP metadata, as opposed to other metadata
                # /PageLabels -- alternate numbering for pages, only affect PDF viewers
                if key == "/Pages":
                    skipped_items.append(key)
                    continue
                if doc_cat_whitelist != ["ALL"] and key not in doc_cat_whitelist:
                    if doc_cat_blacklist == ["ALL"] or key in doc_cat_blacklist:
                        skipped_items.append(key)
                        continue
                copied_items.append(key)
                output_doc._root_object[NameObject(key)] = value

            if args.verbose:
                print("\nCopied these items from the document catalog:\n   ", end="")
                print(*copied_items)
                print("Skipped copy of these items from the document catalog:\n   ", end="")
                print(*skipped_items)

        except (KeyboardInterrupt, EOFError):
            raise
        except: # Just catch any errors here; don't know which might be raised.
            # On exception just warn and get a new PdfFileWriter object, to be safe.
            print("\nWarning: The document catalog data could not be copied to the"
                  "\nnew, cropped document.  Try fixing the PDF document using"
                  "\n'--gsFix' if you have Ghostscript installed.", file=sys.stderr)
            output_doc = PdfFileWriter()

    #output_doc.appendPagesFromReader(input_doc) # Works, but wait and test more.
    for page in [input_doc.getPage(i) for i in range(input_doc.getNumPages())]:
        output_doc.addPage(page)

    tmp_output_doc = PdfFileWriter()
    #tmp_output_doc.appendPagesFromReader(tmp_input_doc)  # Works, but test more.
    for page in [tmp_input_doc.getPage(i) for i in range(tmp_input_doc.getNumPages())]:
        tmp_output_doc.addPage(page)

    ##
    ## Copy the metadata from input_doc to output_doc, modifying the Producer string
    ## if this program didn't already set it.  Get bool for whether this program
    ## cropped the document already.
    ##

    already_cropped_by_this_program = set_cropped_metadata(input_doc, output_doc,
                                                           metadata_info)
    return output_doc, tmp_output_doc, already_cropped_by_this_program
502278
def _create_properties(self):
        """"""
        self._rcbag = {}  # bag for row/column prop editors
        self._fgrid = f = ttk.Labelframe(self._sframe.innerframe,
                                         text=_('Grid options:'), padding=5)
        f.grid(sticky='nswe')
        #  hack to resize correctly when properties are hidden
        label = ttk.Label(f)
        label.grid()

        label_tpl = "{0}:"
        row = 0
        col = 0

        groups = (
            ('00', properties.GRID_PROPERTIES, properties.LAYOUT_OPTIONS),
        )

        for gcode, plist, propdescr in groups:
            for name in plist:
                kwdata = propdescr[name]
                labeltext = label_tpl.format(name)
                label = ttk.Label(self._fgrid, text=labeltext, anchor=tk.W)
                label.grid(row=row, column=col, sticky=tk.EW, pady=2)
                widget = self._create_editor(self._fgrid, name, kwdata)
                widget.grid(row=row, column=col+1, sticky=tk.EW, pady=2)
                row += 1
                self._propbag[gcode+name] = (label, widget)

        # Grid row/col properties
        #labels
        gcode = '01'
        self._fgrc = fgrc = ttk.LabelFrame(self._sframe.innerframe,
                                           text=_('Grid row/column options:'),
                                           padding=5)
        fgrc.grid(row=1, column=0, sticky=tk.NSEW, pady='10 0')

        #hack to resize correctly when properties are hidden
        label = ttk.Label(fgrc)
        label.grid()

        row = col = 0
        icol = 1
        headers = []
        for pname in properties.GRID_RC_PROPERTIES:
            label = ttk.Label(fgrc, text=pname)
            label.grid(row=row, column=icol)
            headers.append(label)
            icol += 1
        self._internal = {'grc_headers': headers}

        #
        name_format = '{}_{}_{}'  # {row/column}_{number}_{name}
        MAX_RC = 50
        #rowconfig
        row += 1
        trow_label = _('Row {0}:')
        tcol_label = _('Column {0}:')
        for index in range(0, MAX_RC):
            labeltext = trow_label.format(index)
            label = ttk.Label(fgrc, text=labeltext)
            label.grid(row=row, column=0)

            labeltext = tcol_label.format(index)
            labelc = ttk.Label(fgrc, text=labeltext)
            labelc.grid(row=row + MAX_RC, column=0, sticky=tk.E, pady=2)

            icol = 1
            for pname in properties.GRID_RC_PROPERTIES:
                kwdata = properties.LAYOUT_OPTIONS[pname]

                alias = name_format.format('row', index, pname)
                widget = self._create_editor(fgrc, alias, kwdata)
                widget.grid(row=row, column=icol, pady=2, sticky='ew')
                self._rcbag[alias] = (label, widget)

                alias = name_format.format('column', index, pname)
                widget = self._create_editor(fgrc, alias, kwdata)
                widget.grid(row=row + MAX_RC, column=icol, pady=2, sticky='ew')
                self._rcbag[alias] = (labelc, widget)

                icol += 1
            row += 1
172340
void add_document(Document doc)
    {
        doc.feature().normalize();
        documents_.add(doc);
        composite_.add_vector(doc.feature());
    }
884717
private static void addDocumentPropertyDefinitions(DocumentTypeDefinitionImpl type) {

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.IS_IMMUTABLE,
                "Is Immutable",
                "Is Immutable",
                PropertyType.BOOLEAN,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.IS_LATEST_VERSION,
                "Is Latest Version",
                "Is Latest Version",
                PropertyType.BOOLEAN,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.IS_MAJOR_VERSION,
                "Is Major Version",
                "Is Major Version",
                PropertyType.BOOLEAN,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.IS_LATEST_MAJOR_VERSION,
                "Is Latest Major Version",
                "Is Latest Major Version",
                PropertyType.BOOLEAN,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.VERSION_LABEL,
                "Version Label",
                "Version Label",
                PropertyType.STRING,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.VERSION_SERIES_ID,
                "Version Series Id",
                "Version Series Id",
                PropertyType.ID,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.IS_VERSION_SERIES_CHECKED_OUT,
                "Is Verison Series Checked Out",
                "Is Verison Series Checked Out",
                PropertyType.BOOLEAN,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.VERSION_SERIES_CHECKED_OUT_ID,
                "Version Series Checked Out Id",
                "Version Series Checked Out Id",
                PropertyType.ID,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.VERSION_SERIES_CHECKED_OUT_BY,
                "Version Series Checked Out By",
                "Version Series Checked Out By",
                PropertyType.STRING,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.CHECKIN_COMMENT,
                "Checkin Comment",
                "Checkin Comment",
                PropertyType.STRING,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.CONTENT_STREAM_LENGTH,
                "Content Stream Length",
                "Content Stream Length",
                PropertyType.INTEGER,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.CONTENT_STREAM_MIME_TYPE,
                "MIME Type",
                "MIME Type",
                PropertyType.STRING,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.CONTENT_STREAM_FILE_NAME,
                "Filename",
                "Filename",
                PropertyType.STRING,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));

        type.addPropertyDefinition(
            createPropDef(
                PropertyIds.CONTENT_STREAM_ID,
                "Content Stream Id",
                "Content Stream Id",
                PropertyType.ID,
                Cardinality.SINGLE,
                Updatability.READONLY,
                false,
                false));
    }
1108971
public function setup(): void
    {
        $this->rtl = I18N::direction() === 'rtl';

        $this->rkeywords = '';

        // I18N: This is a report footer. %s is the name of the application.
        $this->generated_by = I18N::translate('Generated by %s', Webtrees::NAME . ' ' . Webtrees::VERSION);

        // Paper size - defaults to A4 if the report fails to define a size.
        [$this->page_width, $this->page_height] = self::PAPER_SIZES[$this->page_format] ?? self::PAPER_SIZES['A4'];
    }
993352
function setAsRootDocument(doc) {
  rootDoc = doc;
  var window = rootDoc.defaultView;
  window.setTimeout = function(code, delay, arguments) {};
  window.setInterval = function(code, delay, arguments) {};
  anychartify(rootDoc);

  return rootDoc
}
1207223
def setup_document(self, content, **kwargs):
        

        self.reset()
        if isinstance(content, six.text_type):
            raise error.GrabMisuseError('Method `setup_document` accepts only '
                                        'byte string in `content` argument.')

        # Configure Document instance
        doc = Document(grab=self)
        doc.body = content
        doc.status = ''
        doc.head = b'HTTP/1.1 200 OK\r\n\r\n'
        doc.parse(charset=kwargs.get('document_charset'))
        doc.code = 200
        doc.total_time = 0
        doc.connect_time = 0
        doc.name_lookup_time = 0
        doc.url = ''

        for key, value in kwargs.items():
            setattr(doc, key, value)

        self.doc = doc