Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
tmuxp/src/tmuxp/workspace/builder/protocol.py at master · tmux-python/tmuxp · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
tmux-python
tmuxp
Repository navigation
Code
Issues
115
(115)
Pull requests
30
(30)
Only collaborators can create PRs
Discussions
Actions
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
tmuxp
/
src
/
tmuxp
/
workspace
/
builder
/
protocol.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
108 lines (88 loc) · 3.96 KB
master
Breadcrumbs
tmuxp
/
src
/
tmuxp
/
workspace
/
builder
/
protocol.py
Copy path
Top
File metadata and controls
Code
Blame
108 lines (88 loc) · 3.96 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""Public contract for tmuxp workspace builders.
A workspace builder turns an expanded workspace ``dict`` into a live tmux
session. :class:`tmuxp.workspace.builder.classic.ClassicWorkspaceBuilder` is the
default implementation; third parties may ship their own and select them with
the ``workspace_builder`` config key (see
:mod:`tmuxp.workspace.builder.registry`).
This module is intentionally dependency-light (typing only) so builder authors
can import the contract without pulling in tmuxp's resolution machinery.
The contract is synchronous today. Async builders are an *additive* future
extension: a subclass protocol can declare an ``async`` build entry point and a
capability flag, discovered through the same entry-point group, without
changing this sync surface.
"""
from
__future__
import
annotations
import
typing
as
t
if
t
.
TYPE_CHECKING
:
from
libtmux
.
server
import
Server
from
libtmux
.
session
import
Session
@
t
.
runtime_checkable
class
WorkspaceBuilderProtocol
(
t
.
Protocol
):
"""Contract a builder must satisfy to be driven by ``tmuxp load``.
A conforming builder is constructed with at least ``session_config`` and
``server`` (plus the optional ``plugins`` and ``on_*`` callbacks the classic
builder accepts). It exposes :meth:`build`, surfaces the populated tmux
session via :attr:`session`, and honors the plugin/progress integration
points the CLI drives.
Because the protocol carries data members (``session``, ``plugins``, the
``on_*`` callbacks), validate *instances* with :func:`isinstance`;
class-level ``issubclass`` checks are not supported for runtime-checkable
protocols with non-method members.
Examples
--------
A builder implementing the full contract satisfies the protocol:
>>> from tmuxp.workspace.builder.protocol import WorkspaceBuilderProtocol
>>> class MiniBuilder:
... plugins: list = []
... on_progress = None
... on_before_script = None
... on_script_output = None
... on_build_event = None
... def __init__(self, session_config, server, **kwargs):
... self._session_config = session_config
... def build(self, session=None, append=False):
... ...
... def session_exists(self, session_name):
... ...
... def find_current_attached_session(self):
... ...
... @property
... def session(self):
... ...
>>> builder = MiniBuilder(session_config={}, server=None)
>>> isinstance(builder, WorkspaceBuilderProtocol)
True
An object missing the contract does not:
>>> isinstance(object(), WorkspaceBuilderProtocol)
False
"""
plugins
:
list
[
t
.
Any
]
on_progress
:
t
.
Callable
[[
str
],
None
]
|
None
on_before_script
:
t
.
Callable
[[],
None
]
|
None
on_script_output
:
t
.
Callable
[[
str
],
None
]
|
None
on_build_event
:
t
.
Callable
[[
dict
[
str
,
t
.
Any
]],
None
]
|
None
def
__init__
(
self
,
session_config
:
dict
[
str
,
t
.
Any
],
server
:
Server
,
plugins
:
list
[
t
.
Any
]
|
None
=
None
,
on_progress
:
t
.
Callable
[[
str
],
None
]
|
None
=
None
,
on_before_script
:
t
.
Callable
[[],
None
]
|
None
=
None
,
on_script_output
:
t
.
Callable
[[
str
],
None
]
|
None
=
None
,
on_build_event
:
t
.
Callable
[[
dict
[
str
,
t
.
Any
]],
None
]
|
None
=
None
,
)
->
None
:
"""Construct a builder from an expanded workspace and a tmux server."""
...
@
property
def
session
(
self
)
->
Session
:
"""Return the tmux session the builder created or populated."""
...
def
build
(
self
,
session
:
Session
|
None
=
None
,
append
:
bool
=
False
)
->
None
:
"""Build the workspace, creating or populating a tmux session."""
...
def
session_exists
(
self
,
session_name
:
str
)
->
bool
:
"""Return ``True`` if a session with ``session_name`` already exists."""
...
def
find_current_attached_session
(
self
)
->
Session
:
"""Return the session currently attached within ``$TMUX``."""
...
You can’t perform that action at this time.