Insert the LIGO_LW metadata in the xmltext string into the database.

    @return: message received (may be empty) from LDBD Server as a string
776456
def insertmap(self,xmltext,lfnpfn_dict):
    

    pmsg = cPickle.dumps(lfnpfn_dict)

    msg = "INSERTMAP\0" + xmltext + "\0" + pmsg + "\0"
    self.sfile.write(msg)

    ret, output = self.__response__()
    reply = str(output[0])

    if ret:
      msg = "Error executing insert on server %d:%s" % (ret, reply)
      raise LDBDClientException, msg

    return reply
644876
def get_text_metadata(self):
        
        # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template
        metadata = dict(self._mdata['text'])
        metadata.update({'existing_string_values': self._my_map['text']})
        return Metadata(**metadata)
639923
def insert_infocontent_data(germanet_db):
    '''
    
    '''
    gnet           = germanet.GermaNet(germanet_db)
    # use add one smoothing
    gn_counts      = defaultdict(lambda: 1.)
    total_count    = 1
    input_file     = gzip.open(os.path.join(os.path.dirname(__file__),
                                            WORD_COUNT_FILE))
    num_lines_read = 0
    num_lines      = 0
    for line in input_file:
        line       = line.decode('utf-8').strip().split('\t')
        num_lines += 1
        if len(line) != 3:
            continue
        count, pos, word = line
        num_lines_read += 1
        count           = int(count)
        synsets         = set(gnet.synsets(word, pos))
        if not synsets:
            continue
        # Although Resnik (1995) suggests dividing count by the number
        # of synsets, Patwardhan et al (2003) argue against doing
        # this.
        count = float(count) / len(synsets)
        for synset in synsets:
            total_count += count
            paths = synset.hypernym_paths
            scount = float(count) / len(paths)
            for path in paths:
                for ss in path:
                    gn_counts[ss._id] += scount
    print('Read {0} of {1} lines from count file.'.format(num_lines_read,
                                                          num_lines))
    print('Recorded counts for {0} synsets.'.format(len(gn_counts)))
    print('Total count is {0}'.format(total_count))
    input_file.close()
    # update all the synset records in GermaNet
    num_updates = 0
    for synset in germanet_db.synsets.find():
        synset['infocont'] = gn_counts[synset['_id']] / total_count
        germanet_db.synsets.save(synset)
        num_updates += 1
    print('Updated {0} synsets.'.format(num_updates))
737025
def addNotice(self, data):
        
        LOGGER.info('Sending addnotice to Polyglot: {}'.format(data))
        message = { 'addnotice': data }
        self.send(message)
1079218
def create_xml_string(self):
        
        root = self.create_xml()

        xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring(
            root, pretty_print=True
        )
        return xml
1122449
def as_xml(self):
        
        # Build tree
        spacing = ("\n" if (self.pretty_xml) else "")
        root = Element('error', {'xmlns': I3F_NS})
        root.text = spacing
        e_parameter = Element('parameter', {})
        e_parameter.text = self.parameter
        e_parameter.tail = spacing
        root.append(e_parameter)
        if (self.text):
            e_text = Element('text', {})
            e_text.text = self.text
            e_text.tail = spacing
            root.append(e_text)
        # Write out as XML document to return
        tree = ElementTree(root)
        xml_buf = io.BytesIO()
        if (sys.version_info < (2, 7)):
            tree.write(xml_buf, encoding='UTF-8')
        else:
            tree.write(xml_buf, encoding='UTF-8',
                       xml_declaration=True, method='xml')
        return(xml_buf.getvalue().decode('utf-8'))
