![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package python-odorik for openSUSE:Factory checked in at 2015-07-14 17:44:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-odorik (Old) and /work/SRC/openSUSE:Factory/.python-odorik.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-odorik" Changes: -------- --- /work/SRC/openSUSE:Factory/python-odorik/python-odorik.changes 2015-05-22 09:55:07.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-odorik.new/python-odorik.changes 2015-07-14 17:46:07.000000000 +0200 @@ -1,0 +2,8 @@ +Mon Jul 13 09:56:24 UTC 2015 - mcihar@suse.cz + +- Update to 0.5: + * Documentation translated to Czech language. + * More detailed summaries for calls and messages. + * Added options for filtering calls by status and direction. + +------------------------------------------------------------------- Old: ---- odorik-0.4.tar.bz2 New: ---- odorik-0.5.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-odorik.spec ++++++ --- /var/tmp/diff_new_pack.1fVhSn/_old 2015-07-14 17:46:07.000000000 +0200 +++ /var/tmp/diff_new_pack.1fVhSn/_new 2015-07-14 17:46:07.000000000 +0200 @@ -17,7 +17,7 @@ Name: python-odorik -Version: 0.4 +Version: 0.5 Release: 0 Summary: Python module for Odorik API License: GPL-3.0+ ++++++ odorik-0.4.tar.bz2 -> odorik-0.5.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/PKG-INFO new/odorik-0.5/PKG-INFO --- old/odorik-0.4/PKG-INFO 2015-05-20 14:50:46.000000000 +0200 +++ new/odorik-0.5/PKG-INFO 2015-07-13 10:54:59.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: odorik -Version: 0.4 +Version: 0.5 Summary: Python module for Odorik API. Home-page: http://cihar.com/software/odorik/ Author: Michal Čihař @@ -26,6 +26,10 @@ :target: https://pypi.python.org/pypi/odorik :alt: PyPI package + .. image:: https://hosted.weblate.org/widgets/odorik/-/svg-badge.svg + :alt: Translation status + :target: https://hosted.weblate.org/engage/odorik/?utm_source=widget + Documentation ------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/README.rst new/odorik-0.5/README.rst --- old/odorik-0.4/README.rst 2015-05-20 11:24:20.000000000 +0200 +++ new/odorik-0.5/README.rst 2015-05-21 09:53:39.000000000 +0200 @@ -17,6 +17,10 @@ :target: https://pypi.python.org/pypi/odorik :alt: PyPI package +.. image:: https://hosted.weblate.org/widgets/odorik/-/svg-badge.svg + :alt: Translation status + :target: https://hosted.weblate.org/engage/odorik/?utm_source=widget + Documentation ------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/docs/command.rst new/odorik-0.5/docs/command.rst --- old/odorik-0.4/docs/command.rst 2015-05-20 11:24:43.000000000 +0200 +++ new/odorik-0.5/docs/command.rst 2015-07-13 10:42:17.000000000 +0200 @@ -82,7 +82,7 @@ See :ref:`interval` for information how to specify date period. -.. option:: calls [--list] [--line LINE] [DATE PERIOD] +.. option:: calls [--list] [--line LINE] [--direction {in,out,redirected}] [--status {answered,missed}] [DATE PERIOD] Prints calls usage. @@ -90,6 +90,8 @@ The result can be also limited to given line by using ``--line``. + You can additionally filter calls by ``--status`` or ``--direction``. + See :ref:`interval` for information how to specify date period. .. option:: sms [--list] [--line LINE] [DATE PERIOD] @@ -168,7 +170,7 @@ by environment variables ``XDG_CONFIG_HOME`` or ``XDG_CONFIG_DIRS``. Following settings can be configured in the ``[odorik]`` section (you can -customize this by :option:`--config-option`): +customize this by :option:`--config-section`): .. describe:: user diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/docs/conf.py new/odorik-0.5/docs/conf.py --- old/odorik-0.4/docs/conf.py 2015-05-19 18:37:34.000000000 +0200 +++ new/odorik-0.5/docs/conf.py 2015-05-21 09:53:39.000000000 +0200 @@ -364,3 +364,8 @@ # If false, no index is generated. #epub_use_index = True + + +# -- Options for gettext output ------------------------------------------- +locale_dirs = ['locale/'] +gettext_compact = False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/docs/develop.rst new/odorik-0.5/docs/develop.rst --- old/odorik-0.4/docs/develop.rst 2015-05-19 18:37:34.000000000 +0200 +++ new/odorik-0.5/docs/develop.rst 2015-05-21 09:53:39.000000000 +0200 @@ -23,7 +23,7 @@ Travis CI for running the testsuite https://travis-ci.org/nijel/odorik -Codeciv for reporting the testsuite coverage +Codecov for reporting the testsuite coverage https://codecov.io/github/nijel/odorik Landscape for checking quality of our code https://landscape.io/github/nijel/odorik/master diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/docs/news.rst new/odorik-0.5/docs/news.rst --- old/odorik-0.4/docs/news.rst 2015-05-20 10:17:30.000000000 +0200 +++ new/odorik-0.5/docs/news.rst 2015-07-13 10:52:27.000000000 +0200 @@ -1,6 +1,13 @@ Changes ======= +0.5 +--- + +* Documentation translated to Czech language. +* More detailed summaries for calls and messages. +* Added options for filtering calls by status and direction. + 0.4 --- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/docs/python.rst new/odorik-0.5/docs/python.rst --- old/odorik-0.4/docs/python.rst 2015-05-19 18:37:34.000000000 +0200 +++ new/odorik-0.5/docs/python.rst 2015-07-13 10:29:50.000000000 +0200 @@ -95,7 +95,7 @@ Initiates callback. - .. method:: calls(from_date, to_date, line=None): + .. method:: calls(from_date, to_date, line=None, status=None, direction=None): :param from_date: Starting date :type from_date: datetime.datetime @@ -103,6 +103,10 @@ :type to_date: datetime.datetime :param line: Line to use for listing :type line: string or None + :param status: Call status, one of 'answered', 'missed' + :type status: string + :param direction: Call direction, one of 'in', 'out', 'redirected' + :type direction: string :rtype: list Returns list of calls in given interval. Optionally filtered for given diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/odorik/__init__.py new/odorik-0.5/odorik/__init__.py --- old/odorik-0.4/odorik/__init__.py 2015-05-20 11:20:25.000000000 +0200 +++ new/odorik-0.5/odorik/__init__.py 2015-07-13 10:37:46.000000000 +0200 @@ -28,7 +28,7 @@ import json -__version__ = '0.4' +__version__ = '0.5' API_URL = 'https://www.odorik.cz/api/v1/' DEVEL_URL = 'https://github.com/nijel/odorik' @@ -122,7 +122,7 @@ self._check_response(response) return response - def calls(self, from_date, to_date, line=None): + def calls(self, from_date, to_date, line=None, status=None, direction=None): """Return list of calls.""" args = { 'from': from_date.isoformat(), @@ -130,6 +130,10 @@ } if line is not None: args['line'] = line + if status is not None: + args['status'] = status + if direction is not None: + args['direction'] = direction return self.get_json('calls.json', args) def sms(self, from_date, to_date, line=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/odorik/main.py new/odorik-0.5/odorik/main.py --- old/odorik-0.4/odorik/main.py 2015-05-20 11:21:36.000000000 +0200 +++ new/odorik-0.5/odorik/main.py 2015-07-13 10:28:27.000000000 +0200 @@ -37,8 +37,18 @@ SORT_ORDER = [ 'id', 'public_number', - 'call_count', + 'count', + 'count_in', + 'count_out', 'sms_count', + 'sms_count_in', + 'sms_count_out', + 'call_count', + 'call_count_in', + 'call_count_out', + 'call_length', + 'call_length_in', + 'call_length_out', 'bytes_down', 'bytes_up', 'bytes_total', @@ -46,6 +56,8 @@ 'call_price', 'sms_price', 'length', + 'length_in', + 'length_out', 'ringing_length', 'price', ] @@ -194,6 +206,58 @@ result[field] += value[field] return result + @staticmethod + def summary_group(values, fields, group, groups): + """Calculate summary of values groupped by attribute.""" + result = {} + for field in fields: + for group_name in groups: + result['{0}_{1}'.format(field, group_name)] = 0 + + for value in values: + group_name = value[group] + for field in fields: + result['{0}_{1}'.format(field, group_name)] += value[field] + return result + + @classmethod + def calls_summary(cls, calls): + """Wrapper for getting calls summary.""" + result = cls.summary(calls, ('price', 'length')) + result.update( + cls.summary_group( + calls, ('length',), 'direction', ('in', 'out', 'redirected') + ) + ) + result['count'] = len(calls) + result['count_in'] = cls.count_direction(calls, 'in') + result['count_out'] = cls.count_direction(calls, 'out') + return result + + @classmethod + def sms_summary(cls, messages): + """Wrapper for getting sms summary.""" + result = cls.summary(messages, ('price',)) + result['count'] = len(messages) + result['count_in'] = cls.count_direction(messages, 'in') + result['count_out'] = cls.count_direction(messages, 'out') + return result + + @classmethod + def data_summary(cls, data_usage): + """Wrapper for getting data summary.""" + return cls.summary( + data_usage, + ('bytes_total', 'bytes_down', 'bytes_up', 'price') + ) + + @staticmethod + def count_direction(values, direction): + """Counts items with matching direction""" + return len( + [value for value in values if value['direction'] == direction] + ) + def println(self, line): """Print single line to output.""" print(line, file=self.stdout) @@ -209,6 +273,8 @@ return '{0:.2f}'.format(value) elif isinstance(value, int): return '{0}'.format(value) + elif value is None: + return '' return value @classmethod @@ -297,6 +363,8 @@ """Print value.""" header = None if isinstance(value, list): + if len(value) == 0: + return header = sorted(value[0].keys(), key=sort_key) if self.args.format == 'json': @@ -516,25 +584,36 @@ parser = super(Calls, cls).add_parser(subparser) cls.add_list_option(parser) cls.add_line_option(parser) + parser.add_argument( + '--direction', + choices=('in', 'out', 'redirected'), + help='Direction of call', + ) + parser.add_argument( + '--status', + choices=('answered', 'missed'), + help='Status of call', + ) return parser def run(self): """Main execution of the command.""" from_date, to_date = self.get_interval() + args = {} + if self.args.status: + args['status'] = self.args.status + if self.args.direction: + args['direction'] = self.args.direction calls = self.odorik.calls( from_date, to_date, self.resolve('lines', self.args.line), + **args ) if self.args.list: self.print(calls) else: - self.print( - self.summary( - calls, - ('price', 'length', 'ringing_length') - ) - ) + self.print(self.calls_summary(calls)) @register_command @@ -564,12 +643,7 @@ if self.args.list: self.print(sms) else: - self.print( - self.summary( - sms, - ('price',) - ) - ) + self.print(self.sms_summary(sms)) @register_command @@ -607,10 +681,7 @@ if self.args.list: return data_usage else: - return self.summary( - data_usage, - ('bytes_total', 'bytes_down', 'bytes_up', 'price') - ) + return self.data_summary(data_usage) def run(self): """Main execution of the command.""" @@ -679,20 +750,21 @@ to_date, line['public_number'] ) - messages_summary = self.summary(messages, ('price',)) - calls_summary = self.summary( - calls, - ('price', 'length'), - ) - data_summary = self.summary( - data_usage, - ('bytes_total', 'bytes_down', 'bytes_up', 'price') - ) + messages_summary = self.sms_summary(messages) + calls_summary = self.calls_summary(calls) + data_summary = self.data_summary(data_usage) return { 'public_number': line['public_number'], 'id': line['id'], - 'call_count': len(calls), - 'sms_count': len(messages), + 'call_count': calls_summary['count'], + 'call_count_in': calls_summary['count_in'], + 'call_count_out': calls_summary['count_out'], + 'call_length': calls_summary['length'], + 'call_length_in': calls_summary['length_in'], + 'call_length_out': calls_summary['length_out'], + 'sms_count': messages_summary['count'], + 'sms_count_in': messages_summary['count_in'], + 'sms_count_out': messages_summary['count_out'], 'bytes_total': data_summary['bytes_total'], 'data_price': data_summary['price'], 'call_price': calls_summary['price'], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/odorik/test_main.py new/odorik-0.5/odorik/test_main.py --- old/odorik-0.4/odorik/test_main.py 2015-05-20 11:19:56.000000000 +0200 +++ new/odorik-0.5/odorik/test_main.py 2015-07-13 10:30:43.000000000 +0200 @@ -347,6 +347,15 @@ self.assertIn('554.03', output) @httpretty.activate + def test_calls_filter(self): + """Test getting calls list.""" + register_uris() + output = execute( + ['calls', '--list', '--direction', 'in', '--status', 'answered'] + ) + self.assertIn('554.03', output) + + @httpretty.activate def test_calls_line(self): """Test getting calls summary for line.""" register_uris() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/odorik-0.4/odorik.egg-info/PKG-INFO new/odorik-0.5/odorik.egg-info/PKG-INFO --- old/odorik-0.4/odorik.egg-info/PKG-INFO 2015-05-20 14:50:45.000000000 +0200 +++ new/odorik-0.5/odorik.egg-info/PKG-INFO 2015-07-13 10:54:59.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: odorik -Version: 0.4 +Version: 0.5 Summary: Python module for Odorik API. Home-page: http://cihar.com/software/odorik/ Author: Michal Čihař @@ -26,6 +26,10 @@ :target: https://pypi.python.org/pypi/odorik :alt: PyPI package + .. image:: https://hosted.weblate.org/widgets/odorik/-/svg-badge.svg + :alt: Translation status + :target: https://hosted.weblate.org/engage/odorik/?utm_source=widget + Documentation -------------