-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix get_loader().load() from local couldn't get version correctly #59
Conversation
04acf6d
to
e138331
Compare
715e1fc
to
54455d6
Compare
When version is None, it wrongly tried to get version from file name instead of file path.
instead of using os.getcwd, os.path.abspath is better.
ubiconfig/_impl/loaders/local.py
Outdated
# ubi7.1. | ||
version = os.path.basename(os.path.dirname(os.path.abspath(file_path))) | ||
|
||
if not re.search(r"ubi[0-9]{1}\.?[0-9]{0,2}$", version): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm,
are you sure of this? It makes only dot optional.
Shouldn't it be:
ubi[0-9]{1}(\.[0-9]{0,2})?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, it should be r"ubi[0-9].[0-9]{1,2}$|ubi[0-9]$"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is allowed?
ubi7
ubi8
ubi7.1
ubi8.9
ubi7.10
I guess my regex would do the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if ubi[0-9]{1}(.[0-9]{0,2}) is your last version, but if you do:
re.search(r'ubi[0-9]{1}(.[0-9]{0,2})', 'ubi8')
If I change it to 'ubi[0-9]{1}(.[0-9]){0,3}':
re.search(r'ubi[0-9]{1}(.[0-9]){0,3}', 'ubi710')
<_sre.SRE_Match object at 0x7f79f1819558> # shouldn't match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JayZ12138
next time let's code formatter in comment, otherwise it can strip out some chars
I was wrong before:
the shortest correct should be:
r'ubi[0-9](\.[0-9]{1,2})?$'
When version is None, it wrongly tries to get version from filename instead of the file path.