diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-03-02 08:42:53 -0800 |
|---|---|---|
| committer | Jon Dufresne <jon.dufresne@gmail.com> | 2019-03-02 08:42:53 -0800 |
| commit | b057cdf05e4b9d20f6e1743fc9c63d32c54f1908 (patch) | |
| tree | 0028b3683bdf022bb1e0676abdca3588de5c1362 /tablib | |
| parent | a10327a2833da8eee952d8b832afc33c3c55b282 (diff) | |
| download | tablib-b057cdf05e4b9d20f6e1743fc9c63d32c54f1908.tar.gz | |
Trim trailing white space throughout the project
Many editors clean up trailing white space on save. By removing it all
in one go, it helps keep future diffs cleaner by avoiding spurious white
space changes on unrelated lines.
Diffstat (limited to 'tablib')
| -rw-r--r-- | tablib/__init__.py | 1 | ||||
| -rw-r--r-- | tablib/core.py | 4 | ||||
| -rw-r--r-- | tablib/formats/_dbf.py | 3 | ||||
| -rw-r--r-- | tablib/formats/_xls.py | 2 | ||||
| -rw-r--r-- | tablib/formats/_xlsx.py | 4 | ||||
| -rw-r--r-- | tablib/packages/dbfpy3/record.py | 2 | ||||
| -rw-r--r-- | tablib/packages/markup3.py | 36 |
7 files changed, 23 insertions, 29 deletions
diff --git a/tablib/__init__.py b/tablib/__init__.py index 8518082..a217574 100644 --- a/tablib/__init__.py +++ b/tablib/__init__.py @@ -5,4 +5,3 @@ from tablib.core import ( InvalidDatasetType, InvalidDimensions, UnsupportedFormat, __version__ ) - diff --git a/tablib/core.py b/tablib/core.py index 78c4dce..0889845 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -541,14 +541,14 @@ class Dataset(object): .. admonition:: Line endings for Python 3 :class:`Dataset.csv` uses \\r\\n line endings by default so, in Python 3, make - sure to include newline='' otherwise you will get a blank line between each row + sure to include newline='' otherwise you will get a blank line between each row when you open the file in Excel:: with open('output.csv', 'w', newline='') as f: f.write(data.csv) If you do not do this, and you export the file on Windows, your - CSV file will open in Excel with a blank line between each row. + CSV file will open in Excel with a blank line between each row. """ pass diff --git a/tablib/formats/_dbf.py b/tablib/formats/_dbf.py index a0c183d..710797d 100644 --- a/tablib/formats/_dbf.py +++ b/tablib/formats/_dbf.py @@ -89,6 +89,3 @@ def detect(stream): # When unpacking a string argument with less than 8 chars, struct.error is # raised. return False - - - diff --git a/tablib/formats/_xls.py b/tablib/formats/_xls.py index 77e2bb1..82f8b86 100644 --- a/tablib/formats/_xls.py +++ b/tablib/formats/_xls.py @@ -25,7 +25,7 @@ def detect(stream): xlrd.open_workbook(file_contents=stream) return True except (TypeError, XLRDError): - pass + pass try: xlrd.open_workbook(file_contents=stream.read()) return True diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py index 816fd37..ebafc4f 100644 --- a/tablib/formats/_xlsx.py +++ b/tablib/formats/_xlsx.py @@ -129,7 +129,7 @@ def dset_sheet(dataset, ws, freeze_panes=True): if freeze_panes: # Export Freeze only after first Line ws.freeze_panes = 'A2' - + # bold separators elif len(row) < dataset.width: cell.value = unicode('%s' % col, errors='ignore') @@ -145,5 +145,3 @@ def dset_sheet(dataset, ws, freeze_panes=True): cell.value = unicode('%s' % col, errors='ignore') except TypeError: cell.value = unicode(col) - - diff --git a/tablib/packages/dbfpy3/record.py b/tablib/packages/dbfpy3/record.py index 73b6952..d301476 100644 --- a/tablib/packages/dbfpy3/record.py +++ b/tablib/packages/dbfpy3/record.py @@ -220,7 +220,7 @@ class DbfRecord(object): def toString(self): """Return string packed record values.""" # for (_def, _dat) in zip(self.dbf.header.fields, self.fieldData): -# +# return "".join([" *"[self.deleted]] + [ _def.encodeValue(_dat) diff --git a/tablib/packages/markup3.py b/tablib/packages/markup3.py index 1973c00..a4fc637 100644 --- a/tablib/packages/markup3.py +++ b/tablib/packages/markup3.py @@ -33,7 +33,7 @@ class element: self.tag = tag.lower( ) else: self.tag = tag.upper( ) - + def __call__( self, *args, **kwargs ): if len( args ) > 1: raise ArgumentError( self.tag ) @@ -42,14 +42,14 @@ class element: if self.parent is not None and self.parent.class_ is not None: if 'class_' not in kwargs: kwargs['class_'] = self.parent.class_ - + if self.parent is None and len( args ) == 1: x = [ self.render( self.tag, False, myarg, mydict ) for myarg, mydict in _argsdicts( args, kwargs ) ] return '\n'.join( x ) elif self.parent is None and len( args ) == 0: x = [ self.render( self.tag, True, myarg, mydict ) for myarg, mydict in _argsdicts( args, kwargs ) ] return '\n'.join( x ) - + if self.tag in self.parent.twotags: for myarg, mydict in _argsdicts( args, kwargs ): self.render( self.tag, False, myarg, mydict ) @@ -63,7 +63,7 @@ class element: raise DeprecationError( self.tag ) else: raise InvalidElementError( self.tag, self.parent.mode ) - + def render( self, tag, single, between, kwargs ): """Append the actual tags to content.""" @@ -89,7 +89,7 @@ class element: self.parent.content.append( out ) else: return out - + def close( self ): """Append a closing tag unless element has only opening tag.""" @@ -128,11 +128,11 @@ class page: these two keyword arguments may be used to select the set of valid elements in 'xml' mode invalid elements will raise appropriate exceptions - + separator -- string to place between added elements, defaults to newline - + class_ -- a class that will be added to every element if defined""" - + valid_onetags = [ "AREA", "BASE", "BR", "COL", "FRAME", "HR", "IMG", "INPUT", "LINK", "META", "PARAM" ] valid_twotags = [ "A", "ABBR", "ACRONYM", "ADDRESS", "B", "BDO", "BIG", "BLOCKQUOTE", "BODY", "BUTTON", "CAPTION", "CITE", "CODE", "COLGROUP", "DD", "DEL", "DFN", "DIV", "DL", "DT", "EM", "FIELDSET", @@ -163,7 +163,7 @@ class page: self.deptags += list(map( str.lower, self.deptags )) self.mode = 'strict_html' elif mode == 'loose_html': - self.onetags = valid_onetags + deprecated_onetags + self.onetags = valid_onetags + deprecated_onetags self.onetags += list(map( str.lower, self.onetags )) self.twotags = valid_twotags + deprecated_twotags self.twotags += list(map( str.lower, self.twotags )) @@ -187,12 +187,12 @@ class page: return element( attr, case=self.case, parent=self ) def __str__( self ): - + if self._full and ( self.mode == 'strict_html' or self.mode == 'loose_html' ): end = [ '</body>', '</html>' ] else: end = [ ] - + return self.separator.join( self.header + self.content + self.footer + end ) def __call__( self, escape=False ): @@ -232,7 +232,7 @@ class page: lang -- language, usually a two character string, will appear as <html lang='en'> in html mode (ignored in xml mode) - + css -- Cascading Style Sheet filename as a string or a list of strings for multiple css files (ignored in xml mode) @@ -306,7 +306,7 @@ class page: def css( self, filelist ): """This convenience function is only useful for html. It adds css stylesheet(s) to the document via the <link> element.""" - + if isinstance( filelist, str ): self.link( href=filelist, rel='stylesheet', type='text/css', media='all' ) else: @@ -339,10 +339,10 @@ class _oneliner: """An instance of oneliner returns a string corresponding to one element. This class can be used to write 'oneliners' that return a string immediately so there is no need to instantiate the page class.""" - + def __init__( self, case='lower' ): self.case = case - + def __getattr__( self, attr ): if attr.startswith("__") and attr.endswith("__"): raise AttributeError(attr) @@ -353,9 +353,9 @@ upper_oneliner = _oneliner( case='upper' ) def _argsdicts( args, mydict ): """A utility generator that pads argument list and dictionary values, will only be called with len( args ) = 0, 1.""" - + if len( args ) == 0: - args = None, + args = None, elif len( args ) == 1: args = _totuple( args[0] ) else: @@ -418,7 +418,7 @@ _escape = escape def unescape( text ): """Inverse of escape.""" - + if isinstance( text, str ): if '&' in text: text = text.replace( '&', '&' ) |
