Phill has proposed merging lp:~phill-ridout/openlp/pathlib2 into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/pathlib2/+merge/328694
Part 2
Changed the pathedit widget over to using pathlib
Added a 'patched' file dialog
Added a few utility methods
lp:~phill-ridout/openlp/pathlib2 (revision 2763)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/2125/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/2033/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1938/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Code_Analysis/1315/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Test_Coverage/1157/
[SUCCESS] https://ci.openlp.io/job/Branch-04c-Code_Analysis2/287/
[FAILURE] https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/132/
Stopping after failure
--
Your team OpenLP Core is subscribed to branch lp:openlp.
=== added file 'openlp/core/common/path.py'
--- openlp/core/common/path.py 1970-01-01 00:00:00 +
+++ openlp/core/common/path.py 2017-08-07 21:22:21 +
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###
+# OpenLP - Open Source Lyrics Projection #
+# --- #
+# Copyright (c) 2008-2017 OpenLP Developers #
+# --- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for#
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###
+
+from pathlib import Path
+
+
+def path_to_str(path):
+"""
+A utility function to convert a Path object or NoneType to a string equivalent.
+
+:param path: The value to convert to a string
+:type: pathlib.Path or None
+
+:return: An empty string if :param:`path` is None, else a string representation of the :param:`path`
+:rtype: str
+"""
+if not isinstance(path, Path) and path is not None:
+raise TypeError('parameter \'path\' must be of type Path or NoneType')
+if path is None:
+return ''
+else:
+return str(path)
+
+
+def str_to_path(string):
+"""
+A utility function to convert a str object to a Path or NoneType.
+
+This function is of particular use because initating a Path object with an empty string causes the Path object to
+point to the current working directory.
+
+:param string: The string to convert
+:type string: str
+
+:return: None if :param:`string` is empty, or a Path object representation of :param:`string`
+:rtype: pathlib.Path or None
+"""
+if not isinstance(string, str):
+raise TypeError('parameter \'string\' must be of type str')
+if string == '':
+return None
+return Path(string)
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2017-08-06 07:23:26 +
+++ openlp/core/lib/__init__.py 2017-08-07 21:22:21 +
@@ -608,8 +608,42 @@
return list_to_string
+def replace_params(args, kwargs, params):
+"""
+Apply a transformation function to the specified args or kwargs
+
+:param args: Positional arguments
+:type args: (,)
+
+:param kwargs: Key Word arguments
+:type kwargs: dict
+
+:param params: A tuple of tuples with the position and the key word to replace.
+:type params: ((int, str, path_to_str),)
+
+:return: The modified positional and keyword arguments
+:rtype: (tuple, dict)
+
+
+Usage:
+Take a method with the following signature, and assume we which to apply the str function to arg2:
+def method(arg1=None, arg2=None, arg3=None)
+
+As arg2 can be specified postitionally as the second argument (1 with a zero index) or as a keyword, the we
+would call this function as follows:
+
+