mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
create dir if it doesn't exist
This commit is contained in:
parent
b6d1ecc0af
commit
16dd596bb2
2 changed files with 8 additions and 2 deletions
|
@ -40,8 +40,11 @@ class EncryptedJournal(Journal):
|
||||||
"""Opens the journal file defined in the config and parses it into a list of Entries.
|
"""Opens the journal file defined in the config and parses it into a list of Entries.
|
||||||
Entries have the form (date, title, body)."""
|
Entries have the form (date, title, body)."""
|
||||||
filename = filename or self.config["journal"]
|
filename = filename or self.config["journal"]
|
||||||
|
dirname = os.path.dirname(filename)
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
|
if not os.path.isdir(dirname):
|
||||||
|
print(f"[Directory {dirname} created]")
|
||||||
|
os.mkdir(dirname)
|
||||||
self.create_file(filename)
|
self.create_file(filename)
|
||||||
self.password = util.create_password(self.name)
|
self.password = util.create_password(self.name)
|
||||||
print(
|
print(
|
||||||
|
|
|
@ -74,8 +74,11 @@ class Journal:
|
||||||
"""Opens the journal file defined in the config and parses it into a list of Entries.
|
"""Opens the journal file defined in the config and parses it into a list of Entries.
|
||||||
Entries have the form (date, title, body)."""
|
Entries have the form (date, title, body)."""
|
||||||
filename = filename or self.config["journal"]
|
filename = filename or self.config["journal"]
|
||||||
|
dirname = os.path.dirname(filename)
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
|
if not os.path.isdir(dirname):
|
||||||
|
print(f"[Directory {dirname} created]")
|
||||||
|
os.mkdir(dirname)
|
||||||
self.create_file(filename)
|
self.create_file(filename)
|
||||||
print(f"[Journal '{self.name}' created at {filename}]", file=sys.stderr)
|
print(f"[Journal '{self.name}' created at {filename}]", file=sys.stderr)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue