File tree Expand file tree Collapse file tree 5 files changed +48
-10
lines changed
Expand file tree Collapse file tree 5 files changed +48
-10
lines changed Original file line number Diff line number Diff line change 2828 '__version__' ,
2929 'HttpProvider' ,
3030 'Tron' ,
31- ]
31+ ]
Original file line number Diff line number Diff line change 44# See License.txt in the project root for license information.
55# --------------------------------------------------------------------
66
7- """This class is designed to configure and define nodes for different types."""
7+ """
8+ tronapi.manager
9+ ===============
10+
11+ This class is designed to configure and
12+ define nodes for different types.
13+
14+ :copyright: © 2018 by the iEXBase.
15+ :license: MIT License
16+ """
17+
818import logging
919
1020from tronapi import HttpProvider
Original file line number Diff line number Diff line change 33# Licensed under the MIT License.
44# See License.txt in the project root for license information.
55# --------------------------------------------------------------------
6+ from tronapi .utils .help import format_user_agent
67
78
89class BaseProvider (object ):
@@ -21,5 +22,6 @@ def status_page(self, page):
2122 def _http_default_headers ():
2223 """Add default headers"""
2324 return {
24- 'Content-Type' : 'application/json'
25+ 'Content-Type' : 'application/json' ,
26+ 'User-Agent' : format_user_agent ()
2527 }
Original file line number Diff line number Diff line change 44# See License.txt in the project root for license information.
55# --------------------------------------------------------------------
66
7+ """
8+ tronapi.providers.http
9+ ======================
10+
11+ Class for configuring http providers
12+
13+ :copyright: © 2018 by the iEXBase.
14+ :license: MIT License
15+ """
16+
717from collections import namedtuple
818from urllib .parse import urlparse
919
Original file line number Diff line number Diff line change 1- # --------------------------------------------------------------------------------------------
1+ # --------------------------------------------------------------------
22# Copyright (c) iEXBase. All rights reserved.
3- # Licensed under the MIT License. See License.txt in the project root for license information.
4- # --------------------------------------------------------------------------------------------
5-
3+ # Licensed under the MIT License.
4+ # See License.txt in the project root for license information.
5+ # --------------------------------------------------------------------
6+ import platform
67import re
78from typing import Any
89
910import base58
11+ import tronapi
12+
13+
14+ def format_user_agent (name = None ):
15+ """Construct a User-Agent suitable for use in client code.
16+ This will identify use by the provided ``name`` (which should be on the
17+ format ``dist_name/version``), TronAPI version and Python version.
18+ .. versionadded:: 1.1
19+ """
20+ parts = ['TronAPI/%s' % tronapi .__version__ ,
21+ '%s/%s' % (platform .python_implementation (),
22+ platform .python_version ())]
23+ if name :
24+ parts .insert (0 , name )
25+ return ' ' .join (parts )
1026
1127
1228def string_utf8_to_hex (name ):
@@ -18,10 +34,10 @@ def hex_to_base58(value: Any) -> str:
1834
1935
2036def is_valid_url (value ):
21- """
22- Return whether or not given value is a valid URL.
37+ """Return whether or not given value is a valid URL.
2338
24- :param value: URL address string to validate
39+ Args:
40+ value(str): URL address string to validate
2541 """
2642 regex = re .compile (
2743 r'^(?:http|ftp)s?://'
You can’t perform that action at this time.
0 commit comments