update content based on xml or json
777245
function updateVersion(file, content, version) {
    const prev = /id="branch-cordova-sdk"[\s]*version="\d+\.\d+\.\d+"/gim;
    const next = `id="branch-cordova-sdk"\n  version="${version}"`;

    try {
      if (isFileXml(file)) {
        content = content.replace(prev, next);
      } else {
        isChange = content.version !== version;
        content.version = version;
      }
    } catch (e) {
      throw new Error(
        `BRANCH SDK: update to update npm version with file ${file}`
      );
    }
    return content;
  }
522876
function () {
		var ajax = this.obj.$ajax;
		var self = this;
		var version = this.obj.getUserData(0, "version");
		var url = this.serverProcessor + ajax.urlSeparator(this.serverProcessor) + ["dhx_user=" + this._user, "dhx_version=" + version].join("&");
		url = url.replace("editing=true&", "");
		this.getUpdates(url, function (xml) {
			var vers = ajax.xpath("//userdata", xml);
			self.obj.setUserData(0, "version", self._v(vers[0]));

			var upds = ajax.xpath("//update", xml);
			if (upds.length) {
				self._silent_mode = true;

				for (var i = 0; i < upds.length; i++) {
					var status = upds[i].getAttribute('status');
					var id = upds[i].getAttribute('id');
					var parent = upds[i].getAttribute('parent');
					switch (status) {
						case 'inserted':
							self.callEvent("insertCallback", [upds[i], id, parent]);
							break;
						case 'updated':
							self.callEvent("updateCallback", [upds[i], id, parent]);
							break;
						case 'deleted':
							self.callEvent("deleteCallback", [upds[i], id, parent]);
							break;
					}
				}

				self._silent_mode = false;
			}

			self._update_busy = false;
			self = null;
		});
	}
418450
def modify_content(request, page_id, content_type, language_id):
    """"""
    page = get_object_or_404(Page, pk=page_id)
    perm = request.user.has_perm('pages.change_page')
    if perm and request.method == 'POST':
        content = request.POST.get('content', False)
        if not content:
            raise Http404
        page = Page.objects.get(pk=page_id)
        if settings.PAGE_CONTENT_REVISION:
            Content.objects.create_content_if_changed(page, language_id,
                                                      content_type, content)
        else:
            Content.objects.set_or_create_content(page, language_id,
                                                  content_type, content)
        page.invalidate()
        # to update last modification date
        page.save()

        return HttpResponse('ok')
    raise Http404
958667
private void updateOnly() throws TTException {
        try {
            // Initialize variables.
            mLevelInToShredder = 0;
            // mElemsParsed = 0;
            // mIsLastNode = false;
            mMovedToRightSibling = false;
            boolean firstEvent = true;

            // // If structure already exists, make a sync against the current
            // // structure.
            // if (mMaxNodeKey == 0) {
            // // If no content is in the XML, a normal insertNewContent is
            // // executed.
            // insertNewContent();
            // } else {
            if (mWtx.getNode().getKind() == IConstants.ROOT) {
                // Find the start key for the update operation.
                long startkey = ROOT_NODE + 1;
                while (!mWtx.moveTo(startkey)) {
                    startkey++;
                }
            }

            XMLEvent event = null;
            StringBuilder sBuilder = new StringBuilder();
            final XMLEventFactory fac = XMLEventFactory.newInstance();

            // Iterate over all nodes.
            while (mReader.hasNext()) {
                // Parsing the next event.
                if (mDelete == EDelete.ATSTARTMIDDLE) {
                    /*
                     * Do not move StAX parser forward if nodes have been
                     * deleted at the start or in the middle of a subtree.
                     */
                    mDelete = EDelete.NODELETE;
                } else {
                    // After an insert or after nodes were equal.
                    event = mReader.nextEvent();
                    if (event.isCharacters() && event.asCharacters().isWhiteSpace()) {
                        continue;
                    }
                    // mElemsParsed++;

                    assert event != null;
                    if (firstEvent) {
                        // Setup start element from StAX parser.
                        firstEvent = false;

                        if (event.getEventType() == XMLStreamConstants.START_DOCUMENT) {
                            while (mReader.hasNext()
                                && event.getEventType() != XMLStreamConstants.START_ELEMENT) {
                                event = mReader.nextEvent();
                            }
                            assert event.getEventType() == XMLStreamConstants.START_ELEMENT;
                            // mElemsParsed++;
                        }
                        checkState(event.getEventType() == XMLStreamConstants.START_ELEMENT,
                            "StAX parser has to be on START_DOCUMENT or START_ELEMENT event!");

                        // Get root element of subtree or whole XML document
                        // to shredder.
                        mRootElem = event.asStartElement().getName();
                    } else if (event != null && event.isEndElement()
                        && mRootElem.equals(event.asEndElement().getName()) && mLevelInToShredder == 1) {
                        // End with shredding if end_elem equals root-elem.
                        break;
                    }
                }

                assert event != null;

                switch (event.getEventType()) {
                case XMLStreamConstants.START_ELEMENT:
                    processStartTag(event.asStartElement());
                    break;
                case XMLStreamConstants.CHARACTERS:
                    sBuilder.append(event.asCharacters().getData());
                    while (mReader.peek().getEventType() == XMLStreamConstants.CHARACTERS) {
                        sBuilder.append(mReader.nextEvent().asCharacters().getData());
                    }
                    final Characters text = fac.createCharacters(sBuilder.toString().trim());
                    processCharacters(text);
                    sBuilder = new StringBuilder();
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    processEndTag();
                    break;
                default:
                    // Other nodes which are currently not supported by
                    // Treetank.
                }
                // }

                // if (!mIsLastNode) {
                // if (mInserted) {
                // // Remove next node after node, which was inserted, because
                // it must have been deleted.
                // if (mWtx.moveToRightSibling()) {
                // mWtx.remove();
                // }
                // } else {
                // // Remove current node (cursor has been moved to the next
                // node already).
                // mWtx.remove();
                // }
                //
                // // Also remove any siblings.
                // boolean hasRightSibling = false;
                // while (mWtx.getStructuralNode().hasRightSibling()) {
                // hasRightSibling = true;
                // mWtx.remove();
                // }
                // if (hasRightSibling) {
                // mWtx.remove();
                // }
                // }

                mReader.close();
            }
            // TODO: use Java7 multi-catch feature.
        } catch (final XMLStreamException e) {
            throw new TTIOException(e);
        } catch (final IOException e) {
            throw new TTIOException(e);
        }

    }
