示例#1
0
    def __init__(self, config=None, export_tabs=None, bulk_export=None,
                 crawl_yml: dict = None, descript_lang: dict = None):
        try:
            self.datum = '{:%d-%b-%Y}'.format(date.today())
            self.maand_jaar = '{:%B-%Y}'.format(date.today())

            try:
                self.url = config['url']
                self.domain = config['domain']
                self.template_file = config['word_template']
                self.search_console_url = config['search_console_url']
            except KeyError as e:
                raise Exception("Error getting config variables: {}".format(e))

            self.start_path = os.path.dirname(os.path.realpath(__file__))
            self.domain_folder = self.set_data_domain_path()
            self.frog_data_folder = self.get_frog_folder()
            self.graph_data_folder = self.get_graph_folder()
            self.config_folder = self.get_config_folder()
            self.export_tabs = export_tabs
            self.bulk_export = bulk_export
            self.crawl_yml = crawl_yml
            self.descript_lang = descript_lang

            self.ps = None
            self.frog_files = {}
            self.document_fields = None
            self.doc = None
            self.dp = None
            self.data = {}
            self.co_table_headers = None
            self.co_readydata = None
            self.template = None
            self.dimensions_data = None

            cf = readConfig()
            self.config = cf.config
            self.ps_api = self.config['google_page_speed_api']

            self.template = self.get_doc_template()
            self.word_output_file = self.get_doc_word_output()

            self.get_frog_files()
            self.create_crawl_data()
            self.get_crawl_overview_data()
            self.get_google_search_console_data()

            self.ps_all_data = {}

            # self.crawl_data = self.get_crawl_data()

            self.prep_document()
            self.merge_document()
            self.write_document()
        except Exception as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            logging.warning(str(e) + " | " + str(exc_type) +
                            " | " + str(fname) + " | " + str(exc_tb.tb_lineno))
            return
示例#2
0
    def __init__(self):
        self.cf = readConfig()
        self.behandel_datum = ""
        self.declaratie_file = None
        self.backup_file = None
        self.browser = None

        self.get_behandel_datum()
        self.get_declaratie_file()
        if self.start_formulier():
            self.backup_declaratie_file()
示例#3
0
    def __init__(self):

        cf = readConfig()
        self.config = cf.config
        self.datum = '{:%d-%b-%Y}'.format(date.today())

        dir_path = os.path.dirname(os.path.realpath(__file__))
        folder = os.path.join(dir_path, "data")
        data_file_name = "{}_weights.json".format(self.datum)
        self.data_file = os.path.join(folder, data_file_name)

        self.weight_data = {}

        self.start_url = "https://cloud.vitadock.com/signin"
        self.login_url = "https://cloud.vitadock.com/resources/j_spring_security_check"
        self.weight_page = "https://cloud.vitadock.com/portal/target.php?lang=nl_NL"
        self.weight_json = "https://cloud.vitadock.com/portal/server/target_server.php?lang=nl_NL&rnd=12345"

        self.get_data()
示例#4
0
    def __init__(self,
                 user_agent=None,
                 workspace_id=None,
                 start_col=0,
                 start_row=0,
                 name=""):
        if user_agent == workspace_id is None:
            return None

        cf = readConfig()
        self.config = cf.config

        self.start_col = start_col
        self.start_row = start_row

        self.normal_hours_day = 8
        self.normal_work_hours = 7

        self.months = [
            "Unknown", "January", "Febuary", "March", "April", "May", "June",
            "July", "August", "September", "October", "November", "December"
        ]

        self.user_agent = user_agent
        self.user_name = name
        self.workspace_id = workspace_id
        self.response = None
        self.last_month_first = None
        self.last_month_last = None
        self.curr_year = None
        self.filename = None

        self.my_excel_data = []
        self.excel_template = "excel/urenoverzicht-2020.xlsx"
        self.excel_file = None

        self.about_last_month()
        self.get_data()
        self.parse_data()
        self.create_excel()
