Esempio n. 1
0
def process(input):
    gh_username = setup.get_gh_username()
    gh_password = setup.decrypt_password()
    github.Github(gh_username, gh_password)
    click.echo(chalk.blue('you are in git module'))
    click.echo('input = %s' % input)
    USER_CONFIG_FILE_PATH = get_config_file_paths()['USER_CONFIG_FILE_PATH']
    USER_CONFIG_FOLDER_PATH = util.get_folder_path_from_file_path(
        USER_CONFIG_FILE_PATH)
    repo = porcelain.init(USER_CONFIG_FOLDER_PATH)
    porcelain.add(repo)
    porcelain.commit(repo, "A sample commit")
    porcelain.remote_add(repo, ".yoda", "https://github.com/manparvesh/.yoda")
    porcelain.push(repo, "https://github.com/manparvesh/.yoda")
Esempio n. 2
0
import os
import pkgutil
# the main process


@click.group()
def learn():
    """
        The learn module
    """

# ----------------------- / vocabulary code -----------------------#


# config file path
VOCABULARY_CONFIG_FILE_PATH = get_config_file_paths()[
    "VOCABULARY_CONFIG_FILE_PATH"]
VOCABULARY_CONFIG_FOLDER_PATH = util.get_folder_path_from_file_path(
    VOCABULARY_CONFIG_FILE_PATH)

# getting words
words = {}
for line in pkgutil.get_data('yoda', 'resources/vocab-words.txt').split('\n'):
    line = line.strip()
    if len(line) > 0:
        (word, definition) = line.split(' - ')
        words[word.lower().strip()] = definition.strip()


def get_words_list():
    return words
Esempio n. 3
0
import calendar
import datetime
import errno
import os.path
import time
from os import listdir

import click

from config import get_config_file_paths
from util import *

# config file path
DIARY_CONFIG_FILE_PATH = get_config_file_paths()['DIARY_CONFIG_FILE_PATH']
DIARY_CONFIG_FOLDER_PATH = get_folder_path_from_file_path(
    DIARY_CONFIG_FILE_PATH)


def now_time():
    """
    get time
    :return:
    """
    return str(time.strftime("%H:%M:%S"))


def now_date():
    """
    get date
    :return:
    """
Esempio n. 4
0
import json
import os.path
import time
import chalk
import click
from Crypto.Cipher import AES

from config import get_config_file_paths
from modules.setup import cypher_pass_generator
from util import *

# config file path
LIFE_CONFIG_FILE_PATH = get_config_file_paths()['LIFE_CONFIG_FILE_PATH']
LIFE_CONFIG_FOLDER_PATH = get_folder_path_from_file_path(LIFE_CONFIG_FILE_PATH)
RLIST_PARAMS = ('title', 'author', 'kind', 'tags')


def is_in_params(params, query, article):
    """
    Get file path for today's tasks entry file

    :param params:
    :param query:
    :param article:
    :return:
    """
    query = query.lower()
    article_filter = article[params]

    if type(article_filter) is list:
        article_filter = [item.lower() for item in article_filter]
