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


Python utils.Cycler类代码示例

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


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

示例1: objects

def objects():

    if False:
        yield sales.InvoicingMode(
            **dd.babel_values(
                'name',
                en='Default', de="Standard", fr="Standard"))

    if ledger:
        Invoice = dd.resolve_model('sales.VatProductInvoice')
        InvoiceItem = dd.resolve_model('sales.InvoiceItem')
        vt = ledger.VoucherTypes.get_for_model(Invoice)
        JOURNALS = Cycler(vt.get_journals())
        if len(JOURNALS.items) == 0:
            raise Exception("20140127 no journals for %s" % vt)
        PARTNERS = Cycler(Partner.objects.all())
        USERS = Cycler(settings.SITE.user_model.objects.all())
        PRODUCTS = Cycler(rt.models.products.Product.objects.all())
        ITEMCOUNT = Cycler(1, 2, 3)
        for i in range(20):
            jnl = JOURNALS.pop()
            invoice = Invoice(
                journal=jnl,
                partner=PARTNERS.pop(),
                user=USERS.pop(),
                date=settings.SITE.demo_date(i-21))
            yield invoice
            for j in range(ITEMCOUNT.pop()):
                item = InvoiceItem(voucher=invoice, product=PRODUCTS.pop())
                item.product_changed(REQUEST)
                item.before_ui_save(REQUEST)
                yield item
            invoice.register(REQUEST)
            invoice.save()
开发者ID:lino-framework,项目名称:xl,代码行数:34,代码来源:unused_demo.py

示例2: objects

def objects():
    REQUEST = settings.SITE.login()
    Journal = rt.models.ledger.Journal
    Company = rt.models.contacts.Company
    Declaration = rt.models.eevat.Declaration

    office = Company(
        name="Maksu- ja Tolliamet",
        street="Lõõtsa 8a",
        country_id="EE", zip_code="15176", city="Tallinn")
    yield office
    
    USERS = Cycler(settings.SITE.user_model.objects.all())
    JOURNAL = Journal.objects.get(ref=rt.models.eevat.DEMO_JOURNAL_NAME)

    date = datetime.date(dd.plugins.ledger.start_year, 1, 4)
    end_date = settings.SITE.demo_date(-30) 
    while date < end_date:
        dcl = Declaration(
            journal=JOURNAL,
            user=USERS.pop(),
            partner=office,
            entry_date=date,
            voucher_date=date)
        yield dcl
        dcl.register(REQUEST)
        dcl.save()

        date += AMONTH
开发者ID:lino-framework,项目名称:xl,代码行数:29,代码来源:payments.py

示例3: objects

def objects():

    Journal = rt.models.ledger.Journal
    Company = rt.models.contacts.Company
    Declaration = rt.models.bevats.Declaration
    # DeclarationFields = rt.models.declarations.DeclarationFields
    # Account = rt.models.accounts.Account

    # m = import_module(dd.plugins.declarations.country_module)
    # from lino_xl.lib.declarations.be import demo_objects

    yield demo_objects()

    office = Company(
        name="Mehrwertsteuer-Kontrollamt Eupen",
        street="Vervierser Str. 8",
        country_id="BE", zip_code="4700")
    yield office
    
    USERS = Cycler(settings.SITE.user_model.objects.all())
    JOURNAL = Journal.objects.get(ref=rt.models.bevats.DEMO_JOURNAL_NAME)
    # date = datetime.date(dd.plugins.ledger.start_year, 1, 4)
    date = datetime.date(dd.plugins.ledger.start_year, 1, 31)
    end_date = settings.SITE.demo_date(-30) 
    while date < end_date:
        dcl = Declaration(
            journal=JOURNAL,
            user=USERS.pop(),
            partner=office,
            entry_date=date)
        yield dcl
        dcl.register(REQUEST)
        dcl.save()

        date += AMONTH
开发者ID:khchine5,项目名称:xl,代码行数:35,代码来源:demo_bookings.py

示例4: objects

def objects():

    PAYMENT_TERMS = Cycler(rt.models.ledger.PaymentTerm.objects.all())

    for obj in rt.models.contacts.Partner.objects.all():
        obj.payment_term = PAYMENT_TERMS.pop()
        yield obj
开发者ID:khchine5,项目名称:xl,代码行数:7,代码来源:demo.py

示例5: objects

def objects():
    AddressTypes = rt.models.addresses.AddressTypes
    Address = rt.models.addresses.Address
    # Partner = rt.models.contacts.Partner
    Partner = dd.plugins.addresses.partner_model
    Place = rt.models.countries.Place
    eupen = Place.objects.get(name__exact='Eupen')
    STREETS = Cycler(streets_of_eupen())
    TYPES = Cycler(AddressTypes.objects())

    def create_addr_from_owner(o, **kw):
        kw.update(partner=o)
        for k in Address.ADDRESS_FIELDS:
            kw[k] = getattr(o, k)
        return Address(**kw)

    nr = 1
    for p in Partner.objects.filter(city=eupen):
        if nr % 3:
            yield create_addr_from_owner(
                p, primary=True, address_type=AddressTypes.official)
            kw = dict(partner=p)
            kw.update(address_type=TYPES.pop())
            kw.update(street=STREETS.pop())
            kw.update(street_no=str(nr % 200))
            yield Address(**kw)
        nr += 1
开发者ID:khchine5,项目名称:xl,代码行数:27,代码来源:demo2.py

示例6: objects

def objects():
    
    yield sales.InvoicingMode(**babel_values('name',en='Default',de=u"Standard",fr=u"Standard"))
    
    if ledger:
        Invoice = dd.resolve_model('sales.Invoice')
        InvoiceItem = dd.resolve_model('sales.InvoiceItem')
        vt = ledger.VoucherTypes.get_for_model(Invoice)
        JOURNALS = Cycler(vt.get_journals())
        PARTNERS = Cycler(Partner.objects.all())
        USERS = Cycler(settings.SITE.user_model.objects.all())
        PRODUCTS = Cycler(products.Product.objects.all())
        ITEMCOUNT = Cycler(1,2,3)
        for i in range(20):
            jnl = JOURNALS.pop()
            invoice = Invoice(journal=jnl,
              partner=PARTNERS.pop(),
              user=USERS.pop(),
              date=settings.SITE.demo_date(-30+2*i))
            yield invoice
            for j in range(ITEMCOUNT.pop()):
                item = InvoiceItem(voucher=invoice,
                    #~ account=jnl.get_allowed_accounts()[0],
                    product=PRODUCTS.pop(),
                    )
                item.product_changed(REQUEST)
                item.before_ui_save(REQUEST)
                #~ if item.total_incl:
                    #~ print "20121208 ok", item
                #~ else:
                    #~ if item.product.price:
                        #~ raise Exception("20121208")
                yield item
            invoice.register(REQUEST)
            invoice.save()
开发者ID:MaxTyutyunnikov,项目名称:lino,代码行数:35,代码来源:demo.py

示例7: objects

def objects():
    CLIENTS = Cycler(pcsw.Client.objects.filter(
        client_state=pcsw.ClientStates.coached))
    COMPANIES = Cycler(contacts.Company.objects.all())
    for i in range(10):
        yield create(CLIENTS.pop(), COMPANIES.pop(),
                     dd.demo_date(i), i % 2)
开发者ID:khchine5,项目名称:welfare,代码行数:7,代码来源:demo.py

示例8: objects

def objects():

    last_names = demonames.LAST_NAMES_BELGIUM
    male_first_names = demonames.MALE_FIRST_NAMES_FRANCE
    female_first_names = demonames.FEMALE_FIRST_NAMES_FRANCE

    Person = dd.resolve_model("contacts.Person")
    Place = dd.resolve_model('countries.Place')

    CITIES = Cycler(
        Place.objects.filter(country_id='BE', zip_code__startswith='40'))
    STREETS = demonames.streets_of_liege()

    common = dict(language='fr', country_id='BE')
    for i in range(100):
        yield Person(
            first_name=male_first_names.pop(),
            last_name=last_names.pop(),
            gender=mixins.Genders.male,
            city=CITIES.pop(),
            street=STREETS.pop(),
            **common
        )
        yield Person(
            first_name=female_first_names.pop(),
            last_name=last_names.pop(),
            gender=mixins.Genders.female,
            city=CITIES.pop(),
            street=STREETS.pop(),
            **common
        )
开发者ID:cuchac,项目名称:lino,代码行数:31,代码来源:demo_fr.py

示例9: objects

def objects():
    ses = rt.login()
    Client = rt.modules.pcsw.Client
    CLIENTS = Cycler(Client.objects.all())
    for obj in lino_objects():
        if obj.__class__.__name__ == "Event":
            if obj.event_type.invite_client:
                obj.project = CLIENTS.pop()
        yield obj
        obj.update_guests.run_from_code(ses)
开发者ID:khchine5,项目名称:welfare,代码行数:10,代码来源:demo2.py

示例10: handle

    def handle(self, *args, **options):

        dbname = settings.DATABASES['default']['NAME']
        if options.get('interactive'):
            if not confirm("This is going to GARBLE your database (%s).\nAre you sure (y/n) ?" % dbname):
                raise CommandError("User abort.")

        contacts = dd.resolve_app('contacts')

        User = dd.resolve_model(settings.SITE.user_model)
        Person = dd.resolve_model('contacts.Person')
        Household = dd.resolve_model('households.Household')
        Member = dd.resolve_model('households.Member')
        Role = dd.resolve_model('households.Role')
        Country = dd.resolve_model('countries.Country')

        for p in Person.objects.order_by('id'):
            if User.objects.filter(partner=p).count() > 0:
                # users keep their original name
                pass
            else:
                p.nationality = Country.objects.get(
                    isocode=NATIONALITIES.pop())
                p.last_name = LAST_NAMES.pop()
                if p.gender == dd.Genders.male:
                    p.first_name = MALES.pop()
                    FEMALES.pop()
                else:
                    p.first_name = FEMALES.pop()
                    MALES.pop()
                #~ dblogger.log_changes(REQUEST,p)
                p.name = join_words(p.last_name, p.first_name)
                p.save()
                dblogger.info("%s from %s", unicode(p), unicode(p.nationality))

        MEN = Cycler(Person.objects.filter(gender=dd.Genders.male)
                     .order_by('id'))
        WOMEN = Cycler(
            Person.objects.filter(gender=dd.Genders.female).order_by('id'))
        for h in Household.objects.all():
            if h.member_set.all().count() == 0:
                he = MEN.pop()
                she = WOMEN.pop()
                h.name = he.last_name + "-" + she.last_name
                Member(household=h, person=he,
                       role=Role.objects.get(pk=1)).save()
                Member(household=h, person=she,
                       role=Role.objects.get(pk=2)).save()
            else:
                h.name = ''
                h.full_clean()
            h.save()
            dblogger.info(unicode(h))

        dblogger.info("GARBLE done on database %s." % dbname)
开发者ID:khchine5,项目名称:welfare,代码行数:55,代码来源:garble.py

示例11: objects

def objects():
    Account = rt.models.ana.Account
    # Group = rt.models.ana.Group
    GenAccount = rt.models.ledger.Account
    
    def x(ref, name):
        return babeld(Account, name, ref=ref)
        # if len(ref) == 4:
        #     kwargs = dict(ref=ref)
        #     ref = ref[:-1]
        #     while len(ref):
        #         try:
        #             grp = Group.get_by_ref(ref)
        #             kwargs.update(group=grp)
        #             break
        #         except Group.DoesNotExist:
        #             pass
        #         ref = ref[:-1]
        #     return babeld(Account, name, **kwargs)
        # else:
        #     return babeld(Group, name, ref=ref)
        
    yield x("1", _("Operation costs"))
    yield x("1100", _("Wages"))
    yield x("1200", _("Transport"))
    yield x("1300", _("Training"))
    yield x("1400", _("Other costs"))
    
    yield x("2", _("Administrative costs"))
    yield x("2100", _("Secretary wages"))
    yield x("2110", _("Manager wages"))
    yield x("2200", _("Transport"))
    yield x("2300", _("Training"))
    
    yield x("3", _("Investments"))
    yield x("3000", _("Investment"))
    
    yield x("4", _("Project 1"))
    yield x("4100", _("Wages"))
    yield x("4200", _("Transport"))
    yield x("4300", _("Training"))
    
    yield x("5", _("Project 2"))
    yield x("5100", _("Wages"))
    yield x("5200", _("Transport"))
    yield x("5300", _("Other costs"))

    ANA_ACCS = Cycler(Account.get_usable_items().order_by('ref'))
    
    qs = GenAccount.objects.filter(needs_ana=True).order_by('ref')
    for i, ga in enumerate(qs):
        if (i+1) % 3:
            ga.ana_account = ANA_ACCS.pop()
            ga.full_clean()
            ga.save()
