Example #1
0
def index():
    """index projects."""
    from yuan.models import index_project
    for name in Project.all():
        for item in Project.list(name):
            print '%(family)s/%(name)s' % item
            index_project(item, 'sync')
Example #2
0
def calculate():
    projects = []

    for name in Project.all():
        for item in Project.list(name):
            item = Project(family=item['family'], name=item['name'])
            packages = Project.sort(item.packages)

            packages = filter(
                lambda o: o['tag'] == 'stable',
                packages.values()
            )

            if not packages:
                continue

            pkg = Package(**packages[0])
            item.dependents = pkg.get('dependents', [])
            projects.append(item)

    def _sort_by_time(item):
        if 'update_at' in item:
            return datetime.strptime(
                item['updated_at'], '%Y-%m-%dT%H:%M:%SZ'
            )
        return None

    popular = sorted(
        projects, key=lambda o: len(o.dependents), reverse=True
    )[:50]

    latest = sorted(
        projects, key=_sort_by_time, reverse=True
    )[:50]
    return {'popular': popular, 'latest': latest}
Example #3
0
File: status.py Project: souse/yuan
def calculate():
    projects = []

    for name in Project.all():
        for item in Project.list(name):
            item = Project(family=item['family'], name=item['name'])
            packages = Project.sort(item.packages)

            packages = filter(lambda o: o['tag'] == 'stable',
                              packages.values())

            if not packages:
                continue

            pkg = Package(**packages[0])
            item.dependents = pkg.get('dependents', [])
            projects.append(item)

    def _sort_by_time(item):
        if 'update_at' in item:
            return datetime.strptime(item['updated_at'], '%Y-%m-%dT%H:%M:%SZ')
        return None

    popular = sorted(projects, key=lambda o: len(o.dependents),
                     reverse=True)[:50]

    latest = sorted(projects, key=_sort_by_time, reverse=True)[:50]
    return {'popular': popular, 'latest': latest}
Example #4
0
def initsearch():
    """init search engine."""
    from yuan.search import index_project
    for name in Project.all():
        for item in Project.list(name):
            print '%(family)s/%(name)s' % item
            item = Project(family=item['family'], name=item['name'])
            index_project(item, 'update')
Example #5
0
def initdependents():
    from yuan.tasks.dependent import calculate_dependents
    for name in Project.all():
        for item in Project.list(name):
            item = Project(family=item['family'], name=item['name'])
            for key in item.packages:
                pkg = Package(**item.packages[key])
                print(pkg)
                calculate_dependents(pkg, 'update')
Example #6
0
def initassets():
    from yuan.tasks import extract_assets
    for name in Project.all():
        for item in Project.list(name):
            item = Project(family=item['family'], name=item['name'])
            for key in item.packages:
                pkg = Package(**item.packages[key])
                print(pkg)
                extract_assets(pkg, 'upload')