Skip to content

Commit

Permalink
chore: update README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
weibullguy committed Aug 19, 2022
1 parent 43ee993 commit 6da318b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion README.rst
Expand Up @@ -58,9 +58,12 @@ Features
whitespace. Such trailing whitespace is visually indistinguishable
and some editors (or more recently, reindent.py) will trim them.

See the the full documentation at `read-the-docs`_.
See the the full documentation at `read-the-docs`_, especially the
`requirements`_ section for a more detailed discussion of PEP 257 and other
requirements.

.. _read-the-docs: https://docformatter.readthedocs.io
.. _requirements: https://docformatter.readthedocs.io/en/latest/requirements.html

Installation
============
Expand Down
10 changes: 4 additions & 6 deletions docformatter.py
Expand Up @@ -410,7 +410,7 @@ def do_format_standard_in(self, parser: argparse.ArgumentParser):
encoding = None
source = self.stdin.read()
if not isinstance(source, unicode):
encoding = self.stdin.encoding or _get_encoding()
encoding = self.stdin.encoding or self.encodor.system_encoding
source = source.decode(encoding)

formatted_source = self._do_format_code(source)
Expand Down Expand Up @@ -728,6 +728,9 @@ class Encodor:
def __init__(self):
"""Initialize an Encodor instance."""
self.encoding = "latin-1"
self.system_encoding = (
locale.getpreferredencoding() or sys.getdefaultencoding()
)

def do_detect_encoding(self, filename: str) -> None:
"""Return the detected file encoding.
Expand Down Expand Up @@ -1153,11 +1156,6 @@ def _main(argv, standard_out, standard_error, standard_in):
return formator.do_format_files()


def _get_encoding():
"""Return preferred encoding."""
return locale.getpreferredencoding() or sys.getdefaultencoding()


def find_py_files(sources, recursive, exclude=None):
"""Find Python source files.
Expand Down

0 comments on commit 6da318b

Please sign in to comment.