Encodes the current state of the object into a string.

        :return: The encoded string
183942
def encode(self):
        
        opt_dict = {}
        for k, v in self.options.items():
            opt_dict[k] = v[0]

        ss = '{0}://{1}'.format(self.scheme, ','.join(self.hosts))
        if self.bucket:
            ss += '/' + self.bucket

        # URL encode options then decoded forward slash /
        ss += '?' + urlencode(opt_dict).replace('%2F', '/')

        return ss
159598
def get_state_string(self, add_colour=True):
        '''

        '''
        with self._mutex:
            if self.state == self.INACTIVE:
                result = 'Inactive', ['bold', 'blue']
            elif self.state == self.ACTIVE:
                result = 'Active', ['bold', 'green']
            elif self.state == self.ERROR:
                result = 'Error', ['bold', 'white', 'bgred']
            elif self.state == self.UNKNOWN:
                result = 'Unknown', ['bold', 'red']
            elif self.state == self.CREATED:
                result = 'Created', ['reset']
        if add_colour:
            return utils.build_attr_string(result[1], supported=add_colour) + \
                    result[0] + utils.build_attr_string('reset', supported=add_colour)
        else:
            return result[0]
436258
def prnt(self):
        
        print("= = = =\n\n%s object key: \033[32m%s\033[0m" % (self.__class__.__name__, self.key))
        pprnt(self._data or self.clean_value())
820242
def encode(self, object_):
        
        if self.enforce_reversible:
            self.enforce_reversible = False
            if self.decode(self.encode(object_)) != object_:
                raise ValueError('Encoding is not reversible for "%s"' % object_)
            self.enforce_reversible = True

        return object_
1111661
def encode(self):
        

        blob = bytearray()

        for record in self.records:
            blob += record.encode()

        header = struct.pack("<LL", self.SCRIPT_MAGIC, len(blob) + self.SCRIPT_HEADER_LENGTH)
        blob = header + blob

        sha = hashlib.sha256()
        sha.update(blob)
        hash_value = sha.digest()[:16]

        return bytearray(hash_value) + blob
469902
def encode(self):
        
        ret = bytearray()
        for name, len, typecode in self.format:
            value = getattr(self, name)
            buf = struct.pack('<' + typecode, value)
            ret.extend(buf)
        return bytes(ret)
1342220
def to_json_str(self):
    
    _json = self.to_json()
    try:
      return json.dumps(_json, sort_keys=True, cls=JsonEncoder)
    except:
      logging.exception("Could not serialize JSON: %r", _json)
      raise
969297
def encode(obj):
    
    if hasattr(obj, 'json'):
        return obj.json
    if hasattr(obj, '__json__'):
        return obj.__json__()
    return dumps(obj)
776784
def encode(self):
        
        element = ElementTree.Element(self.name)
        element = self._set_nil(element, lambda value: str(value))
        return element
155717
def tostring(self, encoding):
        
        if self.kind == 'string':
            if encoding is not None:
                return self.converted
            return '"{converted}"'.format(converted=self.converted)
        elif self.kind == 'float':
            # python 2 str(float) is not always
            # round-trippable so use repr()
            return repr(self.converted)
        return self.converted
1134084
def get_as_string(self, key):
        
        value = self.get(key)
        return StringConverter.to_string(value)
36394
def encode(self):
        
        element = ElementTree.Element(
            self.name,
            attrib={'type': FieldConstants.ARRAY},
        )
        for item in self.value:
            element.append(item.encode())
        return element
993979
def encode_data(self):
        
        assert self.get_empty() is False
        self._data_encoded = True
        if self._block_allowed:
            data = self._encode_transfer_block_data()
        else:
            data = self._encode_transfer_data()
        return data
1216372
def encode(self) -> str:
        """"""
        creds = ('%s:%s' % (self.login, self.password)).encode(self.encoding)
        return 'Basic %s' % base64.b64encode(creds).decode(self.encoding)
1254211
def to_json(self):
        
        return json.dumps(self.to_dict(), sort_keys=True, indent=2, separators=(',', ': '))
1083067
def bundlestate_to_str(state):
        
        states = {
            pelix.Bundle.INSTALLED: "INSTALLED",
            pelix.Bundle.ACTIVE: "ACTIVE",
            pelix.Bundle.RESOLVED: "RESOLVED",
            pelix.Bundle.STARTING: "STARTING",
            pelix.Bundle.STOPPING: "STOPPING",
            pelix.Bundle.UNINSTALLED: "UNINSTALLED",
        }

        return states.get(state, "Unknown state ({0})".format(state))
288270
def serialize(self):
        
        converted_dict = {
            'success': self.success,
            'assertion': str(self),
            'required': self.required
        }
        return converted_dict