From 57917426e8e962cf94d42b194eb404f48d36397c Mon Sep 17 00:00:00 2001 From: Vinayak Mehta Date: Sat, 30 Jul 2016 18:59:15 +0530 Subject: [PATCH] Fix docstrings --- camelot/lattice.py | 7 ++----- camelot/pdf.py | 20 ++------------------ camelot/stream.py | 3 +-- camelot/table.py | 4 ++-- tools/camelot | 8 ++++---- 5 files changed, 11 insertions(+), 31 deletions(-) diff --git a/camelot/lattice.py b/camelot/lattice.py index 00cf28a..f779d69 100644 --- a/camelot/lattice.py +++ b/camelot/lattice.py @@ -130,7 +130,7 @@ class Lattice: fill : None, 'h', 'v', 'hv' Fill data in horizontal and/or vertical spanning - cells. (optional) + cells. (optional, default: None) scale : int Scaling factor. Large scaling factor leads to smaller lines @@ -150,6 +150,7 @@ class Lattice: debug : 'contour', 'line', 'joint', 'table' Debug by visualizing pdf geometry. + (optional, default: None) Attributes ---------- @@ -299,7 +300,6 @@ class Lattice: cv2.rectangle(img, (t[0], t[1]), (t[2], t[3]), (255, 0, 0), 3) plt.imshow(img) - plt.axis('off') plt.show() elif geometry == 'joint': x_coord = [] @@ -314,7 +314,6 @@ class Lattice: plt.plot(x_coord, y_coord, 'ro') plt.axis([0, max_x + 100, max_y + 100, 0]) plt.imshow(img) - plt.axis('off') plt.show() elif geometry == 'line': for pkey in self.debug_segments.keys(): @@ -323,7 +322,6 @@ class Lattice: plt.plot([v[0], v[2]], [v[1], v[3]]) for h in h_s: plt.plot([h[0], h[2]], [h[1], h[3]]) - plt.axis('off') plt.show() elif geometry == 'table': for pkey in self.debug_tables.keys(): @@ -350,5 +348,4 @@ class Lattice: table.cells[i][j].rb[0]], [table.cells[i][j].lb[1], table.cells[i][j].rb[1]]) - plt.axis('off') plt.show() \ No newline at end of file diff --git a/camelot/pdf.py b/camelot/pdf.py index 2988e3d..eb2e08e 100644 --- a/camelot/pdf.py +++ b/camelot/pdf.py @@ -50,7 +50,7 @@ def _extract_text_objects(layout, LTObject, t=None): LTObject : object Text object, either LTChar or LTTextLineHorizontal. - t : list + t : list (optional, default: None) Returns ------- @@ -84,6 +84,7 @@ class Pdf: pagenos : list List of dicts which specify pdf page ranges. + (optional, default: [{'start': 1, 'end': 1}]) char_margin : float Chars closer than char_margin are grouped together to form a @@ -96,23 +97,6 @@ class Pdf: word_margin : float Insert blank spaces between chars if distance between words is greater than word_margin. (optional, default: 0.1) - - Attributes - ---------- - temp : string - Path to temporary directory. - - lattice_objects : dict - List of text objects. - - stream_objects : dict - List of text objects. - - width : dict - List of dicts with width of each pdf page. - - height : dict - List of dicts with height of each pdf page. """ def __init__(self, pdfname, pagenos=[{'start': 1, 'end': 1}], diff --git a/camelot/stream.py b/camelot/stream.py index 320a6e6..5139537 100644 --- a/camelot/stream.py +++ b/camelot/stream.py @@ -18,7 +18,7 @@ def _group_rows(text, ytol=2): ytol : int Tolerance to account for when grouping rows - together. (default: 2, optional) + together. (optional, default: 2) Returns ------- @@ -206,5 +206,4 @@ class Stream: ) ax.set_xlim(min(xs) - 10, max(xs) + 10) ax.set_ylim(min(ys) - 10, max(ys) + 10) - plt.axis('off') plt.show() diff --git a/camelot/table.py b/camelot/table.py index a1a8c29..2b7a126 100644 --- a/camelot/table.py +++ b/camelot/table.py @@ -39,9 +39,9 @@ class Table: horizontal : list List of horizontal line segments. - jtol : int, default: 2, optional + jtol : int Tolerance to account for when comparing joint and line - coordinates. + coordinates. (optional, default: 2) """ for v in vertical: # find closest x coord diff --git a/tools/camelot b/tools/camelot index 0880611..439112e 100755 --- a/tools/camelot +++ b/tools/camelot @@ -13,10 +13,10 @@ from camelot.stream import Stream doc = """ -camelot parses tables from PDFs! +Camelot: PDF parsing made simpler! usage: - camelot.py [options] [...] + camelot [options] [...] options: -h, --help Show this screen. @@ -38,7 +38,7 @@ lattice_doc = """ Lattice method looks for lines between data to form a table. usage: - camelot.py lattice [options] [--] + camelot lattice [options] [--] options: -F, --fill Fill data in horizontal and/or vertical spanning @@ -59,7 +59,7 @@ stream_doc = """ Stream method looks for spaces between data to form a table. usage: - camelot.py stream [options] [--] + camelot stream [options] [--] options: -n, --ncols Number of columns. [default: 0]