Skip to content

Commit

Permalink
minor updates in CharBuffer to handle different types of quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank committed Jul 28, 2010
1 parent 66afa8c commit f4b0007
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Bio/Nexus/Nexus.py
Expand Up @@ -109,14 +109,16 @@ def next_word(self):
return None
word.append(first)
if first=="'": # word starts with a quote
quoted=True
quoted="'"
elif first=='"':
quoted='"'
elif first in PUNCTUATION: # if it's punctuation, return immediately
return first
while True:
c=self.peek()
if c=="'": # a quote?
if c==quoted: # a quote?
word.append(self.next()) # store quote
if self.peek()=="'": # double quote
if self.peek()==quoted: # double quote
skip=self.next() # skip second quote
elif quoted: # second single quote ends word
break
Expand Down Expand Up @@ -929,6 +931,8 @@ def _utree(self,options):

def _tree(self,options):
opts=CharBuffer(options)
if opts.peek_nonwhitespace()=='*': # a star can be used to make it the default tree in some software packages
dummy=opts.next_nonwhitespace()
name=opts.next_word()
if opts.next_nonwhitespace()!='=':
raise NexusError('Syntax error in tree description: %s' \
Expand Down

0 comments on commit f4b0007

Please sign in to comment.