FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
allure-python/allure-python-commons/src/mapping.py at master · Quron/allure-python · GitHub
Quron
/
allure-python
Public
forked from
allure-framework/allure-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
allure-python
/
allure-python-commons
/
src
/
mapping.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
105 lines (76 loc) · 3.45 KB
Breadcrumbs
allure-python
/
allure-python-commons
/
src
/
mapping.py
Copy path
File metadata and controls
105 lines (76 loc) · 3.45 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
from
itertools
import
chain
,
islice
import
attr
from
allure_commons
.
types
import
Severity
,
LabelType
,
LinkType
from
allure_commons
.
types
import
ALLURE_UNIQUE_LABELS
from
allure_commons
.
model2
import
Label
,
Link
TAG_PREFIX
=
"allure"
def
__is
(
kind
,
t
):
return
kind
in
[
v
for
k
,
v
in
t
.
__dict__
.
items
()
if
not
k
.
startswith
(
'__'
)]
def
parse_tag
(
tag
,
issue_pattern
=
None
,
link_pattern
=
None
):
"""
>>> parse_tag("blocker")
Label(name='severity', value='blocker')
>>> parse_tag("allure.issue:http://example.com/BUG-42")
Link(type='issue', url='http://example.com/BUG-42', name='http://example.com/BUG-42')
>>> parse_tag("allure.link.home:http://qameta.io")
Link(type='link', url='http://qameta.io', name='home')
>>> parse_tag("allure.suite:mapping")
Label(name='suite', value='mapping')
>>> parse_tag("allure.suite:mapping")
Label(name='suite', value='mapping')
>>> parse_tag("allure.label.owner:me")
Label(name='owner', value='me')
>>> parse_tag("foo.label:1")
Label(name='tag', value='foo.label:1')
>>> parse_tag("allure.foo:1")
Label(name='tag', value='allure.foo:1')
"""
schema
,
value
=
islice
(
chain
(
tag
.
split
(
':'
,
1
), [
None
]),
2
)
prefix
,
kind
,
name
=
islice
(
chain
(
schema
.
split
(
'.'
), [
None
], [
None
]),
3
)
if
tag
in
[
severity
for
severity
in
Severity
]:
return
Label
(
name
=
LabelType
.
SEVERITY
,
value
=
tag
)
if
prefix
==
TAG_PREFIX
and
value
is
not
None
:
if
__is
(
kind
,
LinkType
):
if
issue_pattern
and
kind
==
"issue"
and
not
value
.
startswith
(
"http"
):
value
=
issue_pattern
.
format
(
value
)
if
link_pattern
and
kind
==
"link"
and
not
value
.
startswith
(
"http"
):
value
=
issue_pattern
.
format
(
value
)
return
Link
(
type
=
kind
,
name
=
name
or
value
,
url
=
value
)
if
__is
(
kind
,
LabelType
):
return
Label
(
name
=
kind
,
value
=
value
)
if
kind
==
"label"
and
name
is
not
None
:
return
Label
(
name
=
name
,
value
=
value
)
return
Label
(
name
=
LabelType
.
TAG
,
value
=
tag
)
def
labels_set
(
labels
):
"""
>>> labels_set([Label(name=LabelType.SEVERITY, value=Severity.NORMAL),
... Label(name=LabelType.SEVERITY, value=Severity.BLOCKER)
... ])
[Label(name='severity', value=<Severity.BLOCKER: 'blocker'>)]
>>> labels_set([Label(name=LabelType.SEVERITY, value=Severity.NORMAL),
... Label(name='severity', value='minor')
... ])
[Label(name='severity', value='minor')]
>>> labels_set([Label(name=LabelType.EPIC, value="Epic"),
... Label(name=LabelType.EPIC, value="Epic")
... ])
[Label(name='epic', value='Epic')]
>>> labels_set([Label(name=LabelType.EPIC, value="Epic1"),
... Label(name=LabelType.EPIC, value="Epic2")
... ])
[Label(name='epic', value='Epic1'), Label(name='epic', value='Epic2')]
"""
class
Wl
(
object
):
def
__init__
(
self
,
label
):
self
.
label
=
label
def
__repr__
(
self
):
return
"{name}{value}"
.
format
(
**
attr
.
asdict
(
self
.
label
))
def
__eq__
(
self
,
other
):
if
self
.
label
.
name
in
ALLURE_UNIQUE_LABELS
:
return
self
.
label
.
name
==
other
.
label
.
name
return
repr
(
self
)
==
repr
(
other
)
def
__hash__
(
self
):
if
self
.
label
.
name
in
ALLURE_UNIQUE_LABELS
:
return
hash
(
self
.
label
.
name
)
return
hash
(
repr
(
self
))
return
sorted
([
wl
.
label
for
wl
in
set
([
Wl
(
label
)
for
label
in
reversed
(
labels
)])])
Back
|
FazBrowse Home
|
New Git URL