Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add pydoctor to generate automatic documentation
Browse files Browse the repository at this point in the history
AlberTajuelo committed Nov 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 30cf99d commit c8bd55f
Showing 14 changed files with 223 additions and 173 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci-python-apidocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ci-python-apidocs

on:
push:
branches:
- master
- feature/add-docs-static-site-pydoctor

jobs:
ci-python-apidocs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install requirements for documentation generation
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install docutils pydoctor
- name: Generate API documentation with pydoctor
run: |
pydoctor \
--project-name=steampy \
--project-url=https://github.com/$GITHUB_REPOSITORY \
--html-viewsource-base=https://github.com/$GITHUB_REPOSITORY/tree/$GITHUB_SHA \
--make-html \
--html-output=./apidocs \
--project-base-dir="$(pwd)" \
--docformat=restructuredtext \
--intersphinx=https://docs.python.org/3/objects.inv \
./steampy
- name: Push API documentation to Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./apidocs
commit_message: "Generate API documentation"
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ on:
branches: [master]

jobs:
unittest:
ci-python-unittest:
runs-on: ubuntu-latest
strategy:
matrix:
@@ -23,4 +23,4 @@ jobs:
- name: Unit tests
run: |
pip install .
python -m unittest discover -s ./test -p 'test_*.py'
python -m unittest discover -s ./test -p 'test_*.py'
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Please make all pull request with 1 commit that can be easily rebased onto master.
Contributions are the heartbeat of the open source community, transforming it into a vibrant space for learning, inspiring, and creating. Every contribution you bring adds immense value and is genuinely appreciated.

Please add tests for new functions.
If you have a suggestion to enhance the project, we encourage you to fork the repository and initiate a pull request. Alternatively, you can effortlessly open an issue, labeling it as "enhancement." And hey, don't forget to show your support by giving the project a star! Your efforts make a significant difference - thank you!

Here's a quick guide to getting involved:

- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature'). Make sure all pull requests contains only _1 commit_ that can be easily rebased onto master branch. Add tests for new functions.
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request

Your contributions are the driving force behind the project's growth, and we're excited to collaborate with you!
4 changes: 2 additions & 2 deletions LICENSE.txt → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Michał Bukowski gigibukson@gmail.com
Copyright (c) 2023 Michał Bukowski gigibukson@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ 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.
SOFTWARE.
195 changes: 53 additions & 142 deletions README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions steampy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
steampy is a library for Python, inspired by node-steam-tradeoffers, node-steam and other libraries for Node.js.
It was designed as a simple lightweight library, combining features of many steam libraries from Node.js into a
single python module. steampy is capable of logging into steam, fetching trade offers and handling them in simple
manner, using steam user credentials and SteamGuard file, or by passing sessionID and webCookie cookies. 'steampy'
is also capable of using proxies.
steampy is developed with Python 3 using type hints and many other features its
supported for Windows, Linux and MacOs.
"""
3 changes: 3 additions & 0 deletions steampy/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides interactions with Steam
"""
import re
import bs4
import json
3 changes: 3 additions & 0 deletions steampy/confirmation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides Confirmation handler to deal with Steam request (mostly trade and sell)
"""
import enum
import json
import time
3 changes: 3 additions & 0 deletions steampy/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides exceptions handled in Steam
"""
class SevenDaysHoldException(Exception):
pass

3 changes: 3 additions & 0 deletions steampy/guard.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides Steam Guard functions
"""
import os
import hmac
import json
3 changes: 3 additions & 0 deletions steampy/login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides Login in Steam functions
"""
from http import HTTPStatus
from base64 import b64encode

3 changes: 3 additions & 0 deletions steampy/market.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides Steam Market functions
"""
import json
import urllib.parse
from decimal import Decimal
53 changes: 53 additions & 0 deletions steampy/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides models to interact with Steam API
"""
from enum import IntEnum
from collections import namedtuple

@@ -33,53 +36,103 @@ def to_dict(self) -> dict:


class Currency(IntEnum):
"""
All currencies that are supported by Steam you can found them at https://partner.steamgames.com/doc/store/pricing/currencies
"""
USD = 1
"""United States Dollar"""
GBP = 2
"""United Kingdom Pound"""
EURO = 3
"""European Union Euro"""
CHF = 4
"""Swiss Francs"""
RUB = 5
"""Russian Rouble"""
PLN = 6
"""Polish Złoty"""
BRL = 7
"""Brazilian Reals"""
JPY = 8
"""Japanese Yen"""
NOK = 9
"""Norwegian Krone"""
IDR = 10
"""Indonesian Rupiah"""
MYR = 11
"""Malaysian Ringgit"""
PHP = 12
"""Philippine Peso"""
SGD = 13
"""Singapore Dollar"""
THB = 14
"""Thai Baht"""
VND = 15
"""Vietnamese Dong"""
KRW = 16
"""South Korean Won"""
TRY = 17
""" Turkish Lira"""
UAH = 18
"""Ukrainian Hryvnia"""
MXN = 19
"""Mexican Peso"""
CAD = 20
"""Canadian Dollars"""
AUD = 21
"""Australian Dollars"""
NZD = 22
"""New Zealand Dollar"""
CNY = 23
"""Chinese Renminbi (yuan)"""
INR = 24
"""Indian Rupee"""
CLP = 25
"""Chilean Peso"""
PEN = 26
"""Peruvian Sol"""
COP = 27
"""Colombian Peso"""
ZAR = 28
"""South African Rand"""
HKD = 29
"""Hong Kong Dollar"""
TWD = 30
"""New Taiwan Dollar"""
SAR = 31
"""Saudi Riyal"""
AED = 32
"""United Arab Emirates Dirham"""
SEK = 33
"""Swedish Krona"""
ARS = 34
"""Argentine Peso"""
ILS = 35
"""Israeli New Shekel"""
BYN = 36
"""Belarusian Ruble"""
KZT = 37
"""Kazakhstani Tenge"""
KWD = 38
"""Kuwaiti Dinar"""
QAR = 39
"""Qatari Riyal"""
CRC = 40
"""Costa Rican Colón"""
UYU = 41
"""Uruguayan Peso"""
BGN = 42
"""Bulgarian Lev"""
HRK = 43
"""Croatian Kuna"""
CZK = 44
"""Czech Koruna"""
DKK = 45
"""Danish Krone"""
HUF = 46
"""Hungarian Forint"""
RON = 47
"""Romanian Leu"""


