Skip to content

Commit

Permalink
Merge pull request #15 from Rsilnav/master
Browse files Browse the repository at this point in the history
LGTM
  • Loading branch information
arihant2math authored Feb 8, 2024
2 parents d0e83c0 + d243ea4 commit 0f6d82a
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 25 deletions.
91 changes: 90 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,93 @@
# v2.0.0 (unreleased)
# v2.3.4

- Fix issue with Contract deliver endpoint not able to return the right… by @Rsilnav in #14
- Fixed issue with nav.origin returning the wrong symbol

# v2.3.3

- UPDATED: Updated API version support to Dec. 2
- FIXED: minor marketplace error

# v2.3.2

- Bugfix

# v2.3.1

- FIXED: Bugs

# v2.3.0

- BREAKING: Route.origin and Route.destination are now Waypoints
- ADDED: Overloaders to many smaller classes
- FIXED: many bugs

# v2.2.8

- FIXED: Issue where h2 wasn't being installed
- FIXED: more api bugs

# v2.2.7

- More bug fixing

# v2.2.6

- FIXED: Issue with Activity being required

# v2.2.5

- BREAKING: API updated to support v2.1 (All previous API versions are now unsupported)
- ADDED: Some enums for market trade goods

# v2.2.4

- FIXED: More packaging issues

# v2.2.3

- FIXED: More packaging issues

# v2.2.2

- FIXED: GitHub python package publishing

# v2.2.1

- UPDATED: pyrate is now 3.0+
- FIXED: GitHub python package publishing

# v2.2.0

- ADDED: cooldown.active attribute
- UPDATED: Moved version stuff to version.py and added more version info
- UPDATED: Formatting

# v2.1.0

- BREAKING: The Update Ship Cooldown from the Ship class has been removed.
- ADDED: Method to get the cost effective refuel amount to the Fuel class.
- FIXED: Bug that limited retries to one less than what they should be
- FIXED: Bug that caused the wait_for_transit and the equivalent async version to error if there wasn't any transit happening.

# v2.0.4

- UPDATED: New server changes.

# v2.0.3

- Releasing Update

# v2.0.2

- FIXED: Rogue print statement
- FIXED: ship.nav warping instead of navigating

# v2.0.1

- FIXED: Various bugs

# v2.0.0

- BREAKING: Dropped requests as a dependency, switched to httpx
- BREAKING: Added and enabled http2
Expand Down
2 changes: 1 addition & 1 deletion autotraders/paginated_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def prev(self):

def all(self):
"""Gets all the pages and returns the list of all pages"""
for page in range(1, self.pages):
for page in range(1, self.pages + 1):
self.page = page
self.current()
return self.stitch()
Expand Down
34 changes: 11 additions & 23 deletions autotraders/ship/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Ship(SpaceTradersEntity):
cooldown: Optional[Cooldown]

def __init__(
self, symbol, session: AutoTradersSession, data: Optional[dict] = None
self, symbol, session: AutoTradersSession, data: Optional[dict] = None
):
if symbol is None:
symbol = data["symbol"]
Expand Down Expand Up @@ -112,38 +112,26 @@ def __str__(self):
return self.symbol

def wait_transit(self):
if (
sleep_time := (
self.nav.route.arrival - datetime.now(timezone.utc)
).total_seconds()
+ 0.5
> 0
):
sleep_time = (self.nav.route.arrival - datetime.now(timezone.utc)).total_seconds() + 0.5
if sleep_time > 0:
time.sleep(sleep_time)

async def await_transit(self):
if (
sleep_time := (
self.nav.route.arrival - datetime.now(timezone.utc)
).total_seconds()
+ 0.5
> 0
):
sleep_time = (self.nav.route.arrival - datetime.now(timezone.utc)).total_seconds() + 0.5
if sleep_time > 0:
await asyncio.sleep(sleep_time)

def wait_cooldown(self):
if self.cooldown is not None:
time.sleep(
(self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds()
+ 1
)
time_to_sleep = (self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds() + 1
if time_to_sleep > 0:
time.sleep(time_to_sleep)

async def await_cooldown(self):
if self.cooldown is not None:
await asyncio.sleep(
(self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds()
+ 1
)
time_to_sleep = (self.cooldown.expiration - datetime.now(timezone.utc)).total_seconds() + 1
if time_to_sleep > 0:
await asyncio.sleep(time_to_sleep)

def navigate(self, waypoint: Union[str, MapSymbol]):
"""Attempts to move ship to the provided waypoint.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta"
name = "autotraders"
authors = [
{ name = "Ashwin Naren", email = "[email protected]" },
{ name = "Rafael Sillero", email = "[email protected]" },
]
description = "A powerful spacetraders API"
readme = "README.md"
Expand Down

0 comments on commit 0f6d82a

Please sign in to comment.