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

Commit226247f

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

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
@@ -471,10 +471,7 @@ def detectEncoding(self, parseMeta=True, chardet=True):
471471
ifencodingisNoneandchardet:
472472
confidence="tentative"
473473
try:
474-
try:
475-
fromcharade.universaldetectorimportUniversalDetector
476-
exceptImportError:
477-
fromchardet.universaldetectorimportUniversalDetector
474+
fromchardet.universaldetectorimportUniversalDetector
478475
buffers= []
479476
detector=UniversalDetector()
480477
whilenotdetector.done:
@@ -490,7 +487,7 @@ def detectEncoding(self, parseMeta=True, chardet=True):
490487
exceptImportError:
491488
pass
492489
# If all else fails use the default encoding
493-
ifencodingisNone:
490+
ifnotencoding:
494491
confidence="tentative"
495492
encoding=lookupEncoding(self.defaultEncoding)
496493

‎html5lib/tests/test_encoding.py

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

4242
try:
43-
try:
44-
importcharade# flake8: noqa
45-
exceptImportError:
46-
importchardet# flake8: noqa
43+
importchardet# flake8: noqa
4744
exceptImportError:
48-
print("charade/chardet not found, skipping chardet tests")
45+
print("chardet not found, skipping chardet tests")
4946
else:
5047
deftest_chardet():
5148
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=[
@@ -22,27 +20,19 @@
2220
'Topic :: Text Processing :: Markup :: HTML'
2321
]
2422

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

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

4737
setup(name='html5lib',
4838
version=version,
@@ -53,7 +43,7 @@
5343
classifiers=classifiers,
5444
maintainer='James Graham',
5545
maintainer_email='james@hoppipolla.co.uk',
56-
packages=packages,
46+
packages=find_packages(exclude=["*.tests","*.tests.*","tests.*","tests"]),
5747
install_requires=[
5848
'six',
5949
'webencodings',
@@ -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