Gifts budget (4 points) ======================= A group of persons (family, friends, etc.) is going to analyse data concerning Christmas gifts. They have a file in which each line corresponds to a gift and has 4 data fields: the name of the person that has bought the gift (:py:class:`str`), the name of the person that has received it (:py:class:`str`), the price of this gift in euros (:py:class:`int`) and the holiday in which this gift has been offered (:py:class:`str`). You can assume that no-one has given more than one gift to the same person in the same Christmas event. The last data field may have different names referring to the same holiday but they will all contain a *characterization string*. Moreover, these names may include uppercase and lowercase letters. For example, the names ``'Els tres reis'``, ``"Els Reis d'Orient"`` and ``'reis'`` refer to the same holiday and their characterization string is ``'reis'``. Two examples of such a file are files :download:`gifts1.txt` and :download:`gifts2.txt` that you must download in your working folder. Next the 5 first lines of file :download:`gifts1.txt` are shown: .. literalinclude:: gifts1.txt :language: text :lines: 1-5 Besides this file, this group of persons will need a dictionary (:py:class:`dict`) with an item for each person that has bought a gift. The key of this dictionary is the name of this person (:py:class:`str`) and the value is a list with two items; the first one is the number of persons that have received a gift from this person (:py:class:`int`) and the second one is the total amount spent in gifts by this person (:py:class:`int`). Save the two following functions to file ``gifts.py``. 1. Write function :py:func:`gifts1` that takes the name of a file as the one described (:py:class:`str`) and a characterization string (:py:class:`str`) and returns a dictionary (:py:class:`dict`) as the one described, for those gifts given in the holiday corresponding to the characterization string (2.5 points). Examples: .. literalinclude:: test-gifts1.txt :language: python :lines: 3-9 .. note:: You have more tests in file :download:`test-gifts1.txt` 2. Write function :py:func:`gifts2` that takes a dictionary (:py:class:`dict`) as the one described and a characterization string (:py:class:`str`) and creates a file. The name of this file begins by the letter ``'f'``, continues with the characterization string and has the extension ``'txt'``. Example: for the characterization string ``'reis'``, the name of the file is ``'freis.txt'``. Each line of this file corresponds to an item of the dictionary and has three data fields separated by a hyphen: the name of the person and the two integers in the list, in the same order. Lines in this file may be in any order (1.5 points). Examples: .. literalinclude:: test-gifts2.txt :language: python :lines: 3-9 .. note:: You have more tests in file :download:`test-gifts2.txt`