commit 411c31fdaac4ee19f4e9fad9871e5810813dfb2e
parent b72dcd95af18bf044e7e07c74e9e19a9480a6903
Author: lash <dev@holbrook.no>
Date: Mon, 21 Aug 2023 08:24:05 +0100
Avoid dir creation except add
Diffstat:
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
@@ -1,6 +1,7 @@
- 0.3.17:
* Add comments heading for comments section in html
* Reinstate sender information in html message render
+ * Restrict creating non-existing state directory except when adding issue
- 0.3.16:
* Add pypi project description
- 0.3.15:
diff --git a/piknik/cli/__init__.py b/piknik/cli/__init__.py
@@ -8,14 +8,14 @@ from piknik.crypto import PGPSigner
class Context:
- def __init__(self, arg, assembler, mode=0, gpg_home=os.environ.get('GPGHOME')):
+ def __init__(self, arg, assembler, mode=0, gpg_home=os.environ.get('GPGHOME'), create=True):
self.issue_id = arg.issue_id
self.files_dir = arg.files_dir
self.alias = getattr(arg, 'alias', None)
self.show_finished = getattr(arg, 'show_finished', False)
self.show_states = getattr(arg, 'state', [])
#self.store_factory = FileStoreFactory(arg.d)
- store_factory = FileStoreFactory(arg.d)
+ store_factory = FileStoreFactory(arg.d, create=create)
self.signer = None
sign_fn = None
if hasattr(arg, 's'):
diff --git a/piknik/runnable/cmd.py b/piknik/runnable/cmd.py
@@ -44,10 +44,12 @@ except ValueError:
arg, unknown = argp.parse_known_args(strargs)
m = None
+create = False
if arg.cmd == 'show':
m = importlib.import_module('piknik.cli.show')
elif arg.cmd == 'add':
m = importlib.import_module('piknik.cli.add')
+ create = True
elif arg.cmd == 'mod':
m = importlib.import_module('piknik.cli.mod')
elif arg.cmd == 'comment':
@@ -64,7 +66,7 @@ arg = argp.parse_args(sys.argv[1:])
if arg.v:
logg.setLevel(logging.DEBUG)
-m.ctx = Context(arg, m.assembler)
+m.ctx = Context(arg, m.assembler, create=create)
def main():
diff --git a/piknik/store/__init__.py b/piknik/store/__init__.py
@@ -82,10 +82,13 @@ class AliasDir:
class FileStoreFactory:
- def __init__(self, directory=None):
+ def __init__(self, directory=None, create=True):
if directory == None:
directory = os.path.join('.', '.piknik')
self.directory = directory
+ if not create:
+ if not os.path.exists(self.directory):
+ raise FileNotFoundError(self.directory)
def create_states(self, logger=None, default_state=None, verifier=None):
diff --git a/setup.cfg b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = piknik
-version = 0.3.18rc1
+version = 0.3.18rc2
description = CLI issue tracker
author = Louis Holbrook
author_email = dev@holbrook.no