aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMykyta Holubakha <hilobakho@gmail.com>2017-07-07 10:40:11 +0300
committerMykyta Holubakha <hilobakho@gmail.com>2017-07-18 23:26:27 +0300
commit1c7929604b84d982296f082c060fcc305fd9146e (patch)
tree7bba82a909ec6596d6c9572587241a8ea9b51a89 /pomu/util/misc.py
parentFixed a logic error in Dispatcher (diff)
downloadpomu-1c7929604b84d982296f082c060fcc305fd9146e.tar.gz
pomu-1c7929604b84d982296f082c060fcc305fd9146e.tar.bz2
pomu-1c7929604b84d982296f082c060fcc305fd9146e.zip
Overhauled patching support
dropped patch package source module added --patch option to the install command added a patch command to patch an existing package integrated patch support into the Package class created a MergedPackage module for operations on packages already in the pomu repo added ways to patch an existing package added a base package source module (template), with base classes for package-specific metadata and the source module per se added a list_add utility function implemented and_, and_then, and or in util.result
Diffstat (limited to 'pomu/util/misc.py')
-rw-r--r--pomu/util/misc.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/pomu/util/misc.py b/pomu/util/misc.py
new file mode 100644
index 0000000..a6ebb1b
--- /dev/null
+++ b/pomu/util/misc.py
@@ -0,0 +1,22 @@
+"""Miscellaneous utility functions"""
+
+def list_add(dst, src):
+ """
+ Extends the target list with a scalar, or contents of the given list
+ """
+ if isinstance(src, list):
+ dst.extend(src)
+ else:
+ dst.append(src)
+
+
+def pivot(string, idx, keep_pivot=False):
+ """
+ A function to split a string in two, pivoting at string[idx].
+ If keep_pivot is set, the pivot character is included in the second string.
+ Alternatively, it is omitted.
+ """
+ if keep_pivot:
+ return (string[:idx], string[idx:])
+ else:
+ return (string[:idx], string[idx+1:])