當前位置: 首頁>>代碼示例>>Python>>正文


Python Unit.max_revision方法代碼示例

本文整理匯總了Python中pootle_store.models.Unit.max_revision方法的典型用法代碼示例。如果您正苦於以下問題:Python Unit.max_revision方法的具體用法?Python Unit.max_revision怎麽用?Python Unit.max_revision使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pootle_store.models.Unit的用法示例。


在下文中一共展示了Unit.max_revision方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fs_plugin_base

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
def fs_plugin_base(tutorial, tmpdir, settings, system, english, zulu):
    from django.core.cache import caches

    import pootle_fs_pytest

    from pootle.core.models import Revision
    from pootle_store.models import Unit

    caches["exports"].clear()

    Revision.set(Unit.max_revision())

    dir_path = str(tmpdir.dirpath())
    repo_path = os.path.join(dir_path, "__src__")
    src_path = os.path.abspath(
        os.path.join(
            os.path.dirname(pootle_fs_pytest.__file__),
            "data/fs/example_fs"))
    settings.POOTLE_FS_PATH = dir_path
    tutorial_path = os.path.join(dir_path, tutorial.code)
    if os.path.exists(tutorial_path):
        shutil.rmtree(tutorial_path)
    if os.path.exists(repo_path):
        shutil.rmtree(repo_path)
    return tutorial, src_path, repo_path, dir_path
開發者ID:ta2-1,項目名稱:pootle_fs,代碼行數:27,代碼來源:plugin.py

示例2: handle

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
    def handle(self, **options):
        if (not options['flush_rqdata'] and
            not options['flush_lru'] and
            not options['flush_django_cache'] and
            not options['flush_all']):
            raise CommandError("No options were provided. Use one of "
                               "--django-cache, --rqdata, --lru "
                               "or --all.")

        self.stdout.write('Flushing cache...')

        if options['flush_rqdata'] or options['flush_all']:
            # Flush all rq data, dirty counter and restore Pootle revision
            # value.
            r_con = get_redis_connection('redis')
            r_con.flushdb()
            self.stdout.write('RQ data removed.')
            Revision.set(Unit.max_revision())
            self.stdout.write('Max unit revision restored.')

        if options['flush_django_cache'] or options['flush_all']:
            r_con = get_redis_connection('default')
            r_con.flushdb()
            self.stdout.write('All default Django cache data removed.')

        if options['flush_lru'] or options['flush_all']:
            r_con = get_redis_connection('lru')
            r_con.flushdb()
            self.stdout.write('All lru cache data removed.')
開發者ID:ainslied,項目名稱:pootle,代碼行數:31,代碼來源:flush_cache.py

示例3: handle_noargs

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
    def handle_noargs(self, **options):
        if options["restore"]:
            from pootle_store.models import Unit

            Revision.set(Unit.max_revision())

        self.stdout.write("%s" % Revision.get())
開發者ID:likulogy,項目名稱:pootle,代碼行數:9,代碼來源:revision.py

示例4: revision

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
def revision(request, clear_cache):
    """Sets up the cached revision counter for each test call."""
    from pootle.core.models import Revision
    from pootle_store.models import Unit

    if request.node.get_marker("django_db"):
        Revision.set(Unit.max_revision())
    else:
        Revision.initialize()
開發者ID:AshishNamdev,項目名稱:pootle,代碼行數:11,代碼來源:revision.py

示例5: test_max_revision

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
def test_max_revision(af_tutorial_po):
    """Tests `max_revision()` gets the latest revision."""
    initial_max_revision = Unit.max_revision()
    initial_revision = Revision.get()
    assert initial_max_revision == initial_revision
    assert initial_max_revision == 0

    # Let's make 10 translation updates, this must also update their
    # revision numbers
    for i in range(10):
        _update_translation(af_tutorial_po, 0, {'target': str(i)},
                            sync=False)

    end_max_revision = Unit.max_revision()
    end_revision = Revision.get()
    assert end_max_revision == end_revision
    assert end_max_revision != initial_max_revision

    assert end_revision != initial_revision
    assert end_revision == 10