开发者ID:lino-framework,项目名称:xl,代码行数:55,代码来源:minimal_ledger.py

示例12: objects

def objects():

    polls = rt.models.polls

    USERS = Cycler(settings.SITE.user_model.objects.all())

    for p in polls.Poll.objects.exclude(questions_to_add=''):
        p.after_ui_save(None, None)
        yield polls.Response(
            poll=p, user=USERS.pop(), date=dd.today(),
            state=polls.ResponseStates.draft)
开发者ID:khchine5,项目名称:xl,代码行数:11,代码来源:demo2.py

示例13: objects

def objects():

    Obstacle = rt.modules.cv.Obstacle
    ObstacleType = rt.modules.cv.ObstacleType
    Client = rt.modules.pcsw.Client
    ClientStates = rt.modules.pcsw.ClientStates

    CLIENTS = Cycler(Client.objects.filter(
        client_state=ClientStates.coached)[10:15])

    TYPES = Cycler(ObstacleType.objects.all())

    for i in range(20):
        yield Obstacle(person=CLIENTS.pop(), type=TYPES.pop())
开发者ID:khchine5,项目名称:welfare,代码行数:14,代码来源:demo.py

示例14: skills_objects

def skills_objects():
    "was previously in skills.fixtures.demo2"

    Skill = rt.models.skills.Skill
    Competence = rt.models.skills.Competence
    Demand = rt.models.skills.Demand
    # Ticket = rt.models.tickets.Ticket
    User = rt.models.users.User

    yield named(Skill, _('Psychotherapy'))
    yield named(Skill, _('Psychiatry'))

    SKILLS = Cycler(Skill.objects.all())
    END_USERS = Cycler(dd.plugins.skills.end_user_model.objects.all())

    i = 0
    for j in range(2):
        for u in User.objects.all():
            i += 1
            yield Competence(user=u, faculty=SKILLS.pop())
            if i % 2:
                yield Competence(user=u, faculty=SKILLS.pop())
            if i % 3:
                yield Competence(
                    user=u, faculty=SKILLS.pop(),
                    end_user=END_USERS.pop())
            
    for i, t in enumerate(
            dd.plugins.skills.demander_model.objects.all()):
        yield Demand(demander=t, skill=SKILLS.pop())
        if i % 3:
            yield Demand(demander=t, skill=SKILLS.pop())
开发者ID:khchine5,项目名称:book,代码行数:32,代码来源:demo.py

示例15: objects

def objects():

    kwargs = dict(user_type=rt.models.users.UserTypes.user)
    # kwargs = dict()
    
    yield User(username="Albert", **kwargs)
    yield User(username="Boris", **kwargs)
    yield User(username="Claire", **kwargs)
    
    yield Company(name="AllTech inc.")
    yield Company(name="BestTech inc.")
    yield Company(name="CoolTech inc.")
    
    yield EntryType(designation="Consultation")
    yield EntryType(designation="Evaluation")
    yield EntryType(designation="Test")
    yield EntryType(designation="Analysis")
    yield EntryType(designation="Observation")
    
    TYPES = Cycler(EntryType.objects.all())
    COMPANIES = Cycler(Company.objects.all())
    USERS = Cycler(User.objects.all())
    SUBJECTS = Cycler(LOREM_IPSUM.split())
    
    for i in range(200):
        d = settings.SITE.demo_date(-i)
        e = Entry(date=d,
            company=COMPANIES.pop(),
            user=USERS.pop(),
            subject=SUBJECTS.pop(),
            entry_type=TYPES.pop())
        if i % 7:
            yield e
开发者ID:khchine5,项目名称:book,代码行数:33,代码来源:demo.py


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