Skip to content

Commit

Permalink
No changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JarryShaw committed May 10, 2019
1 parent cbbc951 commit e47399d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"BDFL",
"DEVEL",
"EOFS",
"Envs",
"HELPMSG",
"METH",
"NPROCESSORS",
Expand Down
19 changes: 14 additions & 5 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@

__all__ = ['f2format', 'convert', 'ConvertError']

# macros
PARSO_VERSION = ('3.6', '3.7', '3.8')
LOCALE_ENCODING = locale.getpreferredencoding()

# from configparser
BOOLEAN_STATES = {'1': True, '0': False,
'yes': True, 'no': False,
'true': True, 'false': False,
'on': True, 'off': False}

# macros
PARSO_VERSION = ('3.6', '3.7', '3.8')
LOCALE_ENCODING = locale.getpreferredencoding()
F2FORMAT_QUIET = BOOLEAN_STATES.get(os.getenv('F2FORMAT_QUIET', '0').casefold(), False)


class ConvertError(SyntaxError):
pass
Expand Down Expand Up @@ -76,6 +77,9 @@ def convert(string, lineno=None):
- string -- str, context to be converted
- lineno -- dict<int: int>, line number to actual offset mapping
Envs:
- F2FORMAT_VERSION -- encoding to open source files (same as `--encoding` option in CLI)
Returns:
- str -- converted string
Expand Down Expand Up @@ -226,8 +230,13 @@ def f2format(filename):
Args:
- filename -- str, file to be converted
Envs:
- F2FORMAT_QUIET -- run in quiet mode (same as `--quiet` option in CLI)
- F2FORMAT_VERSION -- encoding to open source files (same as `--encoding` option in CLI)
- F2FORMAT_ENCODING -- convert against Python version (same as `--python` option in CLI)
"""
if not BOOLEAN_STATES.get(os.getenv('F2FORMAT_QUIET', '0').casefold(), False):
if not F2FORMAT_QUIET:
print('Now converting %r...' % filename) # pragma: no cover

# fetch encoding
Expand Down

0 comments on commit e47399d

Please sign in to comment.