class TradeOfferState(IntEnum):
55 changes: 30 additions & 25 deletions steampy/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Provides utility functions
"""
import os
import re
import copy
@@ -24,7 +27,6 @@ def func_wrapper(self, *args, **kwargs):

return func_wrapper


def text_between(text: str, begin: str, end: str) -> str:
start = text.index(begin) + len(begin)
end = text.index(end, start)
@@ -42,6 +44,7 @@ def texts_between(text: str, begin: str, end: str):
return



def account_id_to_steam_id(account_id: str) -> str:
first_bytes = int(account_id).to_bytes(4, byteorder='big')
last_bytes = 0x1100001.to_bytes(4, byteorder='big')
@@ -53,18 +56,20 @@ def steam_id_to_account_id(steam_id: str) -> str:


def calculate_gross_price(price_net: Decimal, publisher_fee: Decimal, steam_fee: Decimal = Decimal('0.05')) -> Decimal:
"""Calculate the price including the publisher's fee and the Steam fee.
Arguments:
price_net (Decimal): The amount that the seller receives after a market transaction.
publisher_fee (Decimal): The Publisher Fee is a game specific fee that is determined and collected by the game
publisher. Most publishers have a `10%` fee - `Decimal('0.10')` with a minimum fee of `$0.01`.
steam_fee (Decimal): The Steam Transaction Fee is collected by Steam and is used to protect against nominal
fraud incidents and cover the cost of development of this and future Steam economy features. The fee is
currently `5%` (with a minimum fee of `$0.01`). This fee may be increased or decreased by Steam in the
future.
Returns:
Decimal: Gross price (including fees) - the amount that the buyer pays during a market transaction
"""
Calculate the price including the publisher's fee and the Steam fee.
@param price_net (Decimal): The amount that the seller receives after a market transaction.
@param publisher_fee (Decimal): The Publisher Fee is a game specific fee that is determined and collected by the game
publisher. Most publishers have a 10% fee - Decimal('0.10') with a minimum fee of $0.01.
@param steam_fee (Decimal): The Steam Transaction Fee is collected by Steam and is used to protect against nominal
fraud incidents and cover the cost of development of this and future Steam economy features. The fee is
currently 5% (with a minimum fee of $0.01). This fee may be increased or decreased by Steam in the
future.
@return: Decimal: Gross price (including fees) - the amount that the buyer pays during a market transaction.
"""
price_net *= 100
steam_fee_amount = int(math.floor(max(price_net * steam_fee, 1)))
@@ -74,18 +79,18 @@ def calculate_gross_price(price_net: Decimal, publisher_fee: Decimal, steam_fee:


def calculate_net_price(price_gross: Decimal, publisher_fee: Decimal, steam_fee: Decimal = Decimal('0.05')) -> Decimal:
"""Calculate the price without the publisher's fee and the Steam fee.
Arguments:
price_gross (Decimal): The amount that the buyer pays during a market transaction.
publisher_fee (Decimal): The Publisher Fee is a game specific fee that is determined and collected by the game
publisher. Most publishers have a `10%` fee - `Decimal('0.10')` with a minimum fee of `$0.01`.
steam_fee (Decimal): The Steam Transaction Fee is collected by Steam and is used to protect against nominal
fraud incidents and cover the cost of development of this and future Steam economy features. The fee is
currently `5%` (with a minimum fee of `$0.01`). This fee may be increased or decreased by Steam in the
future.
Returns:
Decimal: Net price (without fees) - the amount that the seller receives after a market transaction.
"""
Calculate the price without the publisher's fee and the Steam fee.
@param price_gross (Decimal): The amount that the buyer pays during a market transaction.
@param publisher_fee (Decimal): The Publisher Fee is a game specific fee that is determined and collected by the game
publisher. Most publishers have a 10% fee - Decimal('0.10') with a minimum fee of $0.01.
@param steam_fee (Decimal): The Steam Transaction Fee is collected by Steam and is used to protect against nominal
fraud incidents and cover the cost of development of this and future Steam economy features. The fee is
currently 5% (with a minimum fee of $0.01). This fee may be increased or decreased by Steam in the
future.
@return: Decimal: Net price (without fees) - the amount that the seller receives after a market transaction.
"""
price_gross *= 100
estimated_net_price = Decimal(int(price_gross / (steam_fee + publisher_fee + 1)))

0 comments on commit c8bd55f

Please sign in to comment.