-
Notifications
You must be signed in to change notification settings - Fork 29.4k
[IMP] use file_path and file_open #135607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f4c7812
to
923703f
Compare
5710352
to
2b04e14
Compare
@robodoo r+ (hoping no longer having conflicts) |
@mart-e linked pull request(s) odoo/enterprise#47475, odoo/upgrade#5187 not ready. Linked PRs are not staged until all of them are ready. |
2b04e14
to
1041c39
Compare
Replace all the calls to get_resource_path to the better file_path or directly use file_open when not needed Doing both a get_resource_path and file_open means checking twice that the file exists. Doing a simple path concatenation before a file_open is safe. If given to another method (e.g. etree.parse), calling file_path is the prefered method. Note that get_resource_path used to return False when the file does not exists while file_path/file_open raises a FileNotFoundException
1041c39
to
d341891
Compare
@robodoo r+ 🙄 |
file_path is superior and can replace every (often unnecessary) calls Merge check_resource_path that is no longer needed Part-of: #135607
Replace all the calls to get_resource_path to the better file_path or directly use file_open when not needed Doing both a get_resource_path and file_open means checking twice that the file exists. Doing a simple path concatenation before a file_open is safe. If given to another method (e.g. etree.parse), calling file_path is the prefered method. Note that get_resource_path used to return False when the file does not exists while file_path/file_open raises a FileNotFoundException closes #135607 Related: odoo/upgrade#5187 Related: odoo/enterprise#47475 Signed-off-by: Martin Trigaux (mat) <[email protected]>
closes #135607 Signed-off-by: Martin Trigaux (mat) <[email protected]>
closes #135607 Signed-off-by: Martin Trigaux (mat) <[email protected]>
Replace all the calls to get_resource_path to the better file_path or directly use file_open when not needed Doing both a get_resource_path and file_open means checking twice that the file exists. Doing a simple path concatenation before a file_open is safe. If given to another method (e.g. etree.parse), calling file_path is the prefered method. Note that get_resource_path used to return False when the file does not exists while file_path/file_open raises a FileNotFoundException closes odoo/odoo#135607 Related: odoo/upgrade#5187 Related: odoo/enterprise#47475 Signed-off-by: Martin Trigaux (mat) <[email protected]>
Hello @mart-e |
@Armin-FalDiS can you be a bit more specific? This commit changed a lot of things and was merged 2 years ago. edit: oh I see, the ir_ui_menu.py part. Hmm it’s unintentional. We only have .png icons but we could support other image format if needed. Don’t hesitate to make a PR to patch this. |
Deprecate the usage of
get_resource_path
/get_module_resource
. Usingfile_path
has the same features with additional security checks.Replace all the deprecated calls to
open
orget_resource_path
with thefile_open
andfile_path
method.Differences between
get_resource_path
andfile_path
:get_resource_path
returns False if the file does not exsits,file_path
raises aFileNotFoundError
file_path
ensures the file is within the addons-pathDifference between
open
andfile_open
file_open
ensures the file is within the addons-path