<commit_before># -*- coding: utf-8 -*-

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))

import facebook
import websites
import feeds
#import beachstatus
from event import EventVault
import logging
import datetime
import time
import locale

locale.setlocale(locale.LC_TIME, '')  # locale for date, time an the infamous german "Umalaute"

LOG_FILENAME = os.path.join(os.path.dirname(__file__), 'log.log')
logging.basicConfig(filename=LOG_FILENAME, level=logging.ERROR)


class HeuteInMannheim:

    def __init__(self):
        super(HeuteInMannheim, self).__init__()
        self.vault = EventVault()  # Initialize main Storage Object

        # Initialize Scrapers
        self.facebook_scraper = facebook.FacebookScraper(self.vault)
        self.website_scraper = websites.WebsiteScraper(self.vault)
        self.feed_scraper = feeds.FeedScraper(self.vault)

        self.events = self.vault.get_events_for_date(datetime.date.today())
        #self.events = self.vault.get_all_events()  # Only for testing/debugging

#        self.beach_status = beachstatus.BeachStatus()
#        self.beach_status = self.beach_status.get_status()

        self.state_output = self.make_html()
        self.write_html()  # Make initial index.html

        logging.info("Total amount of Events: " + str(len(self.vault.get_all_events())))

        #self.loop()  # Currently not used, since I use Cronjobs

    def loop(self):
        """Function to implement a main-loop.
        Repopulates self.events and regenerates self.state_output if it differs."""
        while True:
            time.sleep(3600)
            logging.info("Getting new Events...")
            self.facebook_scraper.go()
            self.website_scraper.go()
            self.feed_scraper.go()
            self.events = self.vault.get_events_for_date(datetime.date.today())
            newstate_output = self.make_html()
            if self.state_output == newstate_output:
                logging.info("New state! --> new HTML!")
                self.state_output = newstate_output
                self.write_html()

    def make_html(self):
        """Generate HTML output from collected events"""
        output = """<!DOCTYPE html>
        <html>
        <head>
            <title>Heute in Mannheim</title>
            <link href="style.css" media="all" rel="stylesheet" type="text/css">
            <meta http-equiv="content-type" content="text/html; charset=utf-8">
            <meta name="description" content="Heute in Mannheim ist eine simple Website, die dir Events in Mannheim anzeigt. Unabhängig, werbefrei, unkommerziell, free as in freedom and free as in beer.">
            <meta name="apple-mobile-web-app-capable" content="yes"><commit_msg>remove loop<commit_after># -*- coding: utf-8 -*-

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))

import facebook
import websites
import feeds
#import beachstatus
from event import EventVault
import logging
import datetime
import time
import locale

locale.setlocale(locale.LC_TIME, '')  # locale for date, time an the infamous german "Umalaute"

LOG_FILENAME = os.path.join(os.path.dirname(__file__), 'log.log')
logging.basicConfig(filename=LOG_FILENAME, level=logging.ERROR)


class HeuteInMannheim:

    def __init__(self):
        super(HeuteInMannheim, self).__init__()
        self.vault = EventVault()  # Initialize main Storage Object

        # Initialize Scrapers
        self.facebook_scraper = facebook.FacebookScraper(self.vault)
        self.website_scraper = websites.WebsiteScraper(self.vault)
        self.feed_scraper = feeds.FeedScraper(self.vault)

        self.events = self.vault.get_events_for_date(datetime.date.today())
        #self.events = self.vault.get_all_events()  # Only for testing/debugging

#        self.beach_status = beachstatus.BeachStatus()
#        self.beach_status = self.beach_status.get_status()

        self.state_output = self.make_html()
        self.write_html()  # Make initial index.html

        logging.info("Total amount of Events: " + str(len(self.vault.get_all_events())))

    def make_html(self):
        """Generate HTML output from collected events"""
        output = """<!DOCTYPE html>
        <html>
        <head>
            <title>Heute in Mannheim</title>
            <link href="style.css" media="all" rel="stylesheet" type="text/css">
            <meta http-equiv="content-type" content="text/html; charset=utf-8">
            <meta name="description" content="Heute in Mannheim ist eine simple Website, die dir Events in Mannheim anzeigt. Unabhängig, werbefrei, unkommerziell, free as in freedom and free as in beer.">
            <meta name="apple-mobile-web-app-capable" content="yes">
{'fraction_non_alphanumeric': 0.11354539709290078, 'fraction_numerical': 0.0016852749104697704, 'mean_word_length': 3.093103448275862, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1243831', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1419, 'n_words': 328}