-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modern Python, self-update, better CLI
- Loading branch information
1 parent
a59788a
commit a20515b
Showing
6 changed files
with
163 additions
and
70 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
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,9 +1,50 @@ | ||
from youseedee import ucd_data | ||
from pprint import pprint | ||
import argparse | ||
import sys | ||
|
||
char = sys.argv[1] | ||
if len(char) > 1: | ||
pprint(ucd_data(int(char,16))) | ||
else: | ||
pprint(ucd_data(ord(char))) | ||
from youseedee import ucd_data, download_files | ||
|
||
|
||
def main(args=None): | ||
parser = argparse.ArgumentParser(description="Get Unicode Character Data") | ||
parser.add_argument( | ||
"--force-download", | ||
action="store_true", | ||
help="Force download of latest Unicode data", | ||
) | ||
parser.add_argument( | ||
"char", | ||
type=str, | ||
help="The character to get data for (either hex codepoint or character)", | ||
) | ||
|
||
args = parser.parse_args(args) | ||
if args.force_download: | ||
download_files() | ||
char = sys.argv[1] | ||
if len(char) > 1: | ||
try: | ||
if ( | ||
char.startswith("U+") | ||
or char.startswith("u+") | ||
or char.startswith("0x") | ||
or char.startswith("0X") | ||
): | ||
codepoint = int(char[2:], 16) | ||
else: | ||
codepoint = int(char, 16) | ||
except ValueError: | ||
print("Could not understand codepoint " + char) | ||
sys.exit(1) | ||
else: | ||
codepoint = ord(char) | ||
data = ucd_data(codepoint) | ||
|
||
print(f"\nCharacter data for '{chr(codepoint)}' (U+{codepoint:04X}, {codepoint})\n") | ||
|
||
for key, value in data.items(): | ||
key = key.replace("_", " ") | ||
print(f"{key:40} {value}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,35 @@ | ||
[project] | ||
dynamic = ["version"] | ||
|
||
name = "youseedee" | ||
description = "Interface to the latest version of the Unicode Character Database" | ||
|
||
license = { file = "README.md" } | ||
|
||
authors = [{ name = "Simon Cozens", email = "simon@simon-cozens.org" }] | ||
|
||
readme = { file = "README.md", content-type = "text/markdown" } | ||
|
||
keywords = [] | ||
dependencies = ["requests", "filelock"] | ||
|
||
[project.urls] | ||
homepage = "https://pypi.org/project/youseedee" | ||
repository = "https://github.com/simoncozens/youseedee" | ||
|
||
[build-system] | ||
requires = ["setuptools>=74.1.0", "setuptools_scm[toml]>=8.1.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["lib"] | ||
|
||
[tool.setuptools_scm] | ||
git_describe_command = "git describe --match 'v*' --tags" | ||
|
||
[project.scripts] | ||
|
||
youseedee = "youseedee.__main__:main" | ||
|
||
[tool.pylint."messages control"] | ||
max-line-length = 120 |
This file was deleted.
Oops, something went wrong.