Skip to content

Commit

Permalink
Fix get_loader().load() from local couldn't get version correctly
Browse files Browse the repository at this point in the history
When version is None, it wrongly tried to get version from file name
instead of file path.
  • Loading branch information
JayZ12138 committed Oct 24, 2019
1 parent 10da83d commit e138331
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Fix LocalLoader couldn't get right version if the argument version of load() is None.

## [v2.1.0] - 2019-10-23

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_requirements():

setup(
name="ubi-config",
version="2.1.0",
version="2.1.1",
author="",
author_email="",
packages=find_packages(exclude=["tests", "tests.*"]),
Expand Down
10 changes: 5 additions & 5 deletions ubiconfig/_impl/loaders/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ def load(self, file_name, version=None):
If version is None, we should get it from its path.
"""
if version is None:
# get version form path, such as configs/ubi7.1/config.yaml, get
# ubi7.1
version = os.path.basename(os.path.dirname(file_name))

if not self._isroot:
file_path = os.path.join(self._path, file_name)
else:
file_path = file_name

if version is None:
# get version from path, such as configs/ubi7.1/config.yaml, get
# ubi7.1
version = os.path.basename(os.path.dirname(file_path))

LOG.info("Loading configuration file locally: %s", file_path)

with open(file_path, "r") as f:
Expand Down

0 comments on commit e138331

Please sign in to comment.