diff --git a/src/__main__.py b/osak/__main__.py similarity index 94% rename from src/__main__.py rename to osak/__main__.py index a94e465..31a4cb5 100644 --- a/src/__main__.py +++ b/osak/__main__.py @@ -13,7 +13,8 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see .""" from argparse import ArgumentParser, BooleanOptionalAction -# import dirproc + +from .procdir import * psr = ArgumentParser( description="OPUS Swiss Army Knife 0.1.0", @@ -22,5 +23,4 @@ psr = ArgumentParser( psr.add_argument("dir", nargs="+") for i in psr.parse_args().dir: - print(i) - # dirproc.proc(i) + process(i) diff --git a/osak/procdir.py b/osak/procdir.py new file mode 100644 index 0000000..d22f2d2 --- /dev/null +++ b/osak/procdir.py @@ -0,0 +1,19 @@ +import os +import brukeropusreader as bor +import re + +match_opus = re.compile(r"_[0-9]+(\.[0-9]+)?T.0$") + +def ifnot(d,v): + if v not in d: + d[v] = {} + +def process(s): + for fn in os.listdir(s): + v = re.search(match_opus, fn) + if v is None: + continue + field = v.group()[1:len(v.group())-2] + print(fn) + print(field) + print()