unicodedata-reader 1.1.0__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/PKG-INFO +1 -1
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/pyproject.toml +1 -1
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/cli.py +5 -2
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/reader.py +19 -1
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/LICENSE +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/README.md +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/__init__.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/__main__.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/bidi_brackets.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/compressor.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/east_asian_width.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/emoji.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/entry.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/general_category.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/line_break.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/set.py +0 -0
- {unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/vertical_orientation.py +0 -0
|
@@ -125,7 +125,8 @@ class UnicodeDataCli(object):
|
|
|
125
125
|
parser.add_argument('text',
|
|
126
126
|
nargs='*',
|
|
127
127
|
help='show properties for the text')
|
|
128
|
-
parser.add_argument('-f', '--
|
|
128
|
+
parser.add_argument('-f', '--clear-cache', action='store_true')
|
|
129
|
+
parser.add_argument('-F', '--no-cache', action='store_true')
|
|
129
130
|
parser.add_argument('--name', help='$NAME in the template')
|
|
130
131
|
parser.add_argument('-t',
|
|
131
132
|
'--template',
|
|
@@ -139,8 +140,10 @@ class UnicodeDataCli(object):
|
|
|
139
140
|
default=0)
|
|
140
141
|
parser.parse_args(namespace=self)
|
|
141
142
|
_init_logging(self.verbose) # pytype: disable=attribute-error
|
|
143
|
+
if self.clear_cache:
|
|
144
|
+
UnicodeDataCachedReader.clear_cache()
|
|
142
145
|
if self.no_cache:
|
|
143
|
-
UnicodeDataReader.
|
|
146
|
+
UnicodeDataReader.default = UnicodeDataReader()
|
|
144
147
|
|
|
145
148
|
def main(self):
|
|
146
149
|
if self.template:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import pathlib
|
|
3
3
|
from typing import Iterable
|
|
4
|
+
import shutil
|
|
4
5
|
import urllib.request
|
|
5
6
|
|
|
6
7
|
from unicodedata_reader.entry import *
|
|
@@ -23,6 +24,12 @@ class UnicodeDataReader(object):
|
|
|
23
24
|
default = None
|
|
24
25
|
is_caching_allowed = True
|
|
25
26
|
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
url_template: str = 'https://www.unicode.org/Public/UNIDATA/{0}.txt'
|
|
30
|
+
) -> None:
|
|
31
|
+
self.url_template = url_template
|
|
32
|
+
|
|
26
33
|
def bidi_brackets(self) -> UnicodeDataEntries:
|
|
27
34
|
name = 'BidiBrackets'
|
|
28
35
|
lines = self.read_lines(name)
|
|
@@ -74,8 +81,11 @@ class UnicodeDataReader(object):
|
|
|
74
81
|
lines = self.read_lines(name)
|
|
75
82
|
return UnicodeVerticalOrientationDataEntries(name=name, lines=lines)
|
|
76
83
|
|
|
84
|
+
def get_url(self, name: str) -> str:
|
|
85
|
+
return self.url_template.format(name)
|
|
86
|
+
|
|
77
87
|
def read_lines(self, name: str) -> Iterable[str]:
|
|
78
|
-
url =
|
|
88
|
+
url = self.get_url(name)
|
|
79
89
|
_logger.debug('Downloading %s', url)
|
|
80
90
|
with urllib.request.urlopen(url) as response:
|
|
81
91
|
body = response.read().decode('utf-8')
|
|
@@ -112,5 +122,13 @@ class UnicodeDataCachedReader(UnicodeDataReader):
|
|
|
112
122
|
|
|
113
123
|
return lines
|
|
114
124
|
|
|
125
|
+
@staticmethod
|
|
126
|
+
def clear_cache(ignore_errors: bool = False):
|
|
127
|
+
cache_dir = UnicodeDataCachedReader._cache_dir
|
|
128
|
+
if not cache_dir or not cache_dir.exists():
|
|
129
|
+
return
|
|
130
|
+
_logger.debug('Deleting cache %s', cache_dir)
|
|
131
|
+
shutil.rmtree(cache_dir, ignore_errors=ignore_errors)
|
|
132
|
+
|
|
115
133
|
|
|
116
134
|
UnicodeDataReader.default = UnicodeDataCachedReader()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/east_asian_width.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/general_category.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unicodedata_reader-1.1.0 → unicodedata_reader-1.2.0}/unicodedata_reader/vertical_orientation.py
RENAMED
|
File without changes
|