Esempio n. 5
0
def new():
    """
    create new config file
    :return:
    """
    chalk.blue('Enter your name:')
    name = raw_input().strip()
    while len(name) == 0:
        chalk.red("You entered nothing!")
        chalk.blue('Enter your name:')
        name = raw_input().strip()

    chalk.blue('What\'s your email id?')
    email = raw_input().strip()
    email_validator = lepl.apps.rfc3696.Email()
    while not email_validator(email):
        chalk.red("Invalid email ID!")
        chalk.blue('What\'s your email id?')
        email = raw_input().strip()

    chalk.blue('What\'s your github username?')
    gh_username = raw_input().strip()
    while len(gh_username) == 0:
        chalk.red("You entered nothing!")
        chalk.blue('What\'s your github username?')
        gh_username = raw_input().strip()

    chalk.blue('Enter your github password:'******'Enter your github password:'******'s encrypt our password
    cipher_key = cypher_pass_generator()
    cipher_IV456 = cypher_pass_generator()

    encrypted_gh_password = encrypt_password(cipher_key, cipher_IV456,
                                             gh_password)

    chalk.blue('Where shall your config be stored? (Default: ~/.yoda/)')
    # because os.path.isdir doesn't expand ~
    config_path = os.path.expanduser(raw_input().strip())
    while not os.path.isdir(config_path):
        if len(config_path) == 0:
            break
        chalk.red('Path doesn\'t exist, yoda!')
        chalk.blue('Where shall your config be stored? (Default: ~/.yoda/)')
        config_path = os.path.expanduser(raw_input().strip())

    update_config_path(config_path)
    CONFIG_FILE_PATH = get_config_file_paths()['USER_CONFIG_FILE_PATH']

    setup_data = dict(name=name,
                      email=email,
                      github=dict(username=gh_username,
                                  password=encrypted_gh_password),
                      encryption=dict(cipher_key=cipher_key,
                                      cipher_IV456=cipher_IV456))

    if not os.path.exists(os.path.dirname(CONFIG_FILE_PATH)):
        try:
            os.makedirs(os.path.dirname(CONFIG_FILE_PATH))
        except OSError as exc:  # Guard against race condition
            if exc.errno != errno.EEXIST:
                raise

    if os.path.isfile(CONFIG_FILE_PATH):
        chalk.red(
            'A configuration file already exists. Are you sure you want to overwrite it? (y/n)'
        )
        overwrite_response = raw_input().lower()
        if not (overwrite_response == 'y' or overwrite_response == 'yes'):
            return

    with open(CONFIG_FILE_PATH, 'w') as config_file:
        yaml.dump(setup_data, config_file, default_flow_style=False)
Esempio n. 6
0
import errno
import getpass
import os.path
import random
import string

import chalk
import click
import lepl.apps.rfc3696
import yaml
from Crypto.Cipher import AES

from config import get_config_file_paths
from config import update_config_path

CONFIG_FILE_PATH = get_config_file_paths()['USER_CONFIG_FILE_PATH']


def cypher_pass_generator(size=16,
                          chars=string.ascii_uppercase + string.digits):
    """
    used to generate key and IV456 for Crypto
    :param size:
    :param chars:
    :return:
    """
    return ''.join(random.choice(chars) for _ in range(size))


def encrypt_password(cipher_key, cipher_IV456, password):
    """
Esempio n. 7
0
import click
import chalk

from config import get_config_file_paths
from util import *

# config file path
LOVE_CONFIG_FILE_PATH = get_config_file_paths()["LOVE_CONFIG_FILE_PATH"]
LOVE_CONFIG_FOLDER_PATH = get_folder_path_from_file_path(LOVE_CONFIG_FILE_PATH)
LOVE_NOTES_FILE_PATH = LOVE_CONFIG_FOLDER_PATH + '/notes.yaml'


def append_data_into_file(data, file_path):
    """
    append data into existing file
    :param data:
    :param file_path:
    """
    with open(file_path) as todays_tasks_entry:
        # read contents
        contents = yaml.load(todays_tasks_entry)
        contents['notes'].append(data)

        # enter data
        with open(file_path, "w") as todays_tasks_entry:
            yaml.dump(contents, todays_tasks_entry, default_flow_style=False)


def status():
    """
    check status
Esempio n. 8
0
from forex_python.converter import CurrencyRates, CurrencyCodes
import time
import datetime
import shlex

from config import get_config_file_paths
import util

CLIENT_ACCESS_TOKEN = os.environ.get('API_AI_TOKEN', config.API_AI_TOKEN)
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
request = ai.text_request()
request.session_id = os.environ.get('API_AI_SESSION_ID',
                                    config.API_AI_SESSION_ID)

# config file path
MONEY_CONFIG_FILE_PATH = get_config_file_paths()['MONEY_CONFIG_FILE_PATH']
MONEY_CONFIG_FOLDER_PATH = util.get_folder_path_from_file_path(
    MONEY_CONFIG_FILE_PATH)

# currency converter
currency_rates = CurrencyRates()
currency_codes = CurrencyCodes()

# check status of setup


def status():
    if os.path.isfile(MONEY_CONFIG_FILE_PATH):
        with open(MONEY_CONFIG_FILE_PATH, 'r') as config_file:
            contents = yaml.load(config_file)
            click.echo(contents)
Esempio n. 9
0
import click
from config import get_config_file_paths
import os.path
import time
from util import *

# config file path
LIFE_CONFIG_FILE_PATH = get_config_file_paths()['LIFE_CONFIG_FILE_PATH']
LIFE_CONFIG_FOLDER_PATH = get_folder_path_from_file_path(LIFE_CONFIG_FILE_PATH)
RLIST_PARAMS = ('title', 'author', 'kind', 'tags')

# get file path for today's tasks entry file


def is_in_params(params, query, article):
    query = query.lower()
    filter = article[params]

    if type(filter) is list:
        filter = [item.lower() for item in filter]
    else:
        filter = filter.lower()

    return (query in filter)


@click.group()
def life():
    '''
        Life command group:\n
        contains helpful commands to organize your life