Skip to content

Commit

Permalink
Merge pull request #58 from nschloe/tracebacks-handling
Browse files Browse the repository at this point in the history
Tracebacks handling
  • Loading branch information
nschloe authored Nov 26, 2019
2 parents 81c7160 + 57a8a1a commit 74333e4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ upload: setup.py
twine upload dist/*

update:
curl https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css > tuna/web/static/bootstrap.min.css
curl https://d3js.org/d3.v5.min.js > tuna/web/static/d3.v5.min.js
curl https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css > tuna/web/static/bootstrap.min.css
curl https://d3js.org/d3.v5.min.js > tuna/web/static/d3.min.js

publish: tag upload

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tuna",
"dependencies": {
"bootstrap": "4.3.1",
"bootstrap": "4.4.0",
"d3": "5.13.1"
}
}
27 changes: 23 additions & 4 deletions test/test_tuna.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@ def test_importprofile():
import time: 2 | 15 | b
import time: 1 | 12 | a
"""

ref = {
"name": "main",
"color": 0,
"children": [
{
"name": "a",
"value": 1e-06,
"children": [{"name": "b", "value": 2e-06, "color": 0}],
"color": 0,
"children": [
{
"name": "b",
"value": 2e-06,
"color": 0,
"children": [{"name": "c", "value": 3e-06, "color": 0}],
}
],
}
],
}
Expand All @@ -45,7 +53,6 @@ def test_importprofile():
out = tuna.read_import_profile(filepath)

assert out == ref, ref
return


def test_importprofile_multiprocessing():
Expand All @@ -69,7 +76,20 @@ def test_importprofile_multiprocessing():
{
"name": "b",
"value": 2e-06,
"children": [{"name": "c", "value": 3e-06, "color": 0}],
"children": [
{
"name": "c",
"value": 3e-06,
"children": [
{
"name": "e",
"value": 4.9999999999999996e-06,
"color": 0,
}
],
"color": 0,
}
],
"color": 0,
},
{"name": "d", "value": 4e-06, "color": 0},
Expand All @@ -87,7 +107,6 @@ def test_importprofile_multiprocessing():
out = tuna.read_import_profile(filepath)

assert out == ref, ref
return


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tuna/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
__author_email__ = "nico.schloemer@gmail.com"
__copyright__ = "Copyright (c) 2018-2019, {} <{}>".format(__author__, __author_email__)
__license__ = "License :: OSI Approved :: MIT License"
__version__ = "0.3.3"
__version__ = "0.3.4"
__maintainer__ = "Nico Schlömer"
__status__ = "Development Status :: 5 - Production/Stable"
19 changes: 11 additions & 8 deletions tuna/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
import mimetypes
import os
import pstats
Expand Down Expand Up @@ -153,18 +154,20 @@ def read_import_profile(filename):
entries = []
with open(filename, "r") as f:
# filtered iterator over lines prefixed with "import time: "
import_lines = (
line[len("import time: ") :].rstrip()
for line in f
if line.startswith("import time: ")
)

try:
line = next(import_lines)
line = next(f)
except UnicodeError:
raise TunaError()

for line in import_lines:
for line in f:
if not line.startswith("import time: "):
logging.warning(
"Didn't recognize and skipped line `{}`".format(line.rstrip())
)
continue

line = line[len("import time: ") :].rstrip()

if line == "self [us] | cumulative | imported package":
continue
items = line.split(" | ")
Expand Down

0 comments on commit 74333e4

Please sign in to comment.