factored out a new not_authority method
changed miniuri/miniuri.py
This commit is contained in:
parent
e9ffead4ec
commit
68f2e96856
1 changed files with 14 additions and 8 deletions
|
|
@ -21,12 +21,8 @@ class Uri( object ):
|
|||
@property
|
||||
def uri( self ):
|
||||
"""build and return uri from attributes"""
|
||||
scheme = path = filename = query = fragment = ''
|
||||
if self.scheme: scheme = self.scheme + '://'
|
||||
if self.path: path = self.path
|
||||
if self.query: query = '?' + self.query
|
||||
if self.fragment: fragment = '#' + self.fragment
|
||||
return ''.join([scheme,self.authority,path,filename,query,fragment])
|
||||
scheme = self.scheme + '://' if self.scheme else ''
|
||||
return ''.join([scheme, self.authority, self.not_authority])
|
||||
|
||||
@uri.setter
|
||||
def uri( self, uri ):
|
||||
|
|
@ -35,7 +31,7 @@ class Uri( object ):
|
|||
self.hostname = self.port = self.path = None
|
||||
self.filename = self.query = self.fragment = None
|
||||
|
||||
if '://' in uri: # attempt to parse scheme
|
||||
if '://' in uri:
|
||||
self.scheme, uri = uri.split( '://' )
|
||||
|
||||
if '#' in uri:
|
||||
|
|
@ -44,9 +40,10 @@ class Uri( object ):
|
|||
if '?' in uri:
|
||||
uri, self.query = uri.split('?')
|
||||
|
||||
# invoke authority setter
|
||||
# invoke authority setter.
|
||||
self.authority = uri.split( '/' )[0]
|
||||
|
||||
# invoke path setter.
|
||||
self.path = uri[ len( self.authority ): ]
|
||||
|
||||
@property
|
||||
|
|
@ -71,6 +68,15 @@ class Uri( object ):
|
|||
if ':' in self.hostname:
|
||||
self.hostname, self.port = self.hostname.split( ':' )
|
||||
|
||||
@property
|
||||
def not_authority(self):
|
||||
"""return everything that isn't part of the authority."""
|
||||
path = query = fragment = ''
|
||||
if self.path: path = self.path
|
||||
if self.query: query = '?' + self.query
|
||||
if self.fragment: fragment = '#' + self.fragment
|
||||
return ''.join([path, query, fragment])
|
||||
|
||||
@property
|
||||
def userinfo( self ):
|
||||
"""return username:password, username, or None"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue