MCPcopy Create free account
hub / github.com/slackapi/python-slack-sdk / get_user_agent

Function get_user_agent

slack_sdk/web/internal_utils.py:42–57  ·  view source on GitHub ↗

Construct the user-agent header with the package info, Python version and OS version. Returns: The user agent string. e.g. 'Python/3.7.17 slackclient/2.0.0 Darwin/17.7.0'

(prefix: Optional[str] = None, suffix: Optional[str] = None)

Source from the content-addressed store, hash-verified

40
41
42def get_user_agent(prefix: Optional[str] = None, suffix: Optional[str] = None):
43 """Construct the user-agent header with the package info,
44 Python version and OS version.
45
46 Returns:
47 The user agent string.
48 e.g. 'Python/3.7.17 slackclient/2.0.0 Darwin/17.7.0'
49 """
50 # __name__ returns all classes, we only want the client
51 client = "{0}/{1}".format("slackclient", version.__version__)
52 python_version = "Python/{v.major}.{v.minor}.{v.micro}".format(v=sys.version_info)
53 system_info = "{0}/{1}".format(platform.system(), platform.release())
54 user_agent_string = " ".join([python_version, client, system_info])
55 prefix = f"{prefix} " if prefix else ""
56 suffix = f" {suffix}" if suffix else ""
57 return prefix + user_agent_string + suffix
58
59
60def _get_url(base_url: str, api_method: str) -> str:

Callers 15

__init__Method · 0.90
_get_headersFunction · 0.90
__init__Method · 0.90
_build_request_headersFunction · 0.90
_build_request_headersFunction · 0.90
_build_request_headersFunction · 0.90
_build_request_headersFunction · 0.90
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected