示例#1
0
 def find_project(self, name, project=None, ignore_project=True):
     self.project = project
     append = settings.get('append')
     if project and append.get(project):
         self.dirname = self.join(
             self.absuser(append.get(project)), name
         )
         echo_plain_green(texts.LOG_PROFILE_PROJECT_FOUND.format(project))
         return
     self.dirname = self.absjoin(
         settings.get('path'), name
     )
     if not ignore_project or self.isdir(self.dirname):
         return
     for project, path in append.items():
         if not path:
             continue
         abspath = self.absuser(path)
         if self.isdir(abspath):
             dirname = self.join(abspath, name)
             if self.isdir(dirname):
                 self.project = project
                 self.dirname = dirname
                 echo_plain_green(
                     texts.LOG_PROFILE_PROJECT_FOUND.format(project))
                 break
示例#2
0
def load(__builtin__, folder):
    from iprofile.settings.registry import settings
    import os

    files = None
    settings.read(ignore_errors=True)
    log_header = '[IProfile] Importing folder:'
    folder = os.path.join(
        settings.get('path'),
        settings.get('last'),
        'startup',
        folder
    )
    if os.path.isdir(folder):
        from glob2 import glob
        import imp

        files = glob('{}/**/*.py'.format(folder))
        for startup_file in files:
            module = imp.load_source('imported_module', startup_file)
            valid_items = (
                (x, y) for x, y in module.__dict__.items()
                if y and not x.startswith('__')
            )
            for name, mod in valid_items:
                setattr(__builtin__, name, mod)
    else:
        print(
            '{} Nothing was imported from "{}"'.format(log_header, folder)
        )
示例#3
0
def tear_down():
    shutil.rmtree(settings.get('path', 'iprofiles'), ignore_errors=True)
    shutil.rmtree('append_test', ignore_errors=True)
    try:
        os.remove('iprofile.yml')
    except OSError:
        pass
示例#4
0
    def delete(self):
        self.remove(self.dirname)

        active = settings.get('active')
        if self.name == active:
            self.deactivate()

        if hasattr(self, '_iprofiledir'):
            delattr(self, '_iprofiledir')
示例#5
0
def set_up():
    if os.path.isfile('iprofile.yml'):
        os.remove('iprofile.yml')
    settings.read(ignore_errors=True)
    settings.update({
        'append': {'test': 'append_test'}
    }).save()
    try:
        os.makedirs(settings.get('path', 'iprofiles'))
    except OSError:
        pass