<commit_before>import urlparse
from buildbot.config import BuilderConfig
from buildbot.schedulers.triggerable import Triggerable

from .factories import TravisFactory, TravisSpawnerFactory
from .mergereq import mergeRequests

class Loader(object):

    def __init__(self, config, vardir):
        self.config = config
        self.vardir = vardir
        self.passwords = {}
        self.properties = {}

    def add_password(self, scheme, netloc, username, password):
        self.passwords[(scheme, netloc)] = (username, password)

    def define_travis_builder(self, name, repository, vcs_type=None, username=None, password=None):
        if not vcs_type:
            if repository.startswith("https://svn."):
                vcs_type = "svn"
            elif repository.startswith("git://github.com/"):
                vcs_type = "git"

        if not username and not password:
            p = urlparse.urlparse(repository)<commit_msg>Ability to load a config file<commit_after>import urlparse
from buildbot.config import BuilderConfig
from buildbot.schedulers.triggerable import Triggerable

from .factories import TravisFactory, TravisSpawnerFactory
from .mergereq import mergeRequests

from yaml import safe_load

class Loader(object):

    def __init__(self, config, vardir):
        self.config = config
        self.vardir = vardir
        self.passwords = {}
        self.properties = {}

    def add_password(self, scheme, netloc, username, password):
        self.passwords[(scheme, netloc)] = (username, password)

    def load(self, path):
        for p in safe_load(path).get("projects", []):
            self.define_travis_builder(**p)

    def define_travis_builder(self, name, repository, vcs_type=None, username=None, password=None):
        if not vcs_type:
            if repository.startswith("https://svn."):
                vcs_type = "svn"
            elif repository.startswith("git://github.com/"):
                vcs_type = "git"

        if not username and not password:
            p = urlparse.urlparse(repository)
{'fraction_non_alphanumeric': 0.09760858955588092, 'fraction_numerical': 0.0, 'mean_word_length': 2.9196940726577436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4300109', 'n_tokens_mistral': 599, 'n_tokens_neox': 581, 'n_words': 150}