Skip to content

Commit

Permalink
Merge pull request #172 from LuminosoInsight/code-review-fixes-2021-04
Browse files Browse the repository at this point in the history
Small fixes from code review
  • Loading branch information
Robyn Speer committed Apr 16, 2021
2 parents 2992a6c + ce4f13e commit d4dad23
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 18 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
@@ -1,3 +1,12 @@
## Version 6.0.1 (April 12, 2021)

- The `remove_terminal_escapes` step was accidentally not being used. This
version restores it.

- Specified in setup.py that ftfy 6 requires Python 3.6 or later.

- Use a lighter link color when the docs are viewed in dark mode.

## Version 6.0 (April 2, 2021)

- New function: `ftfy.fix_and_explain()` can describe all the transformations
Expand All @@ -17,7 +26,7 @@
use less RAM when imported.

- The heuristic `ftfy.badness.is_bad(text)` can be used to determine whether
there apears to be mojibake in a string. Some users were already using
there appears to be mojibake in a string. Some users were already using
the old function `sequence_weirdness()` for that, but this one is actually
designed for that purpose.

Expand Down
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -11,15 +11,15 @@
The full documentation of ftfy is available at [ftfy.readthedocs.org](https://ftfy.readthedocs.org). The documentation covers a lot more than this README, so here are
some links into it:

- [Fixing problems and getting explanations](https://ftfy.readthedocs.io/en/v6.0/explain.html)
- [Configuring ftfy](https://ftfy.readthedocs.io/en/v6.0/config.html)
- [Encodings ftfy can handle](https://ftfy.readthedocs.io/en/v6.0/encodings.html)
- [“Fixer” functions](https://ftfy.readthedocs.io/en/v6.0/fixes.html)
- [Is ftfy an encoding detector?](https://ftfy.readthedocs.io/en/v6.0/detect.html)
- [Heuristics for detecting mojibake](https://ftfy.readthedocs.io/en/v6.0/heuristics.html)
- [Support for “bad” encodings](https://ftfy.readthedocs.io/en/v6.0/bad_encodings.html)
- [Command-line usage](https://ftfy.readthedocs.io/en/v6.0/cli.html)
- [Citing ftfy](https://ftfy.readthedocs.io/en/v6.0/cite.html)
- [Fixing problems and getting explanations](https://ftfy.readthedocs.io/en/v6.0.1/explain.html)
- [Configuring ftfy](https://ftfy.readthedocs.io/en/v6.0.1/config.html)
- [Encodings ftfy can handle](https://ftfy.readthedocs.io/en/v6.0.1/encodings.html)
- [“Fixer” functions](https://ftfy.readthedocs.io/en/v6.0.1/fixes.html)
- [Is ftfy an encoding detector?](https://ftfy.readthedocs.io/en/v6.0.1/detect.html)
- [Heuristics for detecting mojibake](https://ftfy.readthedocs.io/en/v6.0.1/heuristics.html)
- [Support for “bad” encodings](https://ftfy.readthedocs.io/en/v6.0.1/bad_encodings.html)
- [Command-line usage](https://ftfy.readthedocs.io/en/v6.0.1/cli.html)
- [Citing ftfy](https://ftfy.readthedocs.io/en/v6.0.1/cite.html)


## Testimonials
Expand Down
13 changes: 11 additions & 2 deletions docs/conf.py
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '5.9'
version = '6.0'
# The full version, including alpha/beta/rc tags.
release = '5.9'
release = '6.0.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -111,6 +111,15 @@
# I don't know why furo wants inline code to be so small, but don't let it
"font-size--small--2": "100%",
},
"dark_css_variables": {
"color-brand-primary": "#AC8DFF",
"color-brand-content": "#AC8DFF",
"font-stack": "Source Sans Pro, sans-serif",
"font-stack--monospace": "Inconsolata",
"code-font-size": "18px",

"font-size--small--2": "100%",
},
}
html_css_files = [
'css/custom.css',
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
@@ -1,7 +1,7 @@
ftfy: fixes text for you
========================

*Version 6.0*
*Version 6.0.1*

**ftfy** fixes Unicode that's broken in various ways.

Expand Down
5 changes: 3 additions & 2 deletions ftfy/__init__.py
Expand Up @@ -13,7 +13,7 @@
from ftfy.badness import is_bad
from ftfy.formatting import display_ljust

__version__ = "6.0"
__version__ = "6.0.1"


# Though this function does nothing, it lets linters know that we're using
Expand Down Expand Up @@ -343,6 +343,7 @@ def fix_and_explain(
"uncurl_quotes",
"fix_line_breaks",
"fix_surrogates",
"remove_terminal_escapes",
"remove_control_chars",
]:
text = _try_fix(fixer, text, config, steps)
Expand Down Expand Up @@ -517,7 +518,7 @@ def fix_encoding(text: str, config: TextFixerConfig = None, **kwargs):
'ó'
"""
if config is None:
config = TextFixerConfig()
config = TextFixerConfig(explain=False)
config = config._replace(**kwargs)
fixed, _explan = fix_encoding_and_explain(text, config)
return fixed
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -21,7 +21,7 @@

setup(
name="ftfy",
version='6.0',
version='6.0.1',
maintainer='Robyn Speer',
maintainer_email='rspeer@luminoso.com',
license="MIT",
Expand All @@ -33,7 +33,7 @@
packages=['ftfy', 'ftfy.bad_codecs'],
install_requires=['wcwidth'],
tests_require=['pytest'],
python_requires='>=3.5',
python_requires='>=3.6',
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
Expand Down
13 changes: 12 additions & 1 deletion tests/test_characters.py
@@ -1,4 +1,6 @@
from ftfy import fix_encoding, fix_encoding_and_explain, fix_text, apply_plan
from ftfy import (
fix_encoding, fix_encoding_and_explain, fix_text, fix_and_explain, apply_plan
)
from ftfy.fixes import remove_control_chars, fix_surrogates
from ftfy.chardata import possible_encoding
from ftfy.badness import badness
Expand Down Expand Up @@ -44,3 +46,12 @@ def test_surrogates():
assert fix_surrogates('\udbff\udfff') == '\U0010ffff'
assert fix_surrogates('\ud800\udc00') == '\U00010000'


def test_color_escapes():
fixed, plan = fix_and_explain("\001\033[36;44mfoo")
print(plan)
assert fixed == "foo"
assert plan == [
("apply", "remove_terminal_escapes"),
("apply", "remove_control_chars")
]

0 comments on commit d4dad23

Please sign in to comment.