Skip to content

Commit

Permalink
Add a storage class (#1225)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Nov 8, 2022
2 parents 2b8d510 + 0b44cf9 commit 5999e72
Show file tree
Hide file tree
Showing 74 changed files with 6,882 additions and 4,905 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Expand Up @@ -3707,8 +3707,8 @@ helpful feedback and issue reports for the new features added in this, and previ

**User Interface**

* Added a preferences dialog for the program settings. No longer necessary to edit the config file.
PR #30.
* Added a preferences dialog for the program settings. It is no longer necessary to edit the config
file. PR #30.
* The document viewer remembers scroll bar position when pressing `Ctrl+R` on a document already
being viewed. PR #28.
* Removed version number from windows title. PR #28.
Expand Down Expand Up @@ -3749,8 +3749,8 @@ helpful feedback and issue reports for the new features added in this, and previ
**Status Bar**

* Redesign of the status bar adding project and session stats as well as a session timer. PR #21.
* Project word count is written to the project file, which is needed for the session word count. PR
#21.
* Project word count is written to the project file, which is needed for the session word count.
PR #21.
* Closing a project now clears the status bar. PR #21.

**Editor**
Expand Down
21 changes: 19 additions & 2 deletions novelwriter/common.py
Expand Up @@ -25,6 +25,7 @@

import os
import json
import uuid
import hashlib
import logging

Expand Down Expand Up @@ -87,9 +88,10 @@ def checkBool(value, default):
if isinstance(value, bool):
return value
elif isinstance(value, str):
if value == "True":
check = value.lower()
if check in ("true", "yes", "on"):
return True
elif value == "False":
elif check in ("false", "no", "off"):
return False
else:
return default
Expand All @@ -113,6 +115,15 @@ def checkHandle(value, default, allowNone=False):
return default


def checkUuid(value, default):
"""Try to process a value as an uuid, or return a default.
"""
try:
return str(uuid.UUID(value))
except Exception:
return default


# =============================================================================================== #
# Validator Functions
# =============================================================================================== #
Expand Down Expand Up @@ -249,6 +260,12 @@ def simplified(string):
return " ".join(str(string).strip().split())


def yesNo(value):
"""Convert a boolean evaluated variable to a yes or no.
"""
return "yes" if value else "no"


def splitVersionNumber(value):
"""Split a version string on the form aa.bb.cc into major, minor
and patch, and computes an integer value aabbcc.
Expand Down
5 changes: 2 additions & 3 deletions novelwriter/core/__init__.py
Expand Up @@ -19,8 +19,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

from novelwriter.core.doctools import DocMerger, DocSplitter
from novelwriter.core.document import NWDoc
from novelwriter.core.coretools import DocMerger, DocSplitter, ProjectBuilder
from novelwriter.core.index import countWords
from novelwriter.core.project import NWProject
from novelwriter.core.spellcheck import NWSpellEnchant
Expand All @@ -31,8 +30,8 @@
__all__ = [
"DocMerger",
"DocSplitter",
"ProjectBuilder",
"countWords",
"NWDoc",
"NWProject",
"NWSpellEnchant",
"ToHtml",
Expand Down

0 comments on commit 5999e72

Please sign in to comment.