570"""571 Adds a /* prefix if there is no prefix. This is when you need572 to keep context's constrained to a single parent.573 """574ifself.path:575self.path+='*/'576else:577self.path='*/'578self.star_prefix=True

581prefix=str(self)582prefix+=combiner583path=(other.prefixor'')+(other.pathor'')584# We don't need a star prefix if we are joining to this other585# prefix; so we'll get rid of it586ifother.star_prefixandpath=='*/':587path=''588self.prefix=prefix589self.path=path590self.element=other.element591self.condition=other.condition

610# FIXME: I don't think this is right, but lacking any reasonable611# specification on what XPath literals look like (which doesn't seem612# to be in the XPath specification) it is hard to do 'right'613ifisinstance(s,Element):614# This is probably a symbol that looks like an expression...615s=s._format_element()616returnrepr(str(s))

764"""765 Parses things like '1n+2', or 'an+b' generally, returning (a, b)766 """767ifisinstance(s,Element):768s=s._format_element()769ifnotsors=='*':770# Happens when there's nothing, which the CSS parser thinks of as *771return(0,0)772ifisinstance(s,int):773# Happens when you just get a number774return(0,s)775ifs=='odd':776return(2,1)777elifs=='even':778return(2,0)779elifs=='n':780return(1,0)781if'n'notins:782# Just a b783return(0,int(s))784a,b=s.split('n',1)785ifnota:786a=1787elifa=='-'ora=='+':788a=int(a+'1')789else:790a=int(a)791ifnotb:792b=0793elifb=='-'orb=='+':794b=int(b+'1')795else:796b=int(b)797return(a,b)