104634
async def update_contents(self, **params):
		
		if params.get("message"):
			params = json.loads(params.get("message", "{}"))

		if not params:
			return {"error":400, "reason":"Missed required fields"}

		txid = params.get("txid")

		coinid = params.get("coinid").upper()

		try:
			coinid = coinid.replace("TEST", "")
		except:
			pass

		database = client[coinid]
		content_collection = database[settings.CONTENT]

		content = await content_collection.find_one({"txid":txid})

		if not content:
			return {"error":404, 
					"reason":"Update content. Content with txid %s not found" % txid}

		if content.get("hash"):
			self.account.blockchain.setendpoint(settings.bridges[coinid])
			cid = await self.account.blockchain.getcid(hash=content["hash"])

			await content_collection.find_one_and_update({"txid":txid}, {"$set":{"cid":int(cid)}})
			await content_collection.find_one_and_update({"txid":txid}, {"$set":{"hash":None}})


		updated = await content_collection.find_one({"txid":txid})

		return {i:updated[i] for i in updated if i != "_id"}
882697
def update(self):
        '''
        
        '''
        self._json = self._request(
            method='GET',
            url=self.API
        )._json
1057636
def update_from_json(self, json_device):
        """"""
        self.identifier = json_device['Id']
        self.license_plate = json_device['EquipmentHeader']['SerialNumber']
        self.make = json_device['EquipmentHeader']['Make']
        self.model = json_device['EquipmentHeader']['Model']
        self.equipment_id = json_device['EquipmentHeader']['EquipmentID']
        self.active = json_device['EngineRunning']
        self.odo = json_device['Odometer']
        self.latitude = json_device['Location']['Latitude']
        self.longitude = json_device['Location']['Longitude']
        self.altitude = json_device['Location']['Altitude']
        self.speed = json_device['Speed']
        self.last_seen = json_device['Location']['DateTime']
402911
def update_text(self, mapping):
        """"""
        found = False
        for node in self._page.iter("*"):
            if node.text or node.tail:
                for old, new in mapping.items():
                    if node.text and old in node.text:
                        node.text = node.text.replace(old, new)
                        found = True
                    if node.tail and old in node.tail:
                        node.tail = node.tail.replace(old, new)
                        found = True
        if not found:
            raise KeyError("Updating text failed with mapping:{}".format(mapping))
623759
def update(handler, item_document):
    """"""
    data = {'operation': 'update',
            'encrypt': encrypt,
            'item': json.load(item_document)}
    handler.invoke(data)
