cc-ampapi 0.0.0__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cc_ampapi-0.0.0/cc_ampapi.egg-info → cc_ampapi-1.1.0}/PKG-INFO +166 -2
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/README.md +6 -5
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/__init__.py +9 -4
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/analytics.py +2 -1
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/base.py +8 -10
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/controller.py +1 -1
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/core.py +7 -15
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/dataclass.py +53 -8
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/emailsender.py +0 -1
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/filebackup.py +0 -1
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/filemanager.py +2 -3
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/instance.py +0 -1
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/minecraft.py +1 -1
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/modules.py +6 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/util.py +4 -12
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0/cc_ampapi.egg-info}/PKG-INFO +166 -2
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/pyproject.toml +18 -17
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/LICENSE +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/LICENSE-dpy +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/MANIFEST.in +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/adsmodule.py +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/bridge.py +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/enums.py +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/ampapi/types_.py +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/cc_ampapi.egg-info/SOURCES.txt +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/cc_ampapi.egg-info/dependency_links.txt +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/cc_ampapi.egg-info/top_level.txt +0 -0
- {cc_ampapi-0.0.0 → cc_ampapi-1.1.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: cc-ampapi
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A Python wrapper for the AMP API by CubeCoders
|
|
5
5
|
Author-email: k8thekat <Cadwalladerkatelynn+AMPAPI@gmail.com>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -685,6 +685,7 @@ License: GNU GENERAL PUBLIC LICENSE
|
|
|
685
685
|
|
|
686
686
|
Project-URL: GitHub, https://github.com/k8thekat/AMPAPI_Python
|
|
687
687
|
Project-URL: Changelog, https://github.com/k8thekat/AMPAPI_Python/blob/master/CHANGELOG.md
|
|
688
|
+
Keywords: cubecoders,cube coders,amp,api
|
|
688
689
|
Classifier: Development Status :: 5 - Production/Stable
|
|
689
690
|
Classifier: Intended Audience :: Developers
|
|
690
691
|
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
@@ -702,3 +703,166 @@ Requires-Python: >=3.10.0
|
|
|
702
703
|
Description-Content-Type: text/markdown
|
|
703
704
|
License-File: LICENSE
|
|
704
705
|
License-File: LICENSE-dpy
|
|
706
|
+
|
|
707
|
+
# AMP API Python
|
|
708
|
+
___
|
|
709
|
+
CubeCoders AMP API wrapper in Python.
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
<div align="left">
|
|
713
|
+
<a href="https://discord.gg/BtNyU8DFtt"><img src='https://img.shields.io/discord/705500489248145459?color=blue&label=Discord&logo=Discord%20Server&logoColor=green' alt='Discord Server'></a>
|
|
714
|
+
</div>
|
|
715
|
+
|
|
716
|
+
<!--  -->
|
|
717
|
+

|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
### Key Features
|
|
721
|
+
___
|
|
722
|
+
|
|
723
|
+
- Pythonic API wrapper using `async` and `await`.
|
|
724
|
+
- Data is in dataclasses for easier management and interaction.
|
|
725
|
+
- Optional parameter per function or global to disable formatting of data.
|
|
726
|
+
- Parent classes `ADSInstance` and `AMPInstance` to group endpoints together and make handling of multiple Instances easier.
|
|
727
|
+
- This will also limit Instance specific API endpoints (eg. Minecraft) to that Instance type only.
|
|
728
|
+
|
|
729
|
+
### Installing
|
|
730
|
+
___
|
|
731
|
+
|
|
732
|
+
*Python 3.10 or higher is required*
|
|
733
|
+
|
|
734
|
+
To install run the below command to install the required pip packages from [Requirements](./requirements.txt)
|
|
735
|
+
|
|
736
|
+
### PyPi
|
|
737
|
+
___
|
|
738
|
+
-> Visit the package on [Pypi](https://pypi.org/project/cc-ampapi/)
|
|
739
|
+
|
|
740
|
+
```bash
|
|
741
|
+
# Linux/macOS/Windows
|
|
742
|
+
pip install cc-ampapi
|
|
743
|
+
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
### Basic Usage
|
|
747
|
+
___
|
|
748
|
+
1. First you need to fill out the APIParams class with the required fields (url, user and password).
|
|
749
|
+
2. Pass the APIParams class into the Bridge class parameter api_params.
|
|
750
|
+
- You only need to make ONE bridge class; the rest of the API classes will get the same object and handle logging in for you.
|
|
751
|
+
3. You can then use the Parent class `ADSInstance()` or the smaller class `AMPInstance()` or any of the API classes as a stand alone.
|
|
752
|
+
- See [Quick Example](./README.md#quick-example--) for a visual example.
|
|
753
|
+
|
|
754
|
+
### Quick Example -
|
|
755
|
+
|
|
756
|
+
```py
|
|
757
|
+
# You can pull these values from an `.ini` or a `.env` file,
|
|
758
|
+
# then populate the NamedTuple APIparams from `types -> APIParams`
|
|
759
|
+
_params = APIParams(url="http://192.168.13.130:8080",
|
|
760
|
+
user="amp_username",
|
|
761
|
+
password="amp_password")
|
|
762
|
+
|
|
763
|
+
_bridge = Bridge(api_params=_params)
|
|
764
|
+
|
|
765
|
+
async def Sample_API():
|
|
766
|
+
"""
|
|
767
|
+
Example Method to call Instance Endpoints and create the ADS Instance class.
|
|
768
|
+
"""
|
|
769
|
+
|
|
770
|
+
ADS: ADSInstance = ADSInstance()
|
|
771
|
+
# This would populate the ADS class property .AvailableInstances
|
|
772
|
+
await ADS.get_instances()
|
|
773
|
+
# We can break out all our instances into their own attributes.
|
|
774
|
+
# Your instances wont line up like these examples; but you can check the InstanceName and Module to figure out the order of your Instances.
|
|
775
|
+
arkinstance: AMPInstance | AMPMinecraftInstance = ADS.AvailableInstances[1]
|
|
776
|
+
mcinstance: AMPInstance | AMPMinecraftInstance = ADS.AvailableInstances[2]
|
|
777
|
+
|
|
778
|
+
# Pre populated from the dataclass and has the API methods too!
|
|
779
|
+
# You can take a backup really easily.
|
|
780
|
+
await arkinstance.take_backup(title="ARK1_backup", description="This is an ARK backup", sticky=True)
|
|
781
|
+
|
|
782
|
+
# Then you can call instance type specific API methods.
|
|
783
|
+
await mcinstance.mc_add_to_whitelist(user_or_uuid="k8_thekat")
|
|
784
|
+
|
|
785
|
+
# You can also check attributes and other fields of the instance.
|
|
786
|
+
mcinstance.InstanceName
|
|
787
|
+
mcinstance.InstanceID
|
|
788
|
+
|
|
789
|
+
# The State of the Instance. eg. Running, Offline, Restarting. See `types.py -> State_enum
|
|
790
|
+
# This is NOT updated constantly. See about using `get_status()` to keep it current.
|
|
791
|
+
if mcinstance.AppState == State_enum.Stopped:
|
|
792
|
+
await mcinstance.start_instance()
|
|
793
|
+
|
|
794
|
+
# You can also check Metrics of an Instance easily.
|
|
795
|
+
mcinstance.Status.Metrics
|
|
796
|
+
|
|
797
|
+
# Want to kick a random person? Here ya go~
|
|
798
|
+
players: list[Players] = await mcinstance.get_user_list()
|
|
799
|
+
await mcinstance.mc_kick_user_by_id(id=players[0].id)
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
async def Sample_Analytics_API():
|
|
803
|
+
"""
|
|
804
|
+
Example Method to use Instance Analytics.
|
|
805
|
+
"""
|
|
806
|
+
ADS: ADSInstance = ADSInstance()
|
|
807
|
+
await ADS.get_instances()
|
|
808
|
+
# The index value to get to an MC Instance will be different for you; this is just an example.
|
|
809
|
+
# You can check an Instances Type via the `.Module` attribute of any ADS/Instance class.
|
|
810
|
+
mcinstance: AMPInstance | AMPMinecraftInstance = ADS.AvailableInstances[2]
|
|
811
|
+
# Example analytics call without a filter.
|
|
812
|
+
Analytics: Analytics_Summary = await mcinstance.get_analytics_summary()
|
|
813
|
+
# Then with that class you can access lots of Information, such as Top Players, Stats and SessionTime.
|
|
814
|
+
Analytics.topPlayers # This is a list of this Instances Top Players.
|
|
815
|
+
Analytics.stats # This is a list of different fields such as Unique Users, New Users, etc..
|
|
816
|
+
# _____________________________________________
|
|
817
|
+
# Now you can also filter the results to look at a specific User or Country. Simply define the `Analytics_Filter` class and pass it into the method call.
|
|
818
|
+
country_filter: Analytics_Filter = Analytics_Filter(Country="US") # The Country parameter supports `ISO 3166-1 Alpha-2 format` only.
|
|
819
|
+
# These results will be filtered to only users within the US.
|
|
820
|
+
filtered_analytics: Analytics_Summary = await mcinstance.get_analytics_summary(filters=country_filter)
|
|
821
|
+
|
|
822
|
+
user_filter: Analytics_Filter = Analytics_Filter(Username="k8_thekat") # The IGN/Username of the user connected to the Server.
|
|
823
|
+
# These results will be filtered to only users with that match the parameter Username. (eg. k8_thekat).
|
|
824
|
+
filtered_analytics2: Analytics_Summary = await mcinstance.get_analytics_summary(filters=user_filter)
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
### Controlling data formatting -
|
|
831
|
+
- All JSON data returned from the API endpoints is formatted into a Dataclass/Enum/etc if possible.
|
|
832
|
+
- Data formatting can be controlled globally or locally by changing the `format_data` parameter of the method to `False`.
|
|
833
|
+
- When turning off the data formatting, typically you will get a `dictionary` back.
|
|
834
|
+
|
|
835
|
+
### Example -
|
|
836
|
+
```py
|
|
837
|
+
# By default all API calls will be formatted into Dataclasses if possible.
|
|
838
|
+
# You can toggle format_data off with ANY of the API classes that inherit Base().
|
|
839
|
+
ADS.format_data = False
|
|
840
|
+
|
|
841
|
+
# You can turn data formatting back on globally through any Instance object.
|
|
842
|
+
arkinstance.format_data = True
|
|
843
|
+
|
|
844
|
+
# You can turn off or on data formatting per function also.
|
|
845
|
+
await arkinstance.get_updates(format_data=False)
|
|
846
|
+
await arkinstance.get_role_data(format_data=True)
|
|
847
|
+
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
### Contributing to the project
|
|
852
|
+
|
|
853
|
+
# Git Commit message format
|
|
854
|
+
|
|
855
|
+
```
|
|
856
|
+
# file_name.py
|
|
857
|
+
- Change 1
|
|
858
|
+
- Change 2
|
|
859
|
+
-- Change 2 sub-change 1
|
|
860
|
+
|
|
861
|
+
$ This commit message will be omitted because of `$`
|
|
862
|
+
- Everything below it will be ignored too as long as it has a `-`
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
# AMP Version Bump
|
|
866
|
+
If the AMP version has changed, please generate new API spec sheets and upload them with any function changes.
|
|
867
|
+
- Run `await APIUtil.amp_api_update(instance=instance_here)`
|
|
868
|
+
|
|
@@ -28,14 +28,15 @@ ___
|
|
|
28
28
|
To install run the below command to install the required pip packages from [Requirements](./requirements.txt)
|
|
29
29
|
|
|
30
30
|
### PyPi
|
|
31
|
-
|
|
31
|
+
___
|
|
32
|
+
-> Visit the package on [Pypi](https://pypi.org/project/cc-ampapi/)
|
|
33
|
+
|
|
32
34
|
```bash
|
|
33
|
-
# Linux/macOS
|
|
34
|
-
pip install
|
|
35
|
+
# Linux/macOS/Windows
|
|
36
|
+
pip install cc-ampapi
|
|
35
37
|
|
|
36
|
-
# Windows
|
|
37
|
-
pip install cubecoders-amp-api-wrapper
|
|
38
38
|
```
|
|
39
|
+
|
|
39
40
|
### Basic Usage
|
|
40
41
|
___
|
|
41
42
|
1. First you need to fill out the APIParams class with the required fields (url, user and password).
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# ruff: noqa
|
|
1
2
|
"""
|
|
2
3
|
Copyright (C) 2021-2022 Katelynn Cadwallader.
|
|
3
4
|
|
|
@@ -24,12 +25,16 @@ from __future__ import annotations
|
|
|
24
25
|
__title__ = "CubeCoders AMP API"
|
|
25
26
|
__author__ = "k8thekat"
|
|
26
27
|
__license__ = "GNU"
|
|
27
|
-
__version__ = "1.0
|
|
28
|
+
__version__ = "1.1.0"
|
|
28
29
|
__credits__ = "AMP by CubeCoders and associates."
|
|
29
30
|
|
|
30
31
|
from typing import Literal, NamedTuple
|
|
31
32
|
|
|
32
|
-
from . import dataclass as dataclass
|
|
33
|
+
from . import dataclass as dataclass
|
|
34
|
+
from . import enums as enums
|
|
35
|
+
from . import modules as modules
|
|
36
|
+
from . import types_ as types
|
|
37
|
+
from . import util as util
|
|
33
38
|
from .adsmodule import *
|
|
34
39
|
from .analytics import *
|
|
35
40
|
from .base import *
|
|
@@ -47,9 +52,9 @@ class VersionInfo(NamedTuple):
|
|
|
47
52
|
Major: int
|
|
48
53
|
Minor: int
|
|
49
54
|
Revision: int
|
|
50
|
-
releaseLevel: Literal["alpha", "beta", "pre-release", "release", "development"]
|
|
55
|
+
releaseLevel: Literal["alpha", "beta", "pre-release", "release", "development"]
|
|
51
56
|
|
|
52
57
|
|
|
53
|
-
version_info: VersionInfo = VersionInfo(Major=1, Minor=
|
|
58
|
+
version_info: VersionInfo = VersionInfo(Major=1, Minor=1, Revision=0, releaseLevel="release")
|
|
54
59
|
|
|
55
60
|
del NamedTuple, Literal, VersionInfo
|
|
@@ -17,8 +17,6 @@ from pyotp import TOTP
|
|
|
17
17
|
|
|
18
18
|
from .bridge import Bridge
|
|
19
19
|
from .dataclass import APISession, Diagnostics, LoginResults, VersionInfo
|
|
20
|
-
from .enums import *
|
|
21
|
-
from .modules import DeploymentTemplate
|
|
22
20
|
|
|
23
21
|
if TYPE_CHECKING:
|
|
24
22
|
from collections.abc import Callable, Coroutine, Iterable
|
|
@@ -158,7 +156,7 @@ class Base:
|
|
|
158
156
|
from .adsmodule import ADSModule
|
|
159
157
|
from .instance import AMPADSInstance
|
|
160
158
|
|
|
161
|
-
if self.module == "ADS" or type(self)
|
|
159
|
+
if self.module == "ADS" or type(self) is AMPADSInstance or isinstance(self, ADSModule):
|
|
162
160
|
return func(self, *args, **kwargs)
|
|
163
161
|
else:
|
|
164
162
|
raise RuntimeError(self._ads_only)
|
|
@@ -227,7 +225,7 @@ class Base:
|
|
|
227
225
|
self.logger.debug("_call_api -> %s was called with %s", api, parameters)
|
|
228
226
|
|
|
229
227
|
# This should save us some boiler plate code throughout our API calls.
|
|
230
|
-
if parameters
|
|
228
|
+
if parameters is None:
|
|
231
229
|
parameters = {}
|
|
232
230
|
|
|
233
231
|
api_session: APISession = self._bridge._sessions.get(self.instance_id, APISession(id="0", ttl=datetime.now()))
|
|
@@ -255,7 +253,7 @@ class Base:
|
|
|
255
253
|
|
|
256
254
|
post_req_json: Any = await post_req.json()
|
|
257
255
|
|
|
258
|
-
if post_req_json
|
|
256
|
+
if post_req_json is None and _no_data is False:
|
|
259
257
|
raise ConnectionError(self._no_data)
|
|
260
258
|
|
|
261
259
|
# They removed "result" from all replies thus breaking most if not all future code.
|
|
@@ -289,7 +287,7 @@ class Base:
|
|
|
289
287
|
self.logger.error("%s failed because of %s", api, post_req_json)
|
|
290
288
|
raise ValueError(self._failed_api)
|
|
291
289
|
|
|
292
|
-
elif isinstance(post_req_json, dict) and "status" in post_req_json and post_req_json["status"]
|
|
290
|
+
elif isinstance(post_req_json, dict) and "status" in post_req_json and post_req_json["status"] is False:
|
|
293
291
|
self.logger.error("%s failed because of Status: %s", api, post_req_json)
|
|
294
292
|
return ValueError(self._failed_api)
|
|
295
293
|
|
|
@@ -337,7 +335,7 @@ class Base:
|
|
|
337
335
|
sessionID: str = session.id
|
|
338
336
|
|
|
339
337
|
if sessionID == "0":
|
|
340
|
-
if self._bridge.use_2fa
|
|
338
|
+
if self._bridge.use_2fa is True:
|
|
341
339
|
try:
|
|
342
340
|
# Handles time based 2Factory Auth Key/Code
|
|
343
341
|
code = TOTP(self._bridge.token).now()
|
|
@@ -478,7 +476,7 @@ class Base:
|
|
|
478
476
|
raise TypeError(f"The object {dataclass_} is not of the same type as <dataclass>.")
|
|
479
477
|
for field in fields(class_or_instance=dataclass_):
|
|
480
478
|
value: Any = getattr(dataclass_, field.name)
|
|
481
|
-
if value
|
|
479
|
+
if value is None:
|
|
482
480
|
continue
|
|
483
481
|
parameters[field.name] = value
|
|
484
482
|
return parameters
|
|
@@ -562,10 +560,10 @@ class Base:
|
|
|
562
560
|
# so all connections will use the same session id (if possible)
|
|
563
561
|
self._bridge = bridge
|
|
564
562
|
self.url = bridge.url
|
|
565
|
-
if bridge.use_2fa
|
|
563
|
+
if bridge.use_2fa is True:
|
|
566
564
|
if bridge.token == "":
|
|
567
565
|
raise ValueError("You must provide a 2FA Token if you are using 2FA.")
|
|
568
|
-
elif bridge.token.startswith(("'", '"'))
|
|
566
|
+
elif bridge.token.startswith(("'", '"')) is False or bridge.token.endswith(("'", '"')) is False:
|
|
569
567
|
raise ValueError("2FA Token must be enclosed in quotes.")
|
|
570
568
|
# Removed starting and ending quotes
|
|
571
569
|
elif len(bridge.token) < 8:
|
|
@@ -29,7 +29,7 @@ class AMPControllerInstance(ADSModule, Core, EmailSenderPlugin, FileManagerPlugi
|
|
|
29
29
|
self.module: str = "ADS"
|
|
30
30
|
|
|
31
31
|
def __getattr__(self, name: str) -> Union[AttributeError, Any]:
|
|
32
|
-
if name in [field.name for field in fields(class_or_instance=Controller)] and self._controller_exists
|
|
32
|
+
if name in [field.name for field in fields(class_or_instance=Controller)] and self._controller_exists is False:
|
|
33
33
|
raise AttributeError(
|
|
34
34
|
f"'{type(self).__name__}' object has no attribute '{name}' | You must call <AMPControllerInstance>.get_instances() with 'format_data=True' to update this object."
|
|
35
35
|
)
|
|
@@ -28,7 +28,6 @@ from .dataclass import (
|
|
|
28
28
|
User,
|
|
29
29
|
VersionInfo,
|
|
30
30
|
)
|
|
31
|
-
from .enums import *
|
|
32
31
|
from .modules import TriggerID, UserApplicationData
|
|
33
32
|
from .types_ import ActionSpec, APISpec, PermissionNode, ScheduleDataData, TriggersData
|
|
34
33
|
|
|
@@ -45,17 +44,10 @@ class Core(Base):
|
|
|
45
44
|
|
|
46
45
|
Attributes
|
|
47
46
|
-----------
|
|
48
|
-
events: EventID
|
|
49
|
-
You can access all the event IDs an instance has via this attribute. See :class:`EventID` for more information.
|
|
50
47
|
triggers: :class:`TriggerID`
|
|
51
48
|
You can access all the trigger IDs an instance has via this attribute. See :class:`TriggerID` for more information.
|
|
52
49
|
"""
|
|
53
50
|
|
|
54
|
-
# TODO - Need to finish developing this attribute.
|
|
55
|
-
@property
|
|
56
|
-
def events(self) -> None:
|
|
57
|
-
print()
|
|
58
|
-
|
|
59
51
|
@property
|
|
60
52
|
def triggers(self) -> TriggerID:
|
|
61
53
|
try:
|
|
@@ -1111,7 +1103,7 @@ class Core(Base):
|
|
|
1111
1103
|
if format_data is None:
|
|
1112
1104
|
format_data = self.format_data
|
|
1113
1105
|
|
|
1114
|
-
if format_data
|
|
1106
|
+
if format_data is False:
|
|
1115
1107
|
return result
|
|
1116
1108
|
|
|
1117
1109
|
elif isinstance(result, list):
|
|
@@ -1464,8 +1456,8 @@ class Core(Base):
|
|
|
1464
1456
|
|
|
1465
1457
|
Returns
|
|
1466
1458
|
--------
|
|
1467
|
-
:class:`
|
|
1468
|
-
On success returns a :class:`
|
|
1459
|
+
:class:`UserApplicationData`
|
|
1460
|
+
On success returns a :class:`UserApplicationData` class.
|
|
1469
1461
|
"""
|
|
1470
1462
|
|
|
1471
1463
|
await self._connect()
|
|
@@ -1475,8 +1467,8 @@ class Core(Base):
|
|
|
1475
1467
|
)
|
|
1476
1468
|
return result
|
|
1477
1469
|
|
|
1478
|
-
async def get_user_list(self, format_data: Union[bool, None] = None) ->
|
|
1479
|
-
"""|coro|
|
|
1470
|
+
async def get_user_list(self, format_data: Union[bool, None] = None) -> Players:
|
|
1471
|
+
"""|coro|Players
|
|
1480
1472
|
|
|
1481
1473
|
Returns the list of the connected users to the Application.
|
|
1482
1474
|
|
|
@@ -1487,8 +1479,8 @@ class Core(Base):
|
|
|
1487
1479
|
|
|
1488
1480
|
Returns
|
|
1489
1481
|
--------
|
|
1490
|
-
|
|
1491
|
-
On success returns a
|
|
1482
|
+
:class:`Players`
|
|
1483
|
+
On success returns a :class:`Players` dataclasses.
|
|
1492
1484
|
"""
|
|
1493
1485
|
|
|
1494
1486
|
await self._connect()
|
|
@@ -5,8 +5,9 @@ import logging
|
|
|
5
5
|
from dataclasses import dataclass, field, fields
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from logging import Logger
|
|
8
|
+
from operator import attrgetter
|
|
8
9
|
from pprint import pformat
|
|
9
|
-
from typing import TYPE_CHECKING, Any, ClassVar, Union
|
|
10
|
+
from typing import TYPE_CHECKING, Any, ClassVar, NamedTuple, Union
|
|
10
11
|
|
|
11
12
|
from dataclass_wizard.errors import MissingFields
|
|
12
13
|
from typing_extensions import Self
|
|
@@ -17,7 +18,7 @@ if TYPE_CHECKING:
|
|
|
17
18
|
|
|
18
19
|
from typing_extensions import ParamSpec, Self, TypeVar
|
|
19
20
|
|
|
20
|
-
from .types_ import
|
|
21
|
+
from .types_ import MCUserData
|
|
21
22
|
|
|
22
23
|
D = TypeVar("D", bound="Instance")
|
|
23
24
|
T = ParamSpec("T")
|
|
@@ -1794,10 +1795,9 @@ class PlatformInfo:
|
|
|
1794
1795
|
installed_glibc_version: str = field(default="") # "AMPVersionInfo"
|
|
1795
1796
|
|
|
1796
1797
|
|
|
1797
|
-
|
|
1798
|
-
class Players:
|
|
1798
|
+
class Player(NamedTuple):
|
|
1799
1799
|
"""
|
|
1800
|
-
Represents
|
|
1800
|
+
Represents a single player connected to a server.
|
|
1801
1801
|
|
|
1802
1802
|
Attributes
|
|
1803
1803
|
-----------
|
|
@@ -1805,16 +1805,61 @@ class Players:
|
|
|
1805
1805
|
The UUID of the player.
|
|
1806
1806
|
name: :class:`str`
|
|
1807
1807
|
The name of the player.
|
|
1808
|
-
|
|
1809
1808
|
"""
|
|
1810
1809
|
|
|
1811
1810
|
uuid: str = ""
|
|
1812
1811
|
name: str = ""
|
|
1813
1812
|
|
|
1813
|
+
def __eq__(self, other: object) -> bool:
|
|
1814
|
+
return isinstance(other, self.__class__) and self.name == other.name
|
|
1815
|
+
|
|
1816
|
+
def __lt__(self, other: object) -> bool:
|
|
1817
|
+
return isinstance(other, self.__class__) and self.name < other.name
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
@dataclass(init=False)
|
|
1821
|
+
class Players:
|
|
1822
|
+
"""
|
|
1823
|
+
Represents the JSON response data from :meth:`~Core.get_user_list`.
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
.. note::
|
|
1827
|
+
The print out of this dataclass can be long depending on the number of players connected due to separation by newline.
|
|
1828
|
+
|
|
1829
|
+
|
|
1830
|
+
Attributes
|
|
1831
|
+
-----------
|
|
1832
|
+
sorted: list[:class:`Player`]
|
|
1833
|
+
A sorted list of :class:`Player` objects by name.
|
|
1834
|
+
|
|
1835
|
+
"""
|
|
1836
|
+
|
|
1837
|
+
# {'781a2971-c14b-42c2-8742-d1e2b029d00a': 'k8_thekat', '50686fad-4027-4bdb-a4a5-2533f8a1e51f': 'WolfDevilAngel'}
|
|
1838
|
+
sorted: list[Player]
|
|
1839
|
+
|
|
1814
1840
|
def __init__(self, data: dict[str, str]) -> None:
|
|
1815
1841
|
for uuid, name in data.items():
|
|
1816
|
-
|
|
1817
|
-
|
|
1842
|
+
self.sorted.append(Player(uuid=uuid, name=name))
|
|
1843
|
+
self.sorted.sort(key=attrgetter("name"))
|
|
1844
|
+
|
|
1845
|
+
def __repr__(self) -> str:
|
|
1846
|
+
return "\n".join([p.name for p in self.sorted])
|
|
1847
|
+
|
|
1848
|
+
def get_player(self, name_or_uuid: str) -> list[Player]:
|
|
1849
|
+
"""
|
|
1850
|
+
Search for a player by their name or UUID.
|
|
1851
|
+
|
|
1852
|
+
Parameters
|
|
1853
|
+
-----------
|
|
1854
|
+
name_or_uuid: :class:`str`
|
|
1855
|
+
The players name or UUID.
|
|
1856
|
+
|
|
1857
|
+
Returns
|
|
1858
|
+
--------
|
|
1859
|
+
:class:`list[Player]`
|
|
1860
|
+
A list of :class:`Player` objects matching the search string.
|
|
1861
|
+
"""
|
|
1862
|
+
return [p for p in self.sorted if name_or_uuid in (p.name, p.uuid)]
|
|
1818
1863
|
|
|
1819
1864
|
|
|
1820
1865
|
@dataclass
|
|
@@ -2,7 +2,6 @@ from typing import Any, Union
|
|
|
2
2
|
|
|
3
3
|
from .base import Base
|
|
4
4
|
from .dataclass import ActionResult, Directory, FileChunk
|
|
5
|
-
from .enums import *
|
|
6
5
|
|
|
7
6
|
__all__ = ("FileManagerPlugin",)
|
|
8
7
|
|
|
@@ -268,7 +267,7 @@ class FileManagerPlugin(Base):
|
|
|
268
267
|
await self._connect()
|
|
269
268
|
parameters: dict[str, str] = {"ArchivePath": self.sanitize_path(file_path)}
|
|
270
269
|
|
|
271
|
-
if destination_path
|
|
270
|
+
if destination_path is not None:
|
|
272
271
|
parameters["DestinationPath"] = destination_path
|
|
273
272
|
|
|
274
273
|
result: Any = await self._call_api(
|
|
@@ -366,7 +365,7 @@ class FileManagerPlugin(Base):
|
|
|
366
365
|
|
|
367
366
|
await self._connect()
|
|
368
367
|
parameters: dict[str, Any] = {"Filename": self.sanitize_path(file_path), "Offset": offset}
|
|
369
|
-
if chunk_size
|
|
368
|
+
if chunk_size is not None:
|
|
370
369
|
parameters["ChunkSize"] = chunk_size
|
|
371
370
|
|
|
372
371
|
result: Any = await self._call_api(
|
|
@@ -7,7 +7,6 @@ from .analytics import AnalyticsPlugin
|
|
|
7
7
|
from .core import Core
|
|
8
8
|
from .dataclass import ActionResult, Instance, InstanceStatus, Updates
|
|
9
9
|
from .emailsender import EmailSenderPlugin
|
|
10
|
-
from .enums import *
|
|
11
10
|
from .filebackup import LocalFileBackupPlugin
|
|
12
11
|
from .filemanager import FileManagerPlugin
|
|
13
12
|
from .minecraft import MinecraftModule
|
|
@@ -108,6 +108,12 @@ class DeploymentTemplate:
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
class TriggerID:
|
|
111
|
+
"""
|
|
112
|
+
Used for a multitude of functions all related to Triggers and their IDs.
|
|
113
|
+
|
|
114
|
+
Simply access the respective attribute and the unique GUID for that :class:`AMPInstance` Trigger ID will be returned.
|
|
115
|
+
"""
|
|
116
|
+
|
|
111
117
|
a_backup_finishes_archiving: str
|
|
112
118
|
a_backup_finishes_restoring: str
|
|
113
119
|
a_backup_has_failed: str
|
|
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
5
|
import traceback
|
|
6
|
-
from collections import defaultdict
|
|
7
6
|
from datetime import datetime
|
|
8
7
|
from logging import Logger
|
|
9
8
|
from pathlib import Path
|
|
@@ -20,18 +19,11 @@ if TYPE_CHECKING:
|
|
|
20
19
|
from io import TextIOWrapper
|
|
21
20
|
|
|
22
21
|
from .controller import AMPADSInstance, AMPControllerInstance, AMPInstance
|
|
23
|
-
from .
|
|
24
|
-
from .dataclass import Diagnostics, Methods, SettingSpec, SettingsSpecParent, Triggers, TriggerTasks
|
|
22
|
+
from .dataclass import Diagnostics, Methods, SettingSpec, SettingsSpecParent, Triggers
|
|
25
23
|
from .types_ import (
|
|
26
24
|
APISpec,
|
|
27
|
-
APISPecEndpointData,
|
|
28
|
-
APISpecEndpointParameters,
|
|
29
|
-
Consumes,
|
|
30
|
-
MethodsData,
|
|
31
|
-
ParameterMapping,
|
|
32
25
|
PermissionNode,
|
|
33
26
|
ScheduleDataData,
|
|
34
|
-
TriggersData,
|
|
35
27
|
)
|
|
36
28
|
|
|
37
29
|
|
|
@@ -203,7 +195,7 @@ def _permission_node_parse(
|
|
|
203
195
|
if _dir.exists():
|
|
204
196
|
mode = "w"
|
|
205
197
|
|
|
206
|
-
if file
|
|
198
|
+
if file is None:
|
|
207
199
|
file = Path.open(_dir, mode)
|
|
208
200
|
|
|
209
201
|
if index == 0:
|
|
@@ -333,7 +325,7 @@ def _settings_node_parse(
|
|
|
333
325
|
if _dir.exists():
|
|
334
326
|
mode = "w"
|
|
335
327
|
|
|
336
|
-
if file
|
|
328
|
+
if file is None:
|
|
337
329
|
file = Path.open(_dir, mode)
|
|
338
330
|
|
|
339
331
|
if index == 0:
|
|
@@ -358,7 +350,7 @@ def _settings_node_parse(
|
|
|
358
350
|
if isinstance(data_key, list):
|
|
359
351
|
for entry in sorted(data_key):
|
|
360
352
|
file.write(f"\n**Name**: {entry.name}\n")
|
|
361
|
-
if entry.description
|
|
353
|
+
if entry.description is not None and len(entry.description) > 0:
|
|
362
354
|
file.write(f"\t| Description: {str_sanitizer_sphinx(string=entry.description, special_chars=('*',))}\n")
|
|
363
355
|
file.write(f"\t| Node: `{entry.node}`\n")
|
|
364
356
|
file.close()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: cc-ampapi
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A Python wrapper for the AMP API by CubeCoders
|
|
5
5
|
Author-email: k8thekat <Cadwalladerkatelynn+AMPAPI@gmail.com>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -685,6 +685,7 @@ License: GNU GENERAL PUBLIC LICENSE
|
|
|
685
685
|
|
|
686
686
|
Project-URL: GitHub, https://github.com/k8thekat/AMPAPI_Python
|
|
687
687
|
Project-URL: Changelog, https://github.com/k8thekat/AMPAPI_Python/blob/master/CHANGELOG.md
|
|
688
|
+
Keywords: cubecoders,cube coders,amp,api
|
|
688
689
|
Classifier: Development Status :: 5 - Production/Stable
|
|
689
690
|
Classifier: Intended Audience :: Developers
|
|
690
691
|
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
@@ -702,3 +703,166 @@ Requires-Python: >=3.10.0
|
|
|
702
703
|
Description-Content-Type: text/markdown
|
|
703
704
|
License-File: LICENSE
|
|
704
705
|
License-File: LICENSE-dpy
|
|
706
|
+
|
|
707
|
+
# AMP API Python
|
|
708
|
+
___
|
|
709
|
+
CubeCoders AMP API wrapper in Python.
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
<div align="left">
|
|
713
|
+
<a href="https://discord.gg/BtNyU8DFtt"><img src='https://img.shields.io/discord/705500489248145459?color=blue&label=Discord&logo=Discord%20Server&logoColor=green' alt='Discord Server'></a>
|
|
714
|
+
</div>
|
|
715
|
+
|
|
716
|
+
<!--  -->
|
|
717
|
+

|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
### Key Features
|
|
721
|
+
___
|
|
722
|
+
|
|
723
|
+
- Pythonic API wrapper using `async` and `await`.
|
|
724
|
+
- Data is in dataclasses for easier management and interaction.
|
|
725
|
+
- Optional parameter per function or global to disable formatting of data.
|
|
726
|
+
- Parent classes `ADSInstance` and `AMPInstance` to group endpoints together and make handling of multiple Instances easier.
|
|
727
|
+
- This will also limit Instance specific API endpoints (eg. Minecraft) to that Instance type only.
|
|
728
|
+
|
|
729
|
+
### Installing
|
|
730
|
+
___
|
|
731
|
+
|
|
732
|
+
*Python 3.10 or higher is required*
|
|
733
|
+
|
|
734
|
+
To install run the below command to install the required pip packages from [Requirements](./requirements.txt)
|
|
735
|
+
|
|
736
|
+
### PyPi
|
|
737
|
+
___
|
|
738
|
+
-> Visit the package on [Pypi](https://pypi.org/project/cc-ampapi/)
|
|
739
|
+
|
|
740
|
+
```bash
|
|
741
|
+
# Linux/macOS/Windows
|
|
742
|
+
pip install cc-ampapi
|
|
743
|
+
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
### Basic Usage
|
|
747
|
+
___
|
|
748
|
+
1. First you need to fill out the APIParams class with the required fields (url, user and password).
|
|
749
|
+
2. Pass the APIParams class into the Bridge class parameter api_params.
|
|
750
|
+
- You only need to make ONE bridge class; the rest of the API classes will get the same object and handle logging in for you.
|
|
751
|
+
3. You can then use the Parent class `ADSInstance()` or the smaller class `AMPInstance()` or any of the API classes as a stand alone.
|
|
752
|
+
- See [Quick Example](./README.md#quick-example--) for a visual example.
|
|
753
|
+
|
|
754
|
+
### Quick Example -
|
|
755
|
+
|
|
756
|
+
```py
|
|
757
|
+
# You can pull these values from an `.ini` or a `.env` file,
|
|
758
|
+
# then populate the NamedTuple APIparams from `types -> APIParams`
|
|
759
|
+
_params = APIParams(url="http://192.168.13.130:8080",
|
|
760
|
+
user="amp_username",
|
|
761
|
+
password="amp_password")
|
|
762
|
+
|
|
763
|
+
_bridge = Bridge(api_params=_params)
|
|
764
|
+
|
|
765
|
+
async def Sample_API():
|
|
766
|
+
"""
|
|
767
|
+
Example Method to call Instance Endpoints and create the ADS Instance class.
|
|
768
|
+
"""
|
|
769
|
+
|
|
770
|
+
ADS: ADSInstance = ADSInstance()
|
|
771
|
+
# This would populate the ADS class property .AvailableInstances
|
|
772
|
+
await ADS.get_instances()
|
|
773
|
+
# We can break out all our instances into their own attributes.
|
|
774
|
+
# Your instances wont line up like these examples; but you can check the InstanceName and Module to figure out the order of your Instances.
|
|
775
|
+
arkinstance: AMPInstance | AMPMinecraftInstance = ADS.AvailableInstances[1]
|
|
776
|
+
mcinstance: AMPInstance | AMPMinecraftInstance = ADS.AvailableInstances[2]
|
|
777
|
+
|
|
778
|
+
# Pre populated from the dataclass and has the API methods too!
|
|
779
|
+
# You can take a backup really easily.
|
|
780
|
+
await arkinstance.take_backup(title="ARK1_backup", description="This is an ARK backup", sticky=True)
|
|
781
|
+
|
|
782
|
+
# Then you can call instance type specific API methods.
|
|
783
|
+
await mcinstance.mc_add_to_whitelist(user_or_uuid="k8_thekat")
|
|
784
|
+
|
|
785
|
+
# You can also check attributes and other fields of the instance.
|
|
786
|
+
mcinstance.InstanceName
|
|
787
|
+
mcinstance.InstanceID
|
|
788
|
+
|
|
789
|
+
# The State of the Instance. eg. Running, Offline, Restarting. See `types.py -> State_enum
|
|
790
|
+
# This is NOT updated constantly. See about using `get_status()` to keep it current.
|
|
791
|
+
if mcinstance.AppState == State_enum.Stopped:
|
|
792
|
+
await mcinstance.start_instance()
|
|
793
|
+
|
|
794
|
+
# You can also check Metrics of an Instance easily.
|
|
795
|
+
mcinstance.Status.Metrics
|
|
796
|
+
|
|
797
|
+
# Want to kick a random person? Here ya go~
|
|
798
|
+
players: list[Players] = await mcinstance.get_user_list()
|
|
799
|
+
await mcinstance.mc_kick_user_by_id(id=players[0].id)
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
async def Sample_Analytics_API():
|
|
803
|
+
"""
|
|
804
|
+
Example Method to use Instance Analytics.
|
|
805
|
+
"""
|
|
806
|
+
ADS: ADSInstance = ADSInstance()
|
|
807
|
+
await ADS.get_instances()
|
|
808
|
+
# The index value to get to an MC Instance will be different for you; this is just an example.
|
|
809
|
+
# You can check an Instances Type via the `.Module` attribute of any ADS/Instance class.
|
|
810
|
+
mcinstance: AMPInstance | AMPMinecraftInstance = ADS.AvailableInstances[2]
|
|
811
|
+
# Example analytics call without a filter.
|
|
812
|
+
Analytics: Analytics_Summary = await mcinstance.get_analytics_summary()
|
|
813
|
+
# Then with that class you can access lots of Information, such as Top Players, Stats and SessionTime.
|
|
814
|
+
Analytics.topPlayers # This is a list of this Instances Top Players.
|
|
815
|
+
Analytics.stats # This is a list of different fields such as Unique Users, New Users, etc..
|
|
816
|
+
# _____________________________________________
|
|
817
|
+
# Now you can also filter the results to look at a specific User or Country. Simply define the `Analytics_Filter` class and pass it into the method call.
|
|
818
|
+
country_filter: Analytics_Filter = Analytics_Filter(Country="US") # The Country parameter supports `ISO 3166-1 Alpha-2 format` only.
|
|
819
|
+
# These results will be filtered to only users within the US.
|
|
820
|
+
filtered_analytics: Analytics_Summary = await mcinstance.get_analytics_summary(filters=country_filter)
|
|
821
|
+
|
|
822
|
+
user_filter: Analytics_Filter = Analytics_Filter(Username="k8_thekat") # The IGN/Username of the user connected to the Server.
|
|
823
|
+
# These results will be filtered to only users with that match the parameter Username. (eg. k8_thekat).
|
|
824
|
+
filtered_analytics2: Analytics_Summary = await mcinstance.get_analytics_summary(filters=user_filter)
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
### Controlling data formatting -
|
|
831
|
+
- All JSON data returned from the API endpoints is formatted into a Dataclass/Enum/etc if possible.
|
|
832
|
+
- Data formatting can be controlled globally or locally by changing the `format_data` parameter of the method to `False`.
|
|
833
|
+
- When turning off the data formatting, typically you will get a `dictionary` back.
|
|
834
|
+
|
|
835
|
+
### Example -
|
|
836
|
+
```py
|
|
837
|
+
# By default all API calls will be formatted into Dataclasses if possible.
|
|
838
|
+
# You can toggle format_data off with ANY of the API classes that inherit Base().
|
|
839
|
+
ADS.format_data = False
|
|
840
|
+
|
|
841
|
+
# You can turn data formatting back on globally through any Instance object.
|
|
842
|
+
arkinstance.format_data = True
|
|
843
|
+
|
|
844
|
+
# You can turn off or on data formatting per function also.
|
|
845
|
+
await arkinstance.get_updates(format_data=False)
|
|
846
|
+
await arkinstance.get_role_data(format_data=True)
|
|
847
|
+
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
### Contributing to the project
|
|
852
|
+
|
|
853
|
+
# Git Commit message format
|
|
854
|
+
|
|
855
|
+
```
|
|
856
|
+
# file_name.py
|
|
857
|
+
- Change 1
|
|
858
|
+
- Change 2
|
|
859
|
+
-- Change 2 sub-change 1
|
|
860
|
+
|
|
861
|
+
$ This commit message will be omitted because of `$`
|
|
862
|
+
- Everything below it will be ignored too as long as it has a `-`
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
# AMP Version Bump
|
|
866
|
+
If the AMP version has changed, please generate new API spec sheets and upload them with any function changes.
|
|
867
|
+
- Run `await APIUtil.amp_api_update(instance=instance_here)`
|
|
868
|
+
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
|
-
name = "cc-ampapi"
|
|
6
|
+
name = "cc-ampapi"
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "k8thekat", email = "Cadwalladerkatelynn+AMPAPI@gmail.com" },
|
|
10
10
|
]
|
|
11
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
11
12
|
description = "A Python wrapper for the AMP API by CubeCoders"
|
|
12
|
-
readme = { file = "README", content-type = "text/markdown" }
|
|
13
13
|
requires-python = ">=3.10.0"
|
|
14
14
|
license = { file = "LICENSE" }
|
|
15
15
|
classifiers = [
|
|
@@ -27,24 +27,25 @@ classifiers = [
|
|
|
27
27
|
"Topic :: Utilities",
|
|
28
28
|
"Typing :: Typed",
|
|
29
29
|
]
|
|
30
|
-
|
|
30
|
+
keywords = ["cubecoders", "cube coders", "amp", "api"]
|
|
31
31
|
[project.urls]
|
|
32
|
-
GitHub
|
|
32
|
+
GitHub = "https://github.com/k8thekat/AMPAPI_Python"
|
|
33
33
|
Changelog = "https://github.com/k8thekat/AMPAPI_Python/blob/master/CHANGELOG.md"
|
|
34
34
|
|
|
35
35
|
[tool.setuptools.dynamic]
|
|
36
36
|
dependencies = { file = "requirements.txt" }
|
|
37
|
+
version = { attr = "ampapi.__version__" }
|
|
37
38
|
|
|
38
39
|
[tool.setuptools]
|
|
39
|
-
packages
|
|
40
|
+
packages = ["ampapi"]
|
|
40
41
|
include-package-data = true
|
|
41
42
|
|
|
42
43
|
[tool.ruff]
|
|
43
44
|
target-version = "py310"
|
|
44
|
-
line-length
|
|
45
|
+
line-length = 125
|
|
46
|
+
exclude = ["docs/extensions/*.py"]
|
|
45
47
|
|
|
46
48
|
[tool.ruff.lint]
|
|
47
|
-
exclude = ["docs/extensions/*.py"]
|
|
48
49
|
select = [
|
|
49
50
|
"A",
|
|
50
51
|
"C4",
|
|
@@ -54,7 +55,7 @@ select = [
|
|
|
54
55
|
"PTH",
|
|
55
56
|
"RUF",
|
|
56
57
|
"SIM",
|
|
57
|
-
"
|
|
58
|
+
"TC",
|
|
58
59
|
"UP",
|
|
59
60
|
"W",
|
|
60
61
|
"PERF",
|
|
@@ -72,25 +73,25 @@ ignore = [
|
|
|
72
73
|
"UP034",
|
|
73
74
|
"UP038",
|
|
74
75
|
"UP007",
|
|
75
|
-
"ANN101",
|
|
76
|
-
"ANN102",
|
|
76
|
+
#"ANN101",
|
|
77
|
+
#"ANN102",
|
|
77
78
|
"ANN401",
|
|
78
79
|
]
|
|
79
80
|
|
|
80
81
|
[tool.ruff.lint.isort]
|
|
81
82
|
split-on-trailing-comma = false
|
|
82
|
-
combine-as-imports
|
|
83
|
+
combine-as-imports = true
|
|
83
84
|
|
|
84
85
|
[tool.ruff.lint.flake8-annotations]
|
|
85
86
|
allow-star-arg-any = true
|
|
86
87
|
|
|
87
88
|
[tool.ruff.lint.flake8-pytest-style]
|
|
88
|
-
fixture-parentheses
|
|
89
|
-
mark-parentheses
|
|
89
|
+
fixture-parentheses = false
|
|
90
|
+
mark-parentheses = false
|
|
90
91
|
parametrize-names-type = "tuple"
|
|
91
92
|
|
|
92
93
|
[tool.pyright]
|
|
93
|
-
useLibraryCodeForTypes
|
|
94
|
-
typeCheckingMode
|
|
95
|
-
pythonVersion
|
|
94
|
+
useLibraryCodeForTypes = true
|
|
95
|
+
typeCheckingMode = "standard"
|
|
96
|
+
pythonVersion = "3.10"
|
|
96
97
|
reportIncompatibleMethodOverride = false
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|