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)
| 40 | |
| 41 | |
| 42 | def 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 | |
| 60 | def _get_url(base_url: str, api_method: str) -> str: |
no outgoing calls
no test coverage detected