-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
45e971d
commit ded7a87
Showing
25 changed files
with
999 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-节点管理(BlueKing-BK-NODEMAN) available. | ||
Copyright (C) 2017-2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
from configparser import ConfigParser, NoSectionError | ||
|
||
_UNSET = object() | ||
|
||
|
||
class GseConfigParser(ConfigParser): | ||
def optionxform(self, optionstr: str) -> str: | ||
# 返回原始大小写 | ||
return optionstr | ||
|
||
def format_value(self, value): | ||
try: | ||
value = int(value) | ||
except ValueError: | ||
try: | ||
value = float(value) | ||
except ValueError: | ||
pass | ||
return value | ||
|
||
def items(self, section=_UNSET, raw=False, vars=None): | ||
d = self._defaults.copy() | ||
try: | ||
d.update(self._sections[section]) | ||
except KeyError: | ||
if section != self.default_section: | ||
raise NoSectionError(section) | ||
# Update with the entry specific variables | ||
if vars: | ||
for key, value in vars.items(): | ||
d[self.optionxform(key)] = value | ||
value_getter = lambda option: self._interpolation.before_get(self, section, option, d[option], d) # noqa | ||
if raw: | ||
value_getter = lambda option: d[option] # noqa | ||
return [(option, self.format_value(value_getter(option))) for option in d.keys()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.