Register a DOI via the DataCite API.

        :param url: Specify the URL for the API.
        :param doc: Set metadata for DOI.
        :returns: `True` if is registered successfully.
542149
def register(self, url, doc):
        
        try:
            self.pid.register()
            # Set metadata for DOI
            self.api.metadata_post(doc)
            # Mint DOI
            self.api.doi_post(self.pid.pid_value, url)
        except (DataCiteError, HttpError):
            logger.exception("Failed to register in DataCite",
                             extra=dict(pid=self.pid))
            raise
        logger.info("Successfully registered in DataCite",
                    extra=dict(pid=self.pid))
        return True
1305971
def register(self, method, uri, call_back):
        
        found = False

        self.create_route(uri, False)
        self.routes[uri]['handlers'].register_method(method,
                                                     call_back)
1175888
def get_doc(url)
      page = MetaInspector.new(url)
      doc = page.document

      raise page.errors[0] if !page.ok?

      doc
    end
95933
def _setMetadata(self, text):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document__setMetadata(self, text)
1016807
def set_link(self, prop, value):
        
        # https://rdflib.readthedocs.io/en/stable/
        # URIRef == identifiers (urn, http, URI in general)
        # Literal == String or Number (can have a language)
        # BNode == Anonymous nodes (So no specific identifier)
        #		eg. BNode : Edition(MartialEpigrams:URIRef) ---has_metadata--> Metadata(BNode)
        if not isinstance(value, URIRef):
            value = URIRef(value)

        self.metadata.add(prop, value)
383917
def _add_header_domains_xml(self, document):
        
        for domain, attrs in self.header_domains.items():
            header_element = document.createElement(
                'allow-http-request-headers-from'
            )
            header_element.setAttribute('domain', domain)
            header_element.setAttribute('headers', ','.join(attrs['headers']))
            if not attrs['secure']:
                header_element.setAttribute('secure', 'false')
            document.documentElement.appendChild(header_element)
1214968
def insert(self, document):
        

        doc_id = self._get_doc_id(document)
        data = self._read()
        data[doc_id] = dict(document)
        self._write(data)

        return doc_id
139939
def get(self, doc_id):
        """"""
        resp_dict = self._get_query(q='id:{}'.format(doc_id))
        if resp_dict['response']['numFound'] > 0:
            return resp_dict['response']['docs'][0]
468609
def sign(self, xml_doc):
        
        try:
            self.client = Client(self.url)
        except ValueError as e:
            self.message = e.message
        except URLError:
            self.message = 'The url you provided: ' + \
                '%s could not be reached' % self.url
40973
def set_document(request, doc_id, body, errors):
    
    if doc_id in DB:
        errors['doc_id'].add('Document already exists')

    if errors:
        raise errors

    body['doc_id'] = doc_id
    DB[doc_id] = body

    # dict response for jsonify middleware
    return body
67712
private RegisterDocumentResponse registerDocument(RegisterDocumentRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");

        InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, DOC);
        internalRequest.addParameter("register", null);
        String strJson = JsonUtils.toJsonString(request);
        byte[] requestJson = null;
        try {
            requestJson = strJson.getBytes(DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            throw new BceClientException("Unsupported encode.", e);
        }

        internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length));
        internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
        internalRequest.setContent(RestartableInputStream.wrap(requestJson));
        return invokeHttpClient(internalRequest, RegisterDocumentResponse.class);
    }
864521
def AddDatastore(self, urn):
    
    if urn not in self._datastores:
      self._datastores.add(urn)
      return True
    return False
1176939
def render_doc(self):
    ''''''
    if self._doc_view:
      return self._doc_view()
    elif not self._doc:
      self.abort(self.bc_HTTPStatus_NOT_FOUND)
    res = render_template('swagger-ui.html', title=self.title, specs_url=self.specs_url)
    res = res.replace(self.complexReplaceString,self.APIDOCSPath)

    regexp="\"https?:\/\/[a-zA-Z0\-9._]*(:[0-9]*)?" + self.internal_api_prefix.replace("/","\/") + "\/swagger.json\""
    regexp="\"https?:\/\/[a-zA-Z0\-9._]*(:[0-9]*)?" + self.internal_apidoc_prefix.replace("/","\/") + "\/swagger.json\""
    p = re.compile(regexp)
    res = p.sub("\"" + self.apidocsurl + "/swagger.json\"", res)
    '''
    if (self.overrideAPIDOCSPath()):
      #print("About to replace")
      #print(res)
      res = self.reaplcements(res)
      #print("Replaced")
      #print(res)
      #print("End")
    '''
    return res
570772
protected boolean register(String path, List<String> vhosts, HttpHandler handler) {
        return pathology.add(path, vhosts, handler);
    }
803165
public static Document getEventDocFromUrl(String url) throws TVRageException {
        Document doc;
        InputStream in = null;

        try {
            in = new ByteArrayInputStream(requestWebContent(url));

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(in);
            doc.getDocumentElement().normalize();
            return doc;
        } catch (ParserConfigurationException | SAXException | IOException ex) {
            throw new TVRageException(ApiExceptionType.MAPPING_FAILED, UNABLE_TO_PARSE, url, ex);
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                // Input Stream was already closed or null
                LOG.trace("Stream already closed for getEventDocFromUrl", ex);
            }
        }
    }
652261
def write_doc(doc : MetapackDoc, mt_file=None):
    

    from rowgenerators import parse_app_url

    if not mt_file:
        mt_file = doc.ref

    add_giturl(doc)

    u = parse_app_url(mt_file)

    if u.scheme == 'file':
        doc.write(mt_file)
        return True
    else:
        return False
777612
def add(self, document):
        
        docid = int(document.uniqueIdentifier())
        text = u' '.join(document.textParts())

        self.store.executeSQL(self.addSQL, (docid, text))