blackmamba.system¶
System info and decorators.
Warning
This module must not introduce dependency on any other Black Mamba modules and must be importable on any other platform as well.
-
blackmamba.system.
PYTHONISTA
= False¶ bool – True if we’re running within Pythonista or False.
-
blackmamba.system.
PYTHONISTA_VERSION
= None¶ str – Pythonista version or
None
if we’re not within Pythonista.
-
blackmamba.system.
PYTHONISTA_BUNDLE_VERSION
= None¶ int – Pythonista bundle version or
None
if we’re not within Pythonista.
-
blackmamba.system.
PYTHONISTA_VERSION_TUPLE
= None¶ tuple(int) – Pythonista version tuple (3, 1, 1) or
None
if we’re not within Pythonista.
-
blackmamba.system.
IOS_VERSION_TUPLE
= None¶ tuple(int) – iOS version tuple (11, 0) or
None
if we’re not within iOS.
-
class
blackmamba.system.
iOS
(from_version=None, to_version=None)[source]¶ Decorator to execute function under specific iOS versions.
Return value is return value of decorated function or
None
if iOS condition isn’t met.Examples
Run function only within any iOS version:
@iOS() def run_me(): pass
Run function only within iOS >= 11.0:
@iOS('11.0') # or @iOS(from_version='11.0') def run_me(): pass
Run function only within iOS <= 11.0:
@iOS(None, '11.0') # or @iOS(to_version='11.0') def run_me(): pass
-
class
blackmamba.system.
Pythonista
(from_version=None, to_version=None, appex=None)[source]¶ Decorator to execute function under specific Pythonista versions.
By default, function is not executed under application extension. You have to pass
appex=True
if you’d like to run some function under appex as well.Return value is return value of decorated function or
None
if Pythonista condition isn’t met.Examples
Run function only within any Pythonista version:
@Pythonista() def run_me(): pass
Run function only within any Pythonista version and allow appex:
@Pythonista(appex=True) def run_me(): pass
Run function only within any Pythonista version and disallow appex:
@Pythonista(appex=False) def run_me(): pass
Run function only within Pythonista >= 3.1.1:
@Pythonista('3.1.1') # or @Pythonista(from_version='3.1.1') def run_me(): pass
Run function only within Pythonista <= 3.2:
@Pythonista(None, '3.2') # or @Pythonista(to_version='3.2') def run_me(): pass
-
blackmamba.system.
catch_exceptions
(func)[source]¶ Decorator catching all exceptions and printing info to the console.
Use this decorator for functions handling keyboard shortcuts, keyboard events, ... to avoid Pythonista crash.
Parameters: func – Function to decorate Returns: Return value of decorated function.