Skip to content

Commit

Permalink
More WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgate committed Sep 7, 2021
1 parent 709247e commit 2ea5edf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/shelllogger/ShellLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,22 +393,22 @@ def add_child(self, child_name: str) -> ShellLogger:
return child

@staticmethod
def strfdelta(tdelta: timedelta, fmt: str) -> str:
def strfdelta(delta: timedelta, fmt: str) -> str:
"""
Format a time delta object. Use this like you would
:func:`datetime.strftime`.
Parameters:
tdelta: The time delta object.
delta: The time delta object.
fmt: The delta format string.
Returns:
A string representation of the time delta.
"""

# Dictionary to hold time delta info.
d = {'days': tdelta.days}
total_ms = tdelta.microseconds + (tdelta.seconds * 1000000)
d = {'days': delta.days}
total_ms = delta.microseconds + (delta.seconds * 1000000)
d['hrs'], rem = divmod(total_ms, 3600000000)
d['min'], rem = divmod(rem, 60000000)
d['sec'] = rem / 1000000
Expand Down Expand Up @@ -573,7 +573,7 @@ def log(
Note:
To conserve memory, ``stdout`` and ``stderr`` will be
written to the files as they are being generated.
written to files as they are being generated.
"""
start_time = datetime.now()

Expand Down
6 changes: 5 additions & 1 deletion src/shelllogger/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def flatten(element: object) -> object:
Takes a tree of lists and turns it into a flat iterables. Ish.
Parameters:
element:
element: Todo: Figure this out.
"""
if isinstance(element, str):
yield element
Expand Down Expand Up @@ -719,6 +719,8 @@ def embed_style(resource: str) -> str:
Returns:
A string containing the ``<style>...</style>`` block.
Todo: Combine this with the two below?
"""
return ("<style>\n"
+ pkgutil.get_data(__name__, f"resources/{resource}").decode()
Expand Down Expand Up @@ -767,6 +769,8 @@ def load_template(template: str) -> str:
Returns:
A string containing the contents of the file.
Todo: Combine with the one above?
"""
template_file = f"resources/templates/{template}"
return pkgutil.get_data(__name__, template_file).decode()
Expand Down

0 comments on commit 2ea5edf

Please sign in to comment.