当前位置: 首页>>代码示例>>Python>>正文


Python Repository.reader_queryset方法代码示例

本文整理汇总了Python中moneta.repository.models.Repository.reader_queryset方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.reader_queryset方法的具体用法?Python Repository.reader_queryset怎么用?Python Repository.reader_queryset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moneta.repository.models.Repository的用法示例。


在下文中一共展示了Repository.reader_queryset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
    def index(self, request, rid, repo_slug=None, state_slug=''):
        repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
        base_query = Element.objects.filter(repository=repo)
        if state_slug:
            state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
            base_query = base_query.filter(states=state)
        base_query = base_query.order_by('archive', 'version')
        element_infos = []
        for element in base_query:
            if not element.extra_data:
                continue
            provider = json.loads(element.extra_data)['provider']
            element_infos.append(
                (element.name,
                 reverse('vagrant:get_box',
                         kwargs={'rid': rid, 'repo_slug': repo.slug, 'eid': element.id, 'provider': provider,
                                 'archive': element.archive, 'version': element.version}),
                 element.sha1)
            )
        states = [state for state in ArchiveState.objects.filter(repository=repo).order_by('name')]
        tab_infos = [(reverse('vagrant:index', kwargs={'rid': repo.id, 'state_slug': ''}),
                      ArchiveState(name=_('All states'), slug='all-states'), states, ''), ]
        tab_infos += [(reverse('vagrant:index',
                               kwargs={'rid': repo.id, 'state_slug': state.slug}),
                       state, [state], state.slug)
                      for state in states]
        # list of (relative URL, name, list of states, state_slug)

        template_values = {'repo': repo, 'states': states, 'upload_allowed': repo.upload_allowed(request),
                           'state_slug': state_slug, 'elements': element_infos,
                           'index_url': reverse(moneta_url(repo, 'index'), kwargs={'rid': repo.id, }),
                           'tab_infos': tab_infos, 'admin_allowed': repo.admin_allowed(request), }
        return render_to_response(self.index_html, template_values, RequestContext(request))
开发者ID:wagnerwar,项目名称:Moneta,代码行数:35,代码来源:vagrant.py

示例2: xr_search

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def xr_search(request, rpc_args, self, rid, repo_slug, state_slug=None):
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.model)
     state = get_object_or_404(ArchiveState, repository=repo, name=state_slug) if state_slug else None
     global_and = len(rpc_args) == 0 or rpc_args[1] != 'or'
     if len(rpc_args) == 0 or not isinstance(rpc_args[0], dict):
         raise PermissionDenied
     filters = None
     for query_name, attr_name in (('name', 'archive'), ('version', 'version'), ('home_page', 'official_link'),
                                   ('description', 'long_description'),):
         if query_name in rpc_args[0]:
             value = rpc_args[0][query_name]
             if isinstance(value, list):
                 if value:
                     value = value[0]
                 else:
                     value = ''
             value = value.replace('-', '').replace('_', '')
             sub_query = Q(**{attr_name + '__icontains': value})
             if filters is None:
                 filters = sub_query
             elif global_and:
                 filters = filters and sub_query
             else:
                 filters = filters or sub_query
     query = Element.objects.filter(repository=repo)
     if state:
         query = query.filter(states=state)
     if filters is not None:
         query = query.filter(filters)
     res = [{'name': x.archive, 'version': x.version, 'summary': x.long_description,
             '_pypi_ordering': 1.0} for x in query]
     return res
开发者ID:d9pouces,项目名称:Moneta,代码行数:34,代码来源:pypi.py

示例3: get_providers_by_version

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
    def get_providers_by_version(self, request, rid, state_slug, archive):
        repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
        base_query = Element.objects.filter(repository=repo, archive=archive)
        if state_slug:
            state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
            base_query = base_query.filter(states=state)
        versions = {}
        for element in base_query:
            metadata = json.loads(element.extra_data)
            versions.setdefault(element.version, []).append({
                'name': metadata['provider'],
                'url': '%s%s' % (settings.SERVER_NAME, element.get_direct_link()),
                'checksum_type': 'sha1',

                'checksum': element.sha1})
        result = {'name': archive, 'description': _('This box contains %(name)s') % {'name': archive},
                  'versions': [{'version': k, 'status': 'active', 'providers': v} for (k, v) in versions.items()]}
        return result
# Vagrant.configure(2) do |config|
#
#   config.vm.box = "{$relativePathInfo|escape}"
#   config.vm.box_url = '<a href="{$CATALOG_URI|escape}{$pathInfo|escape}">{$CATALOG_URI|escape}{$pathInfo|escape}</a>'
#
#   # Whatever other config stuff you want to do
# end
开发者ID:wagnerwar,项目名称:Moneta,代码行数:27,代码来源:vagrant.py

示例4: browse_repository

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
    def browse_repository(self, request: HttpRequest, rid, repo_slug, query_string='', state_slug=None) -> HttpResponse:
        repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
        result = self.browse_repo_inner(rid, query_string, state_slug=state_slug)
        if isinstance(result, str):  # sha1/sha256/md5
            return HttpResponse(result)
        elif isinstance(result, Element):
            return get_file(request, eid=result.pk, element=result)
        assert isinstance(result, dict)

        new_query_string = ''
        bread_crumbs = [(_('Root'), self.get_browse_url(repo, new_query_string, state_slug=state_slug))]
        while len(result) == 1 and isinstance(result, dict):
            path_component, result = result.popitem()
            new_query_string += path_component + '/'
            bread_crumbs.append((path_component, self.get_browse_url(repo, new_query_string, state_slug=state_slug)))
        if isinstance(result, set):
            url_list = []
            for elt in result:
                new_gavf_elt_filename = new_query_string + elt.filename
                elt_url = self.get_browse_url(repo, new_gavf_elt_filename, state_slug=state_slug)
                url_list += [(new_gavf_elt_filename, elt_url, elt.id),
                             (new_gavf_elt_filename + '.sha1', elt_url + '.sha1', None),
                             (new_gavf_elt_filename + '.sha256', elt_url + '.sha256', None),
                             (new_gavf_elt_filename + '.md5', elt_url + '.md5', None),
                             ]
        else:
            assert isinstance(result, dict)
            url_list = [(new_query_string + key,
                         self.get_browse_url(repo, new_query_string + key, state_slug=state_slug), None)
                        for key in result]
        template_values = {'repo': repo, 'upload_allowed': repo.upload_allowed(request), 'repo_slug': repo_slug,
                           'admin': True, 'paths': url_list, 'request_path': new_query_string, 'state_slug': state_slug,
                           'bread_crumbs': bread_crumbs, }
        status_code = 200 if url_list else 404
        return TemplateResponse(request, 'repositories/maven3/browse.html', template_values, status=status_code)
开发者ID:d9pouces,项目名称:Moneta,代码行数:37,代码来源:maven3.py

示例5: index

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
    def index(self, request, rid):
        repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
        states = [state for state in ArchiveState.objects.filter(repository=repo).order_by('name')]
        tab_infos = [(states, ArchiveState(name=_('All states'), slug='all-states')), ]
        tab_infos += [([state], state) for state in states]

        template_values = {'repo': repo, 'states': states, 'upload_allowed': repo.upload_allowed(request),
                           'index_url': reverse(moneta_url(repo, 'index'), kwargs={'rid': repo.id, }),
                           'tab_infos': tab_infos, 'admin_allowed': repo.admin_allowed(request), }
        return TemplateResponse(request, self.index_html, template_values)
开发者ID:d9pouces,项目名称:Moneta,代码行数:12,代码来源:aptitude.py

示例6: plugin_index

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def plugin_index(self, request: HttpRequest, rid, repo_slug, state_slug=None):
     # noinspection PyUnusedLocal
     repo_slug = repo_slug
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     base_query = Element.objects.filter(repository=repo)
     if state_slug:
         state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
         base_query = base_query.filter(states=state)
     return TemplateResponse(request, 'repositories/jetbrains/updatePlugins.xml', {'elements': base_query},
                             content_type='application/xml')
开发者ID:d9pouces,项目名称:Moneta,代码行数:12,代码来源:jetbrains.py

示例7: specs

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def specs(self, request, rid, repo_slug, state_slug=None, filename='specs.4.8.gz'):
     # noinspection PyUnusedLocal
     repo_slug = repo_slug
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     if state_slug:
         filename = 'specs/%(slug)s/%(filename)s' % {'slug': state_slug, 'filename': filename, }
     else:
         filename = 'specs/%(filename)s' % {'filename': filename, }
     uid = self.storage_uid % repo.pk
     key = storage(settings.STORAGE_CACHE).uid_to_key(uid)
     return sendpath(settings.STORAGE_CACHE, key, filename, 'application/gzip')
开发者ID:wagnerwar,项目名称:Moneta,代码行数:13,代码来源:ruby.py

示例8: download

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def download(self, request, rid, repo_slug, state_slug=None, filename=None):
     # noinspection PyUnusedLocal
     repo_slug = repo_slug
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     base_query = Element.objects.filter(repository=repo)
     if state_slug:
         state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
         base_query = base_query.filter(states=state)
     element = get_object_or_404(base_query, filename=filename)
     from moneta.views import get_file
     return get_file(request, element.pk)
开发者ID:wagnerwar,项目名称:Moneta,代码行数:13,代码来源:ruby.py

