sardana-org / sardana

Moved to GitLab: https://gitlab.com/sardana-org/sardana
39 stars 52 forks source link

Warn when macros gets overriden #930

Open reszelaz opened 6 years ago

reszelaz commented 6 years ago

Reported by @guifrecuni

Two macro libraries may define the same macro. This should be avoided because although with edmac there is no problem, it could be the case of a confusion and edit the one that is not being used.

One thing that just happened to me would be that the macroserver, finding a redefinition could explicitly report it in a log and even with an lsmac mark those that are 'overwriting' a behavior.

cmft commented 6 years ago

Hi @guifrecuni and comunnity,

I agree with the proposal but I have a cosmetic doubts about how lsmac macro should show the overwritten macros:

I propose some options:

Door_cfalcon_1 [1]: lsmac umv mv
   Name   isOverwritten                                                                             Location
 ------ --------------- ------------------------------------------------------------------------------------
     mv            True                                            /home/cfalcon/tools/mis_macros/myascan.py
    umv                   /home/cfalcon/tools/sardana-sardana.git/src/sardana/macroserver/macros/standard.py

or

Door_cfalcon_1 [1]: lsmac umv mv

Note: if [*] is present together with the macro name means that a macro with the same name 
is defined in other module with less precedence and it has been overwritten. 
     Name                                                                             Location
 -------- ------------------------------------------------------------------------------------
   mv [*]                                            /home/cfalcon/tools/mis_macros/myascan.py
      umv   /home/cfalcon/tools/sardana-sardana.git/src/sardana/macroserver/macros/standard.py

or

     Name                                                                             Location
 -------- ------------------------------------------------------------------------------------
   [*] mv                                            /home/cfalcon/tools/mis_macros/myascan.py
      umv   /home/cfalcon/tools/sardana-sardana.git/src/sardana/macroserver/macros/standard.py

Comments and ideas are welcome.

guifrecuni commented 6 years ago

I prefer the [*] idea over a specific column. I'd show the NOTE at the end of the list (last line, warning color) and only if there is at least one macro with such a situation

rhomspuron commented 6 years ago

In addition, we can create another macro like lsoverridden (with a shorter name) to show only the overridden macros, because if there are many macros (like in claess ~1000) the lsmac is not useful.

reszelaz commented 3 years ago

@rhomspuron would be adding a new parameter to the lsmac e.g. only_overridden work for you?