106955
function updateNode(node, content, append) {
  append = append || false;

  while(!append && node.firstChild) {
    node.removeChild(node.firstChild);
  }

  if(content instanceof Element) {
    node.appendChild(content);
  }
  else if(content instanceof Array) {
    content.forEach(function(element) {
      node.appendChild(element);
    });
  }
  else {
    node.textContent = content;
  }
}
1288493
function updateReport() {
				var nodeIndex = getNodeIndex({}, structureJson);
			
				var treeOptions = {
					"plugins" : [ "themes", "json_data", "ui", "cookies", "contextmenu" ],
          "core" : {
            "html_titles" : true
          },
					"cookies" : {
						"save_opened" : $report.attr("id")+"_opened"
					},
					"contextmenu" : {
						"select_node" : true,
						"items" : contextMenuHandler
					},
					"json_data" : {
						"progressive_render" : true,
						"progressive_unload" : true,
						"data" : dataHandler
          }
				};
				$report.jstree(treeOptions)
				.on("loaded.jstree", function(event, data) {
					$cukeTree.cukeTree().reportRendered($report);
				})
				.on("select_node.jstree", function(event, data) {
					var $node = $(data.args[0]);
					$cukeTree.cukeTree().reportNodeSelected({ $report : $report, selected : $node });
				});	
        
        function dataHandler(item, callback) {
          var data = null;
          if (item === -1) {
            data = [getTreeNode("group", structureJson)];
          } else {
            data = getTreeNodeChildren($(item).attr("id"));
          }
          callback(data);
        }
        
        function getTreeNodeChildren(id) {
          var data = [];
          var parent = nodeIndex[id];
          if (parent.children !== undefined) {
            for(var i=0; i<parent.children.length; i++) { data.push(getTreeNode("group", parent.children[i])); }
          }
          if (parent.features !== undefined) {
            for(var i=0; i<parent.features.length; i++) { data.push(getTreeNode("feature", parent.features[i])); }
          }
          if (parent.elements !== undefined) {
            for(var i=0; i<parent.elements.length; i++) { data.push(getTreeNode("scenario", parent.elements[i])); }
          }
          if (parent.steps !== undefined) {
            for(var i=0; i<parent.steps.length; i++) { data.push(getTreeNode("step", parent.steps[i])); }
          }
          return data;
        }
        
        function getTreeNode(type, reportEntry) {
          var cssClasses = "node-"+ reportEntry.result.status;
          cssClasses += " "+ type +" "+ type +"-"+ reportEntry.result.status;
          
          var title = reportEntry.name;
          switch(type) {
            case "group": 
              title += " ("+ getScenarioCount(type, reportEntry) +" scenario(s))"; 
              break;
            case "feature":
              var scenarioCount = reportEntry.elements !== undefined ? reportEntry.elements.length : 0;
              if (reportEntry.profile !== undefined) {
                title += " <span class='profile'>["+ reportEntry.profile +"]</span>";
              }
              title += " ("+ scenarioCount +" scenario(s))"
              break;
            case "scenario":
              for(var i=0; i < (reportEntry.tags !== undefined ? reportEntry.tags.length : 0); i++) {
                title += " <span class='scenario-tag'>"+ reportEntry.tags[i].name +"</span>";
              }
              break;
            case "step":
              title = '<span class="keyword">'+ reportEntry.keyword +'</span>'+ title;
              break;
          }
          
          var addingChildren = reportEntry.result && reportEntry.result.status == "failed";
                  
          var node = {
            attr : { 
              id : reportEntry.nodeId,
              "data-type" : type, 
              class : cssClasses
            },
            state : addingChildren && type !== "step" ? "open" : "closed",
            data : {
              attr : { 
                href : "javascript:;", 
                "data-path" : reportEntry.uri
              },
              title : title,
              icon : type
            }
          };
          
          if (addingChildren) {
            node.children = getTreeNodeChildren(reportEntry.nodeId);
          }
          
          if (reportEntry.result.error_message !== undefined) {
            node.attr["data-error"] = reportEntry.result.error_message;
          }
          
          if (reportEntry.embeddings !== undefined) {
            node.attr["data-embedding-mime-type"] = reportEntry.embeddings[0].mime_type;
            node.attr["data-embedding-data"] = reportEntry.embeddings[0].data;
          }
          
          return node;
        }
			}
990765
def __updateDataItem(self):
        """"""
        uri = self.getUri()        
        self.__dataItem = self.__parseResponseServer(uri)
855462
def set(self, uri, content, **meta):
        
        try:
            node = self._update(uri, content, **meta)
            created = False
        except NodeDoesNotExist:
            node = self._create(uri, content, **meta)
            created = True
        return self._serialize(uri, node), created
387031
def _update(self, data):
      '''
      '''
      self.bullet = data['bullet']
      self.level = data['level']
      self.text = WikiText(data['text_raw'],
                           data['text_rendered'])
176968
function _updatePjson(siteId) {
  pjson.vapid.site = siteId;
  writePkg.sync(pjsonPath, pjson);
}
526477
def update_from_element(self, elem):
        """"""
        self._elem = elem

        for attrname in self.attributes:
            try:
                delattr(self, attrname)
            except AttributeError:
                pass

        document_url = elem.attrib.get('href')
        if document_url is not None:
            self._url = document_url

        return self
935391
function determineJSON(xml) {
	var json = null;
	parseString(xml, function(err, result) {
		if (err) {
			// TODO
			console.log(err);
		} else {
			json = result;
		}
	});
	return json;
}