blocks/__init__
Full documentation pages are generated for docstring
reference only and may contain symbols imported from other
modules. Imported symbols are not distinguished from locally
defined symbols and will appear in any module that they are
imported into. For better information on where symbols should
be imported from, review the sourcecode on the
github.
FoSpy.blocks
module
module-attribute
module = importlib.import_module(f'{__name__}.{name}')
names
module-attribute
names = [
name
for _, name, ispkg in (
pkgutil.iter_modules(package.__path__)
)
if not ispkg
]
package
module-attribute
package = sys.modules[__name__]
Debug
Source code in FoSpy/_debug.py
| class Debug:
def __init__(self):
self.on = False
frame = inspect.currentframe().f_back
self.module_name = frame.f_globals.get("__name__", "<unknown>")
self.label = f"|(Debug message from {self.module_name})"
self.label_width = len(self.label)
def _get_text_width(self, module=None):
if module:
label = f"|(Debug message from {module} via {self.module_name})"
label_width = len(label)
else:
label = self.label
label_width = self.label_width
text_width = DEBUG_WIDTH - label_width
return text_width, label, label_width
def msg(self,msg, module=None):
if not self.on:
return
text_width, label, label_width = self._get_text_width(module)
wrapped = textwrap.fill(str(msg), width=text_width)
for line in wrapped.splitlines():
print(f'{line:<{text_width}}{label:>{label_width}}')
def pmsg(self,msg,module=None,**kwargs):
if not self.on:
return
text_width, label, label_width = self._get_text_width(module)
buf = io.StringIO()
pprint(msg,stream=buf, width=text_width,**kwargs)
txt = buf.getvalue()
for line in txt.splitlines():
print(f'{line:<{text_width}}{label:>{label_width}}')
|
label
instance-attribute
label = f'|(Debug message from {self.module_name})'
label_width
instance-attribute
label_width = len(self.label)
module_name
instance-attribute
module_name = frame.f_globals.get('__name__', '<unknown>')
__init__
Source code in FoSpy/_debug.py
| def __init__(self):
self.on = False
frame = inspect.currentframe().f_back
self.module_name = frame.f_globals.get("__name__", "<unknown>")
self.label = f"|(Debug message from {self.module_name})"
self.label_width = len(self.label)
|
_get_text_width
_get_text_width(module=None)
Source code in FoSpy/_debug.py
| def _get_text_width(self, module=None):
if module:
label = f"|(Debug message from {module} via {self.module_name})"
label_width = len(label)
else:
label = self.label
label_width = self.label_width
text_width = DEBUG_WIDTH - label_width
return text_width, label, label_width
|
msg
Source code in FoSpy/_debug.py
| def msg(self,msg, module=None):
if not self.on:
return
text_width, label, label_width = self._get_text_width(module)
wrapped = textwrap.fill(str(msg), width=text_width)
for line in wrapped.splitlines():
print(f'{line:<{text_width}}{label:>{label_width}}')
|
pmsg
pmsg(msg, module=None, **kwargs)
Source code in FoSpy/_debug.py
| def pmsg(self,msg,module=None,**kwargs):
if not self.on:
return
text_width, label, label_width = self._get_text_width(module)
buf = io.StringIO()
pprint(msg,stream=buf, width=text_width,**kwargs)
txt = buf.getvalue()
for line in txt.splitlines():
print(f'{line:<{text_width}}{label:>{label_width}}')
|
_get_block_classes
_get_block_classes(module)
Source code in FoSpy/blocks/_blockUtils.py
| def _get_block_classes(module):
from .blocks import Block
import inspect
__block_classes__ = []
for name, obj in inspect.getmembers(module, inspect.isclass):
if obj.__module__ != module.__name__:
continue
if issubclass(obj, Block):
__block_classes__.append(name)
return __block_classes__
|