• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python package.Package类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.package.Package的典型用法代码示例。如果您正苦于以下问题:Python Package类的具体用法?Python Package怎么用?Python Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: index

    def index(self, page=1, format='html'):
        """Retrieve a paginated list of uploaded packages.

        Arguments:
          page: The page of packages to get. Each page contains 10 packages.
        """
        if format == 'json':
            pager = QueryPager(int(page), "/packages.json?page=%d",
                               Package.all().order('-updated'),
                               per_page=50)
            return json.dumps({
                "packages": [
                    handlers.request().url(action='show', id=package.name)
                    for package in pager.get_items()
                ],
                "prev": pager.prev_url,
                "next": pager.next_url,
                "pages": pager.page_count
            })
        else:
            pager = QueryPager(int(page), "/packages?page=%d",
                               Package.all().order('-updated'))
            title = 'All Packages'
            if page != 1: title = 'Page %s | %s' % (page, title)
            return handlers.render("packages/index",
                                   packages=pager.get_items(),
                                   pagination=pager.render_pagination(),
                                   layout={'title': title})
开发者ID:dart-lang,项目名称:pub-dartlang,代码行数:28,代码来源:packages.py


示例2: post

 def post(self):
     
     p = Package()
     p._id = self.get_argument('package_name')
     package = Package.lookup(p._id)
     p.avail_timelong = int(self.get_argument('avail_timelong', package['avail_timelong']))
     p.avail_begintime = int(self.get_argument("avail_begintime", package['avail_begintime']))
     p.avail_endtime =  int(self.get_argument("avail_endtime1", package['avail_endtime']))
     #p.avail_begintime =  datetime.datetime.strptime(avail_begintime+':00', "%H:%M")
     #p.avail_endtime =  datetime.datetime.strptime(avail_endtime+':00',"%H:%M")
     '''
     p.pname = self.get_argument('package_name')
     p.avail_timelong = int(self.get_argument('avail_timelong'))
     p.avail_begintime = datetime.datetime.strptime(self.get_argument("avail_begintime"), "%H:%M")
     p.avail_endtime = datetime.datetime.strptime(self.get_argument("avail_endtime"), "%H:%M")
     
     avail_beginhourstr =  self.get_argument("avail_begintime", None)
     nPos1 =avail_beginhourstr.index(':')
     avail_beginhour = int(avail_beginhourstr[0:nPos1])
  
     avail_endhourstr =  self.get_argument("avail_endtime", None)
     nPos2 =avail_endhourstr.index(':')
     avail_endhour = int(avail_endhourstr[0:nPos2])
     
     if avail_endhour <= avail_beginhour:
         p.effective_length = avail_endhour+24 - avail_beginhour
     else:
         p.effective_length = avail_endhour - avail_beginhour
     '''
     p.is_weekday= int(self.get_argument("is_weekday", package['is_weekday']))
     p.created_at = datetime.datetime.now()
     Package.updatePackage(p)
     self.redirect("/get_packages")
开发者ID:hc990,项目名称:let,代码行数:33,代码来源:package_control.py


示例3: job_package

def job_package():
#       Log.info("请异步发送")
        need_do = ''
        orders = Order.get_working_orders()
        for order in orders:
            product = Product.lookup(order['p_id'])
            exchange = Exchange.get_exchange(order['e_id'])
            packages = Package.getPackageByName(order['package_id'])
            for package in packages:
                need_do = need_do+json.dumps({'port':product['port'],'bandwidth':order['bandwidth'],\
                           'status':order['status'],'port_name':product['port'], 'ipAddress':exchange['ipAddress'], \
                          'package_id':package['package_name']})
#             Order.finish_order(order['_id'])   
                                
        need_back=''
        orders = Order.get_back_orders()
        for order in orders:
             custom_time = order['custom_time']
             product = Product.lookup(order['p_id'])
             exchange = Exchange.look(order['e_id'])
             packages = Package.getPackageByName(order['package_id'])
             for package in packages:
                 need_back = need_back+json.dumps({'port':product['port'],'ex_bandwidth':order['bandwidth'],\
                           'status':order['status'],'port_name':product['port'], 'ipAddress':exchange['ipAddress'], \
                          'package_id':package['package_name']})
#              Order.back_order(order['_id'])
        print 'set_package_job end at ',datetime.datetime.now()
开发者ID:hc990,项目名称:let,代码行数:27,代码来源:schedulePackage_job.py


示例4: test_create_requires_uploader

    def test_create_requires_uploader(self):
        Package.new(name='owned-package',
                    uploaders=[self.normal_user('owner')]).put()
        self.be_normal_oauth_user()

        response = self.testapp.get(
            '/packages/owned-package/versions/abcd/create.json', status=403)
        self.assert_json_error(response)
开发者ID:kwalrath,项目名称:pub-dartlang,代码行数:8,代码来源:test_package_versions.py


示例5: test_get_package_json_without_versions

    def test_get_package_json_without_versions(self):
        admin = self.admin_user()
        Package.new(name='test-package', uploaders=[admin]).put()

        response = self.testapp.get('/packages/test-package.json')
        self.assertEqual(response.headers['Content-Type'], 'application/json')
        self.assertEqual(json.loads(response.body), {
            "name": "test-package",
            "uploaders": [admin.email()],
            "versions": []
        })
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:11,代码来源:test_packages.py


示例6: test_api_get_package_without_versions

    def test_api_get_package_without_versions(self):
        admin = self.admin_user()
        Package.new(name='test-package', uploaders=[admin]).put()

        self.be_normal_user()

        response = self.testapp.get('/api/packages/test-package')
        self.assertEqual(response.headers['Content-Type'], 'application/json')
        result = json.loads(response.body)
        self.assertEqual(result["name"], "test-package")
        self.assertEqual(result["versions"], [])
        self.assertEqual(result["latest"], None)
开发者ID:a14n,项目名称:pub-dartlang,代码行数:12,代码来源:test_packages.py


示例7: test_uploadership_is_case_insensitive

    def test_uploadership_is_case_insensitive(self):
        self.be_normal_oauth_user('NAme')
        self.post_package_version(name='new-package', version='0.0.1')

        version = Package.get_by_key_name('new-package').latest_version
        self.assertIsNotNone(version)
        self.assertEqual(version.version, SemanticVersion('0.0.1'))

        self.be_normal_oauth_user('naME')
        self.post_package_version(name='new-package', version='0.0.2')

        version = Package.get_by_key_name('new-package').latest_version
        self.assertIsNotNone(version)
        self.assertEqual(version.version, SemanticVersion('0.0.2'))
开发者ID:kwalrath,项目名称:pub-dartlang,代码行数:14,代码来源:test_package_versions.py


示例8: generate_feed

 def generate_feed(page=1):
     feed = FeedGenerator()
     feed.id("https://pub.dartlang.org/feed.atom")
     feed.title("Pub Packages for Dart")
     feed.link(href="https://pub.dartlang.org/", rel="alternate")
     feed.link(href="https://pub.dartlang.org/feed.atom", rel="self")
     feed.description("Last Updated Packages")
     feed.author({"name": "Dart Team"})
     i = 1
     pager = QueryPager(int(page), "/feed.atom?page=%d",
                        Package.all().order('-updated'),
                        per_page=10)
     for item in pager.get_items():
         i += 1
         entry = feed.add_entry()
         for author in item.latest_version.pubspec.authors:
             entry.author({"name": author[0]})
         entry.title("v" + item.latest_version.pubspec.get("version") +\
             " of " + item.name)
         entry.link(link={"href": item.url, "rel": "alternate",
             "title": item.name})
         entry.id(
             "https://pub.dartlang.org/packages/" + item.name + "#" +\
             item.latest_version.pubspec.get("version"))
         entry.description(
             item.latest_version.pubspec
             .get("description", "Not Available"))
         readme = item.latest_version.readme
         if not readme is None:
             entry.content(item.latest_version.readme.render(), type='html')
         else:
             entry.content("<p>No README Found</p>", type='html')
     return feed
开发者ID:d2m,项目名称:pub-dartlang,代码行数:33,代码来源:feed.py


示例9: test_api_get_package_with_versions

    def test_api_get_package_with_versions(self):
        self.be_admin_user()

        self.create_package('test-package', '1.1.0')
        self.create_package('test-package', '1.1.1')
        self.create_package('test-package', '1.2.0')

        self.be_normal_user()

        package = Package.get_by_key_name('test-package')

        response = self.testapp.get('/api/packages/test-package')
        self.assertEqual(response.headers['Content-Type'], 'application/json')
        self.assertEqual(json.loads(response.body), {
            "name": "test-package",
            "url": "http://localhost:80/api/packages/test-package",
            "uploaders_url": "http://localhost:80/api/packages/test-package/" +
                "uploaders",
            "version_url": "http://localhost:80/api/packages/test-package/" +
                "versions/{version}",
            "new_version_url":
                "http://localhost:80/api/packages/test-package/versions/new",
            "downloads": 0,
            "uploaders": [self.admin_user().email()],
            "created": package.created.isoformat(),
            "versions": [
                self.package_version_dict("test-package", "1.1.0"),
                self.package_version_dict("test-package", "1.1.1"),
                self.package_version_dict("test-package", "1.2.0"),
            ],
            "latest": self.package_version_dict("test-package", "1.2.0")
        })
开发者ID:a14n,项目名称:pub-dartlang,代码行数:32,代码来源:test_packages.py


示例10: setUp

 def setUp(self):
     super(PackageVersionsTest, self).setUp()
     self.package = Package.new(
         name='test-package',
         uploaders=[self.admin_user(),
                    self.normal_user('other-uploader')])
     self.package.put()
开发者ID:kwalrath,项目名称:pub-dartlang,代码行数:7,代码来源:test_package_versions.py


示例11: setUp

 def setUp(self):
     super(PackageUploadersTest, self).setUp()
     self.package = Package.new(
         name='test-package',
         uploaders=[self.normal_user('uploader1'),
                    self.normal_user('uploader2')])
     self.package.put()
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:7,代码来源:test_package_uploaders.py


