Skip to main content

A Python manager for the modules __all__ variable.

Project description

AllStar

"allstar" is a simple library for managing the the __all__ attribute in modules.

The __all__ attribute is used to specify what is imported when using the from module import * syntax. This type of import is commonly used by project mapping tools like documentation generators. It is important to manage __all__ because, for example, you may not want to generate documentation for imported classes, only for the ones you have created.

The library is named "allstar" because the __all__ attribute is imported using the star (*) symbol.

Installation

pip install allstar

Usage

Basic usage

from allstar import Star

# manager instance
# __name__ is used to reference the module and its attributes
star = Star(__name__)

# star.sign adds a callable to the __all__ iterable
@star.sign
class TheClass:
    pass

@star.sign
def the_function():
    pass

print(__all__)  # prints: ['TheClass', 'the_function']

Extended usage

import os, sys, builtins

from allstar import Star

__all__ = ['os']  # Star preserves the previous names

star = Star(__name__)

star.include('builtins')  # include names using strings or references

star.include_all(['os', 'sys'])  # include names using iterables

Some extra features

from allstar import Star

star = Star(__name__)

star.empty()  # empties the __all__ iterable

star.freeze()  # turns the __all__ iterable into a tuple

Author

Alejandro CR

contacto@alejandrocr.co

https://github.com/virtualitems/

Project

https://pypi.org/project/allstar/

https://github.com/virtualitems/allstar

License

MIT License

Copyright (c) 2022 Virtual Items

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

allstar-1.1.6.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

allstar-1.1.6-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file allstar-1.1.6.tar.gz.

File metadata

  • Download URL: allstar-1.1.6.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for allstar-1.1.6.tar.gz
Algorithm Hash digest
SHA256 d93ee46862d0a34e546b40728178d5be9d0391a917b4be25431572db6ee653f8
MD5 1b402c0409fc61b67139d454678622bd
BLAKE2b-256 38eb8cece865c58105aeb2235907b4b1035368f9dc3d14b22218198cedac6cf2

See more details on using hashes here.

File details

Details for the file allstar-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: allstar-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for allstar-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 be020b7b68b2e46f8dba75778db1b248d9e060d90b966b6c6163e7407f4e4b58
MD5 4960a5248ed36ed2878f3873874b3609
BLAKE2b-256 29ec01262c373e542b45b728af66f912b936eae8088e66b725ab661a3110d257

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page