Skip to content

Commit

Permalink
tabla strikes
Browse files Browse the repository at this point in the history
  • Loading branch information
s-nt-s committed Jan 27, 2021
1 parent 6d006a4 commit f0290d1
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 77 deletions.
2 changes: 1 addition & 1 deletion comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from core.api import Api
from core.db import DB
from core.threadme import ThreadMe
from core.util import read_yml_all, mkArg
from core.util import mkArg

import os

Expand Down
5 changes: 3 additions & 2 deletions core/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_root(dom):
class Stats:
def __init__(self):
self.db = DB()
self.min_tag=300
self.min_tag = 300
self.max_date, self.min_date = self.db.one('''
select
max(sent_date),
Expand Down Expand Up @@ -146,7 +146,8 @@ def counts(self):
"total": sum(count_cmt.values()),
"status": count_cmt
},
"posts": self.db.one("select count(*) from POSTS")
#"posts": self.db.one("select count(*) from POSTS")
"posts": self.db.one("select sum(posts) from ACTIVIDAD")
}

def get_karma(self, where=None):
Expand Down
30 changes: 18 additions & 12 deletions core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,31 @@ def chunks(lst, n):
if arr:
yield arr

def read_yml_all(*fls):
def multiopen(*fls):
if len(fls)==1 and "*" in fls[0]:
fls=sorted(glob(fls[0]))
for fl in fls:
if os.path.isfile(fl):
with open(fl, 'r') as f:
for i in yaml.load_all(f, Loader=yaml.FullLoader):
yield i
yield f

def read_yml_all(*fls):
for f in multiopen(*fls):
for i in yaml.load_all(f, Loader=yaml.FullLoader):
yield i

def readlines(*fls):
if len(fls)==1 and "*" in fls[0]:
fls=sorted(glob(fls[0]))
for fl in fls:
if os.path.isfile(fl):
with open(fl, 'r') as f:
for i in f.readlines():
i = i.strip()
if i and not i[0]=="#":
yield i
for f in multiopen(*fls):
for i in f.readlines():
i = i.strip()
if i and not i[0]=="#":
yield i

def read(fl):
with open(fl, "r") as f:
txt = f.read()
txt = txt.strip()
return txt

def parse_tag(tag, main=True):
tag = re_sp.sub(" ", tag).strip()
Expand Down
Loading

0 comments on commit f0290d1

Please sign in to comment.