Skip to content

Commit

Permalink
Cannot figure out ReadParser conditional [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
standage committed Sep 14, 2017
1 parent 2e32025 commit e2ca266
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 2 additions & 0 deletions khmer/_oxli/graphs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ cdef class Hashtable:
cdef FastxParserPtr _parser
if type(parser_or_filename) is FastxParser:
_parser = (<FastxParser>parser_or_filename)._this
elif type(parser_or_filename) is ReadParser:
_parser = # Unholy incantation
else:
_parser = get_parser[CpFastxReader](_bstring(parser_or_filename))
return _parser
Expand Down
10 changes: 3 additions & 7 deletions khmer/_oxli/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ def get_n_primes_near_x(n_primes, x):
if len(primes) != n_primes:
msg = "unable to find {0} prime numbers < {1}".format(n_primes, x)
raise RuntimeError(msg)
return primes
return primes


cdef bytes _bstring(s):
if not isinstance(s, (basestring, bytes)):
raise TypeError("Requires a string-like sequence")
raise TypeError("Requires a string-like sequence, "\
" got {0} of type {1}".format(s, type(s)))

if isinstance(s, unicode):
s = s.encode('utf-8')
Expand All @@ -31,9 +32,6 @@ cdef unicode _ustring(s):
if type(s) is unicode:
# fast path for most common case(s)
return <unicode>s
elif PY_MAJOR_VERSION < 3 and isinstance(s, bytes):
# only accept byte strings in Python 2.x, not in Py3
return (<bytes>s).decode('UTF-8')
elif isinstance(s, unicode):
# an evil cast to <unicode> might work here in some(!) cases,
# depending on what the further processing does. to be safe,
Expand All @@ -59,5 +57,3 @@ cdef void _fill(double * fill_to, object fill_from):
'''UNSAFE fill from flat python iterable to C array.'''
for idx, item in enumerate(fill_from):
fill_to[idx] = <double>item


0 comments on commit e2ca266

Please sign in to comment.