示例12: _get_result

    def _get_result(self, resource_item):
        """Convert a Custom Search API result into a map of package metadata
        that can be rendered.

        If the result does not reference a valid package, return None.

        Arguments:
          resource_item: The API result. It is expected to be a map containing
            a "link" key which will likely be a package URL.
        """
        link = resource_item["link"]
        match = PACKAGE_URL_PATTERN.match(link)
        if not match:
            logging.warning('could not parse search result URL "%s"' % link)
            return None

        package = Package.get_by_key_name(match.group(1))
        if not package:
            logging.warning('could not find search result package "%s"' %
                match.group(1))
            return None

        return {
            "name": package.name,
            "version": package.latest_version.version,
            "desc": package.ellipsized_description,
            "url": "/packages/" + package.name,
            "last_uploaded": package.latest_version.relative_created
        }
开发者ID:a14n,项目名称:pub-dartlang,代码行数:29,代码来源:search.py


示例13: _compute_version_order

 def _compute_version_order(self, name):
     """Compute the sort order for all versions of a given package."""
     versions = list(Package.get_by_key_name(name).version_set.run())
     versions.sort(key=lambda version: version.version)
     for i, version in enumerate(versions):
         version.sort_order = i
     with models.transaction():
         for version in versions: version.put()
开发者ID:butlermatt,项目名称:pub-dartlang,代码行数:8,代码来源:package_versions.py


示例14: test_has_version

    def test_has_version(self):
        package = Package.new(name='test-package',
                              uploaders=[self.admin_user()])
        package.put()
        self.package_version(package, '1.2.3').put()

        self.assertTrue(package.has_version('1.2.3'))
        self.assertFalse(package.has_version('1.2.4'))
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:8,代码来源:test_package.py


示例15: test_delete_is_case_insensitive

    def test_delete_is_case_insensitive(self):
        self.be_normal_oauth_user('uploader1')
        response = self.testapp.delete(
            '/api/packages/test-package/uploaders/' +
                self.normal_user('UpLoAdEr1').email())
        self.assert_json_success(response)

        package = Package.get_by_key_name('test-package')
        self.assertEquals(
            package.uploaders, [self.normal_user('uploader2')])
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:10,代码来源:test_package_uploaders.py


示例16: test_uploader_deletes_uploader

    def test_uploader_deletes_uploader(self):
        self.be_normal_oauth_user('uploader1')
        response = self.testapp.delete(
            '/packages/test-package/uploaders/%s.json' %
                self.normal_user('uploader1').email())
        self.assert_json_success(response)

        package = Package.get_by_key_name('test-package')
        self.assertEquals(
            package.uploaders, [self.normal_user('uploader2')])
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:10,代码来源:test_package_uploaders.py


示例17: get

 def get(self):
     page = self.get_argument('page', 1)
     page = page if page >= 1 else 1
     count = self.get_argument('count', 10)
     count = count if count >= 1 else 10     
     packages = Package.getPackages()                 
     paginator = Paginator(packages, page, count, len(packages))
     template_values = {}
     template_values['paginator'] = paginator
     self.render_template('/site/searchPackage.html', **template_values)
开发者ID:hc990,项目名称:let,代码行数:10,代码来源:package_control.py


示例18: test_uploader_creates_new_uploader

    def test_uploader_creates_new_uploader(self):
        self.be_normal_oauth_user('uploader1')
        response = self.testapp.post('/packages/test-package/uploaders.json',
                                     {'email': self.normal_user().email()})
        self.assert_json_success(response)

        package = Package.get_by_key_name('test-package')
        self.assertEquals(package.uploaders, [
            self.normal_user('uploader1'),
            self.normal_user('uploader2'),
            self.normal_user()
        ])
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:12,代码来源:test_package_uploaders.py


示例19: index

    def index(self, page=1):
        """Retrieve a paginated list of uploaded packages.

        Arguments:
          page: The page of packages to get. Each page contains 10 packages.
        """
        pager = Pager(int(page), "/packages?page=%d", Package.all().order("-updated"))
        title = "All Packages"
        if page != 1:
            title = "Page %s | %s" % (page, title)
        return handlers.render(
            "packages/index", packages=pager.get_items(), pagination=pager.render_pagination(), layout={"title": title}
        )
开发者ID:amouravski,项目名称:pub-dartlang,代码行数:13,代码来源:packages.py


示例20: maybe_package

    def maybe_package(self):
        """Load the current package object.

        This auto-detects the package name from the request parameters. If the
        package doesn't exist, returns None.
        """

        if self._package: return self._package

        name = self._package_name
        if name is None: return None

        self._package = Package.get_by_key_name(name)
        if self._package: return self._package
        return None
开发者ID:dart-lang,项目名称:pub-dartlang,代码行数:15,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python package_version.PackageVersion类代码示例发布时间:2022-05-27
下一篇:
Python order.Order类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap