Skip to content

Ticket3396 show global macros#450

Open
Chsudeepta wants to merge 21 commits intomasterfrom
Ticket3396_ShowGlobalMacros
Open

Ticket3396 show global macros#450
Chsudeepta wants to merge 21 commits intomasterfrom
Ticket3396_ShowGlobalMacros

Conversation

@Chsudeepta
Copy link
Contributor

Description of work

This is the blockserver change to add the globals.txt settings to the config.

To test

This address the issue described here

Acceptance criteria

The globals.txt settings should get added to the current config and passed on to the GUI.


Code Review

  • Is the code of an acceptable quality?
  • Has the author taken into account the multi-threaded nature of the code?
  • Have the changes been recorded appropriately in a PR for release notes?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed.

Final steps

  • Reviewer has updated the submodule in the main EPICS repo? See Reviewing work for the subModules of EPICS in the Git workflow page for details.
  • Reviewer has merged the associated PR for the release notes

@Chsudeepta Chsudeepta force-pushed the Ticket3396_ShowGlobalMacros branch from e0332e2 to 06ce22e Compare November 20, 2025 16:55

"""Contains all the code for defining a configuration or component"""

# ruff: noqa: I001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must: sort imports and remove noqa

def __init__(
self,
name: str,
macros: Dict[str, str],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
macros: Dict[str, str],
macros: dict[str, str],

self.macros = macros

@staticmethod
def _dict_to_list(in_dict: Dict[str, Any]) -> List[Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
def _dict_to_list(in_dict: Dict[str, Any]) -> List[Any]:
def _dict_to_list(in_dict: dict[str, Any]) -> list[Any]:

"""
self.name = name

if macros is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should: macros not type-hinted as being able to be set to None.

Comment on lines +80 to +84
def get(self, name: str) -> None:
return self.__getattribute__(name)

def __getitem__(self, name: str) -> None:
return self.__getattribute__(name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must: what are these doing?

return self.__getattribute__(name)


class GlobalmacroHelper:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: does it need to be a class with one method at all - can it just be a free function?

# along with this program; if not, you can obtain a copy from
# https://www.eclipse.org/org/documents/epl-v10.php or
# http://opensource.org/licenses/eclipse-1.0.php
# ruff: noqa: I001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort the imports.

"""

@staticmethod
def row_to_globalmacro(globalmacros: Dict, row: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should: This function mutates its input argument which is more confusing than necessary.

I feel this function could return tuple[str, str] | None instead, and then the caller adds it to a collection if necessary.

configuration.components = components
configuration.meta = meta
for key, value in globalmacros.items():
configuration.add_globalmacro(key, value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should: this method is already very long and has many responsibilities.

I would like to move as much of the globals.txt parsing logic out of this method as possible - conceptually I would like just one line to remain in this function:

configuration.globalmacros = parse_globals()

This will also make the parse_globals function much easier to unit-test.

if ioc_separator in ioc_macro:
ioc, macro = ioc_macro.split(ioc_separator, maxsplit=1)
else:
ioc = all_iocs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should: We seem to have a "special" key of __ here meaning "all"? If so that's quite confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants