mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 22:16:13 +02:00
Clean up help screen, get rid of util.py (#1027)
* More refactoring of cli.py break up code from cli.py (now in jrnl.py) up into smaller functions get rid of export mode move --encrypt and --decrypt to commands.py clean up the help screen even more update flag name for import * reorganize code, move around lots of functions * clean up import statements * move run function out of cli and into jrnl * rename confusingly named function * move editor function into editor file * rename parse_args.py to args.py to make room for more args functions * Fix error in test suite for windows I accidentally flipped the conditional, so this fixes it. Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com> * Update app description on help screen Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
7c3abb2625
commit
631e08a557
30 changed files with 981 additions and 775 deletions
|
@ -5,7 +5,9 @@ import os
|
|||
import re
|
||||
import sys
|
||||
|
||||
from ..util import RESET_COLOR, WARNING_COLOR
|
||||
from jrnl.color import RESET_COLOR
|
||||
from jrnl.color import WARNING_COLOR
|
||||
|
||||
from .text_exporter import TextExporter
|
||||
|
||||
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import os
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
from ..util import ERROR_COLOR, RESET_COLOR, slugify
|
||||
from jrnl.color import ERROR_COLOR
|
||||
from jrnl.color import RESET_COLOR
|
||||
|
||||
|
||||
class TextExporter:
|
||||
|
@ -35,7 +38,7 @@ class TextExporter:
|
|||
@classmethod
|
||||
def make_filename(cls, entry):
|
||||
return entry.date.strftime(
|
||||
"%Y-%m-%d_{}.{}".format(slugify(str(entry.title)), cls.extension)
|
||||
"%Y-%m-%d_{}.{}".format(cls._slugify(str(entry.title)), cls.extension)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -52,6 +55,15 @@ class TextExporter:
|
|||
)
|
||||
return "[Journal exported to {}]".format(path)
|
||||
|
||||
def _slugify(string):
|
||||
"""Slugifies a string.
|
||||
Based on public domain code from https://github.com/zacharyvoase/slugify
|
||||
"""
|
||||
normalized_string = str(unicodedata.normalize("NFKD", string))
|
||||
no_punctuation = re.sub(r"[^\w\s-]", "", normalized_string).strip().lower()
|
||||
slug = re.sub(r"[-\s]+", "-", no_punctuation)
|
||||
return slug
|
||||
|
||||
@classmethod
|
||||
def export(cls, journal, output=None):
|
||||
"""Exports to individual files if output is an existing path, or into
|
||||
|
|
|
@ -5,7 +5,10 @@ import os
|
|||
import re
|
||||
import sys
|
||||
|
||||
from ..util import ERROR_COLOR, RESET_COLOR, WARNING_COLOR
|
||||
from jrnl.color import ERROR_COLOR
|
||||
from jrnl.color import RESET_COLOR
|
||||
from jrnl.color import WARNING_COLOR
|
||||
|
||||
from .text_exporter import TextExporter
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue