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

rjfarmer / gfModParser / 18542693371

15 Oct 2025 09:07PM UTC coverage: 88.199% (-0.6%) from 88.811%
18542693371

push

github

rjfarmer
Fix string test

1009 of 1144 relevant lines covered (88.2%)

0.88 hits per line

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

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

3
from .. import utils
1✔
4

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

93

94
class Attributes:
1✔
95

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

© 2026 Coveralls, Inc