MCPcopy Create free account
hub / github.com/FastLED/FastLED / get_field_and_option

Function get_field_and_option

ci/github_project_sync.py:154–199  ·  view source on GitHub ↗

Find a single-select field and a specific option by name.

(
    project_id: str, field_name: str, option_name: str
)

Source from the content-addressed store, hash-verified

152
153
154def get_field_and_option(
155 project_id: str, field_name: str, option_name: str
156) -> FieldOption:
157 """Find a single-select field and a specific option by name."""
158 query = """
159 query($projectId: ID!) {
160 node(id: $projectId) {
161 ... on ProjectV2 {
162 fields(first: 50) {
163 nodes {
164 ... on ProjectV2SingleSelectField {
165 id
166 name
167 options {
168 id
169 name
170 }
171 }
172 }
173 }
174 }
175 }
176 }
177 """
178 data = graphql(query, {"projectId": project_id})
179 fields: list[dict[str, Any]] = data["data"]["node"]["fields"]["nodes"]
180
181 for field in fields:
182 if field.get("name") == field_name:
183 for option in field.get("options", []):
184 if option["name"] == option_name:
185 return FieldOption(field_id=field["id"], option_id=option["id"])
186 available: list[str] = []
187 for opt in field.get("options", []):
188 available.append(opt["name"])
189 raise SystemExit(
190 f"Option '{option_name}' not found in field '{field_name}'. "
191 f"Available: {available}"
192 )
193
194 available_fields: list[str] = []
195 for f in fields:
196 name = f.get("name")
197 if name:
198 available_fields.append(name)
199 raise SystemExit(f"Field '{field_name}' not found. Available: {available_fields}")
200
201
202def get_date_field(project_id: str, field_name: str) -> str:

Callers 1

mainFunction · 0.85

Calls 4

FieldOptionClass · 0.85
graphqlFunction · 0.70
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected