%if 0%{fedora} <= 12
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif
%global srcname bunch
Name: python-bunch
Version: 1.0.0
Release: 1%{?dist}
Summary: Python dictionary with attribute-style access
Group: Development/Languages
License: MIT
URL: http://tire.less.ly/hacking/bunch
Source0: http://pypi.python.org/packages/source/b/bunch/bunch-1.0.0.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: dos2unix
%if 0%{?fedora} > 12 || 0%{?rhel}
BuildRequires: python-setuptools
%else
BuildRequires: python-setuptools-devel
%endif
%description
python-bunch provides a python class which can perform as a dict whose keys are
also accessible as attributes, similar to JavaScript objects. For instance::
>>> import bunch
>>> people = bunch.Bunch({'alice': 'here', 'bob': 'there'})
>>> print people['alice'], people.alice
here here
The piece of python-bunch that sets it apart from similar modules found inside
other projects is the bunchify() function which recursively converts from
a dict to a Bunch::
>>> multi_level = {'array': ['scalar', {'mapping': 'to show recursion'} ]}
>>> bunch.bunchify(multi_level)
Bunch(array=['scalar', Bunch(mapping='to show recursion')])
%prep
%setup -q -n %{srcname}-%{version}
dos2unix LICENSE.txt README.txt
%build
%{__python} setup.py build
%install
rm -rf %{buildroot}
%{__python} setup.py install --skip-build --root %{buildroot}
rm %{buildroot}%{python_sitelib}/bunch/test.*
%clean
rm -rf %{buildroot}
%check
PYTHONPATH=build/lib python build/lib/bunch/test.py
%files
%defattr(-,root,root,-)
%doc LICENSE.txt README.txt
%{python_sitelib}/*
%changelog
* Fri Mar 19 2010 Toshio Kuratomi <toshio@fedoraproject.org> - 1.0.0-1
- Initial Fedora Build