Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netvs-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
scc-net
netvs
netvs-middleware
Commits
c4e2cac1
Commit
c4e2cac1
authored
5 months ago
by
!! Julian Keck (old Account; do not use) !!
Browse files
Options
Downloads
Patches
Plain Diff
UPD use abstract types for Inserts in patch-requests
parent
dce0e301
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/patch_request.py
+19
-97
19 additions, 97 deletions
api/patch_request.py
with
19 additions
and
97 deletions
api/patch_request.py
+
19
−
97
View file @
c4e2cac1
...
...
@@ -39,103 +39,25 @@ async def get_available_sites(token: APIToken = Depends(check_auth), conn=Depend
@router.get
(
'
/insert_types
'
)
async
def
get_insert_types
(
token
:
APIToken
=
Depends
(
check_auth
),
conn
=
Depends
(
get_conn
))
->
list
[
InsertType
]:
Mgr
.
check_token
(
conn
,
token
)
ta
=
[
{
'
name
'
:
'
ndcfg.module_type.list
'
,
'
idx
'
:
'
tmp_module_type_list
'
,
'
old
'
:
{
'
filter_params_dict
'
:
{
'
attrs_list
'
:
None
,
'
show
'
:
True
}
}
},
{
'
name
'
:
'
cntl.ot_attr_val.list
'
,
'
idx
'
:
'
ot_attr_val_list
'
,
'
inner_join_ref
'
:
{
'
tmp_module_type_list
'
:
None
},
'
old
'
:
{
'
ot_attr_def_key_word
'
:
'
prq_insert_is_exchangeable
'
,
'
value
'
:
True
,
'
value_operator
'
:
'
eq
'
,
'
filter_params_dict
'
:
{
'
attrs_list
'
:
None
,
'
show
'
:
True
}
}
},
{
'
name
'
:
'
ndcfg.module_type.list
'
,
'
idx
'
:
'
module_type_list
'
,
'
inner_join_ref
'
:
{
'
tmp_module_type_list
'
:
'
self
'
,
'
ot_attr_val_list
'
:
None
},
'
old
'
:
{
'
sorting_params_list
'
:
[
'
name ASC
'
],
}
},
{
'
name
'
:
'
ndcfg.p_port2module_type.list
'
,
'
idx
'
:
'
pp2mt_list
'
,
'
inner_join_ref
'
:
{
'
module_type_list
'
:
'
default
'
},
}
]
result
=
execute_wapi_function
(
conn
,
ta
,
dry_mode
=
True
,
superuser
=
True
)
module_types
:
dict
[
str
,
InsertType
]
=
{}
for
api_type
in
result
[
'
module_type_list
'
]:
module_types
[
api_type
[
'
name
'
]]
=
InsertType
(
name
=
api_type
[
'
name
'
])
for
api_port
in
result
[
'
pp2mt_list
'
]:
if
api_port
[
'
port_type
'
].
lower
().
startswith
(
'
festkabel
'
):
continue
tmp_ports
=
[
api_port
]
cmp_ports
:
list
[
dict
]
=
[]
for
tmp_port
in
tmp_ports
:
if
not
tmp_port
[
'
port_name_suffix
'
].
startswith
(
'
{
'
):
cmp_ports
.
append
(
tmp_port
)
continue
suffix_list
=
list
(
tmp_port
[
'
port_name_suffix
'
].
replace
(
'
{
'
,
''
).
replace
(
'
}
'
,
''
))
tmp_port
[
'
port_count
'
]
-=
(
len
(
suffix_list
)
-
1
)
if
len
(
suffix_list
)
>
0
else
0
for
i
in
suffix_list
if
len
(
suffix_list
)
>
0
else
[
''
]:
cmp_ports
.
append
({
**
tmp_port
,
'
port_name_suffix
'
:
'
::
'
+
i
})
tmp_ports
=
cmp_ports
cmp_ports
:
list
[
dict
]
=
[]
for
tmp_port
in
tmp_ports
:
if
not
tmp_port
[
'
port_name_prefix
'
].
startswith
(
'
{
'
):
cmp_ports
.
append
(
tmp_port
)
continue
prefix_list
=
list
(
tmp_port
[
'
port_name_prefix
'
].
replace
(
'
{
'
,
''
).
replace
(
'
}
'
,
''
))
tmp_port
[
'
port_count
'
]
-=
(
len
(
prefix_list
)
-
1
)
if
len
(
prefix_list
)
>
0
else
0
for
i
in
prefix_list
if
len
(
prefix_list
)
>
0
else
[
''
]:
cmp_ports
.
append
({
**
tmp_port
,
'
port_name_prefix
'
:
i
+
'
::
'
})
tmp_ports
=
cmp_ports
for
p
in
tmp_ports
:
module_types
[
p
[
'
module_type
'
]].
ports
.
append
(
InsertPort
(
type
=
p
[
'
port_type
'
],
type_group
=
p
[
'
port_type_group
'
],
count
=
p
[
'
port_count
'
],
proto
=
p
[
'
port_proto
'
],
name_prefix
=
p
[
'
port_name_prefix
'
],
name_suffix
=
p
[
'
port_name_suffix
'
]
)
)
module_types
:
dict
[
str
,
InsertType
]
=
{
'
1xETH (Gbit)
'
:
InsertType
(
name
=
'
1xETH (Gbit)
'
,
ports
=
[
InsertPort
(
type
=
'
ETH
'
,
type_group
=
'
ETH
'
,
count
=
1
,
proto
=
'
Ethernet
'
,
name_prefix
=
''
,
name_suffix
=
'
::1
'
),
]),
'
2xETH (100 Mbit)
'
:
InsertType
(
name
=
'
2xETH (100 Mbit)
'
,
ports
=
[
InsertPort
(
type
=
'
ETH
'
,
type_group
=
'
ETH
'
,
count
=
1
,
proto
=
'
Ethernet
'
,
name_prefix
=
''
,
name_suffix
=
'
/1
'
),
InsertPort
(
type
=
'
ETH
'
,
type_group
=
'
ETH
'
,
count
=
1
,
proto
=
'
Ethernet
'
,
name_prefix
=
''
,
name_suffix
=
'
/2
'
),
]),
'
1xETH (100 Mbit) + 1xTEL
'
:
InsertType
(
name
=
'
1xETH (100 Mbit) + 1xTEL
'
,
ports
=
[
InsertPort
(
type
=
'
ETH
'
,
type_group
=
'
ETH
'
,
count
=
1
,
proto
=
'
Ethernet
'
,
name_prefix
=
''
,
name_suffix
=
'
/1
'
),
InsertPort
(
type
=
'
TEL
'
,
type_group
=
'
TEL
'
,
count
=
1
,
proto
=
'
ISDN
'
,
name_prefix
=
''
,
name_suffix
=
'
/A
'
),
]),
'
1xETH (100 Mbit) + 2xTEL
'
:
InsertType
(
name
=
'
1xETH (100 Mbit) + 2xTEL
'
,
ports
=
[
InsertPort
(
type
=
'
ETH
'
,
type_group
=
'
ETH
'
,
count
=
1
,
proto
=
'
Ethernet
'
,
name_prefix
=
''
,
name_suffix
=
'
/1
'
),
InsertPort
(
type
=
'
TEL
'
,
type_group
=
'
TEL
'
,
count
=
1
,
proto
=
'
ISDN
'
,
name_prefix
=
''
,
name_suffix
=
'
/A
'
),
InsertPort
(
type
=
'
TEL
'
,
type_group
=
'
TEL
'
,
count
=
1
,
proto
=
'
ISDN
'
,
name_prefix
=
''
,
name_suffix
=
'
/B
'
),
])
}
return
list
(
module_types
.
values
())
...
...
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