Unify INI values#3704
Conversation
Feel free remake (or close) #3488 how you need. Git is not my friend, so I cant help you. #3488 also does:
|
26ef94e to
75b7af8
Compare
619faee to
0932268
Compare
|
update_ini is designed to be scriptable, (-d and -f flags) and I think I had a meta-script that ran it on all the sample configs. |
ef0fb47 to
9cc5bac
Compare
Yes that would be helpful. I only used tested with the -d option so far. |
Sorry, I looked and it's nowhere obvious. It might be sat in a git stash somewhere, but I think it's probably been lost. I doubt it was anything special, I am not much of a scripting wizard. |
|
I copied now
The values are/will not be not used in TRAJ any more. Do you think we should delete them from TRAJ or keep them as a precaution ? |
|
Ate you sure they ate not used in the trajectory planner? |
1d4850e to
c7afc84
Compare
|
|
Ahh yes DEFAULT is what I was recalling. |
|
I think the script is ready for the first review. @andypugh How do we handle the message boxes if upgrading from <1.0 to 1.2?
|
bfb59a9 to
e4c8171
Compare
|
Hi Hans, when do you expect to finish this PR? I'm currently converting the spindle control from PWM to hm2_modbus. So I could test if there are any bugs when changing SPINDLE => SPINDLE_0. |
|
It's more or less ready from my side. This is waiting for a review and then all the INI files needs to be converted by the update_ini script and committed. |
|
I asked the wrong question. I'm just asking. I don't want to do it twice. |
|
I think it will take some weeks |
|
Ok, thanks for information. |
|
I think that the very long message box is fine. We really want users to be aware that a lot has changed, and to think before pressing the buttons. |
|
How does the update script handle The include handling is expanded by the But still, the update script should be aware of |
|
The update_ini program also needs to update quoted strings (see #3946 and #3947). The new ini-parser in python allows you to recall the exact file and line of any variable by using |
There is no MIN_LINEAR_VELOCITY in the TRAJ section.
… (TRAJ --> DISPLAY)
| # We want to work with the base INI file here, not the expanded version if #include is used | ||
| filename = re.sub(r'\.expanded', '', filename) | ||
|
|
There was a problem hiding this comment.
The "expanded" version is no longer generated. If you find an expanded inifile, then it can be removed. The Tcl code has been fixed to use the new inifile parser.
| included_files.append(filename) | ||
| pattern = re.compile(r"^#INCLUDE[ \t]+(\S+)") | ||
| with open(filename, "r", encoding="utf-8") as f: |
There was a problem hiding this comment.
The include match is not entirely correct, although it should normally not matter I guess. The parser uses ^#INCLUDE[ \t]\s*(.*)\s*, which captures anything after the statement and strips leading/trailing whitespace.
However, what may be wrong is that opening the included file uses a specific path methodology with the following cases:
- path/file, if $current_include_filename has a '/' in it:
- --> $(dirname "$current_include_filename")/path/file
- else --> use open(path/file)
- ~/path/file --> $HOME/path/file
- /path/file --> absolute
You need to devise your own running view through the tree of files while tracking through the sections and variables. Includes can happen anywhere, cannot recurse (beware of loops), but may be included multiple times. You must process each file in sequence as the parser would read the files and convert in sequence. You also need tracking already converted files to not double convert and assure that a converted file will be valid when read again in another place (perfectly legal situation).
There was a problem hiding this comment.
You also need tracking already converted files to not double convert and assure that a converted file will be valid when read again in another place (perfectly legal situation).
Double conversion should be no problem - if a file is already converted then there is simply nothing to convert.
There was a problem hiding this comment.
There was a problem hiding this comment.
Yes, it can include spaces. That is how the original also worked. The behaviour was taken from that work.
|
|
||
| for current_file in included_files: | ||
| print(f'===> Updating "{current_file}"...') | ||
| if version == "$Revision$" or version < "1.0": |
There was a problem hiding this comment.
I don't think it would be a good idea to handle included files separately because there is no guarantee there is anything in them you can understand without the context of where you are in the ini-file sequence.
As mentioned above you must read through and convert the files in order to be able to track where you are.
There was a problem hiding this comment.
If you don't want to merge all the includes together, you have to handle them separately.
There was a problem hiding this comment.
Well, yes, you need to handle them one-by-one. However, you must do so as-if you are handling one file and treat everything as one stream while tracking the actual origin.
Example: include variables from a file:
[Tag]
#INCLUDE otherfile.inc
[OtherTag]
#INCLUDE otherfile.incand otherfile.inc contains:
# Note: a nested include is perfectly fine
#INCLUDE common.inc
ValidInTag=blabla
# Changing the following tag will become invalid after change but is necessary for [Tag]
BecomesInvalidInOtherTag=nonoAlthough the error scenario may be rare, the way these includes are made is not. The above include sequence is f.ex. seen in axes and joints that share most parameters. If a converted include file is re-read and would require changes, then you have to flag an error in auto-conversion and say it has to be done manually.
It would also be perfectly legal for an include file to end with a new section header. Returning one level up would then add variables to the section the include file ended with. This would be really borderline sane, but there is nothing that prevents it and the parser happily accepts it. Such scenario will automatically work when you treat the whole ini-file as a text-stream.
The "easy" way out for all the possible problems is to drop auto-conversion of INI-files that contain includes. However, that would make it harder for users. But when you do convert them, then you must support the whole structure and deal with the complexity of how the parser sees and reads the INI-file data when read.
There was a problem hiding this comment.
Yeah that's a bit tricky. But I don't think it's worth the work to handle this case.
But feel free to join this game...
|
It is good that you run the update/test after the ini-file is tested for validity: Lines 417 to 422 in c1f4b6c It guarantees you already know that the file conforms to the formal standard. The content is then of only concern. |
|
Alright then... have a look at this: process_ini.py It takes an ini file and processes it as one stream white tracking includes and converting recursively. Two functions are provided to handle conversion ( The only limitation is that it assumes that you do not re-read an include file that has sections in it. This case would already produce a warning in the new ini-parser (same section name gets its variables merged), so it is probably safe to assume this will not happen. |
|
But how should that fit in the current update_ini script? |
With care? ;-) But seriously, it needs some more work, yes. This was just to show that making a full stream editor for the ini-file is not that difficult. Will make some "suggestion" when I'm done hacking the script. |


Fixes #3238 and #2335.
To be done