Browse Source

remove imports from 'steam' namespace

Since there are many modules, importing anything inside the steam namespace introduces an extra
cost. Cleaning up the space will allow dependent stuff to import just the modules it needs without
anything extra. This will also improve start up times for cli programs.
pull/202/head
Rossen Georgiev 6 years ago
parent
commit
4117911041
  1. 1
      CHANGES.md
  2. 6
      docs/user_guide.rst
  3. 2
      recipes/1.Login/diy_one_off_login.py
  4. 2
      recipes/1.Login/one_off_login.py
  5. 2
      recipes/1.Login/persistent_login.py
  6. 2
      recipes/2.SimpleWebAPI/steam_worker.py
  7. 23
      steam/__init__.py
  8. 2
      steam/client/__init__.py
  9. 2
      steam/client/gc.py
  10. 3
      steam/webauth.py

1
CHANGES.md

@ -4,6 +4,7 @@
This release brings some breaking changes This release brings some breaking changes
- Removed imports from 'steam' namespace
- Replaced builtin CM server list with automatic discovery via WebAPI or DNS - Replaced builtin CM server list with automatic discovery via WebAPI or DNS
- Removed `steam.client.mixins` package - Removed `steam.client.mixins` package
- Renamed `medium` param to `backend` on `SteamAuthenticator` - Renamed `medium` param to `backend` on `SteamAuthenticator`

6
docs/user_guide.rst

@ -21,7 +21,7 @@ Converting between representations
.. code:: python .. code:: python
>>> from steam import SteamID >>> from steam.steamid import SteamID
>>> SteamID() >>> SteamID()
SteamID(id=0, type='Invalid', universe='Invalid', instance=0) SteamID(id=0, type='Invalid', universe='Invalid', instance=0)
@ -92,7 +92,7 @@ Calling an endpoint
.. code:: python .. code:: python
>>> from steam import WebAPI >>> from steam.steamid import WebAPI
>>> api = WebAPI(key="<your api key>") >>> api = WebAPI(key="<your api key>")
# instance.<interface>.<method> # instance.<interface>.<method>
@ -161,7 +161,7 @@ After that we logout.
.. code:: python .. code:: python
from steam import SteamClient from steam.steamid import SteamClient
from steam.enums.emsg import EMsg from steam.enums.emsg import EMsg
client = SteamClient() client = SteamClient()

2
recipes/1.Login/diy_one_off_login.py

@ -1,6 +1,6 @@
from __future__ import print_function from __future__ import print_function
from getpass import getpass from getpass import getpass
from steam import SteamClient from steam.client import SteamClient
print("One-off login recipe") print("One-off login recipe")

2
recipes/1.Login/one_off_login.py

@ -1,5 +1,5 @@
from __future__ import print_function from __future__ import print_function
from steam import SteamClient from steam.client import SteamClient
from steam.enums import EResult from steam.enums import EResult
client = SteamClient() client = SteamClient()

2
recipes/1.Login/persistent_login.py

@ -1,5 +1,5 @@
import logging import logging
from steam import SteamClient from steam.client import SteamClient
from steam.enums import EResult from steam.enums import EResult
# setup logging # setup logging

2
recipes/2.SimpleWebAPI/steam_worker.py

@ -1,7 +1,7 @@
import logging import logging
import gevent import gevent
from binascii import hexlify from binascii import hexlify
from steam import SteamClient from steam.client import SteamClient
from steam.core.msg import MsgProto from steam.core.msg import MsgProto
from steam.enums.emsg import EMsg from steam.enums.emsg import EMsg
from steam.util import proto_to_dict from steam.util import proto_to_dict

23
steam/__init__.py

@ -2,26 +2,3 @@ __version__ = "0.9.0"
__author__ = "Rossen Georgiev" __author__ = "Rossen Georgiev"
version_info = tuple(map(int, __version__.split('.'))) version_info = tuple(map(int, __version__.split('.')))
from steam.steamid import SteamID
from steam.globalid import GlobalID
from steam.webapi import WebAPI
from steam.webauth import WebAuth, MobileWebAuth
# proxy object
# avoids importing steam.enums.emsg unless it's needed
# avoids gevent monkey patching
class SteamClient(object):
def __new__(cls, *args, **kwargs):
from steam.client import SteamClient as SC
bases = cls.__bases__
if bases != (object, ):
if bases[0] != SteamClient:
raise ValueError("SteamClient needs to be the first base for custom classes")
SC = type("SteamClient", (SC,) + bases[1:], {})
return SC(*args, **kwargs)

2
steam/client/__init__.py

@ -27,7 +27,7 @@ from steam.enums.emsg import EMsg
from steam.enums import EResult, EOSType, EPersonaState from steam.enums import EResult, EOSType, EPersonaState
from steam.core.msg import MsgProto from steam.core.msg import MsgProto
from steam.core.cm import CMClient from steam.core.cm import CMClient
from steam import SteamID from steam.steamid import SteamID
from steam.client.builtins import BuiltinBase from steam.client.builtins import BuiltinBase
from steam.util import ip_from_int, ip_to_int, proto_fill_from_dict from steam.util import ip_from_int, ip_to_int, proto_fill_from_dict

2
steam/client/gc.py

@ -8,7 +8,7 @@ Example implementation of Dota 2 GC client with inheritance.
.. code:: python .. code:: python
import myDotaModule import myDotaModule
from steam import SteamClient from steam.client import SteamClient
from steam.core.msg import GCMsgHdrProto from steam.core.msg import GCMsgHdrProto
from steam.client.gc import GameCoordinator from steam.client.gc import GameCoordinator

3
steam/webauth.py

@ -61,7 +61,8 @@ from getpass import getpass
import six import six
import requests import requests
from steam import SteamID, webapi from steam import webapi
from steam.steamid import SteamID
from steam.util.web import make_requests_session, generate_session_id from steam.util.web import make_requests_session, generate_session_id
from steam.core.crypto import rsa_publickey, pkcs1v15_encrypt from steam.core.crypto import rsa_publickey, pkcs1v15_encrypt

Loading…
Cancel
Save