Search is not available for this dataset
text
stringlengths
75
104k
def named_objs(objlist): """ Given a list of objects, returns a dictionary mapping from string name for the object to the object itself. """ objs = [] for k, obj in objlist: if hasattr(k, '__name__'): k = k.__name__ else: k = as_unicode(k) objs.app...
def get_method_owner(meth): """ Returns the instance owning the supplied instancemethod or the class owning the supplied classmethod. """ if inspect.ismethod(meth): if sys.version_info < (3,0): return meth.im_class if meth.im_self is None else meth.im_self else: ...
def _assign_auth_values(self, http_auth): """Take the http_auth value and split it into the attributes that carry the http auth username and password :param str|tuple http_auth: The http auth value """ if not http_auth: pass elif isinstance(http_auth, (tuple...
def ping(self, params=None): """ Returns True if the cluster is up, False otherwise. """ try: self.transport.perform_request('HEAD', '/', params=params) except TransportError: raise gen.Return(False) raise gen.Return(True)
def info(self, params=None): """Get the basic info from the current cluster. :rtype: dict """ _, data = yield self.transport.perform_request('GET', '/', params=params) raise gen.Return(data)
def health(self, params=None): """Coroutine. Queries cluster Health API. Returns a 2-tuple, where first element is request status, and second element is a dictionary with response data. :param params: dictionary of query parameters, will be handed over to the underlying :cl...
def create(self, index, doc_type, body, id=None, params=None): """ Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type='create') `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The nam...
def index(self, index, doc_type, body, id=None, params=None): """ Adds or updates a typed JSON document in a specific index, making it searchable. `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The name of the index :arg doc_type: The type of the document ...
def exists(self, index, id, doc_type='_all', params=None): """ Returns a boolean indicating whether or not given document exists in Elasticsearch. `<http://elasticsearch.org/guide/reference/api/get/>`_ :arg index: The name of the index :arg id: The document ID :arg doc_t...
def get_alias(self, index=None, name=None, params=None): """ Retrieve a specified alias. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html>`_ :arg index: A comma-separated list of index names to filter aliases :arg name: A comma-separated list ...
def search(self, index=None, doc_type=None, body=None, params=None): """ Execute a search query and get back search hits that match the query. `<http://www.elasticsearch.org/guide/reference/api/search/>`_ :arg index: A comma-separated list of index names to search; use `_all` ...
def scroll(self, scroll_id, scroll, params=None): """ Scroll a search request created by specifying the scroll parameter. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID :arg scroll: Specify how long a consistent view of the ind...
def clear_scroll(self, scroll_id, params=None): """ Clear the scroll request created by specifying the scroll parameter to search. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID or a list of scroll IDs """ if no...
def get_mapping(self, index=None, doc_type=None, params=None): """ Retrieve mapping definition of index or index/type. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html>`_ :arg index: A comma-separated list of index names :arg doc_type: A c...
def suggest(self, index=None, body=None, params=None): """ The suggest feature suggests similar looking terms based on a provided text by using a suggester. `<http://elasticsearch.org/guide/reference/api/search/suggest/>`_ :arg index: A comma-separated list of index names to res...
def bytes_to_readable(num): """Converts bytes to a human readable format""" if num < 512: return "0 Kb" elif num < 1024: return "1 Kb" for unit in ['', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb']: if abs(num) < 1024.0: return "%...
def cpu_total_load(self): """Total CPU load for Synology DSM""" system_load = self.cpu_system_load user_load = self.cpu_user_load other_load = self.cpu_other_load if system_load is not None and \ user_load is not None and \ other_load is not None: ...
def memory_size(self, human_readable=True): """Total Memory Size of Synology DSM""" if self._data is not None: # Memory is actually returned in KB's so multiply before converting return_data = int(self._data["memory"]["memory_size"]) * 1024 if human_readable: ...
def _get_network(self, network_id): """Function to get specific network (eth0, total, etc)""" if self._data is not None: for network in self._data["network"]: if network["device"] == network_id: return network
def network_up(self, human_readable=True): """Total upload speed being used""" network = self._get_network("total") if network is not None: return_data = int(network["tx"]) if human_readable: return SynoFormatHelper.bytes_to_readable( ...
def volumes(self): """Returns all available volumes""" if self._data is not None: volumes = [] for volume in self._data["volumes"]: volumes.append(volume["id"]) return volumes
def _get_volume(self, volume_id): """Returns a specific volume""" if self._data is not None: for volume in self._data["volumes"]: if volume["id"] == volume_id: return volume
def volume_size_total(self, volume, human_readable=True): """Total size of volume""" volume = self._get_volume(volume) if volume is not None: return_data = int(volume["size"]["total"]) if human_readable: return SynoFormatHelper.bytes_to_readable( ...
def volume_percentage_used(self, volume): """Total used size in percentage for volume""" volume = self._get_volume(volume) if volume is not None: total = int(volume["size"]["total"]) used = int(volume["size"]["used"]) if used is not None and used > 0 a...
def volume_disk_temp_avg(self, volume): """Average temperature of all disks making up the volume""" volume = self._get_volume(volume) if volume is not None: vol_disks = volume["disks"] if vol_disks is not None: total_temp = 0 total_d...
def volume_disk_temp_max(self, volume): """Maximum temperature of all disks making up the volume""" volume = self._get_volume(volume) if volume is not None: vol_disks = volume["disks"] if vol_disks is not None: max_temp = 0 for vol...
def disks(self): """Returns all available (internal) disks""" if self._data is not None: disks = [] for disk in self._data["disks"]: disks.append(disk["id"]) return disks
def _get_disk(self, disk_id): """Returns a specific disk""" if self._data is not None: for disk in self._data["disks"]: if disk["id"] == disk_id: return disk
def _login(self): """Build and execute login request""" api_path = "%s/auth.cgi?api=SYNO.API.Auth&version=2" % ( self.base_url, ) login_path = "method=login&%s" % (self._encode_credentials()) url = "%s&%s&session=Core&format=cookie" % ( api_path...
def _get_url(self, url, retry_on_error=True): """Function to handle sessions for a GET request""" # Check if we failed to request the url or need to login if self.access_token is None or \ self._session is None or \ self._session_error: # Clear Access Toke...
def _execute_get_url(self, request_url, append_sid=True): """Function to execute and handle a GET request""" # Prepare Request self._debuglog("Requesting URL: '" + request_url + "'") if append_sid: self._debuglog("Appending access_token (SID: " + ...
def update(self): """Updates the various instanced modules""" if self._utilisation is not None: api = "SYNO.Core.System.Utilization" url = "%s/entry.cgi?api=%s&version=1&method=get&_sid=%s" % ( self.base_url, api, self.access...
def utilisation(self): """Getter for various Utilisation variables""" if self._utilisation is None: api = "SYNO.Core.System.Utilization" url = "%s/entry.cgi?api=%s&version=1&method=get" % ( self.base_url, api) self._utilisation =...
def storage(self): """Getter for various Storage variables""" if self._storage is None: api = "SYNO.Storage.CGI.Storage" url = "%s/entry.cgi?api=%s&version=1&method=load_info" % ( self.base_url, api) self._storage = SynoStorage(s...
def for_request(request, body=None): """Creates the context for a specific request.""" tenant, jwt_data = Tenant.objects.for_request(request, body) webhook_sender_id = jwt_data.get('sub') sender_data = None if body and 'item' in body: if 'sender' in body['item']: ...
def tenant_token(self): """The cached token of the current tenant.""" rv = getattr(self, '_tenant_token', None) if rv is None: rv = self._tenant_token = self.tenant.get_token() return rv
def build_attrs(self, extra_attrs=None, **kwargs): "Helper function for building an attribute dictionary." self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs) return self.attrs
def with_apps(*apps): """ Class decorator that makes sure the passed apps are present in INSTALLED_APPS. """ apps_set = set(settings.INSTALLED_APPS) apps_set.update(apps) return override_settings(INSTALLED_APPS=list(apps_set))
def without_apps(*apps): """ Class decorator that makes sure the passed apps are not present in INSTALLED_APPS. """ apps_list = [a for a in settings.INSTALLED_APPS if a not in apps] return override_settings(INSTALLED_APPS=apps_list)
def get_global_settings(self): """ Return a dictionary of all global_settings values. """ return dict((key, getattr(global_settings, key)) for key in dir(global_settings) if key.isupper())
def do_GET(self): """ Handle the retrieval of the code """ parsed_url = urlparse(self.path) if parsed_url[2] == "/" + SERVER_REDIRECT_PATH: # 2 = Path parsed_query = parse_qs(parsed_url[4]) # 4 = Query if "code" not in parsed_query: self.send_response(200) self.send_header("Content-Type", "t...
def _set_app_info(self): """ Set the app info (id & secret) read from the config file on the Reddit object """ redirect_url = "http://{0}:{1}/{2}".format(SERVER_URL, SERVER_PORT, SERVER_REDIRECT_PATH) self.r.set_oauth_app_info(self._get_value(CONFIGKEY_APP_KEY), self._get_value(CONFIG...
def _get_value(self, key, func=None, split_val=None, as_boolean=False, exception_default=None): """ Helper method to get a value from the config """ try: if as_boolean: return self.config.getboolean(key[0], key[1]) value = self.config.get(key[0], key[1]) if split_val is not None: value = valu...
def _change_value(self, key, value): """ Change the value of the given key in the given file to the given value """ if not self.config.has_section(key[0]): self.config.add_section(key[0]) self.config.set(key[0], key[1], str(value)) with open(self.configfile, "w") as f: self.config.write(f)
def _migrate_config(self, oldname=DEFAULT_CONFIG, newname=DEFAULT_CONFIG): """ Migrates the old config file format to the new one """ self._log("Your OAuth2Util config file is in an old format and needs " "to be changed. I tried as best as I could to migrate it.", logging.WARNING) with open(oldname, "r")...
def _start_webserver(self, authorize_url=None): """ Start the webserver that will receive the code """ server_address = (SERVER_URL, SERVER_PORT) self.server = HTTPServer(server_address, OAuth2UtilRequestHandler) self.server.response_code = None self.server.authorize_url = authorize_url t = Thread(targe...
def _wait_for_response(self): """ Wait until the user accepted or rejected the request """ while not self.server.response_code: time.sleep(2) time.sleep(5) self.server.shutdown()
def _get_new_access_information(self): """ Request new access information from reddit using the built in webserver """ if not self.r.has_oauth_app_info: self._log('Cannot obtain authorize url from PRAW. Please check your configuration.', logging.ERROR) raise AttributeError('Reddit Session invalid, please ...
def _check_token_present(self): """ Check whether the tokens are set and request new ones if not """ try: self._get_value(CONFIGKEY_TOKEN) self._get_value(CONFIGKEY_REFRESH_TOKEN) self._get_value(CONFIGKEY_REFRESHABLE) except KeyError: self._log("Request new Token (CTP)") self._get_new_access_i...
def set_access_credentials(self, _retry=0): """ Set the token on the Reddit Object again """ if _retry >= 5: raise ConnectionAbortedError('Reddit is not accessible right now, cannot refresh OAuth2 tokens.') self._check_token_present() try: self.r.set_access_credentials(self._get_value(CONFIGKEY_SCOP...
def refresh(self, force=False, _retry=0): """ Check if the token is still valid and requests a new if it is not valid anymore Call this method before a call to praw if there might have passed more than one hour force: if true, a new token will be retrieved no matter what """ if _retry >= 5: raise C...
def create_manifest_table(dynamodb_client, table_name): """Create DynamoDB table for run manifests Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name """ try: dynamodb_client.create_table( AttributeDefinition...
def list_runids(s3_client, full_path): """Return list of all run ids inside S3 folder. It does not respect S3 pagination (`MaxKeys`) and returns **all** keys from bucket and won't list any prefixes with object archived to AWS Glacier Arguments: s3_client - boto3 S3 client (not service) full_pat...
def split_full_path(path): """Return pair of bucket without protocol and path Arguments: path - valid S3 path, such as s3://somebucket/events >>> split_full_path('s3://mybucket/path-to-events') ('mybucket', 'path-to-events/') >>> split_full_path('s3://mybucket') ('mybucket', None) >>> ...
def is_glacier(s3_client, bucket, prefix): """Check if prefix is archived in Glacier, by checking storage class of first object inside that prefix Arguments: s3_client - boto3 S3 client (not service) bucket - valid extracted bucket (without protocol and prefix) example: sowplow-events-...
def extract_run_id(key): """Extract date part from run id Arguments: key - full key name, such as shredded-archive/run=2012-12-11-01-31-33/ (trailing slash is required) >>> extract_run_id('shredded-archive/run=2012-12-11-01-11-33/') 'shredded-archive/run=2012-12-11-01-11-33/' >>> ext...
def clean_dict(dict): """Remove all keys with Nones as values >>> clean_dict({'key': None}) {} >>> clean_dict({'empty_s': ''}) {'empty_s': ''} """ if sys.version_info[0] < 3: return {k: v for k, v in dict.iteritems() if v is not None} else: return {k: v for k, v in dict....
def add_to_manifest(dynamodb_client, table_name, run_id): """Add run_id into DynamoDB manifest table Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string representing run_id to store """ dynamodb_client.put_ite...
def is_in_manifest(dynamodb_client, table_name, run_id): """Check if run_id is stored in DynamoDB table. Return True if run_id is stored or False otherwise. Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string repr...
def extract_schema(uri): """ Extracts Schema information from Iglu URI >>> extract_schema("iglu:com.acme-corporation_underscore/event_name-dash/jsonschema/1-10-1")['vendor'] 'com.acme-corporation_underscore' """ match = re.match(SCHEMA_URI_REGEX, uri) if match: return { ...
def fix_schema(prefix, schema): """ Create an Elasticsearch field name from a schema string """ schema_dict = extract_schema(schema) snake_case_organization = schema_dict['vendor'].replace('.', '_').lower() snake_case_name = re.sub('([^A-Z_])([A-Z])', '\g<1>_\g<2>', schema_dict['name']).lower() ...
def parse_contexts(contexts): """ Convert a contexts JSON to an Elasticsearch-compatible list of key-value pairs For example, the JSON { "data": [ { "data": { "unique": true }, "schema": "iglu:com.acme/unduplicated/jsonschema/1-0-0" }, ...
def parse_unstruct(unstruct): """ Convert an unstructured event JSON to a list containing one Elasticsearch-compatible key-value pair For example, the JSON { "data": { "data": { "key": "value" }, "schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschem...
def transform(line, known_fields=ENRICHED_EVENT_FIELD_TYPES, add_geolocation_data=True): """ Convert a Snowplow enriched event TSV into a JSON """ return jsonify_good_event(line.split('\t'), known_fields, add_geolocation_data)
def jsonify_good_event(event, known_fields=ENRICHED_EVENT_FIELD_TYPES, add_geolocation_data=True): """ Convert a Snowplow enriched event in the form of an array of fields into a JSON """ if len(event) != len(known_fields): raise SnowplowEventTransformationException( ["Expected {} fie...
def _get_view_data(self, context_data): """ Extract the used view from the TemplateResponse context (ContextMixin) """ view = context_data.get('view') if not isinstance(view, View): view = None # Denote interesting objects in the template context temp...
def get_used_template(response): """ Get the template used in a TemplateResponse. This returns a tuple of "active choice, all choices" """ if not hasattr(response, 'template_name'): return None, None template = response.template_name if template is None: return None, None ...
def print_context(self, context): """ Print the entire template context """ text = [CONTEXT_TITLE] for i, context_scope in enumerate(context): dump1 = linebreaksbr(pformat_django_context_html(context_scope)) dump2 = pformat_dict_summary_html(context_scope)...
def print_variables(self, context): """ Print a set of variables """ text = [] for name, expr in self.variables: # Some extended resolving, to handle unknown variables data = '' try: if isinstance(expr.var, Variable): ...
def pformat_sql_html(sql): """ Highlight common SQL words in a string. """ sql = escape(sql) sql = RE_SQL_NL.sub(u'<br>\n\\1', sql) sql = RE_SQL.sub(u'<strong>\\1</strong>', sql) return sql
def pformat_django_context_html(object): """ Dump a variable to a HTML string with sensible output for template context fields. It filters out all fields which are not usable in a template context. """ if isinstance(object, QuerySet): text = '' lineno = 0 for item in object.a...
def pformat_dict_summary_html(dict): """ Briefly print the dictionary keys. """ if not dict: return ' {}' html = [] for key, value in sorted(six.iteritems(dict)): if not isinstance(value, DICT_EXPANDED_TYPES): value = '...' html.append(_format_dict_item(ke...
def _style_text(text): """ Apply some HTML highlighting to the contents. This can't be done in the """ # Escape text and apply some formatting. # To have really good highlighting, pprint would have to be re-implemented. text = escape(text) text = text.replace(' &lt;iterator object&gt;', ...
def _format_object(object): """ # Instead of just printing <SomeType at 0xfoobar>, expand the fields. """ attrs = iter(object.__dict__.items()) if object.__class__: # Add class members too. attrs = chain(attrs, iter(object.__class__.__dict__.items())) # Remove private and prote...
def _format_lazy(value): """ Expand a _("TEST") call to something meaningful. """ args = value._proxy____args kw = value._proxy____kw if not kw and len(args) == 1 and isinstance(args[0], six.string_types): # Found one of the Xgettext_lazy() calls. return LiteralStr(u'ugettext_laz...
def _try_call(func, extra_exceptions=(), return_exceptions=False): """ Call a method, but :param func: :type func: :param extra_exceptions: :type extra_exceptions: :return: :rtype: """ try: return func() except HANDLED_EXCEPTIONS as e: if return_exceptions: ...
def format(self, object, context, maxlevels, level): """ Format an item in the result. Could be a dictionary key, value, etc.. """ try: return PrettyPrinter.format(self, object, context, maxlevels, level) except HANDLED_EXCEPTIONS as e: return _for...
def _format(self, object, stream, indent, allowance, context, level): """ Recursive part of the formatting """ try: PrettyPrinter._format(self, object, stream, indent, allowance, context, level) except Exception as e: stream.write(_format_exception(e))
def get_token(s, pos, brackets_are_chars=True, environments=True, **parse_flags): """ Parse the next token in the stream. Returns a `LatexToken`. Raises `LatexWalkerEndOfStream` if end of stream reached. .. deprecated:: 1.0 Please use :py:meth:`LatexWalker.get_token()` instead. """ retu...
def get_latex_expression(s, pos, **parse_flags): """ Reads a latex expression, e.g. macro argument. This may be a single char, an escape sequence, or a expression placed in braces. Returns a tuple `(<LatexNode instance>, pos, len)`. `pos` is the first char of the expression, and `len` is its length...
def get_latex_maybe_optional_arg(s, pos, **parse_flags): """ Attempts to parse an optional argument. Returns a tuple `(groupnode, pos, len)` if success, otherwise returns None. .. deprecated:: 1.0 Please use :py:meth:`LatexWalker.get_latex_maybe_optional_arg()` instead. """ return Latex...
def get_latex_braced_group(s, pos, brace_type='{', **parse_flags): """ Reads a latex expression enclosed in braces {...}. The first token of `s[pos:]` must be an opening brace. Returns a tuple `(node, pos, len)`. `pos` is the first char of the expression (which has to be an opening brace), and `len...
def get_latex_environment(s, pos, environmentname=None, **parse_flags): """ Reads a latex expression enclosed in a \\begin{environment}...\\end{environment}. The first token in the stream must be the \\begin{environment}. Returns a tuple (node, pos, len) with node being a :py:class:`LatexEnvironmentNod...
def get_latex_nodes(s, pos=0, stop_upon_closing_brace=None, stop_upon_end_environment=None, stop_upon_closing_mathmode=None, **parse_flags): """ Parses latex content `s`. Returns a tuple `(nodelist, pos, len)` where nodelist is a list of `LatexNode` 's. If `stop_upon_closing_brace`...
def get_token(self, pos, brackets_are_chars=True, environments=True, keep_inline_math=None): """ Parses the latex content given to the constructor (and stored in `self.s`), starting at position `pos`, to parse a single "token", as defined by :py:class:`LatexToken`. Parse the tok...
def get_latex_expression(self, pos, strict_braces=None): """ Parses the latex content given to the constructor (and stored in `self.s`), starting at position `pos`, to parse a single LaTeX expression. Reads a latex expression, e.g. macro argument. This may be a single char, an escape ...
def get_latex_maybe_optional_arg(self, pos): """ Parses the latex content given to the constructor (and stored in `self.s`), starting at position `pos`, to attempt to parse an optional argument. Attempts to parse an optional argument. If this is successful, we return a tuple `(n...
def get_latex_braced_group(self, pos, brace_type='{'): """ Parses the latex content given to the constructor (and stored in `self.s`), starting at position `pos`, to read a latex group delimited by braces. Reads a latex expression enclosed in braces ``{ ... }``. The first token of ...
def get_latex_environment(self, pos, environmentname=None): r""" Parses the latex content given to the constructor (and stored in `self.s`), starting at position `pos`, to read a latex environment. Reads a latex expression enclosed in a ``\begin{environment}...\end{environment}`...
def get_latex_nodes(self, pos=0, stop_upon_closing_brace=None, stop_upon_end_environment=None, stop_upon_closing_mathmode=None): """ Parses the latex content given to the constructor (and stored in `self.s`) into a list of nodes. Returns a tuple `(nodelist, pos, ...
def latex2text(content, tolerant_parsing=False, keep_inline_math=False, keep_comments=False): """ Extracts text from `content` meant for database indexing. `content` is some LaTeX code. .. deprecated:: 1.0 Please use :py:class:`LatexNodes2Text` instead. """ (nodelist, tpos, tlen) = late...
def latexnodes2text(nodelist, keep_inline_math=False, keep_comments=False): """ Extracts text from a node list. `nodelist` is a list of nodes as returned by :py:func:`pylatexenc.latexwalker.get_latex_nodes()`. .. deprecated:: 1.0 Please use :py:class:`LatexNodes2Text` instead. """ retur...
def set_tex_input_directory(self, tex_input_directory, latex_walker_init_args=None, strict_input=True): """ Set where to look for input files when encountering the ``\\input`` or ``\\include`` macro. Alternatively, you may also override :py:meth:`read_input_file()` to implement ...
def read_input_file(self, fn): """ This method may be overridden to implement a custom lookup mechanism when encountering ``\\input`` or ``\\include`` directives. The default implementation looks for a file of the given name relative to the directory set by :py:meth:`set_tex_inp...
def latex_to_text(self, latex, **parse_flags): """ Parses the given `latex` code and returns its textual representation. The `parse_flags` are the flags to give on to the :py:class:`pylatexenc.latexwalker.LatexWalker` constructor. """ return self.nodelist_to_text(latexwa...
def nodelist_to_text(self, nodelist): """ Extracts text from a node list. `nodelist` is a list of nodes as returned by :py:meth:`pylatexenc.latexwalker.LatexWalker.get_latex_nodes()`. In addition to converting each node in the list to text using `node_to_text()`, we apply some g...
def _nodelistcontents_to_text(self, nodelist): """ Turn the node list to text representations of each node. Basically apply `node_to_text()` to each node. (But not quite actually, since we take some care as to where we add whitespace.) """ s = '' prev_node = Non...
def node_to_text(self, node, prev_node_hint=None): """ Return the textual representation of the given `node`. If `prev_node_hint` is specified, then the current node is formatted suitably as following the node given in `prev_node_hint`. This might affect how much space we keep/...
def utf8tolatex(s, non_ascii_only=False, brackets=True, substitute_bad_chars=False, fail_bad_chars=False): u""" Encode a UTF-8 string to a LaTeX snippet. If `non_ascii_only` is set to `True`, then usual (ascii) characters such as ``#``, ``{``, ``}`` etc. will not be escaped. If set to `False` (the def...
def _unascii(s): """Unpack `\\uNNNN` escapes in 's' and encode the result as UTF-8 This method takes the output of the JSONEncoder and expands any \\uNNNN escapes it finds (except for \\u0000 to \\u001F, which are converted to \\xNN escapes). For performance, it assumes that the input is valid JSO...