Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: remove broad Exception catching fromconfig.py#2212

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intomainfromjlvillal/config
Aug 7, 2022
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletionsgitlab/config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,8 @@

HELPER_ATTRIBUTES = ["job_token", "http_password", "private_token", "oauth_token"]

_CONFIG_PARSER_ERRORS = (configparser.NoOptionError, configparser.NoSectionError)


def _resolve_file(filepath: Union[Path, str]) -> str:
resolved = Path(filepath).resolve(strict=True)
Expand DownExpand Up@@ -148,108 +150,102 @@ def _parse_config(self) -> None:
# Value Error means the option exists but isn't a boolean.
# Get as a string instead as it should then be a local path to a
# CA bundle.
try:
self.ssl_verify = _config.get("global", "ssl_verify")
except Exception: # pragma: no cover
pass
except Exception:
self.ssl_verify = _config.get("global", "ssl_verify")
except _CONFIG_PARSER_ERRORS:
pass
try:
self.ssl_verify = _config.getboolean(self.gitlab_id, "ssl_verify")
except ValueError:
# Value Error means the option exists but isn't a boolean.
# Get as a string instead as it should then be a local path to a
# CA bundle.
try:
self.ssl_verify = _config.get(self.gitlab_id, "ssl_verify")
except Exception: # pragma: no cover
pass
except Exception:
self.ssl_verify = _config.get(self.gitlab_id, "ssl_verify")
except _CONFIG_PARSER_ERRORS:
pass

try:
self.timeout = _config.getint("global", "timeout")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass
try:
self.timeout = _config.getint(self.gitlab_id, "timeout")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

try:
self.private_token = _config.get(self.gitlab_id, "private_token")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

try:
self.oauth_token = _config.get(self.gitlab_id, "oauth_token")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

try:
self.job_token = _config.get(self.gitlab_id, "job_token")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

try:
self.http_username = _config.get(self.gitlab_id, "http_username")
self.http_password = _config.get(
self.gitlab_id, "http_password"
) # pragma: no cover
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

self._get_values_from_helper()

try:
self.api_version = _config.get("global", "api_version")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass
try:
self.api_version = _config.get(self.gitlab_id, "api_version")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass
if self.api_version not in ("4",):
raise GitlabDataError(f"Unsupported API version: {self.api_version}")

for section in ["global", self.gitlab_id]:
try:
self.per_page = _config.getint(section, "per_page")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass
if self.per_page is not None and not 0 <= self.per_page <= 100:
raise GitlabDataError(f"Unsupported per_page number: {self.per_page}")

try:
self.pagination = _config.get(self.gitlab_id, "pagination")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

try:
self.order_by = _config.get(self.gitlab_id, "order_by")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

try:
self.user_agent = _config.get("global", "user_agent")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass
try:
self.user_agent = _config.get(self.gitlab_id, "user_agent")
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

try:
self.retry_transient_errors = _config.getboolean(
"global", "retry_transient_errors"
)
exceptException:
except_CONFIG_PARSER_ERRORS:
pass
try:
self.retry_transient_errors = _config.getboolean(
self.gitlab_id, "retry_transient_errors"
)
exceptException:
except_CONFIG_PARSER_ERRORS:
pass

def _get_values_from_helper(self) -> None:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp