[MRG + 1] Make pep8 (#125)
* Make setup.py pep8 Add new line at end of file, fix bare except, remove unused import. * Make tests/*.py pep8 Add some newlines at and of files and a visual indent. * Make docs/*.py pep8 Fix block comments and add new lines at end of files. * Make camelot/*.py pep8 Fixed unused import, a few weirdly ordered imports, a docstring typo and many new lines at the end of lines. * Fix imports Fix import order and remove a couple more unused imports. * Fix indents Fix indentation (no opening delimiter alignment). * Add newlines
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .stream import Stream
|
||||
from .lattice import Lattice
|
||||
from .lattice import Lattice
|
||||
|
||||
@@ -18,4 +18,4 @@ class BaseParser(object):
|
||||
self.horizontal_text = get_text_objects(self.layout, ltype="lh")
|
||||
self.vertical_text = get_text_objects(self.layout, ltype="lv")
|
||||
self.pdf_width, self.pdf_height = self.dimensions
|
||||
self.rootname, __ = os.path.splitext(self.filename)
|
||||
self.rootname, __ = os.path.splitext(self.filename)
|
||||
|
||||
@@ -201,8 +201,9 @@ class Lattice(BaseParser):
|
||||
if 'ghostscript' in subprocess.check_output(['gs', '-version']).decode('utf-8').lower():
|
||||
gs_call.insert(0, 'gs')
|
||||
else:
|
||||
gs_call.insert(0, 'gsc')
|
||||
subprocess.call(gs_call, stdout=open(os.devnull, 'w'),
|
||||
gs_call.insert(0, "gsc")
|
||||
subprocess.call(
|
||||
gs_call, stdout=open(os.devnull, 'w'),
|
||||
stderr=subprocess.STDOUT)
|
||||
|
||||
def _generate_table_bbox(self):
|
||||
@@ -339,10 +340,10 @@ class Lattice(BaseParser):
|
||||
|
||||
_tables = []
|
||||
# sort tables based on y-coord
|
||||
for table_idx, tk in enumerate(sorted(self.table_bbox.keys(),
|
||||
key=lambda x: x[1], reverse=True)):
|
||||
for table_idx, tk in enumerate(sorted(
|
||||
self.table_bbox.keys(), key=lambda x: x[1], reverse=True)):
|
||||
cols, rows, v_s, h_s = self._generate_columns_and_rows(table_idx, tk)
|
||||
table = self._generate_table(table_idx, cols, rows, v_s=v_s, h_s=h_s)
|
||||
_tables.append(table)
|
||||
|
||||
return _tables
|
||||
return _tables
|
||||
|
||||
@@ -116,7 +116,7 @@ class Stream(BaseParser):
|
||||
row_y = t.y0
|
||||
temp.append(t)
|
||||
rows.append(sorted(temp, key=lambda t: t.x0))
|
||||
__ = rows.pop(0) # hacky
|
||||
__ = rows.pop(0) # hacky
|
||||
return rows
|
||||
|
||||
@staticmethod
|
||||
@@ -211,7 +211,7 @@ class Stream(BaseParser):
|
||||
text = Stream._group_rows(text, row_close_tol=row_close_tol)
|
||||
elements = [len(r) for r in text]
|
||||
new_cols = [(t.x0, t.x1)
|
||||
for r in text if len(r) == max(elements) for t in r]
|
||||
for r in text if len(r) == max(elements) for t in r]
|
||||
cols.extend(Stream._merge_columns(sorted(new_cols)))
|
||||
return cols
|
||||
|
||||
@@ -357,10 +357,10 @@ class Stream(BaseParser):
|
||||
|
||||
_tables = []
|
||||
# sort tables based on y-coord
|
||||
for table_idx, tk in enumerate(sorted(self.table_bbox.keys(),
|
||||
key=lambda x: x[1], reverse=True)):
|
||||
for table_idx, tk in enumerate(sorted(
|
||||
self.table_bbox.keys(), key=lambda x: x[1], reverse=True)):
|
||||
cols, rows = self._generate_columns_and_rows(table_idx, tk)
|
||||
table = self._generate_table(table_idx, cols, rows)
|
||||
_tables.append(table)
|
||||
|
||||
return _tables
|
||||
return _tables
|
||||
|
||||
Reference in New Issue
Block a user