diff --git a/.buildinfo b/.buildinfo index 4039e8d..3650f15 100644 --- a/.buildinfo +++ b/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 7b68701295de0775485f86965b71e1f4 +config: a541620f197690f748937dc6f81a382b tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/_modules/example/boilerplate.html b/_modules/example/boilerplate.html index 8e6ba3d..838ac80 100644 --- a/_modules/example/boilerplate.html +++ b/_modules/example/boilerplate.html @@ -5,7 +5,7 @@
-
import json
+from datetime import datetime
from logging import Logger, StreamHandler
from os import environ as env
from pathlib import Path
from typing import Any, Optional
from aiohttp import ClientSession
+from msgpackr.constants import UNDEFINED
from novelai_api import NovelAIAPI
from novelai_api.utils import get_encryption_key
@@ -142,6 +144,10 @@ Source code for example.boilerplate
[docs] def default(self, o: Any) -> Any:
if isinstance(o, bytes):
return o.hex()
+ if o is UNDEFINED:
+ return "<UNDEFINED>"
+ if isinstance(o, datetime):
+ return o.isoformat()
return super().default(o)
@@ -183,7 +189,7 @@ Navigation
".",
":",
"\n",
- "ve",
- "s",
- "t",
- "n",
- "d",
- "ll",
- "re",
- "m",
"-",
"*",
")",
@@ -1002,7 +994,7 @@ Navigation
from zlib import decompress as inflate
import argon2
+from msgpackr import Unpacker
from nacl.exceptions import CryptoError
from nacl.secret import SecretBox
from novelai_api.Keystore import Keystore
+from novelai_api.Msgpackr_Extensions import Ext20, Ext30, Ext31, Ext40, Ext41, Ext42
from novelai_api.NovelAIError import NovelAIError
from novelai_api.Preset import Model, Preset
from novelai_api.python_utils import assert_type
from novelai_api.Tokenizer import Tokenizer
+unpacker = Unpacker()
+unpacker.register_extensions(Ext20, Ext30, Ext31, Ext40, Ext41, Ext42)
+unpacker_state = unpacker.export_state()
+
# API utils
[docs]def argon_hash(email: str, password: str, size: int, domain: str) -> str:
@@ -242,13 +248,16 @@ Source code for novelai_api.utils
del item["decrypted"]
-[docs]def decrypt_user_data(items: Union[List[Dict[str, Any]], Dict[str, Any]], keystore: Keystore):
+[docs]def decrypt_user_data(
+ items: Union[List[Dict[str, Any]], Dict[str, Any]], keystore: Keystore, uncompress_document: bool = False
+):
"""
Decrypt the data of each item in :ref: items
If an item has already been decrypted, it won't be decrypted a second time
:param items: Item or list of items to decrypt
:param keystore: Keystore retrieved with the get_keystore method
+ :param uncompress_document: If True, the document will be decompressed
"""
# 1 item
@@ -281,6 +290,11 @@ Source code for novelai_api.utils
item["nonce"] = nonce
item["decrypted"] = True
item["compressed"] = is_compressed
+
+ if uncompress_document and "document" in data:
+ unpacker.restore_state(unpacker_state)
+ data["document"] = unpacker.unpack(b64decode(data["document"]))
+
continue
except json.JSONDecodeError:
@@ -464,7 +478,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Module code »
novelai_api.utils
diff --git a/_modules/tests/api/boilerplate.html b/_modules/tests/api/boilerplate.html
index aa9610d..ab69ff1 100644
--- a/_modules/tests/api/boilerplate.html
+++ b/_modules/tests/api/boilerplate.html
@@ -5,7 +5,7 @@
- tests.api.boilerplate — NovelAI API 0.27.0 documentation
+ tests.api.boilerplate — NovelAI API 0.28.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Module code »
tests.api.boilerplate
@@ -260,7 +260,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Module code »
tests.api.boilerplate
diff --git a/_modules/tests/api/test_decrypt_encrypt_integrity_check.html b/_modules/tests/api/test_decrypt_encrypt_integrity_check.html
index e3ec283..4e9b15a 100644
--- a/_modules/tests/api/test_decrypt_encrypt_integrity_check.html
+++ b/_modules/tests/api/test_decrypt_encrypt_integrity_check.html
@@ -5,7 +5,7 @@
- tests.api.test_decrypt_encrypt_integrity_check — NovelAI API 0.27.0 documentation
+ tests.api.test_decrypt_encrypt_integrity_check — NovelAI API 0.28.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Module code »
tests.api.test_decrypt_encrypt_integrity_check
@@ -307,7 +307,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Module code »
tests.api.test_decrypt_encrypt_integrity_check
diff --git a/_modules/tests/api/test_textgen_presets.html b/_modules/tests/api/test_textgen_presets.html
index bb2994c..5904790 100644
--- a/_modules/tests/api/test_textgen_presets.html
+++ b/_modules/tests/api/test_textgen_presets.html
@@ -5,7 +5,7 @@
- tests.api.test_textgen_presets — NovelAI API 0.27.0 documentation
+ tests.api.test_textgen_presets — NovelAI API 0.28.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Module code »
tests.api.test_textgen_presets
@@ -163,7 +163,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Module code »
tests.api.test_textgen_presets
diff --git a/_static/documentation_options.js b/_static/documentation_options.js
index 25d9074..afb5c56 100644
--- a/_static/documentation_options.js
+++ b/_static/documentation_options.js
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
- VERSION: '0.27.0',
+ VERSION: '0.28.0',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
diff --git a/_static/js/hoverxref.js b/_static/js/hoverxref.js
index 39d523b..5553ed0 100644
--- a/_static/js/hoverxref.js
+++ b/_static/js/hoverxref.js
@@ -86,7 +86,7 @@ function getEmbedURL(url) {
'url': url,
}
console.debug('Data: ' + JSON.stringify(params));
- var url = 'https://readthedocs.org' + '/api/v3/embed/?' + $.param(params);
+ var url = '/_' + '/api/v3/embed/?' + $.param(params);
console.debug('URL: ' + url);
return url
}
@@ -111,7 +111,7 @@ function addTooltip(target) {
var url = getEmbedURL(href);
$.ajax({
url: url,
- headers: {'X-HoverXRef-Version': '1.3.0'},
+ headers: {'X-HoverXRef-Version': '1.4.0'},
}).done(
function (data) {
// call the 'content' method to update the content of our tooltip with the returned data.
@@ -202,7 +202,7 @@ $(document).ready(function() {
var url = getEmbedURL(href);
$.ajax({
url: url,
- headers: {'X-HoverXRef-Version': '1.3.0'},
+ headers: {'X-HoverXRef-Version': '1.4.0'},
}).done(
function (data) {
var content = $('');
diff --git a/example/example.boilerplate.html b/example/example.boilerplate.html
index a57d336..0f81af3 100644
--- a/example/example.boilerplate.html
+++ b/example/example.boilerplate.html
@@ -6,7 +6,7 @@
- boilerplate — NovelAI API 0.27.0 documentation
+ boilerplate — NovelAI API 0.28.0 documentation
@@ -52,7 +52,7 @@ Navigation
previous |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
example directory »
boilerplate
@@ -198,7 +198,7 @@ Navigation
previous |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
example directory »
boilerplate
diff --git a/example/example.html b/example/example.html
index e0542b1..3f57f99 100644
--- a/example/example.html
+++ b/example/example.html
@@ -6,7 +6,7 @@
- example directory — NovelAI API 0.27.0 documentation
+ example directory — NovelAI API 0.28.0 documentation
@@ -52,7 +52,7 @@ Navigation
previous |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
example directory
@@ -284,7 +284,7 @@ Navigation
previous |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
example directory
diff --git a/genindex.html b/genindex.html
index 8ae0665..0fc9874 100644
--- a/genindex.html
+++ b/genindex.html
@@ -5,7 +5,7 @@
- Index — NovelAI API 0.27.0 documentation
+ Index — NovelAI API 0.28.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Index
@@ -1519,7 +1519,7 @@ Navigation
modules |
- NovelAI API 0.27.0 documentation »
+ NovelAI API 0.28.0 documentation »
Index
diff --git a/index.html b/index.html
index 3c427cb..7270e3b 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
- novelai-api — NovelAI API 0.27.0 documentation
+ novelai-api — NovelAI API 0.28.0 documentation
@@ -48,7 +48,7 @@ Navigation
Activity
Decrypt the data of each item in :ref: items If an item has already been decrypted, it won’t be decrypted a second time
items – Item or list of items to decrypt
keystore – Keystore retrieved with the get_keystore method
uncompress_document – If True, the document will be decompressed