async-universalis 4.0.0.dev0__tar.gz → 4.0.2.dev0__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.
- {async_universalis-4.0.0.dev0/async_universalis.egg-info → async_universalis-4.0.2.dev0}/PKG-INFO +1 -1
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis/__init__.py +67 -40
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0/async_universalis.egg-info}/PKG-INFO +1 -1
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/LICENSE +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/MANIFEST.in +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/README.md +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis/_enums.py +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis/_types.py +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis/errors.py +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis/items.json +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis/py.typed +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis.egg-info/SOURCES.txt +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis.egg-info/dependency_links.txt +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis.egg-info/requires.txt +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis.egg-info/top_level.txt +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/pyproject.toml +0 -0
- {async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/setup.cfg +0 -0
|
@@ -23,7 +23,7 @@ from __future__ import annotations
|
|
|
23
23
|
__title__ = "Universalis API wrapper"
|
|
24
24
|
__author__ = "k8thekat"
|
|
25
25
|
__license__ = "GNU"
|
|
26
|
-
__version__ = "4.0.
|
|
26
|
+
__version__ = "4.0.2-dev"
|
|
27
27
|
__credits__ = "Universalis and Square Enix"
|
|
28
28
|
|
|
29
29
|
|
|
@@ -241,14 +241,6 @@ class UniversalisAPI:
|
|
|
241
241
|
data = await session.get(url=url, **request_params)
|
|
242
242
|
|
|
243
243
|
LOGGER.debug("<%s._request> | Status Code: %s | Content Type: %s", __class__.__name__, data.status, data.content_type)
|
|
244
|
-
if not 200 <= data.status < 300:
|
|
245
|
-
raise UniversalisError(data.status, url, "generic http request")
|
|
246
|
-
if data.status == 400:
|
|
247
|
-
raise UniversalisError(
|
|
248
|
-
data.status,
|
|
249
|
-
url,
|
|
250
|
-
"invalid parameters",
|
|
251
|
-
)
|
|
252
244
|
# 404 - The world/DC or item requested is invalid. When requesting multiple items at once, an invalid item ID will not trigger this.
|
|
253
245
|
# Instead, the returned list of unresolved item IDs will contain the invalid item ID or IDs.
|
|
254
246
|
if data.status == 404:
|
|
@@ -257,7 +249,14 @@ class UniversalisAPI:
|
|
|
257
249
|
url,
|
|
258
250
|
"invalid World/DC or Item ID",
|
|
259
251
|
)
|
|
260
|
-
|
|
252
|
+
if data.status == 400:
|
|
253
|
+
raise UniversalisError(
|
|
254
|
+
data.status,
|
|
255
|
+
url,
|
|
256
|
+
"invalid parameters",
|
|
257
|
+
)
|
|
258
|
+
if not 200 <= data.status < 300:
|
|
259
|
+
raise UniversalisError(data.status, url, "generic http request")
|
|
261
260
|
self.api_call_time = datetime.datetime.now(datetime.UTC)
|
|
262
261
|
res: Any = await data.json()
|
|
263
262
|
return res
|
|
@@ -284,11 +283,11 @@ class UniversalisAPI:
|
|
|
284
283
|
|
|
285
284
|
|
|
286
285
|
.. note::
|
|
287
|
-
- If you specify a
|
|
286
|
+
- If you specify a :class:`World` when getting marketboard data..
|
|
288
287
|
- All `<CurrentData.listings>` and `<CurrentData.recent_history>` will not have the attributes `world_name`.
|
|
289
|
-
- If you specify a
|
|
288
|
+
- If you specify a :class:`DataCenter` when getting marketboard data...
|
|
290
289
|
- All `<CurrentData.listings>` and `<CurrentData.recent_history>` will have the `world_id` and `world_name` attributes.
|
|
291
|
-
-
|
|
290
|
+
- :class:`CurrentData` will also have an additional attribute called `dc_name`.
|
|
292
291
|
|
|
293
292
|
.. note::
|
|
294
293
|
You can change the default DataCenter by setting the `<UniversalisAPI>.datacenter` property.
|
|
@@ -359,11 +358,11 @@ class UniversalisAPI:
|
|
|
359
358
|
- See `https://docs.universalis.app/` and use their forms to generate a string with the fields you want.
|
|
360
359
|
|
|
361
360
|
.. note::
|
|
362
|
-
- If you specify a
|
|
361
|
+
- If you specify a :class:`World` when getting marketboard data..
|
|
363
362
|
- All `<CurrentData.listings>` and `<CurrentData.recent_history>` will not have the attributes `world_name`.
|
|
364
|
-
- If you specify a
|
|
363
|
+
- If you specify a :class:`DataCenter` when getting marketboard data...
|
|
365
364
|
- All `<CurrentData.listings>` and `<CurrentData.recent_history>` will have the `world_id` and `world_name` attributes.
|
|
366
|
-
-
|
|
365
|
+
- :class:`CurrentData` will also have an additional attribute called `dc_name`.
|
|
367
366
|
|
|
368
367
|
|
|
369
368
|
.. note::
|
|
@@ -441,11 +440,18 @@ class UniversalisAPI:
|
|
|
441
440
|
LOGGER.debug("<%s._get_bulk_current_data>. | URL: %s | Response:\n%s", __class__.__name__, api_url, res)
|
|
442
441
|
|
|
443
442
|
# results.extend([CurrentData(universalis=self, data=value) for value in res.get("items").values() if "listings" in value])
|
|
444
|
-
data
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
443
|
+
if data is None:
|
|
444
|
+
data = MultiPart(
|
|
445
|
+
universalis=self,
|
|
446
|
+
resolved_items=[
|
|
447
|
+
CurrentData(universalis=self, data=value) for value in res.get("items").values() if "listings" in value
|
|
448
|
+
],
|
|
449
|
+
**res,
|
|
450
|
+
)
|
|
451
|
+
else:
|
|
452
|
+
data.items.extend([CurrentData(universalis=self, data=value) for value in res.get("items").values() if "listings" in value])
|
|
453
|
+
data.unresolved_items.extend(res["unresolvedItems"])
|
|
454
|
+
|
|
449
455
|
return data
|
|
450
456
|
|
|
451
457
|
async def get_history_data(
|
|
@@ -470,9 +476,9 @@ class UniversalisAPI:
|
|
|
470
476
|
|
|
471
477
|
|
|
472
478
|
.. note::
|
|
473
|
-
- If you specify a
|
|
479
|
+
- If you specify a :class:`World` when getting marketboard data..
|
|
474
480
|
- All `<HistoryData.entries>` will not have the attributes `world_name`.
|
|
475
|
-
- If you specify a
|
|
481
|
+
- If you specify a :class:`DataCenter` when getting marketboard data...
|
|
476
482
|
- All `<HistoryData.entries>` will have the `world_id` and `world_name` attributes.
|
|
477
483
|
- `<HistoryData>` will also have an additional attribute called `dc_name`.
|
|
478
484
|
|
|
@@ -538,9 +544,9 @@ class UniversalisAPI:
|
|
|
538
544
|
|
|
539
545
|
|
|
540
546
|
.. note::
|
|
541
|
-
- If you specify a
|
|
547
|
+
- If you specify a :class:`World` when getting marketboard data..
|
|
542
548
|
- All `<HistoryData.entries>` will not have the attributes `world_name`.
|
|
543
|
-
- If you specify a
|
|
549
|
+
- If you specify a :class:`DataCenter` when getting marketboard data...
|
|
544
550
|
- All `<HistoryData.entries>` will have the `world_id` and `world_name` attributes.
|
|
545
551
|
- `<HistoryData>` will also have an additional attribute called `dc_name`.
|
|
546
552
|
|
|
@@ -592,7 +598,7 @@ class UniversalisAPI:
|
|
|
592
598
|
if world_or_dc is None:
|
|
593
599
|
world_or_dc = self.default_datacenter
|
|
594
600
|
|
|
595
|
-
# If we are given a single entry in our list; use the `
|
|
601
|
+
# If we are given a single entry in our list; use the `get_history_data` instead.
|
|
596
602
|
# We could modify the `join` statement below; but this is far easier and provides the same results.
|
|
597
603
|
# So if the `dcName` key exists, we searched by a DataCenter.
|
|
598
604
|
# otherwise the `worldName` and `worldID` key will exist.
|
|
@@ -623,11 +629,15 @@ class UniversalisAPI:
|
|
|
623
629
|
res,
|
|
624
630
|
)
|
|
625
631
|
# results.extend(HistoryData(universalis=self, data=value) for value in res.get("items").values() if "entries" in value)
|
|
626
|
-
data
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
632
|
+
if data is None:
|
|
633
|
+
data = MultiPart(
|
|
634
|
+
universalis=self,
|
|
635
|
+
resolved_items=[HistoryData(universalis=self, data=value) for value in res.get("items").values() if "entries" in value],
|
|
636
|
+
**res,
|
|
637
|
+
)
|
|
638
|
+
else:
|
|
639
|
+
data.items.extend([HistoryData(universalis=self, data=value) for value in res.get("items").values() if "entries" in value])
|
|
640
|
+
data.unresolved_items.extend(res["unresolvedItems"])
|
|
631
641
|
return data
|
|
632
642
|
|
|
633
643
|
@staticmethod
|
|
@@ -710,7 +720,7 @@ class Generic:
|
|
|
710
720
|
_repr_keys: list[str]
|
|
711
721
|
|
|
712
722
|
world_id: Optional[int]
|
|
713
|
-
world_name: Optional[str]
|
|
723
|
+
# world_name: Optional[str]
|
|
714
724
|
# This value only exists if you look up results by "Datacenter" instead of "World"
|
|
715
725
|
dc_name: Optional[str]
|
|
716
726
|
_raw: DataTypedAliase | MultiPartData
|
|
@@ -732,6 +742,23 @@ class Generic:
|
|
|
732
742
|
f"{e}: {getattr(self, e)}" for e in sorted(self.__dict__) if e.startswith("_") is False
|
|
733
743
|
])
|
|
734
744
|
|
|
745
|
+
@property
|
|
746
|
+
def world_name(self) -> Optional[str]:
|
|
747
|
+
"""The Final Fantasy 14 World name, if applicable.
|
|
748
|
+
|
|
749
|
+
.. note::
|
|
750
|
+
- If you specify a :class:`World` when getting marketboard data..
|
|
751
|
+
- All `<CurrentData.listings>` and `<CurrentData.recent_history>` will not have the attributes `world_name`.
|
|
752
|
+
- If you specify a :class:`DataCenter` when getting marketboard data...
|
|
753
|
+
- All `<CurrentData.listings>` and `<CurrentData.recent_history>` will have the `world_id` and `world_name` attributes.
|
|
754
|
+
- :class:`CurrentData` will also have an additional attribute called `dc_name`.
|
|
755
|
+
"""
|
|
756
|
+
return self._world_name
|
|
757
|
+
|
|
758
|
+
@world_name.setter
|
|
759
|
+
def world_name(self, value: Optional[str]) -> None:
|
|
760
|
+
self._world_name: Optional[str] = value
|
|
761
|
+
|
|
735
762
|
|
|
736
763
|
class GenericData(Generic):
|
|
737
764
|
"""Base class for mutual attributes and properties for Universalis data.
|
|
@@ -931,8 +958,8 @@ class CurrentData(GenericData):
|
|
|
931
958
|
self.listings = value
|
|
932
959
|
|
|
933
960
|
# This should handle price formatting.
|
|
934
|
-
elif "price" in key.lower() and (isinstance(value, (int, float))):
|
|
935
|
-
|
|
961
|
+
# elif "price" in key.lower() and (isinstance(value, (int, float))):
|
|
962
|
+
# setattr(self, key, f"{round(value):,d}")
|
|
936
963
|
|
|
937
964
|
elif key.lower() == "has_data" and isinstance(value, int):
|
|
938
965
|
self.has_data = bool(value)
|
|
@@ -1060,8 +1087,8 @@ class CurrentDataEntries(Generic):
|
|
|
1060
1087
|
setattr(self, key, bool(value))
|
|
1061
1088
|
|
|
1062
1089
|
# This should handle price formatting.
|
|
1063
|
-
elif isinstance(value, (int, float)) and ("price" in key.lower() or key.lower() == "total" or key.lower() == "tax"):
|
|
1064
|
-
|
|
1090
|
+
# elif isinstance(value, (int, float)) and ("price" in key.lower() or key.lower() == "total" or key.lower() == "tax"):
|
|
1091
|
+
# setattr(self, key, f"{round(value):,d}")
|
|
1065
1092
|
|
|
1066
1093
|
else:
|
|
1067
1094
|
setattr(self, key, value)
|
|
@@ -1218,8 +1245,8 @@ class HistoryData(GenericData):
|
|
|
1218
1245
|
if key.lower() == "entries" and isinstance(value, list):
|
|
1219
1246
|
self.entries = value
|
|
1220
1247
|
# This should handle price formatting.
|
|
1221
|
-
elif isinstance(value, (int, float)) and "velocity" in key:
|
|
1222
|
-
|
|
1248
|
+
# elif isinstance(value, (int, float)) and "velocity" in key:
|
|
1249
|
+
# setattr(self, key, f"{round(value):,d}")
|
|
1223
1250
|
else:
|
|
1224
1251
|
setattr(self, key, value)
|
|
1225
1252
|
self.name = self._universalis._get_item(self.item_id) # type: ignore[reportPrivateUsage] # noqa: SLF001
|
|
@@ -1300,8 +1327,8 @@ class HistoryDataEntries(Generic):
|
|
|
1300
1327
|
setattr(self, key, bool(value))
|
|
1301
1328
|
|
|
1302
1329
|
# This should handle price formatting.
|
|
1303
|
-
elif isinstance(value, (int, float)) and "price" in key:
|
|
1304
|
-
|
|
1330
|
+
# elif isinstance(value, (int, float)) and "price" in key:
|
|
1331
|
+
# setattr(self, key, f"{round(value):,d}")
|
|
1305
1332
|
else:
|
|
1306
1333
|
setattr(self, key, value)
|
|
1307
1334
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{async_universalis-4.0.0.dev0 → async_universalis-4.0.2.dev0}/async_universalis.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|