예제 #1
0
파일: test_main.py 프로젝트: 0101/pipetools
    def test_in(self):
        container = 'asdf'

        f = ~X._in_(container)

        assert f('a')
        assert not f('b')
예제 #2
0
    def test_in(self):
        container = 'asdf'

        f = ~X._in_(container)

        assert f('a')
        assert not f('b')
예제 #3
0
    def test_in(self):
        container = "asdf"

        f = ~X._in_(container)

        assert f("a")
        assert not f("b")
예제 #4
0
def create_units():
    "Creates CarUnits for existing Cars that don't have them"
    cars_with_units = CarUnit.objects.values_list('car_id', flat=True)
    taken_unit_ids = set(CarUnit.objects.values_list('unit_id', flat=True))
    free_unit_ids = count(1) > where_not(X._in_(taken_unit_ids))
    cars_without_units = Car.objects.all() > where_not(X.id._in_(cars_with_units))
    for car, unit_id in izip(cars_without_units, free_unit_ids):
        unit(unit_id, car)
예제 #5
0
def split_by_events(journey, entry):
    """
    Returns whether the last two events in `journey` were ENGINE_OFF and LOCKED

    -- where we only care about events: ENGINE_OFF, ENGINE_ON, UNLOCKED, LOCKED
    """
    from metrocar.car_unit_api.models import Events

    events_of_interest = (
        Events.ENGINE_OFF,
        Events.ENGINE_ON,
        Events.UNLOCKED,
        Events.LOCKED,
    )
    events = journey['events'] > where(X._in_(events_of_interest)) | tuple
    return (len(events) >= 2 and
        (events[-2], events[-1]) == (Events.ENGINE_OFF, Events.LOCKED))
예제 #6
0
    def __init__(self, *args, **kwargs):
        super(SmartAdmin, self).__init__(*args, **kwargs)

        if self.list_display == admin.ModelAdmin.list_display:
            self.list_display = ('__str__', ) + (self._get_fields(
                lambda field: type(field) not in self.list_display_exclude))

        self.date_hierarchy = (self.date_hierarchy or self.all_fields > maybe
            | select_first(type | X._in_([DateTimeField, DateField]))
            | X.name)

        self.list_filter = self.list_filter or self._get_list_filter()

        self.search_fields = self.search_fields or self._get_search_fields()
        self.raw_id_fields = self.raw_id_fields or self._get_fields(
            self.should_be_raw_id_field)

        self.filter_horizontal = self.filter_horizontal or self._get_fields(
            type | (X == ManyToManyField))