開發者ID:OpenSource-ECom,項目名稱:pootle,代碼行數:22,代碼來源:revision.py

示例6: test_max_revision

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
def test_max_revision(revision, project0_nongnu, store0):
    """Tests `max_revision()` gets the latest revision."""

    initial_max_revision = Unit.max_revision()
    initial_revision = Revision.get()
    assert initial_max_revision == initial_revision

    # Let's make 10 translation updates, this must also update their revision
    # numbers
    unit = store0.units.first()
    for i in range(10):
        unit.target = str(i)
        unit.save()
        unit.refresh_from_db()

    end_max_revision = Unit.max_revision()
    end_revision = Revision.get()
    assert end_max_revision == end_revision
    assert end_max_revision != initial_max_revision

    assert end_revision != initial_revision
    assert end_revision == 10 + initial_revision
開發者ID:arky,項目名稱:pootle,代碼行數:24,代碼來源:revision.py

示例7: test_max_revision

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
def test_max_revision(af_tutorial_po):
    """Tests `max_revision()` gets the latest revision."""

    # update a store first, initial_revision = 1 after this update
    af_tutorial_po.update(overwrite=False, only_newer=False)

    initial_max_revision = Unit.max_revision()
    initial_revision = Revision.get()
    assert initial_max_revision == initial_revision
    assert initial_max_revision == 1

    # Let's make 10 translation updates, this must also update their
    # revision numbers
    for i in range(10):
        _update_translation(af_tutorial_po, 0, {"target": str(i)}, sync=False)

    end_max_revision = Unit.max_revision()
    end_revision = Revision.get()
    assert end_max_revision == end_revision
    assert end_max_revision != initial_max_revision

    assert end_revision != initial_revision
    assert end_revision == 10 + initial_revision
開發者ID:Jobava,項目名稱:pootle,代碼行數:25,代碼來源:revision.py

示例8: test_max_revision

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
def test_max_revision(revision, project0_nongnu, store0):
    """Tests `max_revision()` gets the latest revision."""
    store0.sync()

    # update a store first, initial_revision = 1 after this update
    store0.update(store0.file.store)

    initial_max_revision = Unit.max_revision()
    initial_revision = Revision.get()
    assert initial_max_revision == initial_revision

    # Let's make 10 translation updates, this must also update their revision
    # numbers
    for i in range(10):
        _update_translation(store0, 0, {'target': str(i)},
                            sync=False)

    end_max_revision = Unit.max_revision()
    end_revision = Revision.get()
    assert end_max_revision == end_revision
    assert end_max_revision != initial_max_revision

    assert end_revision != initial_revision
    assert end_revision == 10 + initial_revision
開發者ID:SafaAlfulaij,項目名稱:pootle,代碼行數:26,代碼來源:revision.py

示例9: check_revision

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
def check_revision(app_configs=None, **kwargs):
    from pootle.core.models import Revision
    from pootle_store.models import Unit

    errors = []
    revision = Revision.get()
    try:
        max_revision = Unit.max_revision()
    except (OperationalError, ProgrammingError):
        return errors
    if revision is None or revision < max_revision:
        errors.append(checks.Critical(
            _("Revision is missing or has an incorrect value."),
            hint=_("Run `revision --restore` to reset the revision counter."),
            id="pootle.C016",
        ))

    return errors
開發者ID:RevelSystems,項目名稱:cat-pootle,代碼行數:20,代碼來源:checks.py

示例10: handle

# 需要導入模塊: from pootle_store.models import Unit [as 別名]
# 或者: from pootle_store.models.Unit import max_revision [as 別名]
    def handle(self, **options):
        if options['restore']:
            from pootle_store.models import Unit
            Revision.set(Unit.max_revision())

        self.stdout.write('%s' % Revision.get())
開發者ID:AlfredWei,項目名稱:pootle,代碼行數:8,代碼來源:revision.py


注:本文中的pootle_store.models.Unit.max_revision方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。