Skip to content

Commit

Permalink
fix typos and remove unused variables across codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshvarma committed Jul 16, 2020
1 parent 3834562 commit f4eab45
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
15 changes: 5 additions & 10 deletions src/pyxpdf/globalconfig.pxi
Expand Up @@ -4,7 +4,7 @@ from pyxpdf.includes.UnicodeMap cimport UnicodeMap
# NOTE: This class should be always a singleton
# only one object of this class should exist i.e
# global variable `Config`
# This is beacuse xpdf `GlobalParams` class's destructor
# This is because xpdf `GlobalParams` class's destructor
# frees global builtin font tables. So more that one
# `_GlobalParamsConfig` class will lead to double free
# or corruption error.
Expand All @@ -15,7 +15,7 @@ cdef class _GlobalParamsConfig:
public object __doc__

cdef _set_defaults(self):
# only call after initialising self._global
# only call after initializing self._global
# default text encoding
self._global.setTextEncoding("UTF-8")

Expand Down Expand Up @@ -159,16 +159,11 @@ cdef class _GlobalParamsConfig:

@text_eol.setter
def text_eol(self, eol):
cdef EndOfLineKind c_eol
if eol == "unix":
c_eol = EndOfLineKind.eolUnix
elif eol == "dos":
c_eol = EndOfLineKind.eolDOS
elif eol == 'mac':
c_eol = EndOfLineKind.eolMac
# cdef EndOfLineKind c_eol
if eol.lower() in (u'unix', u'mac', u'dos'):
self._global.setTextEOL(_chars(eol))
else:
raise XPDFConfigError(f"Invalid EOL type - {eol}.")
self._global.setTextEOL(_chars(eol))


@property
Expand Down
8 changes: 4 additions & 4 deletions src/pyxpdf/imageoutput.pxi
Expand Up @@ -39,7 +39,7 @@ DEF BITMAP_RESOLUTION = 150
#FIXME: buggy as hell, text does not render properly.
cdef bytearray splash_bitmap_to_1bpc_1comp(SplashBitmap *bitmap):
cdef:
int idx, x, y, i
int idx, y, i
int height = bitmap.getHeight()
int width = bitmap.getWidth()
SplashBitmapRowSize row_size = bitmap.getRowSize()
Expand All @@ -49,7 +49,7 @@ cdef bytearray splash_bitmap_to_1bpc_1comp(SplashBitmap *bitmap):

for y in range(height):
i = 0
for x in range(0, width, 8):
for _ in range(0, width, 8):
p = &data[y * row_size + i]
idx = y * row_size + i
img[idx] = p[0]
Expand Down Expand Up @@ -376,13 +376,11 @@ cdef class RawImageOutput(PDFOutputDevice):
double scale_y) except NULL:
cdef:
int rotation = 0
int total_pages = self.doc.doc.getNumPages()
double page_h = 0
double page_w = 0
double tmp
double res_x = self.resolution_x
double res_y = self.resolution_y
SplashBitmap* bitmap

if self.use_cropbox:
page_h = self.doc.doc.getPageCropHeight(page_no + 1)
Expand Down Expand Up @@ -604,6 +602,8 @@ cdef class PDFImage:
mode = "L"
elif c_img.bitmapColorMode == SplashColorMode.splashModeRGB8:
mode = "RGB"
else:
raise XPDFInternalError(f"Unsupported Bitmap SplashColorMode.")
buff = splash_bitmap_to_buffer(bmap, mode)
img.image = pillow_image_from_buffer(mode, bmap.getHeight(), bmap.getWidth(), buff)

Expand Down
2 changes: 1 addition & 1 deletion src/pyxpdf/xpdf.pyx
Expand Up @@ -101,6 +101,6 @@ include "textoutput.pxi"
# Python Objects based on SplashOutputDev.pxd
include "imageoutput.pxi"

# Pythonn Objects based on PDFDoc.pxd ,Page.pxd
# Python Objects based on PDFDoc.pxd ,Page.pxd
include "document.pxi"

0 comments on commit f4eab45

Please sign in to comment.