• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rjfarmer / gfModParser / 18387296101

09 Oct 2025 07:45PM UTC coverage: 88.772% (+0.08%) from 88.694%
18387296101

push

github

rjfarmer
More typing

18 of 22 new or added lines in 4 files covered. (81.82%)

1012 of 1140 relevant lines covered (88.77%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.33
/gfModParser/modules/attributes.py
1
# SPDX-License-Identifier: GPL-2.0+
2

3
from typing import Set
1✔
4

5
from .. import utils
1✔
6

7
_all = set(
1✔
8
    [
9
        "ALLOCATABLE",
10
        "ARTIFICIAL",
11
        "ASYNCHRONOUS",
12
        "DIMENSION",
13
        "CODIMENSION",
14
        "CONTIGUOUS",
15
        "EXTERNAL",
16
        "INTRINSIC",
17
        "OPTIONAL",
18
        "POINTER",
19
        "VOLATILE",
20
        "TARGET",
21
        "THREADPRIVATE",
22
        "DUMMY",
23
        "RESULT",
24
        "DATA",
25
        "IN_NAMELIST",
26
        "IN_COMMON",
27
        "FUNCTION",
28
        "SUBROUTINE",
29
        "SEQUENCE",
30
        "ELEMENTAL",
31
        "PURE",
32
        "RECURSIVE",
33
        "GENERIC",
34
        "ALWAYS_EXPLICIT",
35
        "CRAY_POINTER",
36
        "CRAY_POINTEE",
37
        "IS_BIND_C",
38
        "IS_C_INTEROP",
39
        "IS_ISO_C",
40
        "VALUE",
41
        "ALLOC_COMP",
42
        "COARRAY_COMP",
43
        "LOCK_COMP",
44
        "EVENT_COMP",
45
        "POINTER_COMP",
46
        "PROC_POINTER_COMP",
47
        "PRIVATE_COMP",
48
        "ZERO_COMP",
49
        "PROTECTED",
50
        "ABSTRACT",
51
        "IS_CLASS",
52
        "PROCEDURE",
53
        "PROC_POINTER",
54
        "VTYPE",
55
        "VTAB",
56
        "CLASS_POINTER",
57
        "IMPLICIT_PURE",
58
        "UNLIMITED_POLY",
59
        "OMP_DECLARE_TARGET",
60
        "ARRAY_OUTER_DEPENDENCY",
61
        "MODULE_PROCEDURE",
62
        "OACC_DECLARE_CREATE",
63
        "OACC_DECLARE_COPYIN",
64
        "OACC_DECLARE_DEVICEPTR",
65
        "OACC_DECLARE_DEVICE_RESIDENT",
66
        "OACC_DECLARE_LINK",
67
        "OMP_DECLARE_TARGET_LINK",
68
        "PDT_KIND",
69
        "PDT_LEN",
70
        "PDT_TYPE",
71
        "PDT_TEMPLATE",
72
        "PDT_ARRAY",
73
        "PDT_STRING",
74
        "OACC_ROUTINE_LOP_GANG",
75
        "OACC_ROUTINE_LOP_WORKER",
76
        "OACC_ROUTINE_LOP_VECTOR",
77
        "OACC_ROUTINE_LOP_SEQ",
78
        "OACC_ROUTINE_NOHOST",
79
        "OMP_REQ_REVERSE_OFFLOAD",
80
        "OMP_REQ_UNIFIED_ADDRESS",
81
        "OMP_REQ_UNIFIED_SHARED_MEMORY",
82
        "OMP_REQ_SELF_MAPS",
83
        "OMP_REQ_DYNAMIC_ALLOCATORS",
84
        "OMP_REQ_MEM_ORDER_SEQ_CST",
85
        "OMP_REQ_MEM_ORDER_ACQ_REL",
86
        "OMP_REQ_MEM_ORDER_ACQUIRE",
87
        "OMP_REQ_MEM_ORDER_RELAXED",
88
        "OMP_REQ_MEM_ORDER_RELEASE",
89
        "OMP_DEVICE_TYPE_HOST",
90
        "OMP_DEVICE_TYPE_NOHOST",
91
        "OMP_DEVICE_TYPE_ANYHOST",
92
    ]
93
)
94

95

96
class Attributes:
1✔
97

98
    def __init__(self, attributes, *, version):
1✔
99
        self._attributes = attributes
1✔
100
        self._attr = None
1✔
101
        self.version = version
1✔
102

103
    @property
1✔
104
    def flavor(self) -> str:
1✔
105
        return utils.string_clean(self._attributes[0])
1✔
106

107
    @property
1✔
108
    def intent(self) -> str:
1✔
109
        return utils.string_clean(self._attributes[1])
1✔
110

111
    @property
1✔
112
    def procedure(self) -> str:
1✔
113
        return utils.string_clean(self._attributes[2])
1✔
114

115
    @property
1✔
116
    def if_source(self) -> str:
1✔
117
        return utils.string_clean(self._attributes[3])
1✔
118

119
    @property
1✔
120
    def save(self) -> str:
1✔
121
        return utils.string_clean(self._attributes[4])
1✔
122

123
    @property
1✔
124
    def external_attribute(self) -> bool:
1✔
125
        return int(self._attributes[5]) == 1
1✔
126

127
    @property
1✔
128
    def extension(self) -> bool:
1✔
129
        return int(self._attributes[6]) == 1
1✔
130

131
    @property
1✔
132
    def attributes(self) -> Set[str]:
1✔
133
        if self._attr is None:
1✔
134
            self._attr = set([utils.string_clean(i) for i in self._attributes[7:]])
1✔
135
        return self._attr
1✔
136

137
    @property
1✔
138
    def is_parameter(self) -> bool:
1✔
139
        return self.flavor == "PARAMETER"
1✔
140

141
    @property
1✔
142
    def is_variable(self) -> bool:
1✔
143
        return self.flavor == "VARIABLE"
1✔
144

145
    @property
1✔
146
    def is_procedure(self) -> bool:
1✔
147
        return self.flavor == "PROCEDURE"
1✔
148

149
    @property
1✔
150
    def is_derived(self) -> bool:
1✔
151
        return self.flavor == "DERIVED"
1✔
152

153
    @property
1✔
154
    def is_module(self) -> bool:
1✔
155
        return self.flavor == "MODULE"
1✔
156

157
    @property
1✔
158
    def is_namelist(self) -> bool:
1✔
159
        return self.flavor == "NAMELIST"
1✔
160

161
    def __dir__(self):
1✔
162
        # Get things defined by the getattr plus the properties (needs to dir() the class though)
163
        return [i.lower() for i in _all] + dir(self.__class__)
1✔
164

165
    def __getattr__(self, key):
1✔
166
        if key.upper() in _all:
1✔
167
            return key.upper() in self.attributes
1✔
168
        else:
169
            raise AttributeError(f"Key not found {key}")
1✔
170

171
    def __contains__(self, key):
1✔
NEW
172
        return key in self._attr
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc