-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
20 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
|
||
from typing import Optional | ||
|
||
from a_sync import _flags, exceptions | ||
|
||
|
||
def get_flag_name(kwargs: dict) -> str: | ||
def get_flag_name(kwargs: dict) -> Optional[str]: | ||
present_flags = [flag for flag in _flags.VIABLE_FLAGS if flag in kwargs] | ||
if len(present_flags) == 0: | ||
raise exceptions.NoFlagsFound('kwargs', kwargs.keys()) | ||
return None | ||
if len(present_flags) != 1: | ||
raise exceptions.TooManyFlags('kwargs', present_flags) | ||
return present_flags[0] | ||
|
||
def is_sync(kwargs: dict, pop_flag: bool = False) -> bool: | ||
flag = get_flag_name(kwargs) | ||
def is_sync(flag: str, kwargs: dict, pop_flag: bool = False) -> bool: | ||
flag_value = kwargs.pop(flag) if pop_flag else kwargs[flag] | ||
return _flags.negate_if_necessary(flag, flag_value) |
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