Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
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
clients
python
DuniterPy
Commits
6bbbc620
Commit
6bbbc620
authored
3 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#146
,
#170
: Define endpoints regex with f-string
Import constants as const
parent
f8b9b80f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
duniterpy/api/endpoint.py
+9
-30
9 additions, 30 deletions
duniterpy/api/endpoint.py
with
9 additions
and
30 deletions
duniterpy/api/endpoint.py
+
9
−
30
View file @
6bbbc620
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
import
re
import
re
from
typing
import
Any
,
Dict
,
Optional
,
Type
,
TypeVar
from
typing
import
Any
,
Dict
,
Optional
,
Type
,
TypeVar
from
duniterpy
import
constants
from
duniterpy
import
constants
as
const
from
..documents
import
MalformedDocumentError
from
..documents
import
MalformedDocumentError
...
@@ -143,11 +143,7 @@ BMAEndpointType = TypeVar("BMAEndpointType", bound="BMAEndpoint")
...
@@ -143,11 +143,7 @@ BMAEndpointType = TypeVar("BMAEndpointType", bound="BMAEndpoint")
class
BMAEndpoint
(
Endpoint
):
class
BMAEndpoint
(
Endpoint
):
API
=
"
BASIC_MERKLED_API
"
API
=
"
BASIC_MERKLED_API
"
re_inline
=
re
.
compile
(
re_inline
=
re
.
compile
(
"
^BASIC_MERKLED_API(?: ({host_regex}))?(?: ({ipv4_regex}))?(?: ({ipv6_regex}))?(?: ([0-9]+))$
"
.
format
(
f
"
^
{
API
}
(?: (
{
const
.
HOST_REGEX
}
))?(?: (
{
const
.
IPV4_REGEX
}
))?(?: (
{
const
.
IPV6_REGEX
}
))?(?: ([0-9]+))$
"
host_regex
=
constants
.
HOST_REGEX
,
ipv4_regex
=
constants
.
IPV4_REGEX
,
ipv6_regex
=
constants
.
IPV6_REGEX
,
)
)
)
def
__init__
(
self
,
server
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
)
->
None
:
def
__init__
(
self
,
server
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
)
->
None
:
...
@@ -240,12 +236,7 @@ SecuredBMAEndpointType = TypeVar("SecuredBMAEndpointType", bound="SecuredBMAEndp
...
@@ -240,12 +236,7 @@ SecuredBMAEndpointType = TypeVar("SecuredBMAEndpointType", bound="SecuredBMAEndp
class
SecuredBMAEndpoint
(
BMAEndpoint
):
class
SecuredBMAEndpoint
(
BMAEndpoint
):
API
=
"
BMAS
"
API
=
"
BMAS
"
re_inline
=
re
.
compile
(
re_inline
=
re
.
compile
(
"
^BMAS(?: ({host_regex}))?(?: ({ipv4_regex}))?(?: ({ipv6_regex}))? ([0-9]+)(?: ({path_regex}))?$
"
.
format
(
f
"
^
{
API
}
(?: (
{
const
.
HOST_REGEX
}
))?(?: (
{
const
.
IPV4_REGEX
}
))?(?: (
{
const
.
IPV6_REGEX
}
))? ([0-9]+)(?: (
{
const
.
PATH_REGEX
}
))?$
"
host_regex
=
constants
.
HOST_REGEX
,
ipv4_regex
=
constants
.
IPV4_REGEX
,
ipv6_regex
=
constants
.
IPV6_REGEX
,
path_regex
=
constants
.
PATH_REGEX
,
)
)
)
def
__init__
(
self
,
server
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
,
path
:
str
)
->
None
:
def
__init__
(
self
,
server
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
,
path
:
str
)
->
None
:
...
@@ -326,13 +317,7 @@ WS2PEndpointType = TypeVar("WS2PEndpointType", bound="WS2PEndpoint")
...
@@ -326,13 +317,7 @@ WS2PEndpointType = TypeVar("WS2PEndpointType", bound="WS2PEndpoint")
class
WS2PEndpoint
(
Endpoint
):
class
WS2PEndpoint
(
Endpoint
):
API
=
"
WS2P
"
API
=
"
WS2P
"
re_inline
=
re
.
compile
(
re_inline
=
re
.
compile
(
"
^WS2P ({ws2pid_regex}) ((?:{host_regex})|(?:{ipv4_regex})|(?:{ipv6_regex})) ([0-9]+)?(?: ({path_regex}))?$
"
.
format
(
f
"
^
{
API
}
(
{
const
.
WS2PID_REGEX
}
) ((?:
{
const
.
HOST_REGEX
}
)|(?:
{
const
.
IPV4_REGEX
}
)|(?:
{
const
.
IPV6_REGEX
}
)) ([0-9]+)?(?: (
{
const
.
PATH_REGEX
}
))?$
"
ws2pid_regex
=
constants
.
WS2PID_REGEX
,
host_regex
=
constants
.
HOST_REGEX
,
ipv4_regex
=
constants
.
IPV4_REGEX
,
ipv6_regex
=
constants
.
IPV6_REGEX
,
path_regex
=
constants
.
PATH_REGEX
,
)
)
)
def
__init__
(
self
,
ws2pid
:
str
,
server
:
str
,
port
:
int
,
path
:
str
)
->
None
:
def
__init__
(
self
,
ws2pid
:
str
,
server
:
str
,
port
:
int
,
path
:
str
)
->
None
:
...
@@ -413,9 +398,7 @@ ESCoreEndpointType = TypeVar("ESCoreEndpointType", bound="ESCoreEndpoint")
...
@@ -413,9 +398,7 @@ ESCoreEndpointType = TypeVar("ESCoreEndpointType", bound="ESCoreEndpoint")
class
ESCoreEndpoint
(
Endpoint
):
class
ESCoreEndpoint
(
Endpoint
):
API
=
"
ES_CORE_API
"
API
=
"
ES_CORE_API
"
re_inline
=
re
.
compile
(
re_inline
=
re
.
compile
(
"
^ES_CORE_API ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)$
"
.
format
(
f
"
^
{
API
}
((?:
{
const
.
HOST_REGEX
}
)|(?:
{
const
.
IPV4_REGEX
}
)) ([0-9]+)$
"
host_regex
=
constants
.
HOST_REGEX
,
ipv4_regex
=
constants
.
IPV4_REGEX
)
)
)
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
...
@@ -474,9 +457,7 @@ ESUserEndpointType = TypeVar("ESUserEndpointType", bound="ESUserEndpoint")
...
@@ -474,9 +457,7 @@ ESUserEndpointType = TypeVar("ESUserEndpointType", bound="ESUserEndpoint")
class
ESUserEndpoint
(
Endpoint
):
class
ESUserEndpoint
(
Endpoint
):
API
=
"
ES_USER_API
"
API
=
"
ES_USER_API
"
re_inline
=
re
.
compile
(
re_inline
=
re
.
compile
(
"
^ES_USER_API ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)$
"
.
format
(
"
^{API} ((?:{const.HOST_REGEX})|(?:{const.IPV4_REGEX})) ([0-9]+)$
"
host_regex
=
constants
.
HOST_REGEX
,
ipv4_regex
=
constants
.
IPV4_REGEX
)
)
)
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
...
@@ -537,9 +518,7 @@ ESSubscribtionEndpointType = TypeVar(
...
@@ -537,9 +518,7 @@ ESSubscribtionEndpointType = TypeVar(
class
ESSubscribtionEndpoint
(
Endpoint
):
class
ESSubscribtionEndpoint
(
Endpoint
):
API
=
"
ES_SUBSCRIPTION_API
"
API
=
"
ES_SUBSCRIPTION_API
"
re_inline
=
re
.
compile
(
re_inline
=
re
.
compile
(
"
^ES_SUBSCRIPTION_API ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)$
"
.
format
(
f
"
^
{
API
}
((?:
{
const
.
HOST_REGEX
}
)|(?:
{
const
.
IPV4_REGEX
}
)) ([0-9]+)$
"
host_regex
=
constants
.
HOST_REGEX
,
ipv4_regex
=
constants
.
IPV4_REGEX
)
)
)
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
...
@@ -599,7 +578,7 @@ GVAEndpointType = TypeVar("GVAEndpointType", bound="GVAEndpoint")
...
@@ -599,7 +578,7 @@ GVAEndpointType = TypeVar("GVAEndpointType", bound="GVAEndpoint")
class
GVAEndpoint
(
Endpoint
):
class
GVAEndpoint
(
Endpoint
):
API
=
"
GVA
"
API
=
"
GVA
"
endpoint_format
=
f
"
^GVA(?: (
{
const
ants
.
ENDPOINT_FLAGS_REGEX
}
))?(?: (
{
const
ants
.
HOST_REGEX
}
))?(?: (
{
const
ants
.
IPV4_REGEX
}
))?(?: (
{
const
ants
.
IPV6_REGEX
}
))? ([0-9]+)(?: (
{
const
ants
.
PATH_REGEX
}
))?$
"
endpoint_format
=
f
"
^GVA(?: (
{
const
.
ENDPOINT_FLAGS_REGEX
}
))?(?: (
{
const
.
HOST_REGEX
}
))?(?: (
{
const
.
IPV4_REGEX
}
))?(?: (
{
const
.
IPV6_REGEX
}
))? ([0-9]+)(?: (
{
const
.
PATH_REGEX
}
))?$
"
re_inline
=
re
.
compile
(
endpoint_format
)
re_inline
=
re
.
compile
(
endpoint_format
)
def
__init__
(
def
__init__
(
...
@@ -728,7 +707,7 @@ GVASUBEndpointType = TypeVar("GVASUBEndpointType", bound="GVASUBEndpoint")
...
@@ -728,7 +707,7 @@ GVASUBEndpointType = TypeVar("GVASUBEndpointType", bound="GVASUBEndpoint")
class
GVASUBEndpoint
(
GVAEndpoint
):
class
GVASUBEndpoint
(
GVAEndpoint
):
API
=
"
GVASUB
"
API
=
"
GVASUB
"
endpoint_format
=
f
"
^GVASUB(?: (
{
const
ants
.
ENDPOINT_FLAGS_REGEX
}
))?(?: (
{
const
ants
.
HOST_REGEX
}
))?(?: (
{
const
ants
.
IPV4_REGEX
}
))?(?: (
{
const
ants
.
IPV6_REGEX
}
))? ([0-9]+)(?: (
{
const
ants
.
PATH_REGEX
}
))?$
"
endpoint_format
=
f
"
^GVASUB(?: (
{
const
.
ENDPOINT_FLAGS_REGEX
}
))?(?: (
{
const
.
HOST_REGEX
}
))?(?: (
{
const
.
IPV4_REGEX
}
))?(?: (
{
const
.
IPV6_REGEX
}
))? ([0-9]+)(?: (
{
const
.
PATH_REGEX
}
))?$
"
re_inline
=
re
.
compile
(
endpoint_format
)
re_inline
=
re
.
compile
(
endpoint_format
)
...
...
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