simplify provider
This commit is contained in:
parent
36fbb3aa69
commit
3b525b39aa
4 changed files with 13 additions and 28 deletions
|
@ -1,10 +1,13 @@
|
||||||
BPATH = "/L/backups/smscalls"
|
import os
|
||||||
import re
|
from pathlib import Path
|
||||||
import pytz
|
|
||||||
_RE = re.compile(r'calls-\d+.xml')
|
|
||||||
|
|
||||||
from typing import Dict, List, NamedTuple, Iterator, Iterable
|
from typing import Dict, List, NamedTuple, Iterator, Iterable
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import pytz
|
||||||
|
|
||||||
|
from lxml import etree # type: ignore
|
||||||
|
|
||||||
|
BPATH = Path("/L/backups/smscalls")
|
||||||
|
|
||||||
|
|
||||||
class Call(NamedTuple):
|
class Call(NamedTuple):
|
||||||
dt: datetime
|
dt: datetime
|
||||||
|
@ -17,7 +20,6 @@ class Call(NamedTuple):
|
||||||
|
|
||||||
|
|
||||||
def _extract_calls(fname: str) -> Iterator[Call]:
|
def _extract_calls(fname: str) -> Iterator[Call]:
|
||||||
from lxml import etree # type: ignore
|
|
||||||
tr = etree.parse(fname)
|
tr = etree.parse(fname)
|
||||||
for cxml in tr.findall('call'):
|
for cxml in tr.findall('call'):
|
||||||
# TODO we've got local tz herer, not sure if useful..
|
# TODO we've got local tz herer, not sure if useful..
|
||||||
|
@ -31,9 +33,8 @@ def _extract_calls(fname: str) -> Iterator[Call]:
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_calls():
|
def get_calls():
|
||||||
import os
|
|
||||||
calls: Dict[datetime, Call] = {}
|
calls: Dict[datetime, Call] = {}
|
||||||
for n in sorted([x for x in os.listdir(BPATH) if _RE.match(x)]):
|
for n in sorted(BPATH.glob('calls-*.xml')):
|
||||||
# for c in _extract_calls(os.path.join(BPATH, n)):
|
# for c in _extract_calls(os.path.join(BPATH, n)):
|
||||||
# cc = calls.get(c.dt, None)
|
# cc = calls.get(c.dt, None)
|
||||||
# if cc is not None and cc != c:
|
# if cc is not None and cc != c:
|
||||||
|
@ -41,3 +42,7 @@ def get_calls():
|
||||||
calls.update({c.dt: c for c in _extract_calls(os.path.join(BPATH, n))})
|
calls.update({c.dt: c for c in _extract_calls(os.path.join(BPATH, n))})
|
||||||
# always replacing with latter is good, we get better contact names
|
# always replacing with latter is good, we get better contact names
|
||||||
return sorted(calls.values(), key=lambda c: c.dt)
|
return sorted(calls.values(), key=lambda c: c.dt)
|
||||||
|
|
||||||
|
|
||||||
|
def test():
|
||||||
|
assert len(get_calls()) > 10
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
from calls import get_calls
|
|
||||||
|
|
||||||
for c in get_calls():
|
|
||||||
print(c)
|
|
10
ci.sh
10
ci.sh
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd "$(this_dir)" || exit
|
|
||||||
|
|
||||||
. ~/bash_ci
|
|
||||||
|
|
||||||
ci_run mypy calls
|
|
||||||
ci_run pylint -E calls
|
|
||||||
|
|
||||||
ci_report_errors
|
|
6
run
6
run
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
python3 -m calls
|
|
Loading…
Add table
Add a link
Reference in a new issue