Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def open(self, filename=None):
"""Opens the journal file defined in the config and parses it into a list of Entries.
Entries have the form (date, title, body)."""
filename = filename or self.config['journal']
if not os.path.exists(filename):
self.create_file(filename)
self.password = util.create_password(self.name)
print(f"Encrypted journal '{self.name}' created at {filename}", file=sys.stderr)
text = self._load(filename)
self.entries = self._parse(text)
self.sort()
log.debug("opened %s with %d entries", self.__class__.__name__, len(self))
return self
def from_journal(cls, other: Journal):
new_journal = super().from_journal(other)
new_journal.password = other.password if hasattr(other, "password") else util.create_password(other.name)
return new_journal