bitmapist 3.112__tar.gz → 3.114__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bitmapist-3.112 → bitmapist-3.114}/PKG-INFO +1 -1
- {bitmapist-3.112 → bitmapist-3.114}/bitmapist/__init__.py +74 -75
- {bitmapist-3.112 → bitmapist-3.114}/bitmapist/cohort/__init__.py +56 -46
- {bitmapist-3.112 → bitmapist-3.114}/bitmapist/cohort/tmpl/form_data.mako +4 -4
- {bitmapist-3.112 → bitmapist-3.114}/bitmapist/cohort/tmpl/table_data.mako +2 -2
- {bitmapist-3.112 → bitmapist-3.114}/bitmapist/cohort/tmpl/table_data_csv.mako +3 -3
- bitmapist-3.114/pyproject.toml +235 -0
- bitmapist-3.112/pyproject.toml +0 -50
- {bitmapist-3.112 → bitmapist-3.114}/AUTHORS +0 -0
- {bitmapist-3.112 → bitmapist-3.114}/README.md +0 -0
- {bitmapist-3.112 → bitmapist-3.114}/bitmapist/py.typed +0 -0
- {bitmapist-3.112 → bitmapist-3.114}/static/bitmapist.png +0 -0
- {bitmapist-3.112 → bitmapist-3.114}/static/bitmapist.svg +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""
|
|
3
2
|
bitmapist
|
|
4
3
|
~~~~~~~~~
|
|
@@ -79,15 +78,19 @@ Additionally you can supply an extra argument to mark_event to bypass the defaul
|
|
|
79
78
|
:developer: Amir Salihefendic ( http://amix.dk )
|
|
80
79
|
:license: BSD
|
|
81
80
|
"""
|
|
82
|
-
from builtins import range, bytes
|
|
83
81
|
|
|
84
|
-
import
|
|
85
|
-
|
|
86
|
-
from typing import Union, Optional
|
|
87
|
-
from redis.client import Redis, Pipeline
|
|
82
|
+
from __future__ import annotations
|
|
83
|
+
|
|
88
84
|
import calendar
|
|
85
|
+
import threading
|
|
89
86
|
from collections import defaultdict
|
|
90
|
-
from datetime import
|
|
87
|
+
from datetime import date, datetime, timedelta
|
|
88
|
+
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
89
|
+
|
|
90
|
+
import redis
|
|
91
|
+
|
|
92
|
+
if TYPE_CHECKING:
|
|
93
|
+
from redis.client import Pipeline, Redis
|
|
91
94
|
|
|
92
95
|
local_thread = threading.local()
|
|
93
96
|
|
|
@@ -104,7 +107,7 @@ TRACK_HOURLY = False
|
|
|
104
107
|
TRACK_UNIQUE = False
|
|
105
108
|
|
|
106
109
|
|
|
107
|
-
def setup_redis(name: str, host: str, port: int, **kw) -> None:
|
|
110
|
+
def setup_redis(name: str, host: str, port: int, **kw: Any) -> None:
|
|
108
111
|
"""
|
|
109
112
|
Setup a redis system.
|
|
110
113
|
|
|
@@ -115,9 +118,9 @@ def setup_redis(name: str, host: str, port: int, **kw) -> None:
|
|
|
115
118
|
|
|
116
119
|
Example::
|
|
117
120
|
|
|
118
|
-
setup_redis(
|
|
121
|
+
setup_redis("stats_redis", "localhost", 6380)
|
|
119
122
|
|
|
120
|
-
mark_event(
|
|
123
|
+
mark_event("active", 1, system="stats_redis")
|
|
121
124
|
"""
|
|
122
125
|
redis_client = kw.pop("redis_client", redis.StrictRedis)
|
|
123
126
|
SYSTEMS[name] = redis_client(host=host, port=port, **kw)
|
|
@@ -132,8 +135,7 @@ def get_redis(system: str = "default") -> Union[Redis, Pipeline]:
|
|
|
132
135
|
"""
|
|
133
136
|
if isinstance(system, redis.StrictRedis):
|
|
134
137
|
return system
|
|
135
|
-
|
|
136
|
-
return SYSTEMS[system]
|
|
138
|
+
return SYSTEMS[system]
|
|
137
139
|
|
|
138
140
|
|
|
139
141
|
# --- Events marking and deleting
|
|
@@ -170,10 +172,10 @@ def mark_event(
|
|
|
170
172
|
Examples::
|
|
171
173
|
|
|
172
174
|
# Mark id 1 as active
|
|
173
|
-
mark_event(
|
|
175
|
+
mark_event("active", 1)
|
|
174
176
|
|
|
175
177
|
# Mark task completed for id 252
|
|
176
|
-
mark_event(
|
|
178
|
+
mark_event("tasks:completed", 252)
|
|
177
179
|
"""
|
|
178
180
|
_mark(
|
|
179
181
|
event_name, uuid, system, now, track_hourly, track_unique, use_pipeline, value=1
|
|
@@ -244,7 +246,7 @@ def mark_unique(event_name: str, uuid: int, system: str = "default") -> None:
|
|
|
244
246
|
Examples::
|
|
245
247
|
|
|
246
248
|
# Mark id 42 as premium
|
|
247
|
-
mark_unique(
|
|
249
|
+
mark_unique("premium", 42)
|
|
248
250
|
"""
|
|
249
251
|
_mark_unique(event_name, uuid, system, value=1)
|
|
250
252
|
|
|
@@ -264,7 +266,7 @@ def unmark_unique(event_name: str, uuid: int, system: str = "default") -> None:
|
|
|
264
266
|
Examples::
|
|
265
267
|
|
|
266
268
|
# Mark id 42 as not premium anymore
|
|
267
|
-
unmark_unique(
|
|
269
|
+
unmark_unique("premium", 42)
|
|
268
270
|
"""
|
|
269
271
|
_mark_unique(event_name, uuid, system, value=0)
|
|
270
272
|
|
|
@@ -293,9 +295,7 @@ def get_event_names(
|
|
|
293
295
|
|
|
294
296
|
|
|
295
297
|
def delete_all_events(system: str = "default") -> None:
|
|
296
|
-
"""
|
|
297
|
-
Delete all events from the database.
|
|
298
|
-
"""
|
|
298
|
+
"""Delete all events from the database."""
|
|
299
299
|
cli = get_redis(system)
|
|
300
300
|
keys = cli.keys("trackist_*")
|
|
301
301
|
if keys:
|
|
@@ -303,9 +303,7 @@ def delete_all_events(system: str = "default") -> None:
|
|
|
303
303
|
|
|
304
304
|
|
|
305
305
|
def delete_temporary_bitop_keys(system: str = "default") -> None:
|
|
306
|
-
"""
|
|
307
|
-
Delete all temporary keys that are used when using bit operations.
|
|
308
|
-
"""
|
|
306
|
+
"""Delete all temporary keys that are used when using bit operations."""
|
|
309
307
|
cli = get_redis(system)
|
|
310
308
|
keys = cli.keys("trackist_bitop_*")
|
|
311
309
|
if keys:
|
|
@@ -313,9 +311,7 @@ def delete_temporary_bitop_keys(system: str = "default") -> None:
|
|
|
313
311
|
|
|
314
312
|
|
|
315
313
|
def delete_runtime_bitop_keys() -> None:
|
|
316
|
-
"""
|
|
317
|
-
Delete all BitOp keys that were created.
|
|
318
|
-
"""
|
|
314
|
+
"""Delete all BitOp keys that were created."""
|
|
319
315
|
bitop_keys = _bitop_keys()
|
|
320
316
|
for system in bitop_keys:
|
|
321
317
|
if len(bitop_keys[system]) > 0:
|
|
@@ -348,14 +344,13 @@ class MixinIter:
|
|
|
348
344
|
# find set bits, generate smth like [1, 0, ...]
|
|
349
345
|
bits = [(char >> i) & 1 for i in range(7, -1, -1)]
|
|
350
346
|
# list of positions with ones
|
|
351
|
-
set_bits =
|
|
347
|
+
set_bits = [pos for pos, val in enumerate(bits) if val]
|
|
352
348
|
# yield everything we need
|
|
353
349
|
for bit in set_bits:
|
|
354
350
|
yield char_num * 8 + bit
|
|
355
351
|
|
|
356
352
|
def __iter__(self):
|
|
357
|
-
|
|
358
|
-
yield item
|
|
353
|
+
yield from self.get_uuids()
|
|
359
354
|
|
|
360
355
|
|
|
361
356
|
class MixinBitOperations:
|
|
@@ -418,15 +413,14 @@ class MixinContains:
|
|
|
418
413
|
|
|
419
414
|
Example::
|
|
420
415
|
|
|
421
|
-
user_active_today = 123 in DayEvents(
|
|
416
|
+
user_active_today = 123 in DayEvents("active", 2012, 10, 23)
|
|
422
417
|
"""
|
|
423
418
|
|
|
424
419
|
def __contains__(self, uuid):
|
|
425
420
|
cli = get_redis(self.system)
|
|
426
421
|
if cli.getbit(self.redis_key, uuid):
|
|
427
422
|
return True
|
|
428
|
-
|
|
429
|
-
return False
|
|
423
|
+
return False
|
|
430
424
|
|
|
431
425
|
|
|
432
426
|
class UniqueEvents(
|
|
@@ -452,11 +446,11 @@ class GenericPeriodEvents(
|
|
|
452
446
|
MixinIter, MixinCounts, MixinContains, MixinEventsMisc, MixinBitOperations
|
|
453
447
|
):
|
|
454
448
|
def next(self):
|
|
455
|
-
"""
|
|
449
|
+
"""Next object in a datetime line"""
|
|
456
450
|
return self.delta(value=1)
|
|
457
451
|
|
|
458
452
|
def prev(self):
|
|
459
|
-
"""
|
|
453
|
+
"""Prev object in a datetime line"""
|
|
460
454
|
return self.delta(value=-1)
|
|
461
455
|
|
|
462
456
|
|
|
@@ -466,7 +460,7 @@ class YearEvents(GenericPeriodEvents):
|
|
|
466
460
|
|
|
467
461
|
Example::
|
|
468
462
|
|
|
469
|
-
YearEvents(
|
|
463
|
+
YearEvents("active", 2012)
|
|
470
464
|
"""
|
|
471
465
|
|
|
472
466
|
@classmethod
|
|
@@ -480,9 +474,7 @@ class YearEvents(GenericPeriodEvents):
|
|
|
480
474
|
self.year = not_none(year, now.year)
|
|
481
475
|
self.system = system
|
|
482
476
|
|
|
483
|
-
months = []
|
|
484
|
-
for m in range(1, 13):
|
|
485
|
-
months.append(MonthEvents(event_name, self.year, m, system))
|
|
477
|
+
months = [MonthEvents(event_name, self.year, m, system) for m in range(1, 13)]
|
|
486
478
|
or_op = BitOpOr(system, *months)
|
|
487
479
|
self.redis_key = or_op.redis_key
|
|
488
480
|
|
|
@@ -502,7 +494,7 @@ class MonthEvents(GenericPeriodEvents):
|
|
|
502
494
|
|
|
503
495
|
Example::
|
|
504
496
|
|
|
505
|
-
MonthEvents(
|
|
497
|
+
MonthEvents("active", 2012, 10)
|
|
506
498
|
"""
|
|
507
499
|
|
|
508
500
|
@classmethod
|
|
@@ -516,7 +508,7 @@ class MonthEvents(GenericPeriodEvents):
|
|
|
516
508
|
self.year = not_none(year, now.year)
|
|
517
509
|
self.month = not_none(month, now.month)
|
|
518
510
|
self.system = system
|
|
519
|
-
self.redis_key = _prefix_key(event_name, "
|
|
511
|
+
self.redis_key = _prefix_key(event_name, f"{self.year}-{self.month}")
|
|
520
512
|
|
|
521
513
|
def delta(self, value):
|
|
522
514
|
year, month = add_month(self.year, self.month, value)
|
|
@@ -536,23 +528,25 @@ class WeekEvents(GenericPeriodEvents):
|
|
|
536
528
|
|
|
537
529
|
Example::
|
|
538
530
|
|
|
539
|
-
WeekEvents(
|
|
531
|
+
WeekEvents("active", 2012, 48)
|
|
540
532
|
"""
|
|
541
533
|
|
|
542
534
|
@classmethod
|
|
543
|
-
def from_date(
|
|
535
|
+
def from_date(
|
|
536
|
+
cls, event_name: str, dt: Optional[date] = None, system: str = "default"
|
|
537
|
+
):
|
|
544
538
|
dt = dt or datetime.utcnow()
|
|
545
539
|
dt_year, dt_week, _ = dt.isocalendar()
|
|
546
540
|
return cls(event_name, dt_year, dt_week, system=system)
|
|
547
541
|
|
|
548
|
-
def __init__(self, event_name, year=None, week=None, system="default"):
|
|
542
|
+
def __init__(self, event_name: str, year=None, week=None, system="default"):
|
|
549
543
|
now = datetime.utcnow()
|
|
550
544
|
now_year, now_week, _ = now.isocalendar()
|
|
551
545
|
self.event_name = event_name
|
|
552
546
|
self.year = not_none(year, now_year)
|
|
553
547
|
self.week = not_none(week, now_week)
|
|
554
548
|
self.system = system
|
|
555
|
-
self.redis_key = _prefix_key(event_name, "W
|
|
549
|
+
self.redis_key = _prefix_key(event_name, f"W{self.year}-{self.week}")
|
|
556
550
|
|
|
557
551
|
def delta(self, value):
|
|
558
552
|
dt = iso_to_gregorian(self.year, self.week + value, 1)
|
|
@@ -574,11 +568,11 @@ class DayEvents(GenericPeriodEvents):
|
|
|
574
568
|
|
|
575
569
|
Example::
|
|
576
570
|
|
|
577
|
-
DayEvents(
|
|
571
|
+
DayEvents("active", 2012, 10, 23)
|
|
578
572
|
"""
|
|
579
573
|
|
|
580
574
|
@classmethod
|
|
581
|
-
def from_date(cls, event_name, dt=None, system="default"):
|
|
575
|
+
def from_date(cls, event_name: str, dt: Optional[date] = None, system="default"):
|
|
582
576
|
dt = dt or datetime.utcnow()
|
|
583
577
|
return cls(event_name, dt.year, dt.month, dt.day, system=system)
|
|
584
578
|
|
|
@@ -589,18 +583,16 @@ class DayEvents(GenericPeriodEvents):
|
|
|
589
583
|
self.month = not_none(month, now.month)
|
|
590
584
|
self.day = not_none(day, now.day)
|
|
591
585
|
self.system = system
|
|
592
|
-
self.redis_key = _prefix_key(
|
|
593
|
-
event_name, "%s-%s-%s" % (self.year, self.month, self.day)
|
|
594
|
-
)
|
|
586
|
+
self.redis_key = _prefix_key(event_name, f"{self.year}-{self.month}-{self.day}")
|
|
595
587
|
|
|
596
588
|
def delta(self, value):
|
|
597
589
|
dt = date(self.year, self.month, self.day) + timedelta(days=value)
|
|
598
590
|
return self.__class__(self.event_name, dt.year, dt.month, dt.day, self.system)
|
|
599
591
|
|
|
600
|
-
def period_start(self):
|
|
592
|
+
def period_start(self) -> datetime:
|
|
601
593
|
return datetime(self.year, self.month, self.day)
|
|
602
594
|
|
|
603
|
-
def period_end(self):
|
|
595
|
+
def period_end(self) -> datetime:
|
|
604
596
|
return datetime(self.year, self.month, self.day, 23, 59, 59, 999999)
|
|
605
597
|
|
|
606
598
|
|
|
@@ -610,16 +602,24 @@ class HourEvents(GenericPeriodEvents):
|
|
|
610
602
|
|
|
611
603
|
Example::
|
|
612
604
|
|
|
613
|
-
HourEvents(
|
|
605
|
+
HourEvents("active", 2012, 10, 23, 13)
|
|
614
606
|
"""
|
|
615
607
|
|
|
616
608
|
@classmethod
|
|
617
|
-
def from_date(
|
|
609
|
+
def from_date(
|
|
610
|
+
cls, event_name: str, dt: Optional[datetime] = None, system="default"
|
|
611
|
+
):
|
|
618
612
|
dt = dt or datetime.utcnow()
|
|
619
613
|
return cls(event_name, dt.year, dt.month, dt.day, dt.hour, system=system)
|
|
620
614
|
|
|
621
615
|
def __init__(
|
|
622
|
-
self,
|
|
616
|
+
self,
|
|
617
|
+
event_name: str,
|
|
618
|
+
year: Optional[int] = None,
|
|
619
|
+
month: Optional[int] = None,
|
|
620
|
+
day: Optional[int] = None,
|
|
621
|
+
hour: Optional[int] = None,
|
|
622
|
+
system: str = "default",
|
|
623
623
|
):
|
|
624
624
|
now = datetime.utcnow()
|
|
625
625
|
self.event_name = event_name
|
|
@@ -629,7 +629,7 @@ class HourEvents(GenericPeriodEvents):
|
|
|
629
629
|
self.hour = not_none(hour, now.hour)
|
|
630
630
|
self.system = system
|
|
631
631
|
self.redis_key = _prefix_key(
|
|
632
|
-
event_name, "
|
|
632
|
+
event_name, f"{self.year}-{self.month}-{self.day}-{self.hour}"
|
|
633
633
|
)
|
|
634
634
|
|
|
635
635
|
def delta(self, value):
|
|
@@ -640,10 +640,10 @@ class HourEvents(GenericPeriodEvents):
|
|
|
640
640
|
self.event_name, dt.year, dt.month, dt.day, dt.hour, self.system
|
|
641
641
|
)
|
|
642
642
|
|
|
643
|
-
def period_start(self):
|
|
643
|
+
def period_start(self) -> datetime:
|
|
644
644
|
return datetime(self.year, self.month, self.day, self.hour)
|
|
645
645
|
|
|
646
|
-
def period_end(self):
|
|
646
|
+
def period_end(self) -> datetime:
|
|
647
647
|
return datetime(self.year, self.month, self.day, self.hour, 59, 59, 999999)
|
|
648
648
|
|
|
649
649
|
|
|
@@ -653,7 +653,6 @@ class HourEvents(GenericPeriodEvents):
|
|
|
653
653
|
class BitOperation(
|
|
654
654
|
MixinIter, MixinContains, MixinCounts, MixinEventsMisc, MixinBitOperations
|
|
655
655
|
):
|
|
656
|
-
|
|
657
656
|
"""
|
|
658
657
|
Base class for bit operations (AND, OR, XOR).
|
|
659
658
|
|
|
@@ -666,32 +665,33 @@ class BitOperation(
|
|
|
666
665
|
Example::
|
|
667
666
|
|
|
668
667
|
active_2_months = BitOpAnd(
|
|
669
|
-
MonthEvents(
|
|
670
|
-
MonthEvents(
|
|
668
|
+
MonthEvents("active", last_month.year, last_month.month),
|
|
669
|
+
MonthEvents("active", now.year, now.month),
|
|
671
670
|
)
|
|
672
671
|
|
|
673
672
|
active_2_months = BitOpAnd(
|
|
674
673
|
BitOpAnd(
|
|
675
|
-
MonthEvents(
|
|
676
|
-
MonthEvents(
|
|
674
|
+
MonthEvents("active", last_month.year, last_month.month),
|
|
675
|
+
MonthEvents("active", now.year, now.month),
|
|
677
676
|
),
|
|
678
|
-
MonthEvents(
|
|
677
|
+
MonthEvents("active", now.year, now.month),
|
|
679
678
|
)
|
|
680
679
|
|
|
681
680
|
"""
|
|
682
681
|
|
|
683
|
-
def __init__(self, op_name, system_or_event, *events):
|
|
682
|
+
def __init__(self, op_name: str, system_or_event, *events):
|
|
684
683
|
# Smartly resolve system_or_event, makes it possible to build a cleaner API
|
|
685
684
|
if hasattr(system_or_event, "redis_key"):
|
|
686
|
-
events =
|
|
687
|
-
events.insert(0, system_or_event)
|
|
685
|
+
events = (system_or_event, *events)
|
|
688
686
|
system = self.system = "default"
|
|
689
687
|
else:
|
|
690
688
|
system = self.system = system_or_event
|
|
691
689
|
|
|
692
690
|
event_redis_keys = [ev.redis_key for ev in events]
|
|
693
691
|
|
|
694
|
-
self.redis_key = "trackist_bitop_
|
|
692
|
+
self.redis_key = "trackist_bitop_{}_{}".format(
|
|
693
|
+
op_name, "-".join(event_redis_keys)
|
|
694
|
+
)
|
|
695
695
|
_bitop_keys()[system].add(self.redis_key)
|
|
696
696
|
|
|
697
697
|
cli = get_redis(system)
|
|
@@ -721,8 +721,8 @@ class BitOpNot(BitOperation):
|
|
|
721
721
|
# --- Private
|
|
722
722
|
|
|
723
723
|
|
|
724
|
-
def _prefix_key(event_name: str, date: str):
|
|
725
|
-
return "trackist_
|
|
724
|
+
def _prefix_key(event_name: str, date: str) -> str:
|
|
725
|
+
return f"trackist_{event_name}_{date}"
|
|
726
726
|
|
|
727
727
|
|
|
728
728
|
# --- Helper functions
|
|
@@ -741,23 +741,22 @@ def add_month(year: int, month: int, delta: int) -> tuple[int, int]:
|
|
|
741
741
|
|
|
742
742
|
|
|
743
743
|
def not_none(*keys):
|
|
744
|
-
"""
|
|
745
|
-
Helper function returning first value which is not None
|
|
746
|
-
"""
|
|
744
|
+
"""Helper function returning first value which is not None"""
|
|
747
745
|
for key in keys:
|
|
748
746
|
if key is not None:
|
|
749
747
|
return key
|
|
748
|
+
return None
|
|
750
749
|
|
|
751
750
|
|
|
752
|
-
def iso_year_start(iso_year):
|
|
753
|
-
"The gregorian calendar date of the first day of the given ISO year"
|
|
751
|
+
def iso_year_start(iso_year: int) -> date:
|
|
752
|
+
"""The gregorian calendar date of the first day of the given ISO year"""
|
|
754
753
|
fourth_jan = date(iso_year, 1, 4)
|
|
755
754
|
delta = timedelta(fourth_jan.isoweekday() - 1)
|
|
756
755
|
return fourth_jan - delta
|
|
757
756
|
|
|
758
757
|
|
|
759
|
-
def iso_to_gregorian(iso_year, iso_week, iso_day):
|
|
760
|
-
"Gregorian calendar date for the given ISO year, week and day"
|
|
758
|
+
def iso_to_gregorian(iso_year: int, iso_week: int, iso_day: int) -> date:
|
|
759
|
+
"""Gregorian calendar date for the given ISO year, week and day"""
|
|
761
760
|
year_start = iso_year_start(iso_year)
|
|
762
761
|
return year_start + timedelta(days=iso_day - 1, weeks=iso_week - 1)
|
|
763
762
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""
|
|
3
2
|
bitmapist.cohort
|
|
4
3
|
~~~~~~~~~~~~~~~~
|
|
@@ -62,23 +61,24 @@ Get the data and render it via HTML::
|
|
|
62
61
|
:developer: Amir Salihefendic ( http://amix.dk )
|
|
63
62
|
:license: BSD
|
|
64
63
|
"""
|
|
64
|
+
|
|
65
|
+
from datetime import date, datetime, timedelta
|
|
65
66
|
from os import path
|
|
67
|
+
from typing import Any, Callable, Optional
|
|
66
68
|
|
|
67
|
-
from datetime import datetime, timedelta
|
|
68
69
|
from dateutil.relativedelta import relativedelta
|
|
69
|
-
|
|
70
70
|
from mako.lookup import TemplateLookup
|
|
71
71
|
|
|
72
72
|
from bitmapist import (
|
|
73
|
-
|
|
73
|
+
BitOpAnd,
|
|
74
74
|
DayEvents,
|
|
75
|
+
GenericPeriodEvents,
|
|
75
76
|
MonthEvents,
|
|
77
|
+
WeekEvents,
|
|
76
78
|
YearEvents,
|
|
77
|
-
BitOpAnd,
|
|
78
79
|
delete_runtime_bitop_keys,
|
|
79
80
|
)
|
|
80
81
|
|
|
81
|
-
|
|
82
82
|
# --- HTML rendering
|
|
83
83
|
|
|
84
84
|
|
|
@@ -93,7 +93,7 @@ def render_html_form(
|
|
|
93
93
|
select1b=None,
|
|
94
94
|
select2=None,
|
|
95
95
|
select2b=None,
|
|
96
|
-
|
|
96
|
+
as_percent=1,
|
|
97
97
|
num_results=31,
|
|
98
98
|
num_of_rows=12,
|
|
99
99
|
start_date=None,
|
|
@@ -137,7 +137,7 @@ def render_html_form(
|
|
|
137
137
|
select2=select2,
|
|
138
138
|
select2b=select2b,
|
|
139
139
|
action_url=action_url,
|
|
140
|
-
|
|
140
|
+
as_percent=as_percent,
|
|
141
141
|
num_results=int(num_results),
|
|
142
142
|
num_of_rows=int(num_of_rows),
|
|
143
143
|
start_date=start_date,
|
|
@@ -147,17 +147,17 @@ def render_html_form(
|
|
|
147
147
|
|
|
148
148
|
def render_html_data(
|
|
149
149
|
dates_data,
|
|
150
|
-
|
|
150
|
+
as_percent=True,
|
|
151
151
|
time_group="days",
|
|
152
|
-
num_results=31,
|
|
153
|
-
num_of_rows=12,
|
|
152
|
+
num_results: int = 31,
|
|
153
|
+
num_of_rows: int = 12,
|
|
154
154
|
start_date=None,
|
|
155
155
|
):
|
|
156
156
|
"""
|
|
157
157
|
Render's data as HTML, inside a TABLE element.
|
|
158
158
|
|
|
159
159
|
:param :dates_data The data that's returned by `get_dates_data`
|
|
160
|
-
:param :
|
|
160
|
+
:param :as_percent Should the data be shown as percents or as counts. Defaults to `True`
|
|
161
161
|
:param :time_group What is the data grouped by? Can be `days`, `weeks`, `months`, `years`
|
|
162
162
|
"""
|
|
163
163
|
return (
|
|
@@ -165,7 +165,7 @@ def render_html_data(
|
|
|
165
165
|
.get_template("table_data.mako")
|
|
166
166
|
.render(
|
|
167
167
|
dates_data=dates_data,
|
|
168
|
-
|
|
168
|
+
as_percent=as_percent,
|
|
169
169
|
time_group=time_group,
|
|
170
170
|
num_results=num_results,
|
|
171
171
|
num_of_rows=num_of_rows,
|
|
@@ -176,21 +176,19 @@ def render_html_data(
|
|
|
176
176
|
|
|
177
177
|
def render_csv_data(
|
|
178
178
|
dates_data,
|
|
179
|
-
|
|
179
|
+
as_percent=True,
|
|
180
180
|
time_group="days",
|
|
181
|
-
num_results=31,
|
|
182
|
-
num_of_rows=12,
|
|
181
|
+
num_results: int = 31,
|
|
182
|
+
num_of_rows: int = 12,
|
|
183
183
|
start_date=None,
|
|
184
184
|
):
|
|
185
|
-
"""
|
|
186
|
-
Render's data as CSV.
|
|
187
|
-
"""
|
|
185
|
+
"""Render's data as CSV."""
|
|
188
186
|
return (
|
|
189
187
|
get_lookup()
|
|
190
188
|
.get_template("table_data_csv.mako")
|
|
191
189
|
.render(
|
|
192
190
|
dates_data=dates_data,
|
|
193
|
-
|
|
191
|
+
as_percent=as_percent,
|
|
194
192
|
time_group=time_group,
|
|
195
193
|
num_results=num_results,
|
|
196
194
|
num_of_rows=num_of_rows,
|
|
@@ -209,7 +207,7 @@ def get_dates_data(
|
|
|
209
207
|
select2b=None,
|
|
210
208
|
time_group="days",
|
|
211
209
|
system="default",
|
|
212
|
-
|
|
210
|
+
as_percent=1,
|
|
213
211
|
num_results=31,
|
|
214
212
|
num_of_rows=12,
|
|
215
213
|
start_date=None,
|
|
@@ -223,7 +221,7 @@ def get_dates_data(
|
|
|
223
221
|
:param :select2b Second filter (could be `playlist:created`, optional)
|
|
224
222
|
:param :time_group What is the data grouped by? Can be `days`, `weeks`, `months`, `years`
|
|
225
223
|
:param :system What bitmapist should be used?
|
|
226
|
-
:param :
|
|
224
|
+
:param :as_percent If `True` then percents as calculated and shown. Defaults to `True`
|
|
227
225
|
:return A list of day data, formatted like `[[datetime, count], ...]`
|
|
228
226
|
"""
|
|
229
227
|
num_results = int(num_results)
|
|
@@ -241,14 +239,20 @@ def get_dates_data(
|
|
|
241
239
|
|
|
242
240
|
date_range = num_results
|
|
243
241
|
now = now - timedelta(days=num_results - 1)
|
|
244
|
-
|
|
242
|
+
|
|
243
|
+
def timedelta_inc(d):
|
|
244
|
+
return timedelta(days=d)
|
|
245
|
+
|
|
245
246
|
# Weeks
|
|
246
247
|
elif time_group == "weeks":
|
|
247
248
|
fn_get_events = _weeks_events_fn
|
|
248
249
|
|
|
249
250
|
date_range = num_results
|
|
250
251
|
now = now - relativedelta(weeks=num_results - 1)
|
|
251
|
-
|
|
252
|
+
|
|
253
|
+
def timedelta_inc(w):
|
|
254
|
+
return relativedelta(weeks=w)
|
|
255
|
+
|
|
252
256
|
# Months
|
|
253
257
|
elif time_group == "months":
|
|
254
258
|
fn_get_events = _month_events_fn
|
|
@@ -256,7 +260,10 @@ def get_dates_data(
|
|
|
256
260
|
date_range = num_results
|
|
257
261
|
now = now - relativedelta(months=num_results - 1)
|
|
258
262
|
now -= timedelta(days=now.day - 1)
|
|
259
|
-
|
|
263
|
+
|
|
264
|
+
def timedelta_inc(m):
|
|
265
|
+
return relativedelta(months=m)
|
|
266
|
+
|
|
260
267
|
# Years
|
|
261
268
|
elif time_group == "years":
|
|
262
269
|
fn_get_events = _year_events_fn
|
|
@@ -265,11 +272,13 @@ def get_dates_data(
|
|
|
265
272
|
|
|
266
273
|
date_range = num_results
|
|
267
274
|
now = now - relativedelta(years=num_results - 1)
|
|
268
|
-
|
|
275
|
+
|
|
276
|
+
def timedelta_inc(m):
|
|
277
|
+
return relativedelta(years=m)
|
|
269
278
|
|
|
270
279
|
dates = []
|
|
271
280
|
|
|
272
|
-
for
|
|
281
|
+
for _i in range(date_range):
|
|
273
282
|
result = [now]
|
|
274
283
|
|
|
275
284
|
# events for select1 (+select1b)
|
|
@@ -282,7 +291,7 @@ def get_dates_data(
|
|
|
282
291
|
result.append(select1_count)
|
|
283
292
|
|
|
284
293
|
# Move in time
|
|
285
|
-
for t_delta in range(
|
|
294
|
+
for t_delta in range(num_of_rows + 1):
|
|
286
295
|
if select1_count == 0:
|
|
287
296
|
result.append("")
|
|
288
297
|
continue
|
|
@@ -304,12 +313,11 @@ def get_dates_data(
|
|
|
304
313
|
|
|
305
314
|
# Append to result
|
|
306
315
|
if both_count == 0:
|
|
307
|
-
result.append(
|
|
316
|
+
result.append(0.0)
|
|
317
|
+
elif as_percent:
|
|
318
|
+
result.append((float(both_count) / float(select1_count)) * 100)
|
|
308
319
|
else:
|
|
309
|
-
|
|
310
|
-
result.append((float(both_count) / float(select1_count)) * 100)
|
|
311
|
-
else:
|
|
312
|
-
result.append(both_count)
|
|
320
|
+
result.append(both_count)
|
|
313
321
|
|
|
314
322
|
dates.append(result)
|
|
315
323
|
now = now + timedelta_inc(1)
|
|
@@ -322,10 +330,10 @@ def get_dates_data(
|
|
|
322
330
|
|
|
323
331
|
# --- Custom handlers
|
|
324
332
|
|
|
325
|
-
CUSTOM_HANDLERS = {}
|
|
333
|
+
CUSTOM_HANDLERS: dict[str, Callable[..., Any]] = {}
|
|
326
334
|
|
|
327
335
|
|
|
328
|
-
def set_custom_handler(event_name, callback):
|
|
336
|
+
def set_custom_handler(event_name: str, callback) -> None:
|
|
329
337
|
"""
|
|
330
338
|
Set a custom handler for `event_name`.
|
|
331
339
|
This makes it possible to construct event names that are complex
|
|
@@ -339,9 +347,12 @@ def set_custom_handler(event_name, callback):
|
|
|
339
347
|
using web or ios, could look like::
|
|
340
348
|
|
|
341
349
|
def active_web_ios(key, cls, cls_args):
|
|
342
|
-
return cls(
|
|
350
|
+
return cls("active", *cls_args) & (
|
|
351
|
+
cls("web", *cls_args) | cls("ios", *cls_args)
|
|
352
|
+
)
|
|
343
353
|
|
|
344
|
-
|
|
354
|
+
|
|
355
|
+
set_custom_handler("active_web_ios", active_web_ios)
|
|
345
356
|
|
|
346
357
|
And then use something like::
|
|
347
358
|
|
|
@@ -359,41 +370,40 @@ def set_custom_handler(event_name, callback):
|
|
|
359
370
|
# --- Private
|
|
360
371
|
|
|
361
372
|
|
|
362
|
-
def _dispatch(key, cls, cls_args):
|
|
373
|
+
def _dispatch(key: str, cls: type[GenericPeriodEvents], cls_args):
|
|
363
374
|
if key in CUSTOM_HANDLERS:
|
|
364
375
|
return CUSTOM_HANDLERS[key](key, cls, cls_args)
|
|
365
|
-
|
|
366
|
-
return cls(key, *cls_args)
|
|
376
|
+
return cls(key, *cls_args)
|
|
367
377
|
|
|
368
378
|
|
|
369
|
-
def _day_events_fn(key, date, system):
|
|
379
|
+
def _day_events_fn(key: str, date: date, system: str):
|
|
370
380
|
cls = DayEvents
|
|
371
381
|
cls_args = (date.year, date.month, date.day, system)
|
|
372
382
|
return _dispatch(key, cls, cls_args)
|
|
373
383
|
|
|
374
384
|
|
|
375
|
-
def _weeks_events_fn(key, date, system):
|
|
385
|
+
def _weeks_events_fn(key: str, date: date, system: str):
|
|
376
386
|
cls = WeekEvents
|
|
377
387
|
cls_args = (date.year, date.isocalendar()[1], system)
|
|
378
388
|
return _dispatch(key, cls, cls_args)
|
|
379
389
|
|
|
380
390
|
|
|
381
|
-
def _month_events_fn(key, date, system):
|
|
391
|
+
def _month_events_fn(key: str, date: date, system: str):
|
|
382
392
|
cls = MonthEvents
|
|
383
393
|
cls_args = (date.year, date.month, system)
|
|
384
394
|
return _dispatch(key, cls, cls_args)
|
|
385
395
|
|
|
386
396
|
|
|
387
|
-
def _year_events_fn(key, date, system):
|
|
397
|
+
def _year_events_fn(key: str, date: date, system: str):
|
|
388
398
|
cls = YearEvents
|
|
389
399
|
cls_args = (date.year, system)
|
|
390
400
|
return _dispatch(key, cls, cls_args)
|
|
391
401
|
|
|
392
402
|
|
|
393
|
-
_LOOKUP = None
|
|
403
|
+
_LOOKUP: Optional[TemplateLookup] = None
|
|
394
404
|
|
|
395
405
|
|
|
396
|
-
def get_lookup():
|
|
406
|
+
def get_lookup() -> TemplateLookup:
|
|
397
407
|
global _LOOKUP
|
|
398
408
|
|
|
399
409
|
if not _LOOKUP:
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
</dd>
|
|
37
37
|
|
|
38
38
|
<dd>
|
|
39
|
-
As
|
|
40
|
-
<select name="
|
|
41
|
-
<option value="1" ${ 'selected="selected"' if
|
|
42
|
-
<option value="0" ${ 'selected="selected"' if not
|
|
39
|
+
As percent:
|
|
40
|
+
<select name="as_percent">
|
|
41
|
+
<option value="1" ${ 'selected="selected"' if as_percent else '' }>Yes</option>
|
|
42
|
+
<option value="0" ${ 'selected="selected"' if not as_percent else '' }>No</option>
|
|
43
43
|
</select>
|
|
44
44
|
</dd>
|
|
45
45
|
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
## '' denotes no entry
|
|
72
72
|
%if data_entry != '':
|
|
73
|
-
%if
|
|
73
|
+
%if as_percent:
|
|
74
74
|
<%
|
|
75
75
|
color = 'hsla(200, 100%%, 0%%, %s);' % (round(float(data_entry/100)+0.5, 1))
|
|
76
76
|
%>
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
%>
|
|
111
111
|
|
|
112
112
|
<td class="avg_row">
|
|
113
|
-
%if
|
|
113
|
+
%if as_percent:
|
|
114
114
|
${ round(average, 2) }%
|
|
115
115
|
%else:
|
|
116
116
|
${ int(average) }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Date,Total,${ ",".join(str(i) for i in range(0,
|
|
1
|
+
Date,Total,${ ",".join(str(i) for i in range(0, num_of_rows+1)) }
|
|
2
2
|
%for row_data in dates_data:
|
|
3
3
|
<%
|
|
4
4
|
if time_group == 'months':
|
|
@@ -13,12 +13,12 @@ else:
|
|
|
13
13
|
total_count = row_data[1]
|
|
14
14
|
|
|
15
15
|
day_results = []
|
|
16
|
-
for i in range(2,
|
|
16
|
+
for i in range(2, num_of_rows+3):
|
|
17
17
|
prct = row_data[i]
|
|
18
18
|
if prct == '':
|
|
19
19
|
day_results.append('')
|
|
20
20
|
else:
|
|
21
|
-
if
|
|
21
|
+
if as_percent:
|
|
22
22
|
day_results.append(str(round(prct, 2)))
|
|
23
23
|
else:
|
|
24
24
|
day_results.append(str(int(prct)))
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "bitmapist"
|
|
3
|
+
version = "3.114"
|
|
4
|
+
description="Implements a powerful analytics library using Redis bitmaps."
|
|
5
|
+
authors = [
|
|
6
|
+
"Amir Salihefendic <dev@doist.com>",
|
|
7
|
+
"Doist Developers <dev@doist.com>",
|
|
8
|
+
]
|
|
9
|
+
license="BSD"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
repository = "https://github.com/Doist/bitmapist"
|
|
12
|
+
keywords=[ "redis", "bitmap", "analytics", "bitmaps", "realtime", "cohort", ]
|
|
13
|
+
classifiers=[
|
|
14
|
+
"Development Status :: 5 - Production/Stable",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: BSD License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
]
|
|
26
|
+
packages=[ { include = "bitmapist" } ]
|
|
27
|
+
exclude = ['tests/']
|
|
28
|
+
include = [
|
|
29
|
+
'AUTHORS',
|
|
30
|
+
'README.md',
|
|
31
|
+
'static/bitmapist.png',
|
|
32
|
+
'static/bitmapist.svg',
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[tool.poetry.dependencies]
|
|
36
|
+
python = ">=3.9,<3.13"
|
|
37
|
+
redis = ">=2.10,<5.0"
|
|
38
|
+
python-dateutil = "*"
|
|
39
|
+
future = ">=0.14.3,<0.19.0"
|
|
40
|
+
Mako= "^1.0.4"
|
|
41
|
+
|
|
42
|
+
[tool.poetry.dev-dependencies]
|
|
43
|
+
pytest-runner = "*"
|
|
44
|
+
pytest = "*"
|
|
45
|
+
pre-commit = "*"
|
|
46
|
+
tox = "*"
|
|
47
|
+
mypy = "*"
|
|
48
|
+
ruff = "^0.4.1"
|
|
49
|
+
|
|
50
|
+
[build-system]
|
|
51
|
+
requires = ["poetry-core>=1.0.0"]
|
|
52
|
+
build-backend = "poetry.core.masonry.api"
|
|
53
|
+
|
|
54
|
+
[tool.ruff]
|
|
55
|
+
# By default, always show source code snippets.
|
|
56
|
+
output-format = 'full'
|
|
57
|
+
|
|
58
|
+
extend-exclude = [
|
|
59
|
+
"env",
|
|
60
|
+
"runtime",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.ruff.lint]
|
|
64
|
+
select = [
|
|
65
|
+
"ASYNC", # flake8-async
|
|
66
|
+
"B", # flake8-bugbear
|
|
67
|
+
"C4", # flake8-comprehensions
|
|
68
|
+
"D", # pydocstyle,
|
|
69
|
+
"E", "W", # pycodestyle
|
|
70
|
+
"F", # pyflakes
|
|
71
|
+
"I", # isort
|
|
72
|
+
"PL", # pylint
|
|
73
|
+
"RUF", # ruff
|
|
74
|
+
"S", # flake8-bandit
|
|
75
|
+
"T20", # flake8-print
|
|
76
|
+
"SIM", # flake8-simplify
|
|
77
|
+
"UP", # pyupgrade
|
|
78
|
+
"TCH", # flake8-type-checking
|
|
79
|
+
"TRY", # tryceratops
|
|
80
|
+
"BLE", # flake8-blind-except
|
|
81
|
+
"LOG", # flake8-logging
|
|
82
|
+
"G", # flake8-logging-format
|
|
83
|
+
"RET", # flake8-logging-return
|
|
84
|
+
"ISC", # flake8-implicit-str-concat
|
|
85
|
+
"INP", # flake8-no-pep420
|
|
86
|
+
"PIE", # flake8-pie
|
|
87
|
+
"PT", # flake8-pytest-style
|
|
88
|
+
"PERF", # perflint
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
ignore = [
|
|
92
|
+
## D - pydocstyle ##
|
|
93
|
+
# D1XX errors are OK. Don't force people into over-documenting.
|
|
94
|
+
"D100", "D101", "D102", "D103", "D104", "D105", "D107",
|
|
95
|
+
# These need to be fixed.
|
|
96
|
+
"D205",
|
|
97
|
+
"D400",
|
|
98
|
+
"D401",
|
|
99
|
+
|
|
100
|
+
## E / W - pycodestyle ##
|
|
101
|
+
"E501", # line too long
|
|
102
|
+
|
|
103
|
+
## PL - pylint ##
|
|
104
|
+
# Commented-out rules are rules that we disable in pylint but are not supported by ruff yet.
|
|
105
|
+
|
|
106
|
+
"PLR6301", # no-self-use
|
|
107
|
+
"PLC2701", # import-private-name
|
|
108
|
+
|
|
109
|
+
# Import order issues
|
|
110
|
+
# "PLC0411", # wrong-import-order
|
|
111
|
+
# "PLC0412", # wrong-import-position
|
|
112
|
+
"PLC0414", # ungrouped-imports
|
|
113
|
+
"PLC0415", # import-outside-top-level
|
|
114
|
+
|
|
115
|
+
# flake8-implicit-str-concat
|
|
116
|
+
"ISC001", # May conflict with the formatter
|
|
117
|
+
|
|
118
|
+
# Documentation issues
|
|
119
|
+
# "C0114", # missing-module-docstring
|
|
120
|
+
|
|
121
|
+
# Complexity issues
|
|
122
|
+
"PLR0904", # too-many-public-methods
|
|
123
|
+
# "PLC0302", # too-many-lines
|
|
124
|
+
"PLR1702", # too-many-nested-blocks
|
|
125
|
+
# "PLR0902", # too-many-instance-attributes
|
|
126
|
+
"PLR0911", # too-many-return-statements
|
|
127
|
+
"PLR0915", # too-many-statements
|
|
128
|
+
"PLR0912", # too-many-branches
|
|
129
|
+
# "PLR0903", # too-few-public-methods
|
|
130
|
+
"PLR0914", # too-many-locals
|
|
131
|
+
# "PLC0301", # line-too-long
|
|
132
|
+
"PLR0913", # too-many-arguments
|
|
133
|
+
"PLR0917", # too-many-positional
|
|
134
|
+
"PLR2004", # magic-value-comparison
|
|
135
|
+
"PLW0603", # global-statement
|
|
136
|
+
"PLW2901", # redefined-loop-name
|
|
137
|
+
|
|
138
|
+
## RUF - ruff ##
|
|
139
|
+
"RUF001", # ambiguous-unicode-character-string
|
|
140
|
+
"RUF002", # ambiguous-unicode-character-docstring
|
|
141
|
+
"RUF003", # ambiguous-unicode-character-comment
|
|
142
|
+
"RUF012", # mutable-class-default
|
|
143
|
+
|
|
144
|
+
# Enable when Poetry supports PEP 621 and we migrate our confguration to it.
|
|
145
|
+
# See: https://github.com/python-poetry/poetry-core/pull/567
|
|
146
|
+
"RUF200",
|
|
147
|
+
|
|
148
|
+
"S101", # assert
|
|
149
|
+
"S104", # hardcoded-bind-all-interfaces
|
|
150
|
+
"S105", # hardcoded-password-string
|
|
151
|
+
"S106", # hardcoded-password-func-arg
|
|
152
|
+
"S303", # suspicious-insecure-hash-usage
|
|
153
|
+
"S310", # suspicious-url-open-usage
|
|
154
|
+
"S311", # suspicious-non-cryptographic-random-usage
|
|
155
|
+
"S324", # hashlib-insecure-hash-function
|
|
156
|
+
"S603", # subprocess-without-shell-equals-true
|
|
157
|
+
"S607", # start-process-with-partial-path
|
|
158
|
+
"S608", # hardcoded-sql-expression
|
|
159
|
+
|
|
160
|
+
## SIM - flake8-simplify ##
|
|
161
|
+
"SIM102", # collapsible-if
|
|
162
|
+
"SIM114", # if-with-same-arms
|
|
163
|
+
"SIM117", # multiple-with-statements
|
|
164
|
+
|
|
165
|
+
# Enable when the rule is out of preview and false-positives are handled.
|
|
166
|
+
# See: https://docs.astral.sh/ruff/rules/in-dict-keys/
|
|
167
|
+
"SIM118", # in-dict-keys
|
|
168
|
+
|
|
169
|
+
## TRY - tryceratops ##
|
|
170
|
+
"TRY003", # raise-vanilla-args
|
|
171
|
+
"TRY004", # type-check-without-type-error
|
|
172
|
+
"TRY301", # raise-within-try
|
|
173
|
+
|
|
174
|
+
## BLE - flake8-blind-except ##
|
|
175
|
+
"BLE001", # blind-except
|
|
176
|
+
|
|
177
|
+
## RET - flake8-return ##
|
|
178
|
+
"RET504", # unnecessary-assign
|
|
179
|
+
|
|
180
|
+
## PT - flake8-pytest-style ##
|
|
181
|
+
"PT004", # pytest-missing-fixture-name-underscore
|
|
182
|
+
"PT012", # pytest-raises-with-multiple-statements
|
|
183
|
+
|
|
184
|
+
## UP - pyupgrade ##
|
|
185
|
+
"UP038", # non-pep604-isinstance
|
|
186
|
+
|
|
187
|
+
## B - flake8-bugbear ##
|
|
188
|
+
"B008", # function-call-in-default-argument
|
|
189
|
+
"B009", # get-attr-with-constant
|
|
190
|
+
"B010", # set-attr-with-constant
|
|
191
|
+
"B018", # useless-expression
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
flake8-pytest-style.fixture-parentheses = false
|
|
195
|
+
flake8-pytest-style.mark-parentheses = false
|
|
196
|
+
|
|
197
|
+
pylint.allow-dunder-method-names = [
|
|
198
|
+
"__json__",
|
|
199
|
+
"__get_pydantic_core_schema__"
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
[tool.ruff.lint.flake8-type-checking]
|
|
203
|
+
runtime-evaluated-base-classes = [
|
|
204
|
+
"pydantic.BaseModel",
|
|
205
|
+
"typing_extensions.TypedDict",
|
|
206
|
+
"sqlalchemy.orm.DeclarativeBase",
|
|
207
|
+
]
|
|
208
|
+
runtime-evaluated-decorators = [
|
|
209
|
+
"pydantic.dataclasses.dataclass",
|
|
210
|
+
"pydantic.validate_call",
|
|
211
|
+
]
|
|
212
|
+
|
|
213
|
+
[tool.ruff.lint.per-file-ignores]
|
|
214
|
+
# Open devnull without a context manager
|
|
215
|
+
"conftest.py" = ["SIM115"]
|
|
216
|
+
|
|
217
|
+
[tool.ruff.lint.isort]
|
|
218
|
+
section-order = [
|
|
219
|
+
"future",
|
|
220
|
+
"standard-library",
|
|
221
|
+
"third-party",
|
|
222
|
+
"first-party",
|
|
223
|
+
"local-folder",
|
|
224
|
+
]
|
|
225
|
+
|
|
226
|
+
[tool.ruff.lint.pydocstyle]
|
|
227
|
+
convention = "pep257"
|
|
228
|
+
|
|
229
|
+
[tool.ruff.lint.pyupgrade]
|
|
230
|
+
# Required by tools like Pydantic that use type information at runtime.
|
|
231
|
+
# https://github.com/asottile/pyupgrade/issues/622#issuecomment-1088766572
|
|
232
|
+
keep-runtime-typing = true
|
|
233
|
+
|
|
234
|
+
[tool.ruff.format]
|
|
235
|
+
docstring-code-format = true
|
bitmapist-3.112/pyproject.toml
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
[tool.poetry]
|
|
2
|
-
name = "bitmapist"
|
|
3
|
-
version = "3.112"
|
|
4
|
-
description="Implements a powerful analytics library using Redis bitmaps."
|
|
5
|
-
authors = [
|
|
6
|
-
"Amir Salihefendic <dev@doist.com>",
|
|
7
|
-
"Doist Developers <dev@doist.com>",
|
|
8
|
-
]
|
|
9
|
-
license="BSD"
|
|
10
|
-
readme = "README.md"
|
|
11
|
-
repository = "https://github.com/Doist/bitmapist"
|
|
12
|
-
keywords=[ "redis", "bitmap", "analytics", "bitmaps", "realtime", "cohort", ]
|
|
13
|
-
classifiers=[
|
|
14
|
-
"Development Status :: 5 - Production/Stable",
|
|
15
|
-
"Intended Audience :: Developers",
|
|
16
|
-
"License :: OSI Approved :: BSD License",
|
|
17
|
-
"Operating System :: OS Independent",
|
|
18
|
-
"Programming Language :: Python",
|
|
19
|
-
"Programming Language :: Python :: 3",
|
|
20
|
-
"Programming Language :: Python :: 3.9",
|
|
21
|
-
"Programming Language :: Python :: 3.10",
|
|
22
|
-
"Programming Language :: Python :: 3.11",
|
|
23
|
-
"Programming Language :: Python :: 3.12",
|
|
24
|
-
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
-
]
|
|
26
|
-
packages=[ { include = "bitmapist" } ]
|
|
27
|
-
exclude = ['tests/']
|
|
28
|
-
include = [
|
|
29
|
-
'AUTHORS',
|
|
30
|
-
'README.md',
|
|
31
|
-
'static/bitmapist.png',
|
|
32
|
-
'static/bitmapist.svg',
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
[tool.poetry.dependencies]
|
|
36
|
-
python = ">=3.9,<3.13"
|
|
37
|
-
redis = ">=2.10,<5.0"
|
|
38
|
-
python-dateutil = "*"
|
|
39
|
-
future = ">=0.14.3,<0.19.0"
|
|
40
|
-
Mako= "^1.0.4"
|
|
41
|
-
|
|
42
|
-
[tool.poetry.dev-dependencies]
|
|
43
|
-
pytest-runner = "*"
|
|
44
|
-
pytest = "*"
|
|
45
|
-
pre-commit = "*"
|
|
46
|
-
tox = "*"
|
|
47
|
-
|
|
48
|
-
[build-system]
|
|
49
|
-
requires = ["poetry-core>=1.0.0"]
|
|
50
|
-
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|