Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HELpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
HELpy
Commits
ba4c8f72
Commit
ba4c8f72
authored
1 month ago
by
Krzysztof Mochocki
Browse files
Options
Downloads
Patches
Plain Diff
Move url to communication and add sub-package interface
parent
9c97dcca
No related branches found
No related tags found
1 merge request
!80
Draft: Remove notifications
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beekeepy/beekeepy/_communication/__init__.py
+28
-0
28 additions, 0 deletions
beekeepy/beekeepy/_communication/__init__.py
beekeepy/beekeepy/_communication/url.py
+11
-0
11 additions, 0 deletions
beekeepy/beekeepy/_communication/url.py
with
39 additions
and
0 deletions
beekeepy/beekeepy/_communication/__init__.py
+
28
−
0
View file @
ba4c8f72
from
__future__
import
annotations
from
beekeepy._communication
import
rules
from
beekeepy._communication.abc.communicator
import
AbstractCommunicator
from
beekeepy._communication.abc.overseer
import
AbstractOverseer
from
beekeepy._communication.aiohttp_communicator
import
AioHttpCommunicator
from
beekeepy._communication.httpx_communicator
import
HttpxCommunicator
from
beekeepy._communication.overseers
import
CommonOverseer
,
StrictOverseer
from
beekeepy._communication.request_communicator
import
RequestCommunicator
from
beekeepy._communication.settings
import
CommunicationSettings
from
beekeepy._communication.url
import
AnyUrl
,
HttpUrl
,
P2PUrl
,
Url
,
WsUrl
__all__
=
[
"
CommunicationSettings
"
,
"
CommonOverseer
"
,
"
StrictOverseer
"
,
"
AioHttpCommunicator
"
,
"
HttpxCommunicator
"
,
"
RequestCommunicator
"
,
"
AnyUrl
"
,
"
HttpUrl
"
,
"
P2PUrl
"
,
"
Url
"
,
"
WsUrl
"
,
"
AbstractCommunicator
"
,
"
AbstractOverseer
"
,
"
rules
"
,
]
This diff is collapsed.
Click to expand it.
beekeepy/beekeepy/_
interface
/url.py
→
beekeepy/beekeepy/_
communication
/url.py
+
11
−
0
View file @
ba4c8f72
...
...
@@ -3,6 +3,8 @@ from __future__ import annotations
from
typing
import
Generic
,
Literal
,
TypeVar
,
get_args
from
urllib.parse
import
urlparse
from
typing_extensions
import
Self
P2PProtocolT
=
Literal
[
""
]
HttpProtocolT
=
Literal
[
"
http
"
,
"
https
"
]
WsProtocolT
=
Literal
[
"
ws
"
,
"
wss
"
]
...
...
@@ -18,6 +20,7 @@ class Url(Generic[ProtocolT]):
if
protocol
is
not
None
and
protocol
not
in
allowed_proto
:
raise
ValueError
(
f
"
Unknown protocol: `
{
protocol
}
`, allowed:
{
allowed_proto
}
"
)
target_protocol
:
str
=
protocol
or
self
.
_default_protocol
()
if
isinstance
(
url
,
Url
):
self
.
__protocol
:
str
=
url
.
__protocol
self
.
__address
:
str
=
url
.
__address
...
...
@@ -78,6 +81,14 @@ class Url(Generic[ProtocolT]):
"""
return
[
""
]
@classmethod
def
factory
(
cls
,
*
,
port
:
int
=
0
,
address
:
str
=
"
127.0.0.1
"
)
->
Self
:
return
cls
((
f
"
{
cls
.
_default_protocol
()
}
://
"
if
cls
.
_default_protocol
()
else
""
)
+
f
"
{
address
}
:
{
port
}
"
)
@classmethod
def
_default_protocol
(
cls
)
->
str
:
return
cls
.
_allowed_protocols
()[
0
]
class
HttpUrl
(
Url
[
HttpProtocolT
]):
@classmethod
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment