<commit_before>import os.path
from pathlib import Path
from datetime import datetime

from babel.dates import format_timedelta
from babel.dates import format_datetime

from pynote import config


def load_notes():
    path = Path(config.DATA)
    data = [Note(f) for f in path.iterdir()
            if f.is_file() and f.suffix not in config.IGNORE_EXTENSIONS]
    return sorted(data, key=lambda n: n.age)


class Note:

    def __init__(self, path):
        self.path = path
        self.title = path.stem
        if path.exists():
            with path.open() as f:
                self.content = f.read()
        else:
            path.touch()
        self.updated = self._getmtime()
        self.age = self._calc_age()

    def __repr__(self):
        return "{}('{}')".format(self.__class__.__name__, self.path)

    @classmethod
    def create(cls, title):
        if config.EXTENSION:
            path = Path(os.path.join(config.DATA, title + config.EXTENSION))
        else:
            path = Path(os.path.join(config.DATA, title))
        if path.exists():<commit_msg>Added is_encrypted attribute to container.Note<commit_after>import os.path
from pathlib import Path
from datetime import datetime

from babel.dates import format_timedelta
from babel.dates import format_datetime

from pynote import config


def load_notes():
    path = Path(config.DATA)
    data = [Note(f) for f in path.iterdir()
            if f.is_file() and f.suffix not in config.IGNORE_EXTENSIONS]
    return sorted(data, key=lambda n: n.age)


class Note:

    def __init__(self, path):
        self.path = path
        self.title = path.stem
        # Get content, if the file is not present create an empty one.
        if not path.exists():
            path.touch()
            self.content = ''
        else:
            with path.open() as f:
                self.content = f.read()

        # Check whether the note is encrypted or not.
        # It is indicated by the first suffix: my-note.crypt.txt
        if path.suffixes:
            if path.suffixes[0] == '.crypt':
                self.is_encrypted = True
            else:
                self.is_encrypted = False
        else:
            self.is_encrypted = False

        self.updated = self._getmtime()
        self.age = self._calc_age()

    def __repr__(self):
        return "{}('{}')".format(self.__class__.__name__, self.path)

    @classmethod
    def create(cls, title):
        if config.EXTENSION:
            path = Path(os.path.join(config.DATA, title + config.EXTENSION))
        else:
            path = Path(os.path.join(config.DATA, title))
        if path.exists():
{'fraction_non_alphanumeric': 0.10466439135381114, 'fraction_numerical': 0.0003792188092529389, 'mean_word_length': 2.1404761904761904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2714998', 'n_tokens_mistral': 808, 'n_tokens_neox': 776, 'n_words': 222}