Skip to content

Commit

Permalink
📓 Updated docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
djotaku committed Mar 23, 2020
1 parent 729c81e commit aff2535
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion photostats/get_exif.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@


def scan_tree(directory: str):
"""Recursively yield DirEntry objects for given directory."""
"""Recursively yield DirEntry objects for given directory.
:param directory: A string with the directory to scan for photos.
:returns: A list of files in the directory."""
for entry in os.scandir(directory):
if entry.is_dir(follow_symlinks=False):
yield from scan_tree(entry.path) # see below for Python 2.x
Expand Down
4 changes: 2 additions & 2 deletions photostats/lenses.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Create a graphs relating to lens usage on a directory of photos."""

from collections import Counter
import matplotlib.pyplot as plt # type: ignore

from photostats import get_exif
from photostats.utils import create_plot


def get_lens_make_model(exif_list: list) -> dict:
"""Obtain lens make and model for each photo passed in.
Expand Down Expand Up @@ -58,7 +58,7 @@ def main(exif, graph_path):
graph_path=graph_path, graph_filename="lens_focal_length")


if __name__ == '__main__':
if __name__ == '__main__': # pragma: no cover
test_directory = "/media/Photos/My Photos 2005 and on/2020/"
test_graph_path = "/home/ermesa/tmp/photostats"
test_photos = get_exif.get_photos(test_directory)
Expand Down
12 changes: 11 additions & 1 deletion photostats/utils/create_plot.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
"""Create a plot and save to disk."""
"""Create a graph and save to disk."""

import matplotlib.pyplot as plt # type: ignore


def create_plot(group_names: list, group_data: list, x_label: str = "", y_label: str = "", title: str = "",
graph_path: str = "", graph_filename: str = ""):
"""Create matplotlib bar graph.
:param group_names: A list with the names for bars
:param group_data: A list with the data that pairs with the names.
:param x_label: The label for the x-axis on the graph.
:param y_label: The label for the y-axis on the graph.
:param title: The Title for the graph.
:param graph_path: The path to save the graph to.
:param graph_filename: The filename to give the png file of the graph.
"""
plt.style.use('fivethirtyeight')
plt.rcParams.update({'figure.autolayout': True})
fig, ax = plt.subplots(figsize=(8, 8))
Expand Down

0 comments on commit aff2535

Please sign in to comment.