9
9
if TYPE_CHECKING :
10
10
from galaxy .tool_util .lint import LintContext
11
11
from galaxy .tool_util .parser .interface import ToolSource
12
+ from galaxy .util import ElementTree
12
13
13
14
14
15
class DoiEmptyNone (Linter ):
15
16
@classmethod
16
17
def lint (cls , tool_source : "ToolSource" , lint_ctx : "LintContext" ):
17
18
tool_xml = getattr (tool_source , "xml_tree" , None )
19
+ if not tool_xml :
20
+ return
18
21
for citation , * _ in _doi_citations (tool_xml ):
19
22
if citation .text is None :
20
23
lint_ctx .error ("Empty DOI citation" , linter = cls .name (), node = citation )
@@ -24,6 +27,8 @@ class DoiEmpty(Linter):
24
27
@classmethod
25
28
def lint (cls , tool_source : "ToolSource" , lint_ctx : "LintContext" ):
26
29
tool_xml = getattr (tool_source , "xml_tree" , None )
30
+ if not tool_xml :
31
+ return
27
32
for citation , publication_id , doiless_publication_id in _doi_citations (tool_xml ):
28
33
if citation .text is None :
29
34
continue
@@ -35,6 +40,8 @@ class DoiValid(Linter):
35
40
@classmethod
36
41
def lint (cls , tool_source : "ToolSource" , lint_ctx : "LintContext" ):
37
42
tool_xml = getattr (tool_source , "xml_tree" , None )
43
+ if not tool_xml :
44
+ return
38
45
for citation , publication_id , doiless_publication_id in _doi_citations (tool_xml ):
39
46
if citation .text is None or not doiless_publication_id :
40
47
continue
@@ -48,6 +55,8 @@ class DoiValidWithDoi(Linter):
48
55
@classmethod
49
56
def lint (cls , tool_source : "ToolSource" , lint_ctx : "LintContext" ):
50
57
tool_xml = getattr (tool_source , "xml_tree" , None )
58
+ if not tool_xml :
59
+ return
51
60
for citation , publication_id , doiless_publication_id in _doi_citations (tool_xml ):
52
61
if citation .text is None or not doiless_publication_id :
53
62
continue
@@ -65,6 +74,8 @@ class DoiInvalid(Linter):
65
74
@classmethod
66
75
def lint (cls , tool_source : "ToolSource" , lint_ctx : "LintContext" ):
67
76
tool_xml = getattr (tool_source , "xml_tree" , None )
77
+ if not tool_xml :
78
+ return
68
79
for citation , publication_id , doiless_publication_id in _doi_citations (tool_xml ):
69
80
if citation .text is None or not doiless_publication_id :
70
81
continue
@@ -78,6 +89,8 @@ class DoiUnexpectedResponse(Linter):
78
89
@classmethod
79
90
def lint (cls , tool_source : "ToolSource" , lint_ctx : "LintContext" ):
80
91
tool_xml = getattr (tool_source , "xml_tree" , None )
92
+ if not tool_xml :
93
+ return
81
94
for citation , publication_id , doiless_publication_id in _doi_citations (tool_xml ):
82
95
if citation .text is None or not doiless_publication_id :
83
96
continue
@@ -89,7 +102,7 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
89
102
)
90
103
91
104
92
- def _doi_citations (tool_xml ):
105
+ def _doi_citations (tool_xml : "ElementTree" ):
93
106
for element in tool_xml .getroot ().findall ("citations" ):
94
107
for citation in list (element ):
95
108
if citation .tag == "citation" and citation .attrib .get ("type" , "" ) == "doi" :
0 commit comments