Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd44346b

Browse files
committed
setup refactor v1.5:
* drop usage of charade - no longer maintained* refactor setup for simplicity
1 parent44b0bbc commitd44346b

File tree

6 files changed

+24
-41
lines changed

6 files changed

+24
-41
lines changed

‎README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ functionality:
113113

114114
- ``genshi`` has a treewalker (but not builder); and
115115

116-
- ``charade`` can be used as a fallback when character encoding cannot
117-
be determined; ``chardet``, from which it was forked, can also be used
118-
on Python 2.
116+
- ``chardet`` can be used as a fallback when character encoding cannot
117+
be determined.
119118

120119
- ``ordereddict`` can be used under Python 2.6
121120
(``collections.OrderedDict`` is used instead on later versions) to

‎debug-info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"maxsize":sys.maxsize
1313
}
1414

15-
search_modules= ["charade","chardet","datrie","genshi","html5lib","lxml","six"]
15+
search_modules= ["chardet","datrie","genshi","html5lib","lxml","six"]
1616
found_modules= []
1717

1818
forminsearch_modules:

‎html5lib/inputstream.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,7 @@ def detectEncoding(self, parseMeta=True, chardet=True):
477477
ifencodingisNoneandchardet:
478478
confidence="tentative"
479479
try:
480-
try:
481-
fromcharade.universaldetectorimportUniversalDetector
482-
exceptImportError:
483-
fromchardet.universaldetectorimportUniversalDetector
480+
fromchardet.universaldetectorimportUniversalDetector
484481
buffers= []
485482
detector=UniversalDetector()
486483
whilenotdetector.done:
@@ -496,7 +493,7 @@ def detectEncoding(self, parseMeta=True, chardet=True):
496493
exceptImportError:
497494
pass
498495
# If all else fails use the default encoding
499-
ifencodingisNone:
496+
ifnotencoding:
500497
confidence="tentative"
501498
encoding=self.defaultEncoding
502499

‎html5lib/tests/test_encoding.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ def test_encoding():
5454
yield (runPreScanEncodingTest,test[b'data'],test[b'encoding'])
5555

5656
try:
57-
try:
58-
importcharade# flake8: noqa
59-
exceptImportError:
60-
importchardet# flake8: noqa
57+
importchardet# flake8: noqa
6158
exceptImportError:
62-
print("charade/chardet not found, skipping chardet tests")
59+
print("chardet not found, skipping chardet tests")
6360
else:
6461
deftest_chardet():
6562
withopen(os.path.join(test_dir,"encoding" ,"chardet","test_big5.txt"),"rb")asfp:

‎requirements-optional.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# streams.
55
genshi
66

7-
#charade can be used as a fallback in case we are unable to determine
7+
#chardet can be used as a fallback in case we are unable to determine
88
# the encoding of a document.
9-
charade
9+
chardet>2.2
1010

1111
# lxml is supported with its own treebuilder ("lxml") and otherwise
1212
# uses the standard ElementTree support

‎setup.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
importast
2-
importos
31
importcodecs
4-
5-
fromsetuptoolsimportsetup
2+
fromos.pathimportjoin,dirname
3+
fromsetuptoolsimportsetup,find_packages
64

75

86
classifiers=[
@@ -23,27 +21,19 @@
2321
'Topic :: Text Processing :: Markup :: HTML'
2422
]
2523

26-
packages= ['html5lib']+ ['html5lib.'+name
27-
fornameinos.listdir(os.path.join('html5lib'))
28-
ifos.path.isdir(os.path.join('html5lib',name))and
29-
notname.startswith('.')andname!='tests']
30-
31-
current_dir=os.path.dirname(__file__)
32-
withcodecs.open(os.path.join(current_dir,'README.rst'),'r','utf8')asreadme_file:
33-
withcodecs.open(os.path.join(current_dir,'CHANGES.rst'),'r','utf8')aschanges_file:
24+
here=dirname(__file__)
25+
withcodecs.open(join(here,'README.rst'),'r','utf8')asreadme_file:
26+
withcodecs.open(join(here,'CHANGES.rst'),'r','utf8')aschanges_file:
3427
long_description=readme_file.read()+'\n'+changes_file.read()
3528

3629
version=None
37-
withopen(os.path.join("html5lib","__init__.py"),"rb")asinit_file:
38-
t=ast.parse(init_file.read(),filename="__init__.py",mode="exec")
39-
assertisinstance(t,ast.Module)
40-
assignments=filter(lambdax:isinstance(x,ast.Assign),t.body)
41-
forainassignments:
42-
if (len(a.targets)==1and
43-
isinstance(a.targets[0],ast.Name)and
44-
a.targets[0].id=="__version__"and
45-
isinstance(a.value,ast.Str)):
46-
version=a.value.s
30+
withopen(join(here,'html5lib','__init__.py'))asfp:
31+
forlineinfp:
32+
_locals= {}
33+
ifline.startswith('__version__'):
34+
exec(line,None,_locals)
35+
version=_locals['__version__']
36+
break
4737

4838
setup(name='html5lib',
4939
version=version,
@@ -54,7 +44,7 @@
5444
classifiers=classifiers,
5545
maintainer='James Graham',
5646
maintainer_email='james@hoppipolla.co.uk',
57-
packages=packages,
47+
packages=find_packages(exclude=["*.tests","*.tests.*","tests.*","tests"]),
5848
install_requires=[
5949
'six',
6050
],
@@ -70,13 +60,13 @@
7060

7161
# Standard extras, will be installed when the extra is requested.
7262
"genshi": ["genshi"],
73-
"charade": ["charade"],
63+
"chardet": ["chardet>=2.2"],
7464

7565
# The all extra combines a standard extra which will be used anytime
7666
# the all extra is requested, and it extends it with a conditional
7767
# extra that will be installed whenever the condition matches and the
7868
# all extra is requested.
79-
"all": ["genshi","charade"],
69+
"all": ["genshi","chardet>=2.2"],
8070
"all:python_implementation == 'CPython'": ["datrie","lxml"],
8171
},
8272
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp