From 707324959d3cf2b53f7961d8ceb42ab8a2c315e2 Mon Sep 17 00:00:00 2001 From: RussellBallestrini Date: Fri, 29 Jun 2012 20:19:48 -0400 Subject: [PATCH] moved miniuri.py our of src and added README --- README | 53 ++++++++++++++++++++++++++++++++++++ src/miniuri.py => miniuri.py | 18 ++++-------- setup.py | 27 ++++++------------ 3 files changed, 68 insertions(+), 30 deletions(-) create mode 100644 README rename src/miniuri.py => miniuri.py (87%) diff --git a/README b/README new file mode 100644 index 0000000..da9ad97 --- /dev/null +++ b/README @@ -0,0 +1,53 @@ +How to install +=================== + +easy_install miniuri + +What does it do? +==================== + +miniuri is a universal URI parser class. + +The parser grants access to the following attributes:: + + foo://username:password@test.com:808/go/to/index.php?pet=cat&name=bam#eye + \_/ \_______________/ \______/ \_/ \___/ \_/ \_______________/\_/ + | | | | | | | | + | userinfo hostname | | | query fragment + | \___________________________|/\________|____|_/ + | | | | | | + scheme authority | path | extension + | | + port filename +How to use +==================== + +This example shows how you can set and get any of the URI attributes:: + + >>> from miniuri import Uri + >>> u = Uri( "http://www.foxhop.net/samsung/HL-T5087SA/red-LED-failure" ) + >>> u.uri = "https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5" + >>> print u.uri + https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5 + >>> print u.hostname + www.foxhop.net + >>> print u.scheme + https + >>> u.username = 'max' + >>> print u + https://max:pass@www.foxhop.net:81/path/filename.jpg?p=2#5 + +How do I thank you? +======================= + +You should follow me on http://twitter.com/russellbal + + +License +======================= + +Public Domain + + + + diff --git a/src/miniuri.py b/miniuri.py similarity index 87% rename from src/miniuri.py rename to miniuri.py index 706666c..2ff83b6 100644 --- a/src/miniuri.py +++ b/miniuri.py @@ -1,7 +1,7 @@ class Uri( object ): """ - This is a universal URI parser class. - Pass a URI string in for access to the following attributes: + miniuri is a universal URI parser class. + The parser grants access to the following attributes: foo://username:password@test.com:808/go/to/index.php?pet=cat&name=bam#eye \_/ \_______________/ \______/ \_/ \___/ \_/ \_______________/\_/ @@ -13,23 +13,17 @@ class Uri( object ): | | port filename - This example shows how you can set and get any of the URI attributes: + How to use: .. code-block:: python >>> from miniuri import Uri - >>> u = Uri( "http://www.foxhop.net/samsung/HL-T5087SA/red-LED-failure" ) - >>> u.uri = "https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5" - >>> print u.uri - https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5 + >>> u = Uri("https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5") >>> print u.hostname www.foxhop.net - >>> print u.scheme - https >>> u.username = 'max' - >>> print u + >>> print u.uri https://max:pass@www.foxhop.net:81/path/filename.jpg?p=2#5 """ - def __init__( self, uri = None ): if uri: self.uri = uri # invoke uri.setter @@ -42,7 +36,7 @@ class Uri( object ): if self.filename: filename = '/' + self.filename if self.query: query = '?' + self.query if self.fragment: fragment = '#' + self.fragment - return ''.join( [scheme, self.authority, path, filename, query, fragment] ) + return ''.join([scheme,self.authority,path,filename,query,fragment]) @uri.setter def uri( self, uri ): diff --git a/setup.py b/setup.py index 55f9426..88f639a 100644 --- a/setup.py +++ b/setup.py @@ -1,35 +1,26 @@ -from setuptools import setup, find_packages +# installation: easy_install miniuri -""" -Installation -=============== -easy_install miniuri -""" -#requires = [] +from setuptools import setup setup( name='miniuri', - version='0.0.1', - description='Universal URI parser', + version='0.0.2', + long_description = open('README').read(), + description='miniuri: The Universal URI Parser', + keywords = 'miniuri uri url parser', author = 'Russell Ballestrini', author_email = 'russell@ballestrini.net', - keywords = 'uri url parser', - url = 'https://bitbucket.org/russellballestrini/miniuri/src/tip/miniuri/miniuri.py', + url = 'https://bitbucket.org/russellballestrini/miniuri/src', platforms=['All'], license='Public Domain', - #install_requires = requires, - #packages=find_packages(), - package_dir = {'': 'src'}, py_modules = ['miniuri'], include_package_data=True, - #zip_safe=False ) -# setup keyword args: -# http://peak.telecommunity.com/DevCenter/setuptools +# setup keyword args: http://peak.telecommunity.com/DevCenter/setuptools -# build and upload to pypi with this: +# built and uploaded to pypi with this: #python setup.py sdist bdist_egg register upload