Debian Codegraph @

src/briefcase/channels/__init__.py

raw
1 from __future__ import annotations
2
3 from importlib.metadata import entry_points
4
5 from briefcase.channels.base import (
6 BasePublicationChannel,
7 PublishCommandAPI, # noqa: F401
8 )
9 from briefcase.exceptions import BriefcaseCommandError
10
11
12 def get_publication_channels(
13 platform: str,
14 output_format: str,
15 ) -> dict[str, type[BasePublicationChannel]]:
16 """Load built-in and third-party publication channels for a platform/format.
17
18 :param platform: The target platform (e.g., "iOS")
19 :param output_format: The output format (e.g., "Xcode")
20 :returns: A dict mapping channel names to channel classes.
21 """
22 return {
23 ep.name: ep.load()
24 for ep in entry_points(group=f"briefcase.channels.{platform}.{output_format}")
25 }
26
27
28 def get_publication_channel(
29 name: str,
30 platform: str,
31 output_format: str,
32 ) -> BasePublicationChannel:
33 """Get a publication channel by name for a platform/format.
34
35 :param name: The channel name
36 :param platform: The target platform
37 :param output_format: The output format
38 :returns: An instantiated publication channel.
39 """
40 channels = get_publication_channels(platform, output_format)
41 if name not in channels:
42 available = ", ".join(sorted(channels)) or "none"
43 raise BriefcaseCommandError(
44 f"Unknown publication channel: {name}\n\n"
45 f"Available channels for {platform}/{output_format}: {available}"
46 )
47 return channels[name]()