From 458b09029054d823e261d83ed1a1e9a27f6a2eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20N=C3=B8rgaard?= Date: Sat, 31 Dec 2022 19:11:00 +0000 Subject: [PATCH] add license header and fix metadata --- MANIFEST.in | 3 --- a2s/__init__.py | 7 +++---- a2s/a2s_async.pyi | 27 +++++++++++++++++++++++++-- a2s/a2s_fragment.py | 24 ++++++++++++++++++++++++ a2s/a2s_sync.py | 24 ++++++++++++++++++++++++ a2s/a2s_sync.pyi | 27 +++++++++++++++++++++++++-- a2s/byteio.py | 24 ++++++++++++++++++++++++ a2s/datacls.py | 35 +++++++++++++++++++++++++++++------ a2s/defaults.py | 24 ++++++++++++++++++++++++ a2s/exceptions.py | 25 +++++++++++++++++++++++++ a2s/info.py | 23 +++++++++++++++++++++++ a2s/players.py | 24 ++++++++++++++++++++++++ a2s/rules.py | 24 ++++++++++++++++++++++++ pyproject.toml | 2 +- setup.py | 2 ++ 15 files changed, 277 insertions(+), 18 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c9e6c81..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.md -include LICENSE -include a2s/py.typed diff --git a/a2s/__init__.py b/a2s/__init__.py index c68a690..b894cd0 100644 --- a/a2s/__init__.py +++ b/a2s/__init__.py @@ -23,7 +23,6 @@ SOFTWARE. """ from a2s.exceptions import BrokenMessageError as BrokenMessageError, BufferExhaustedError as BufferExhaustedError - -from a2s.info import info as info, ainfo as ainfo, SourceInfo as SourceInfo, GoldSrcInfo as GoldSrcInfo -from a2s.players import players as players, aplayers as aplayers, Player as Player -from a2s.rules import rules as rules, arules as arules +from a2s.info import GoldSrcInfo as GoldSrcInfo, SourceInfo as SourceInfo, ainfo as ainfo, info as info +from a2s.players import Player as Player, aplayers as aplayers, players as players +from a2s.rules import arules as arules, rules as rules diff --git a/a2s/a2s_async.pyi b/a2s/a2s_async.pyi index 8091341..2f95e11 100644 --- a/a2s/a2s_async.pyi +++ b/a2s/a2s_async.pyi @@ -1,8 +1,31 @@ -from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union, overload +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -from .a2s_async import A2SStreamAsync +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union, overload if TYPE_CHECKING: + from .a2s_async import A2SStreamAsync from .info import GoldSrcInfo, InfoProtocol, SourceInfo from .players import Player, PlayersProtocol from .rules import RulesProtocol diff --git a/a2s/a2s_fragment.py b/a2s/a2s_fragment.py index 9758333..8c7497d 100644 --- a/a2s/a2s_fragment.py +++ b/a2s/a2s_fragment.py @@ -1,3 +1,27 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + import bz2 import io diff --git a/a2s/a2s_sync.py b/a2s/a2s_sync.py index 0950660..cf5f5e2 100644 --- a/a2s/a2s_sync.py +++ b/a2s/a2s_sync.py @@ -1,3 +1,27 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + from __future__ import annotations import io diff --git a/a2s/a2s_sync.pyi b/a2s/a2s_sync.pyi index a2f48ea..6946647 100644 --- a/a2s/a2s_sync.pyi +++ b/a2s/a2s_sync.pyi @@ -1,8 +1,31 @@ -from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union, overload +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -from .a2s_sync import A2SStream +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union, overload if TYPE_CHECKING: + from .a2s_sync import A2SStream from .info import GoldSrcInfo, InfoProtocol, SourceInfo from .players import Player, PlayersProtocol from .rules import RulesProtocol diff --git a/a2s/byteio.py b/a2s/byteio.py index 25e3a95..2bbe734 100644 --- a/a2s/byteio.py +++ b/a2s/byteio.py @@ -1,3 +1,27 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + from __future__ import annotations import io diff --git a/a2s/datacls.py b/a2s/datacls.py index bc62b73..7b8abf9 100644 --- a/a2s/datacls.py +++ b/a2s/datacls.py @@ -1,4 +1,28 @@ """ +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +----- + Cheap dataclasses module backport Check out the official documentation to see what this is trying to @@ -7,14 +31,14 @@ https://docs.python.org/3/library/dataclasses.html """ from __future__ import annotations -from collections import OrderedDict import copy - -from typing import Any, Generator, Tuple, TYPE_CHECKING, Dict +from collections import OrderedDict +from typing import TYPE_CHECKING, Any, Dict, Generator, Tuple if TYPE_CHECKING: from typing_extensions import Self + class DataclsBase: _defaults: "OrderedDict[str, Any]" @@ -29,9 +53,8 @@ class DataclsBase: yield (name, getattr(self, name)) def __repr__(self) -> str: - return "{}({})".format( - self.__class__.__name__, - ", ".join(name + "=" + repr(value) for name, value in self)) + return "{}({})".format(self.__class__.__name__, ", ".join(name + "=" + repr(value) for name, value in self)) + class DataclsMeta(type): def __new__(cls, name: str, bases: Tuple[type, ...], prop: Dict[str, Any]) -> Self: diff --git a/a2s/defaults.py b/a2s/defaults.py index 07991ac..f996ec3 100644 --- a/a2s/defaults.py +++ b/a2s/defaults.py @@ -1,3 +1,27 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + DEFAULT_TIMEOUT = 3.0 DEFAULT_ENCODING = "utf-8" DEFAULT_RETRIES = 5 diff --git a/a2s/exceptions.py b/a2s/exceptions.py index fad37c5..6fda6e4 100644 --- a/a2s/exceptions.py +++ b/a2s/exceptions.py @@ -1,3 +1,28 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + + class BrokenMessageError(Exception): pass diff --git a/a2s/info.py b/a2s/info.py index c0487a3..501b552 100644 --- a/a2s/info.py +++ b/a2s/info.py @@ -1,3 +1,26 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" from __future__ import annotations from typing import Optional, Tuple, Union diff --git a/a2s/players.py b/a2s/players.py index 8bb23fd..4a91e36 100644 --- a/a2s/players.py +++ b/a2s/players.py @@ -1,3 +1,27 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + from typing import List, Optional, Tuple from a2s.a2s_async import request_async diff --git a/a2s/rules.py b/a2s/rules.py index e2a7e09..85a8562 100644 --- a/a2s/rules.py +++ b/a2s/rules.py @@ -1,3 +1,27 @@ +""" +MIT License + +Copyright (c) 2020 Gabriel Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + from typing import Dict, Optional, Tuple from a2s.a2s_async import request_async diff --git a/pyproject.toml b/pyproject.toml index ef0b3c5..d3eee77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ combine_star = true line_length = 125 [tool.pyright] -include = ["a2s/**/*.py"] +include = ["a2s/**/*.py", "a2s/**/*.pyi"] useLibraryCodeForTypes = true typeCheckingMode = "strict" pythonVersion = "3.7" diff --git a/setup.py b/setup.py index e2b6aab..b8b082f 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ setuptools.setup( long_description_content_type="text/markdown", url="https://github.com/Yepoleb/python-a2s", packages=["a2s"], + package_data={"a2s": ["a2s/py.typed", "*.pyi", "**/*.pyi"]}, license="MIT License", classifiers=[ "Development Status :: 4 - Beta", @@ -22,6 +23,7 @@ setuptools.setup( "Programming Language :: Python :: 3", "Operating System :: OS Independent", "Topic :: Games/Entertainment", + "Typing :: Typed", ], python_requires=">=3.7", )