示例#1
0
    def from_repo(cls, repo_path, local_dir=None):
        """
        make a script list from given repositry path.

        @param str repo_path repositry path.
        @return obj ScriptsList
        """
        list = ScriptsList()
        if local_dir:
            repo = git.Repo(local_dir+'/'+sign_repopath(repo_path))
        else:
            repo = git.Repo(repo_path)
        # update scripts.
        repo.rebase()
    
        for category in repo.categories:
            # @TODO: refactory -> category.scripts()
            for script_name,script_blob in category.items():
                script = Script.from_blob(script_blob)
                entry = {
                        'repo':repo_path,
                        'category':category.name,
                         'name':script.name,
                         'id':script_name,
                         'selected':False}
                list._items.append(entry)
        return list
示例#2
0
from lazyscripts.category import Category
from lazyscripts.script import ScriptSet, ScriptsList, ScriptsBuilder
from lazyscripts.repo import git, sign_repopath
from t import get_repodir, get_datadir, remote_repo

set = ScriptSet.from_scriptslist(
            ScriptsList(get_datadir()+'/scripts.list'), True)

_repos = {remote_repo:git.Repo(get_repodir()+'/'+sign_repopath(remote_repo))}
_cat = Category(name='Networking', scripts_builder=ScriptsBuilder(_repos))
e = {'repo': remote_repo, 
    'category': 'Networking',
    'name': 'ie6', 
    'id': 'ie6',
    'selected':False}
_cat.add_entry(e)

def test_get_script_from_category():
    "test to get script form a category."
    assert 'Script' == _cat.get('ie6').__class__.__name__

def test_get_categories():
    'test to get categories form scripts list'
    # checks all items are Category class.
    for category in set.categories():
        assert 'Category' == category.__class__.__name__, category.__class__

    # checks get Category Instance by spefied category name.
    ast_cats = ['Networking', 'Graphic', 'Localization', 
                'Productivity', 'Entertain', 'Customize','Game', 
                'Multimedia']