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


Python Creator.from_updated方法代码示例

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


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

示例1: test__preset_links

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def test__preset_links(self):
        router = Router(db, self._request, auth)

        data = dict(
            shop=None,
            tumblr=None,
        )
        self._creator = Creator.from_updated(self._creator, data)

        # Creator not set.
        self.assertEqual(router.preset_links(), [])

        # Set creator but still no presets
        router.request.vars.creator = 'FirstLast'
        self.assertEqual(router.preset_links(), [])

        def test_presets(links, expect):
            soups = [BeautifulSoup(str(x)) for x in links]
            anchors = [x.find('a') for x in soups]
            self.assertEqual(
                [x.string for x in anchors],
                expect
            )
            for anchor in anchors:
                if anchor.string == 'shop':
                    self.assertEqual(anchor['href'], 'http://www.shop.com')
                elif anchor.string == 'tumblr':
                    self.assertEqual(anchor['href'], 'http://user.tumblr.com')
                self.assertEqual(anchor['target'], '_blank')

        # Set creator.shop
        data = dict(
            shop='http://www.shop.com',
            tumblr=None
        )
        self._creator = Creator.from_updated(self._creator, data)
        router.creator = None
        test_presets(router.preset_links(), ['shop'])

        # Set creator.tumblr
        data = dict(
            shop=None,
            tumblr='http://user.tumblr.com',
        )
        self._creator = Creator.from_updated(self._creator, data)
        router.creator = None
        test_presets(router.preset_links(), ['tumblr'])

        # Set both creator.shop and creator.tumblr
        data = dict(
            shop='http://www.shop.com',
            tumblr='http://user.tumblr.com',
        )
        self._creator = Creator.from_updated(self._creator, data)
        router.creator = None
        test_presets(router.preset_links(), ['shop', 'tumblr'])
开发者ID:zcomx,项目名称:zcomix.com,代码行数:58,代码来源:test_routing.py

示例2: tearDownClass

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def tearDownClass(cls):
        for job in db(db.job).select():
            job.delete_record()
        db.commit()

        if cls._max_optimize_img_log_id:
            query = (db.optimize_img_log.id > cls._max_optimize_img_log_id)
            db(query).delete()
            db.commit()

        Creator.from_updated(cls._creator, cls._creator_as_dict)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:13,代码来源:test_login.py

示例3: update_contributions_remaining

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
def update_contributions_remaining(book):
    """Update the contributions_remaining for the creator of the book.

    Args
        book: Book instance
    """
    if not book:
        return

    data = dict(
        contributions_remaining=calc_contributions_remaining(book)
    )
    updated_book = Book.from_updated(book, data)

    if not updated_book.creator_id:
        return

    creator = Creator.from_id(updated_book.creator_id)
    if not creator:
        return

    total = contributions_remaining_by_creator(creator)
    if creator.contributions_remaining != total:
        data = dict(contributions_remaining=total)
        creator = Creator.from_updated(creator, data)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:27,代码来源:books.py

示例4: creator_torrent

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
def creator_torrent(creator_id):
    """Create a torrent for a creator."""
    creator = Creator.from_id(creator_id)
    result = CreatorTorrentCreator(creator).archive()
    LOG.debug('Created: %s', result)

    if creator.rebuild_torrent:
        creator = Creator.from_updated(creator, dict(rebuild_torrent=False))
开发者ID:zcomx,项目名称:zcomix.com,代码行数:10,代码来源:create_torrent.py

示例5: test__share_url

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
 def test__share_url(self):
     # C0301 (line-too-long): *Line too long (%%s/%%s)*
     # pylint: disable=C0301
     data = dict(twitter=None)
     self._creator = Creator.from_updated(self._creator, data)
     media = TwitterSocialMedia(self._book, creator=self._creator)
     self.assertEqual(
         media.share_url(),
         'https://twitter.com/share?url=http%3A%2F%2F{cid}.zco.mx%2FTestSocialMedia&text=Check+out+%27Test+Social+Media%27+by+First+Last&hashtage='.format(cid=self._creator.id)
     )
     data = dict(twitter='@zco')
     self._creator = Creator.from_updated(self._creator, data)
     media = TwitterSocialMedia(self._book, creator=self._creator)
     self.assertEqual(
         media.share_url(),
         'https://twitter.com/share?url=http%3A%2F%2F{cid}.zco.mx%2FTestSocialMedia&text=Check+out+%27Test+Social+Media%27+by+%40zco&hashtage='.format(cid=self._creator.id)
     )
开发者ID:zcomx,项目名称:zcomix.com,代码行数:19,代码来源:test_social_media.py

示例6: book_torrent

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
def book_torrent(book_id):
    """Create a torrent for a book."""
    book = Book.from_id(book_id)
    result = BookTorrentCreator(book).archive()
    LOG.debug('Created: %s', result)

    creator = Creator.from_id(book.creator_id)
    if not creator.rebuild_torrent:
        creator = Creator.from_updated(creator, dict(rebuild_torrent=True))
开发者ID:zcomx,项目名称:zcomix.com,代码行数:11,代码来源:create_torrent.py

示例7: test__creator_crud

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def test__creator_crud(self):

        def get_creator():
            """Return a creator"""
            return Creator.from_id(self._creator.id)

        old_creator = get_creator()

        web.login()

        url = '{url}/creator_crud.json'.format(url=self.url)
        data = {
            'name': 'paypal_email',
            'value': '[email protected]',
        }
        web.post(url, data=data)

        creator = get_creator()
        self.assertEqual(
            creator.paypal_email,
            '[email protected]'
        )

        # Invalid name
        data = {
            'name': '_invalid_field_',
            'value': '[email protected]',
        }
        web.post(url, data=data)
        self.assertEqual(
            web.text,
            '{"status": "error", "msg": "Invalid data provided"}\n'
        )

        # No data
        data = {}
        web.post(url, data=data)
        self.assertEqual(
            web.text,
            '{"status": "error", "msg": "Invalid data provided"}\n'
        )

        Creator.from_updated(self._creator, old_creator.as_dict())
开发者ID:zcomx,项目名称:zcomix.com,代码行数:45,代码来源:test_login.py

示例8: archive

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def archive(self, base_path=None):
        """Archive the torrent.

        Returns:
            string, name of archive file.
        """
        result = BaseTorrentCreator.archive(self, base_path=base_path)
        if self.creator:
            data = dict(torrent=result)
            self.creator = Creator.from_updated(self.creator, data)
        return result
开发者ID:zcomx,项目名称:zcomix.com,代码行数:13,代码来源:torrents.py

示例9: test__requires_agreed_to_terms

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def test__requires_agreed_to_terms(self):
        env = globals()
        auth = env['auth']
        session = env['session']
        session.auth = Storage({})              # Not logged in

        auth_user = self.add(AuthUser, dict(
            email='[email protected]',
        ))

        creator = self.add(Creator, dict(
            auth_user_id=auth_user.id,
            agreed_to_terms=False,
        ))

        auth.user = auth_user

        @requires_agreed_to_terms()
        def func():
            return 'Success'

        # agreed_to_terms=False, should not permit access
        self.assertRaisesHTTP(303, func)

        # auth_user is impersonating, should permit access
        # Simulate a logged in session
        session.auth = Storage(
            user=auth_user,
            impersonator='_fake_impersonator_'
        )
        self.assertTrue(auth.is_logged_in())
        self.assertTrue(auth.is_impersonating())
        self.assertEqual(func(), 'Success')

        # Reset membership
        session.auth = Storage(user=auth_user)   # No longer impersonating
        self.assertRaisesHTTP(303, func)

        # agreed_to_terms=False, should permit access
        Creator.from_updated(creator, dict(agreed_to_terms=True))
        self.assertEqual(func(), 'Success')
开发者ID:zcomx,项目名称:zcomix.com,代码行数:43,代码来源:test_access.py

示例10: test__follow_url

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
 def test__follow_url(self):
     tests = [
         # (facebook, expect)
         (None, None),
         ('http://www.facebook.com/auser', 'http://www.facebook.com/auser'),
     ]
     for t in tests:
         data = dict(facebook=t[0])
         self._creator = Creator.from_updated(self._creator, data)
         media = FacebookSocialMedia(
             self._book, creator=self._creator)
         self.assertEqual(media.follow_url(), t[1])
开发者ID:zcomx,项目名称:zcomix.com,代码行数:14,代码来源:test_social_media.py

示例11: main

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
def main():
    """Main processing."""

    usage = '%prog [options]'
    parser = OptionParser(usage=usage, version=VERSION)

    parser.add_option(
        '--man',
        action='store_true', dest='man', default=False,
        help='Display manual page-like help and exit.',
    )
    parser.add_option(
        '-v', '--verbose',
        action='store_true', dest='verbose', default=False,
        help='Print messages to stdout.',
    )
    parser.add_option(
        '--vv',
        action='store_true', dest='vv', default=False,
        help='More verbose.',
    )

    (options, args) = parser.parse_args()

    if options.man:
        man_page()
        quit(0)

    set_cli_logging(LOG, options.verbose, options.vv)

    if len(args) > 0:
        parser.print_help()
        exit(1)

    LOG.debug('Starting')

    for creator in creators_needing_purge():
        LOG.debug('Purging torrent for creator: %s', creator.name)
        delete_torrent(creator)
        data = dict(
            torrent=None,
            rebuild_torrent=False,
        )
        creator = Creator.from_updated(creator, data)

    count = num_books_with_cbz()
    LOG.debug('Number of books with cbz file: %s', count)
    if count == 0:
        delete_all_torrent()
    else:
        LOG.debug('"All" torrent required, not deleting.')

    LOG.debug('Done')
开发者ID:zcomx,项目名称:zcomix.com,代码行数:55,代码来源:purge_torrents.py

示例12: clear_creator_indicia

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
def clear_creator_indicia(creator):
    """Clear indicia for creator.

    Args:
        creator: Creator instance
    Returns:
        creator
    """
    fields = ['indicia_image', 'indicia_portrait', 'indicia_landscape']

    data = {}
    for field in fields:
        if creator[field]:
            on_delete_image(creator[field])
            data[field] = None

    creator = Creator.from_updated(creator, data)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:19,代码来源:update_creator_indicia.py

示例13: test__creator_img_handler

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def test__creator_img_handler(self):

        def get_creator():
            """Return a Creator instance"""
            return Creator.from_id(self._creator.id)

        old_creator = Creator.from_updated(self._creator, dict(image=None))
        self.assertFalse(old_creator.image)

        web.login()

        # Use requests to simplify uploading a file.
        sample_file = os.path.join(self._test_data_dir, 'web_plus.jpg')
        files = {'up_files': open(sample_file, 'rb')}
        response = requests.post(
            web.app + '/login/creator_img_handler',
            files=files,
            cookies=web.cookies,
            verify=False,
        )
        self.assertEqual(response.status_code, 200)

        creator = get_creator()
        self.assertTrue(creator.image)

        response_2 = requests.delete(
            web.app + '/login/creator_img_handler',
            cookies=web.cookies,
            verify=False,
        )
        self.assertEqual(response_2.status_code, 200)
        creator = get_creator()
        self.assertFalse(creator.image)

        # Reset the image
        sample_file = os.path.join(self._test_data_dir, 'web_plus.jpg')
        files = {'up_files': open(sample_file, 'rb')}
        response = requests.post(
            web.app + '/login/creator_img_handler',
            files=files,
            cookies=web.cookies,
            verify=False,
        )
        self.assertEqual(response.status_code, 200)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:46,代码来源:test_login.py

示例14: test__profile_onaccept

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def test__profile_onaccept(self):
        tracker = TableTracker(db.job)

        auth_user = self.add(AuthUser, dict(
            name='Test Profile Onaccept'
        ))

        creator = self.add(Creator, dict(
            email='[email protected]',
        ))

        self.assertEqual(creator.name_for_search, None)
        self.assertEqual(creator.name_for_url, None)

        # form has no email
        form = Storage({'vars': Storage()})
        profile_onaccept(form)
        creator = Creator.from_id(creator.id)
        self.assertEqual(creator.name_for_search, None)
        self.assertEqual(creator.name_for_url, None)

        # creator.auth_user_id not set
        form.vars.id = auth_user.id
        profile_onaccept(form)
        creator = Creator.from_id(creator.id)
        self.assertEqual(creator.name_for_search, None)
        self.assertEqual(creator.name_for_url, None)

        data = dict(auth_user_id=auth_user.id)
        creator = Creator.from_updated(creator, data)
        profile_onaccept(form)
        creator = Creator.from_id(creator.id)
        self.assertEqual(creator.name_for_search, 'test-profile-onaccept')
        self.assertEqual(creator.name_for_url, 'TestProfileOnaccept')

        for record in tracker.diff():
            job = Job.from_id(record.id)
            self._objects.append(job)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:40,代码来源:test_creators.py

示例15: test__on_change_name

# 需要导入模块: from applications.zcomx.modules.creators import Creator [as 别名]
# 或者: from applications.zcomx.modules.creators.Creator import from_updated [as 别名]
    def test__on_change_name(self):
        tracker = TableTracker(db.job)

        auth_user = self.add(AuthUser, dict(
            name='Test On Change Name'
        ))

        creator = self.add(Creator, dict(
            email='[email protected]'
        ))

        def test_prefetch_job():
            query = (db.job.command.like('%search_prefetch.py'))
            jobs = db(query).select()
            self.assertTrue(len(jobs) > 0)
            for job in jobs:
                job.delete_record()
            db.commit()

        self.assertEqual(creator.name_for_search, None)
        self.assertEqual(creator.name_for_url, None)

        # creator.auth_user_id not set
        self.assertRaises(LookupError, on_change_name, creator)

        creator = Creator.from_updated(creator, dict(
            auth_user_id=auth_user.id
        ))
        updated_creator = on_change_name(creator)
        test_prefetch_job()
        self.assertEqual(
            updated_creator.name_for_search, 'test-on-change-name')
        self.assertEqual(updated_creator.name_for_url, 'TestOnChangeName')

        for record in tracker.diff():
            job = Job.from_id(record.id)
            self._objects.append(job)
开发者ID:zcomx,项目名称:zcomix.com,代码行数:39,代码来源:test_creators.py


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