Skip to content

Commit

Permalink
Use bytes for detection
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jul 28, 2014
1 parent 3e67005 commit f6691a7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions doc2dash/parsers/base.py
@@ -1,4 +1,3 @@
import codecs
import errno
import logging
import os
Expand Down Expand Up @@ -53,9 +52,7 @@ def detect(cl, path):
that file.
"""
try:
with codecs.open(os.path.join(path, cl.DETECT_FILE),
"rb",
encoding="latin1") as f:
with open(os.path.join(path, cl.DETECT_FILE), "rb") as f:
return cl.DETECT_PATTERN in f.read()
except IOError as e:
if e.errno == errno.ENOENT:
Expand Down
2 changes: 1 addition & 1 deletion doc2dash/parsers/intersphinx.py
Expand Up @@ -44,7 +44,7 @@ class InterSphinxParser(_BaseParser):
name = "intersphinx"

DETECT_FILE = "objects.inv"
DETECT_PATTERN = "# Sphinx inventory version 2"
DETECT_PATTERN = b"# Sphinx inventory version 2"

def parse(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion doc2dash/parsers/pydoctor.py
Expand Up @@ -17,7 +17,7 @@ class PyDoctorParser(_BaseParser):
name = 'pydoctor'

DETECT_FILE = 'index.html'
DETECT_PATTERN = '''\
DETECT_PATTERN = b'''\
This documentation was automatically generated by
<a href="http://codespeak.net/~mwh/pydoctor/">pydoctor</a>'''

Expand Down
2 changes: 1 addition & 1 deletion doc2dash/parsers/sphinx.py
Expand Up @@ -19,7 +19,7 @@ class SphinxParser(_BaseParser):
name = 'sphinx'

DETECT_FILE = '_static/searchtools.js'
DETECT_PATTERN = '* Sphinx JavaScript util'
DETECT_PATTERN = b'* Sphinx JavaScript util'

def parse(self):
"""
Expand Down

0 comments on commit f6691a7

Please sign in to comment.