1144819
def insert_text(self, string):
        """
        self.l_buffer.insert_text(string, self.argument_reset)
        self.finalize()
1186253
def new_message(self):
        
        msg = {}
        msg['data'] = []
        msg['type'] = self.plugin_type
        msg['source'] = self.name
        msg['ts'] = (datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()
        return msg
759694
def to_payload
      payload = String.new
      payload << MARKER
      payload << VERSION
      payload << Bitcoin.pack_var_int(quantities.size) << quantities.map{|q| LEB128.encode_unsigned(q).read }.join
      payload << Bitcoin.pack_var_int(metadata.length) << metadata.bytes.map{|b| sprintf("%02x", b)}.join.htb
      payload
    end
1046629
def register_to_ldbd(client, program, paramdict, version = u'0', cvs_repository = u'-', cvs_entry_time = 0, comment = u'-', is_online = False, jobid = 0, domain = None, ifos = u'-'):
	
	xmldoc = ligolw.Document()
	xmldoc.appendChild(ligolw.LIGO_LW())
	process = register_to_xmldoc(xmldoc, program, paramdict, version = version, cvs_repository = cvs_repository, cvs_entry_time = cvs_entry_time, comment = comment, is_online = is_online, jobid = jobid, domain = domain, ifos = ifos)

	fake_file = StringIO.StringIO()
	xmldoc.write(fake_file)
	client.insert(fake_file.getvalue())

	return process
1326809
public String getMessage()
    {
        if (code == NO_DATA)
            return "A document cannot be added without resource data.";
        else if (code == NO_LOCATOR)
            return "A document cannot be added without a resource locator.";
        else if (code == INVALID_JSON)
            return "The provided JSON could not be compiled. Check that the JSON provided is valid.";
        else if (code == NOT_CONFIGURED)
            return "The exporter must be configured before this action can be taken.";
        else if (code == BENCODE_FAILED)
            return "The document could not be bencoded. The resource data may be an invalid structure.";
        else if (code == SIGNING_FAILED)
            return "The document could not be digitally signed. Check that the private key data is correct.";
        else if (code == NO_KEY)
            return "No private key could be found in the provided private key data.";
        else if (code == NO_KEY_STREAM)
            return "The private key data could not be accessed. Check that a valid local file or valid private key dump is provided.";
        else if (code == NULL_FIELD)
            return "A required field was not provided with valid input.";
        else if (code == BATCH_ZERO)
            return "Batch size must be larger than zero.";
        else if (code == NO_DOCUMENTS)
            return "At least one document must be included in order to send data.";
        else if (code == NO_RESPONSE)
            return "The Learning Registry node did not return a response to the request.";
        else if (code == INVALID_RESPONSE)
            return "The response from the Learning Registry node did not match the form of an expected response.";
        else if (code == JSON_FAILED)
            return "The batch of documents could not be converted to a JSON string. Check that no invalid characters were included in the data of any document.";
        else if (code == JSON_IMPORT_FAILED)
            return "The batch of documents could not be converted to a JSON string. Check that the node did not return an error or invalid JSON.";
        else if (code == IMPORT_FAILED)
            return "Capturing data from the node failed. Please check that the node is running and returning results properly.";
        else if (code == INPUT_STREAM_FAILED)
			return "The provided inputs could not be converted into input streams.";
		else if (code == SIGNATURE_NOT_FOUND)
			return "A signature matching the provided key could not be found.";
		else if (code == SIGNATURE_INVALID)
			return "The signature stream does not contain a valid signature.";
		else if (code == MESSAGE_INVALID)
			return "The message stream could not be parsed.";
		else if (code == INVALID_PUBLIC_KEY)
			return "The public key stream does not contain a valid public key.";
		else
            return "An unknown error has ocurred.";
    }
918638
def send(self):
        
        parse_links = self.parse_links or self.parse_markdown_links

        message = {
            'annotations': [],
            'entities': {
                'parse_links': parse_links,
                'parse_markdown_links': self.parse_markdown_links,
            }
        }

        if self.photo:
            photo, photo_meta = _upload_file(self.api, self.photo)
            message['annotations'].append({
                'type': 'net.app.core.oembed',
                'value': {
                    '+net.app.core.file': {
                        'file_id': photo.id,
                        'file_token': photo.file_token,
                        'format': 'oembed',
                    }
                }
            })

        if self.attachment:
            attachment, attachment_meta = _upload_file(self.api, self.attachment)
            message['annotations'].append({
                'type': 'net.app.core.attachments',
                'value': {
                    '+net.app.core.file_list': [
                        {
                            'file_id': attachment.id,
                            'file_token': attachment.file_token,
                            'format': 'metadata',
                        }
                    ]
                }
            })

        if self.text:
            message['text'] = self.text
        else:
            message['machine_only'] = True

        if self.headline:
            message['annotations'].append({
                'type': 'net.app.core.broadcast.message.metadata',
                'value': {
                    'subject': self.headline,
                },
            })

        if self.read_more_link:
            message['annotations'].append({
                'type': 'net.app.core.crosspost',
                'value': {
                    'canonical_url': self.read_more_link,
                }
            })

        return self.api.create_message(self.channel_id, data=message)
549063
def insert(self, payload):
        
        response = self.session.post(self._get_table_url(), data=json.dumps(payload))
        return self._get_content(response)
589697
def import_xml(self, xml_gzipped_file_path, taxids=None, silent=False):
        
        version = self.session.query(models.Version).filter(models.Version.knowledgebase == 'Swiss-Prot').first()
        version.import_start_date = datetime.now()

        entry_xml = '<entries>'
        number_of_entries = 0
        interval = 1000
        start = False

        if sys.platform in ('linux', 'linux2', 'darwin'):
            log.info('Load gzipped XML from {}'.format(xml_gzipped_file_path))

            zcat_command = 'gzcat' if sys.platform == 'darwin' else 'zcat'

            number_of_lines = int(getoutput("{} {} | wc -l".format(zcat_command, xml_gzipped_file_path)))

            tqdm_desc = 'Import {} lines'.format(number_of_lines)

        else:
            print('bin was anderes')
            number_of_lines = None
            tqdm_desc = None

        with gzip.open(xml_gzipped_file_path) as fd:

            for line in tqdm(fd, desc=tqdm_desc, total=number_of_lines, mininterval=1, disable=silent):

                end_of_file = line.startswith(b"</uniprot>")

                if line.startswith(b"<entry "):
                    start = True

                elif end_of_file:
                    start = False

                if start:
                    entry_xml += line.decode("utf-8")

                if line.startswith(b"</entry>") or end_of_file:
                    number_of_entries += 1
                    start = False

                    if number_of_entries == interval or end_of_file:

                        entry_xml += "</entries>"
                        self.insert_entries(entry_xml, taxids)

                        if end_of_file:
                            break

                        else:
                            entry_xml = "<entries>"
                            number_of_entries = 0

        version.import_completed_date = datetime.now()
        self.session.commit()
464233
def to_xml(xml_builder)
      attributes = {
          'metadata:type' => type,
      }

      if value.nil?
        attributes['metadata:null'] = 'true'
        xml_builder['data'].send(name.to_sym, attributes)
      else
        xml_builder['data'].send(name.to_sym, attributes, xml_value)
      end
    end
920030
def toxml(self):
        

        xmlstr = '<OnStart'

        chxmlstr = ''

        for action in self.actions:
            chxmlstr += action.toxml()

        if chxmlstr:
            xmlstr += '>' + chxmlstr + '</OnStart>'
        else:
            xmlstr += '/>'

        return xmlstr
124796
def get_ligolw_element(xmldoc):
    
    from ligo.lw.ligolw import LIGO_LW
    try:
        from glue.ligolw.ligolw import LIGO_LW as LIGO_LW2
    except ImportError:
        ligolw_types = (LIGO_LW,)
    else:
        ligolw_types = (LIGO_LW, LIGO_LW2)

    if isinstance(xmldoc, ligolw_types):
        return xmldoc
    else:
        for node in xmldoc.childNodes:
            if isinstance(node, ligolw_types):
                return node
    raise ValueError("Cannot find LIGO_LW element in XML Document")