示例9: xr_package_releases

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def xr_package_releases(request, rpc_args, self, rid, repo_slug, state_slug=None):
     if len(rpc_args) == 0:
         raise PermissionDenied
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.model)
     if state_slug:
         state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
         query = Element.objects.filter(repository=repo, states=state, archive=rpc_args[0])
     else:
         query = Element.objects.filter(repository=repo, archive=rpc_args[0])
     versions = [LooseVersion(x.version) for x in query]
     versions.sort()
     return [str(x) for x in versions]
开发者ID:d9pouces,项目名称:Moneta,代码行数:14,代码来源:pypi.py

示例10: gem_specs

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def gem_specs(self, request, rid, repo_slug, state_slug=None, filename=None):
     name, sep, version = filename.rpartition('-')
     if sep != '-':
         raise Http404
     # noinspection PyUnusedLocal
     repo_slug = repo_slug
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     base_query = Element.objects.filter(repository=repo)
     if state_slug:
         state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
         base_query = base_query.filter(states=state)
     element = get_object_or_404(base_query, name=name, version=version)
     return HttpResponse(self.yaml_data(element), content_type='text/yaml')
开发者ID:wagnerwar,项目名称:Moneta,代码行数:15,代码来源:ruby.py

示例11: get_file

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def get_file(self, request, rid, repo_slug, state_slug, folder, filename):
     """
     Return a HttpResponse
     :param request: HttpRequest
     :raise:
     """
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     q = Element.objects.filter(repository__id=rid, filename=filename)[0:1]
     q = list(q)
     if len(q) == 0:
         raise Http404
     element = q[0]
     return get_file(request, element.id, compression=None, path='', element=element, name=None)
开发者ID:wagnerwar,项目名称:Moneta,代码行数:15,代码来源:aptitude.py

示例12: simple

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def simple(self, request, rid, repo_slug, state_slug=None, search_pattern=''):
     search_pattern = search_pattern.replace('-', '').replace('_', '')
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     base_query = Element.objects.filter(repository=repo)
     if state_slug:
         state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
         base_query = base_query.filter(states=state)
     if search_pattern:
         base_query = base_query.filter(archive__iexact=search_pattern)
     view_name = moneta_url(repo, 'get_file')
     elements = [(x.filename, x.md5, reverse(view_name, kwargs={'eid': x.id, })) for x in base_query[0:1000]]
     template_values = {'elements': elements, 'rid': rid, }
     return TemplateResponse(request, 'repositories/pypi/simple.html', template_values)
开发者ID:d9pouces,项目名称:Moneta,代码行数:15,代码来源:pypi.py

示例13: repodata_file

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def repodata_file(self, request, rid, repo_slug, state_slug, arch, filename, compression):
     if filename not in ('comps.xml', 'primary.xml', 'other.xml', 'filelists.xml', 'repomd.xml', ):
         return HttpResponse(_('File not found'), status=404)
     if compression and filename == 'repomd.xml':
         return HttpResponse(_('File not found'), status=404)
     # noinspection PyUnusedLocal
     repo_slug = repo_slug
     filename = self.index_filename(state_slug, arch, filename + compression)
     mimetype = 'text/xml'
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     uid = self.storage_uid % repo.id
     key = storage(settings.STORAGE_CACHE).uid_to_key(uid)
     return sendpath(settings.STORAGE_CACHE, key, filename, mimetype)
开发者ID:wagnerwar,项目名称:Moneta,代码行数:15,代码来源:yum.py

示例14: get_box

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def get_box(self, request: HttpRequest, rid, repo_slug, eid, archive, version, provider):
     # noinspection PyUnusedLocal
     repo_slug = repo_slug
     # noinspection PyUnusedLocal
     archive = archive
     # noinspection PyUnusedLocal
     provider = provider
     # noinspection PyUnusedLocal
     version = version
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.archive_type)
     elements = list(Element.objects.filter(repository=repo, pk=eid)[0:1])
     if not elements:
         return JsonResponse({'errors': ['Not found', ], })
     return get_file(request, eid, element=elements[0])
开发者ID:d9pouces,项目名称:Moneta,代码行数:16,代码来源:vagrant.py

示例15: xr_list_packages

# 需要导入模块: from moneta.repository.models import Repository [as 别名]
# 或者: from moneta.repository.models.Repository import reader_queryset [as 别名]
 def xr_list_packages(request, rpc_args, self, rid, repo_slug, state_slug=None):
     repo = get_object_or_404(Repository.reader_queryset(request), id=rid, archive_type=self.model)
     if state_slug:
         state = get_object_or_404(ArchiveState, repository=repo, name=state_slug)
         query = Element.objects.filter(repository=repo, states=state).order_by('name')
     else:
         query = Element.objects.filter(repository=repo).order_by('name')
     results = []
     prev = None
     for value in query:
         if value.name != prev:
             results.append(value.name)
             prev = value.name
     return results
开发者ID:d9pouces,项目名称:Moneta,代码行数:16,代码来源:pypi.py


注:本文中的moneta.repository.models.Repository.reader_queryset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。