SIGACTor / sigactor /

import csv
from datetime import datetime
from .manual_activity import ManualActivity
import os
from .post import Post
import urllib.request
import yaml

class Home():
    def __init__(self):
        self.version = '0.1.19dev'

            '\nWelcome to SIGACTor ' + self.version + ', currently available '
            'for the Syria team and reading posts from the '
            "Syrian Observatory for Human Rights' Facebook Page."
        ) = [
            'Grid Prec',
            'Pro-regime KIA',
            'Pro-regime WIA',
            'Anti-regime KIA',
            'Anti-regime WIA',
            'Total KIA',
            'Total WIA',
            'Full Text',
            'Source Text',
            'Country Team',
            'Date Begin',
            'Date End',
            'Posted Date',

        self.source = input('\nWhat source should be retrieved? ')

        # print('\nPreparing CSV...') =
        self.csv_title ='%Y-%m-%d-%H%M') + '.csv'
        self.csv_directory = os.path.join(os.path.expanduser('~'), 'SIGACTS')
        self.csv_path = os.path.join(self.csv_directory, self.csv_title)

        print('\nPreparing locations...')
        locations = urllib.request.urlopen(
        self.locations = yaml.load(locations)

        # if not os.path.exists(self.csv_directory):
            # os.makedirs(self.csv_directory)

        # self.csvwrite(

        self.unchecked_values = [
            'Grid Prec',
            'Full Text',
            'Source Text',
            'Country Team',
            'Date Begin',
            'Date End',

        self.posts = []
        self.activities = []

        print('\nPreparing feed...')
        sohr = urllib.request.urlopen(
        self.sohr = yaml.load(sohr)

        while True:
            self.entered_date = input(
                '\nPlease enter a starting time. (YYYY-MM-DD-hhmm,'
                'or enter "m" to manually enter an activity) '

            if self.entered_date == 'm':

            self.entered_date += (

                self.start_date = datetime.strptime(
                    self.entered_date, '%Y-%m-%d-%H%M%z'
            except ValueError:
                print('Invalid date. ')

        self.stop = False
        for item in self.sohr:
            if self.stop:

            item_date = (
                item['date'].strftime('%Y-%m-%dT%H:%M:%S') + '+0000'
            item_date = datetime.strptime(item_date, '%Y-%m-%dT%H:%M:%S%z')

            if item_date >= self.start_date:
                self.posts.append(Post(self, item, item_date))

        # print(
            # '\nSaved CSV as', self.csv_path,
        # )

    def csvwrite(self, values):
        # with open(self.csv_path, 'a') as csvfile:
            # csvwriter = csv.writer(csvfile, dialect='excel')
            # csvwriter.writerow(values)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.