Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
scan samples and output
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenCappuccino committed Oct 7, 2022
1 parent 2001d42 commit f81e1be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Tungsten output
output.json
output.txt
output/**/*.json

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
Expand Down
Empty file added output/.gitkeep
Empty file.
19 changes: 14 additions & 5 deletions tungsten/__main__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import json
import os
import time

from tungsten.parsers.globally_harmonized_system import GhsSdsJsonEncoder
from tungsten.parsers.sigma_aldrich import parse_sigma_aldrich
from dataclasses import asdict;


def main() -> None:
file = open("output.json", "w")
# noinspection PyTypeChecker
ghssds = parse_sigma_aldrich(open("tests/samples/sigma_aldrich_sigma_w5402.pdf", "rb", buffering=0))
json.dump(asdict(ghssds), file, cls=GhsSdsJsonEncoder, skipkeys=True)
file.close()
files = os.listdir("./tests/samples/")
paths = ["./tests/samples/" + file for file in files]

for i in range(len(paths)):
start = time.perf_counter()
# noinspection PyTypeChecker
ghssds = parse_sigma_aldrich(open(paths[i], "rb", buffering=0))
file = open("./output/" + files[i].split(sep=".")[0] + ".json", "w")
json.dump(asdict(ghssds), file, cls=GhsSdsJsonEncoder, skipkeys=True)
file.close()
print(time.perf_counter() - start, "seconds")


if __name__ == "__main__":
Expand Down

0 comments on commit f81e1be

Please sign in to comment.