示例#5
0
    def __init__(self):

        self.gitignore_start_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'start_files',
            "gitignore.txt")
        self.readme_start_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'start_files',
            "readme.txt")
        try:
            config_file = os.path.join(
                os.path.dirname(os.path.abspath(__file__)), 'config',
                'config.yml')
            cf = readConfig(config_file)
            try:
                self.GitHub_Token = cf.config['github_token']
                self.projects_folder_name = cf.config['projects_folder_name']
                self.license_template = cf.config['license_template']
                self.twitter = cf.config['twitter']
                self.email = cf.config['email']
            except KeyError as e:
                raise Exception(f"Config file broken {e}")

            yn = ['y', 'n']
            checkers = [None, ""]
            correct = 1
            self.repo = None
            self.user = None

            if self.GitHub_Token is None or self.GitHub_Token == '':
                raise Exception("No GitHub Token")

            home_folder = str(
                Path.home())  # this is the users home folder on any OS
            self.project_folder = os.path.join(home_folder,
                                               self.projects_folder_name)

            project_folder = Path(self.project_folder)
            if not project_folder.exists():
                raise Exception(
                    "Sorry, but your projects folder does not exists! {} ".
                    format(self.project_folder))

            self.project_name = None
            while self.project_name in checkers:
                self.project_name = input(
                    "What is the name of your new project? ")
                while correct not in yn and self.project_name not in checkers:
                    correct = input(
                        "Is this project name correct? {} - {} : ".format(
                            self.project_name, str(yn)))
                    if correct == "y":
                        break

            self.private_repo = None
            while self.private_repo not in yn:
                self.private_repo = input(
                    "Do you want to create a public repository? {} : ".format(
                        str(yn)))
                if self.private_repo == "y":
                    self.private_repo = True
                    break
                elif self.private_repo == "n":
                    self.private_repo = False
                    break

            self.auto_init = None
            while self.auto_init in checkers:
                self.auto_init = input(
                    "Do you want to create a readme file and initialize the repository? {} : "
                    "".format(str(yn)))
                if self.auto_init == "y":
                    self.auto_init = True
                    break
                elif self.auto_init == "n":
                    self.auto_init = False
                    break

            self.description = None
            while self.description in checkers:
                self.description = input(
                    "Please provide a small repository description. (you can change it later) "
                )

            self.homepage = None
            while self.homepage in checkers:
                self.homepage = input(
                    "Please proivde a url with more information about your repository. "
                    "(you can change it later) ")

            if self.create_git_repository():
                if self.clone_git_repository():
                    self.create_extra_files()

        except Exception as e:
            logger.warning(e)
            return
示例#6
0
import gzip # For reading data
import pandas as pd # data handling
import colorsys # Generate color gradient.
import sys # Read command line arguments:
import argparse # Now command line arugments are properly set.
import pickle

# Importing custom functions:
from functions.helper_fun import *
from functions.color_fun import *
from functions.dataIntegrator import dataIntegrator
from functions.chromosome_plotter import chromosome_plotter
from functions.readConfig import readConfig

# reading parameters:
config = readConfig()

if __name__ == '__main__':

    # Processing command line parameters:
    parser = argparse.ArgumentParser(description='Script to plot genome chunks colored based on GC content and gene annotation. See github: https://github.com/DSuveges/GenomePlotter')
    parser.add_argument('-c', '--chromosome', type = str, help='Selected chromosome to process', required = True)
    parser.add_argument('-w', '--width', type = int, help='Number of chunks in one row.', default = 200)
    parser.add_argument('-p', '--pixel', type = int, help='The size of a plotted chunk in pixels (default: 3).', default = 9)
    parser.add_argument('-s', '--darkStart', type = float, help='Fraction of the width from where the colors start getting darker (default: 0.75).', default = 0.75)
    parser.add_argument('-m', '--darkMax', type = float, help='How dark a pixel can get at the right end of the plot (default: 0.15).', default = 0.15)
    parser.add_argument('-f', '--folder', type = str, help = 'The working directory (default is the current working directory)', default='.')
    parser.add_argument('-t', '--test', type = int, help = 'The number of chunks to be read (by default the whole chromosome is processed.)', default = 0)
    parser.add_argument('-d', '--dummy', type = bool, help = 'If instead of the chunks, a dummy is drawn with identical dimensions', default = False)
    parser.add_argument('--config', type = str, help = 'Specifying json file containing custom configuration', default = 'config.json')
示例#7
0
    def write_document(self):
        self.doc.save(self.word_output_file)


if __name__ == '__main__':
    dir_path = os.path.dirname(os.path.realpath(__file__))
    profiles = os.path.join(dir_path, "data")

    word_output = os.path.join(dir_path, "word_output")
    os.makedirs(word_output, exist_ok=True)

    bulk_export = None
    bulk_export_file = os.path.join(dir_path, 'config', 'bulk_exports.yml')
    if os.path.isfile(bulk_export_file):
        bulk_export = readConfig(bulk_export_file)

    crawl_yml = None
    crawl_overview_file = os.path.join(
        dir_path, 'config', 'crawl_overview.yml')
    if os.path.isfile(crawl_overview_file):
        crawl_yml = readConfig(crawl_overview_file)
    else:
        print('No yml file')

    descript_lang = None
    descript_file = os.path.join(dir_path, 'config', 'crawl_overview_lang.yml')
    if os.path.isfile(descript_file):
        descript_lang = readConfig(descript_file)

    export_tabs = None