<commit_before>#! /usr/bin/python3
import time
import datetime
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))


from backend.firebase_util import send_fcm, put_feed_into_db
from backend.reddit_util import submit_to_reddit, edit_submission, delete_submission
from backend.scrape_util import format_text
from backend.rss_util import parse_feed, Feed
from backend.scopes import SCOPE_NEWS, SCOPE_UPLOADPLAN, SCOPE_PIETCAST

old_feed = None
submission_url = ""

def in_between_time(start_hour, end_hour):
    now = int(datetime.datetime.now().hour)
    if start_hour <= end_hour:
        return start_hour <= now < end_hour
    else:  # over midnight e.g., 23-04
        return start_hour <= now or now < end_hour


def write(text, filename):
    with open(filename, "w+") as text_file:
        print(text, file=text_file)


def read(filename):
    try:
        with open(filename, "r") as text_file:
            return text_file.read().rstrip()
    except Exception:
        print("No file created yet? ENOENT")
        return ""
		
		
def smart_truncate(content, link, length=220):
    if not len(content) <= length:
        content = content[:length].rsplit(' ', 1)[0] + '...  '
		
    return content + "<a href=\"" + link + "\">Auf pietsmiet.de weiterlesen <span>→</span></a>"<commit_msg>add encoding for max compatibility with other linux systems<commit_after>#! /usr/bin/python3
# -*- coding: utf-8 -*-
import time
import datetime
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))


from backend.firebase_util import send_fcm, put_feed_into_db
from backend.reddit_util import submit_to_reddit, edit_submission, delete_submission
from backend.scrape_util import format_text
from backend.rss_util import parse_feed, Feed
from backend.scopes import SCOPE_NEWS, SCOPE_UPLOADPLAN, SCOPE_PIETCAST

old_feed = None
submission_url = ""

def in_between_time(start_hour, end_hour):
    now = int(datetime.datetime.now().hour)
    if start_hour <= end_hour:
        return start_hour <= now < end_hour
    else:  # over midnight e.g., 23-04
        return start_hour <= now or now < end_hour


def write(text, filename):
    with open(filename, "w+", encoding='utf-8') as text_file:
        print(text, file=text_file)


def read(filename):
    try:
        with open(filename, "r", encoding='utf-8') as text_file:
            return text_file.read().rstrip()
    except Exception:
        print("No file created yet? ENOENT")
        return ""
		
		
def smart_truncate(content, link, length=220):
    if not len(content) <= length:
        content = content[:length].rsplit(' ', 1)[0] + '...  '
		
    return content + "<a href=\"" + link + "\">Auf pietsmiet.de weiterlesen <span>→</span></a>"
{'fraction_non_alphanumeric': 0.12218999274836838, 'fraction_numerical': 0.008339376359680928, 'mean_word_length': 3.6683587140439933, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 11, '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': '723872', 'n_tokens_mistral': 935, 'n_tokens_neox': 901, 'n_words': 233}