about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/taskw
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-12-01 19:00:09 +0100
committerAlyssa Ross <hi@alyssa.is>2023-12-01 19:00:09 +0100
commit9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d (patch)
tree4368f9e4cb2d5b93a956c085337e45cb70f1e331 /nixpkgs/pkgs/development/python-modules/taskw
parenta9cbfb6941b47d6f50129e6e36927882392daed7 (diff)
parent2344fe1da14cb08b0c18743b207995f9b8597915 (diff)
downloadnixlib-9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d.tar
nixlib-9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d.tar.gz
nixlib-9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d.tar.bz2
nixlib-9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d.tar.lz
nixlib-9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d.tar.xz
nixlib-9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d.tar.zst
nixlib-9e9b07490d5bab5d115c66b80bdb10ff0c11ed8d.zip
Merge https://github.com/NixOS/nixpkgs
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/taskw')
-rw-r--r--nixpkgs/pkgs/development/python-modules/taskw/default.nix6
-rw-r--r--nixpkgs/pkgs/development/python-modules/taskw/support-relative-path-in-taskrc.patch79
2 files changed, 84 insertions, 1 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/taskw/default.nix b/nixpkgs/pkgs/development/python-modules/taskw/default.nix
index 32e40801c6ea..5e9b2f3269e1 100644
--- a/nixpkgs/pkgs/development/python-modules/taskw/default.nix
+++ b/nixpkgs/pkgs/development/python-modules/taskw/default.nix
@@ -20,7 +20,11 @@ buildPythonPackage rec {
     hash = "sha256-EQm9+b3nqbMqUAejAsh4MD/2UYi2QiWsdKMomkxUi90=";
   };
 
-  patches = [ ./use-template-for-taskwarrior-install-path.patch ];
+  patches = [
+    ./use-template-for-taskwarrior-install-path.patch
+    # Remove when https://github.com/ralphbean/taskw/pull/151 is merged.
+    ./support-relative-path-in-taskrc.patch
+  ];
   postPatch = ''
     substituteInPlace taskw/warrior.py \
       --replace '@@taskwarrior@@' '${pkgs.taskwarrior}'
diff --git a/nixpkgs/pkgs/development/python-modules/taskw/support-relative-path-in-taskrc.patch b/nixpkgs/pkgs/development/python-modules/taskw/support-relative-path-in-taskrc.patch
new file mode 100644
index 000000000000..25b1b28eff5c
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/taskw/support-relative-path-in-taskrc.patch
@@ -0,0 +1,79 @@
+From 958b63ceec02b179482141cfb846ddbcae711a1b Mon Sep 17 00:00:00 2001
+From: Scott Mcdermott <scott@smemsh.net>
+Date: Sat, 28 Aug 2021 21:12:38 -0700
+Subject: [PATCH] RcFile: _read: try taskrc directory when trying to load
+ includes
+
+Taskwarrior itself tries includes as absolute path, then cwd, then
+relative to rcfile, then in various search paths (see
+GothenburgBitFactory/libshared -> src/Configuration.cpp ->
+Configuration::parse()).
+
+We won't try to duplicate that whole arrangement here, but at least look
+relative to the rcfile in addition to cwd/absolute, like taskwarrior
+does.  This will allow specification as relative path in most cases.
+Otherwise, we'd have to chdir anyways because includes are always tried
+as-is by taskw.  They would only work if specified as absolute paths or
+if in cwd
+
+We use a TaskRc() class variable to store the rcdir because there could
+be an include chain and all the instances will need to know the same
+one, but will be processing different paths, so we have to capture the
+directory of the first one processed, ie the base rcfile.
+
+Fixes #150
+
+Co-authored-by: Raito Bezarius <masterancpp@gmail.com>
+---
+ taskw/taskrc.py | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/taskw/taskrc.py b/taskw/taskrc.py
+index 1b6f8e5..b72dee6 100644
+--- a/taskw/taskrc.py
++++ b/taskw/taskrc.py
+@@ -1,5 +1,6 @@
+ import logging
+ import os
++import os.path
+ 
+ from taskw.fields import (
+     ChoiceField,
+@@ -39,6 +40,7 @@ class TaskRc(dict):
+ 
+     """
+ 
++    rcdir = None
+     UDA_TYPE_MAP = {
+         'date': DateField,
+         'duration': DurationField,
+@@ -54,6 +56,8 @@ class TaskRc(dict):
+                     path
+                 )
+             )
++            if not self.rcdir:
++                TaskRc.rcdir = os.path.dirname(os.path.realpath(self.path))
+             config = self._read(self.path)
+         else:
+             self.path = None
+@@ -92,6 +96,17 @@ class TaskRc(dict):
+ 
+     def _read(self, path):
+         config = {}
++        if not os.path.exists(path) and TaskRc.rcdir is not None:
++            # include path may be given relative to dir of rcfile
++            oldpath = path
++            path = os.path.join(TaskRc.rcdir, oldpath)
++            if not os.path.exists(path):
++                logger.error(
++                    "rcfile does not exist, tried %s and %s",
++                    oldpath, path
++                )
++                raise FileNotFoundError
++
+         with open(path, 'r') as config_file:
+             for raw_line in config_file.readlines():
+                 line = sanitize(raw_line)
+-- 
+2.42.0
+