|
3 | 3 | from typing import Callable, Tuple, Dict, Generator, List |
4 | 4 | from typing import Any, Union, Iterable |
5 | 5 | import sys |
6 | | -import requests |
7 | 6 | import io |
8 | 7 | import os |
9 | 8 | import re |
|
12 | 11 | import matplotlib |
13 | 12 | from PIL import Image |
14 | 13 | from functools import wraps |
15 | | -from .params import Projection, GenerateMode, Marker, Gateway |
| 14 | +from .params import Projection, GenerateMode, Marker |
16 | 15 | from .params import SAMILA_VERSION |
17 | 16 | from .params import DEFAULT_MARKER, DEFAULT_START, DEFAULT_STOP, DEFAULT_STEP, DEFAULT_COLOR, DEFAULT_IMAGE_SIZE, DEFAULT_DEPTH |
18 | 17 | from .params import DEFAULT_CMAP_NAME, DEFAULT_CMAP_RANGE, DEFAULT_ROTATION, DEFAULT_GENERATE_MODE |
19 | 18 | from .params import DEFAULT_BACKGROUND_COLOR, DEFAULT_SPOT_SIZE, DEFAULT_PROJECTION, DEFAULT_ALPHA, DEFAULT_LINEWIDTH |
20 | | -from .params import VALID_COLORS, HEX_COLOR_PATTERN, NFT_STORAGE_API, OVERVIEW |
| 19 | +from .params import VALID_COLORS, HEX_COLOR_PATTERN, OVERVIEW |
21 | 20 | from .params import DATA_TYPE_ERROR, DATA_FORMAT_ERROR, CONFIG_TYPE_ERROR, CONFIG_FORMAT_ERROR, PLOT_DATA_ERROR, CONFIG_NO_STR_FUNCTION_ERROR |
22 | | -from .params import NO_FIG_ERROR_MESSAGE, FIG_SAVE_SUCCESS_MESSAGE, NFT_STORAGE_SUCCESS_MESSAGE, SAVE_NO_DATA_ERROR |
| 21 | +from .params import NO_FIG_ERROR_MESSAGE, FIG_SAVE_SUCCESS_MESSAGE, SAVE_NO_DATA_ERROR |
23 | 22 | from .params import INVALID_COLOR_TYPE_ERROR, COLOR_SIZE_ERROR |
24 | 23 | from .params import BOTH_COLOR_COMPLEMENT_WARNING, COLOR_NOT_FOUND_WARNING, DEPRECATION_WARNING |
25 | 24 | from .params import DATA_SAVE_SUCCESS_MESSAGE, SEED_LOWER_BOUND, SEED_UPPER_BOUND |
@@ -508,41 +507,6 @@ def _GI_initializer(g: "GenerativeImage", function1: Callable, function2: Callab |
508 | 507 | g.missed_points_number = 0 |
509 | 508 |
|
510 | 509 |
|
511 | | -def nft_storage_upload( |
512 | | - api_key: str, |
513 | | - data: bytes, |
514 | | - timeout: int, |
515 | | - gateway: Gateway) -> Dict[str, Any]: |
516 | | - """ |
517 | | - Upload file to nft.storage. |
518 | | -
|
519 | | - :param api_key: API key |
520 | | - :param data: image data |
521 | | - :param timeout: upload timeout (in seconds) |
522 | | - :param gateway: IPFS gateway |
523 | | - """ |
524 | | - result = {"status": True, "message": NFT_STORAGE_SUCCESS_MESSAGE} |
525 | | - try: |
526 | | - headers = {'Authorization': 'Bearer {0}'.format(api_key)} |
527 | | - response = requests.post( |
528 | | - url=NFT_STORAGE_API, |
529 | | - data=data, |
530 | | - headers=headers, |
531 | | - timeout=timeout) |
532 | | - response_json = response.json() |
533 | | - if response_json["ok"]: |
534 | | - result["message"] = gateway.value.format( |
535 | | - response_json['value']['cid']) |
536 | | - return result |
537 | | - result["status"] = False |
538 | | - result["message"] = response_json["error"]["message"] |
539 | | - return result |
540 | | - except Exception as e: |
541 | | - result["status"] = False |
542 | | - result["message"] = str(e) |
543 | | - return result |
544 | | - |
545 | | - |
546 | 510 | def save_data_file(g: "GenerativeImage", file_adr: str) -> Dict[str, Any]: |
547 | 511 | """ |
548 | 512 | Save data as file. |
@@ -682,7 +646,7 @@ def save_fig_file(figure: matplotlib.figure.Figure, file_adr: str, depth: float) |
682 | 646 | return result |
683 | 647 |
|
684 | 648 |
|
685 | | -def save_fig_buf(figure: matplotlib.figure.Figure, depth: float) -> Dict[str, Any]: |
| 649 | +def save_fig_buf(figure: matplotlib.figure.Figure, depth: float) -> Dict[str, Any]: # pragma: no cover |
686 | 650 | """ |
687 | 651 | Save figure as buffer. |
688 | 652 |
|
|
0 commit comments