-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add chardet encoding detection (#193)
- Loading branch information
Showing
8 changed files
with
56 additions
and
17 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
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ description = "An ellipsometry analysis tool for reproducible and comprehensible | |
dynamic = ["version"] | ||
authors = [ | ||
{ name = "Marius Müller", email = "[email protected]" }, | ||
{ name = "Florian Dobener", email = "[email protected]" } | ||
{ name = "Florian Dobener", email = "[email protected]" }, | ||
] | ||
requires-python = ">=3.8" | ||
license = { file = "LICENSE.txt" } | ||
|
@@ -19,7 +19,7 @@ classifiers = [ | |
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12" | ||
"Programming Language :: Python :: 3.12", | ||
] | ||
dependencies = [ | ||
"scipy", | ||
|
@@ -32,6 +32,7 @@ dependencies = [ | |
"rapidfuzz", | ||
"lark>=1.1.5", | ||
"pint", | ||
"chardet", | ||
] | ||
|
||
[project.optional-dependencies] | ||
|
@@ -75,16 +76,16 @@ indent-width = 4 | |
|
||
[tool.ruff.lint] | ||
select = [ | ||
"E", # pycodestyle | ||
"W", # pycodestyle | ||
"PL", # pylint | ||
"E", # pycodestyle | ||
"W", # pycodestyle | ||
"PL", # pylint | ||
"NPY201", # numpy | ||
] | ||
ignore = [ | ||
"E501", # Line too long ({width} > {limit} characters) | ||
"E701", # Multiple statements on one line (colon) | ||
"E731", # Do not assign a lambda expression, use a def | ||
"E402", # Module level import not at top of file | ||
"E501", # Line too long ({width} > {limit} characters) | ||
"E701", # Multiple statements on one line (colon) | ||
"E731", # Do not assign a lambda expression, use a def | ||
"E402", # Module level import not at top of file | ||
"PLR0911", # Too many return statements | ||
"PLR0912", # Too many branches | ||
"PLR0913", # Too many arguments in function definition | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import chardet | ||
|
||
|
||
def detect_encoding(fname: str) -> str: | ||
r"""Detects the encoding of file fname. | ||
Args: | ||
fname (str): Filename | ||
Returns: | ||
str: Encoding identifier string. | ||
""" | ||
with open(fname, "rb") as f: | ||
raw_data = f.read() | ||
result = chardet.detect(raw_data) | ||
return result["encoding"] |
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