• R/O
  • SSH

chkcsv: Commit

Default repository for chkcsv.py.


Commit MetaInfo

Revisionfd3cad105aa5f0b31b6d0e7558857704d08e5e3b (tree)
Zeit2019-01-04 00:20:21
AutorDreas Nielsen <dnielsen@inte...>
CommiterDreas Nielsen

Log Message

Merged formatting changes.

Ändern Zusammenfassung

Diff

diff -r b20d06375291 -r fd3cad105aa5 chkcsv/chkcsv.py
--- a/chkcsv/chkcsv.py Wed Jan 02 20:30:53 2019 -0800
+++ b/chkcsv/chkcsv.py Thu Jan 03 07:20:21 2019 -0800
@@ -79,7 +79,7 @@
7979
8080 class CsvChecker():
8181 """Create an object to check a specific column of a defined type.
82-
82+
8383 :param fmt_spec: A ConfigParser object.
8484 :param colname: The name of the data column.
8585 :param column_required_default: A Boolean indicating whether the column is required by default.
@@ -192,16 +192,16 @@
192192 # Basic format checking functions. These return None if the data are acceptable,
193193 # a textual description of the problem otherwise.
194194 def chk_req(self, data):
195- return "missing data" if len(data)==0 else None
195+ return "missing data" if len(data) == 0 else None
196196 def chk_min(self, data):
197- return None if (not self.data_required and len(data)==0) or \
197+ return None if (not self.data_required and len(data) == 0) or \
198198 len(data) >= self.minlen else "data too short"
199199 def chk_max(self, data):
200200 return None if len(data) <= self.maxlen else "data too long"
201201 def chk_pat(self, data):
202- return None if len(data)==0 or self.rx.match(data) else "pattern mismatch"
202+ return None if len(data) == 0 or self.rx.match(data) else "pattern mismatch"
203203 def chk_int(self, data):
204- if len(data)==0:
204+ if len(data) == 0:
205205 return None
206206 try:
207207 x = int(data)
@@ -209,7 +209,7 @@
209209 except ValueError:
210210 return "not an integer"
211211 def chk_float(self, data):
212- if len(data)==0:
212+ if len(data) == 0:
213213 return None
214214 try:
215215 x = float(data)
@@ -217,20 +217,20 @@
217217 except ValueError:
218218 return "not a floating-point number"
219219 def chk_bool(self, data):
220- if len(data)==0:
220+ if len(data) == 0:
221221 return None
222222 return None if data in (u'True', u'true', u'TRUE', u'T', u't', u'Yes', u'yes', u'YES', u'Y', u'y',
223223 u'False', u'false', u'FALSE', u'F', u'f',
224224 u'No', u'no', u'NO', u'N', u'n', True, False) else u"unrecognized boolean"
225225 def chk_datetime(self, data):
226- if len(data)==0:
226+ if len(data) == 0:
227227 return None
228228 if type(data) == type(datetime.datetime.now()):
229229 return None
230230 if type(data) == type(datetime.date.today()):
231231 return None
232232 if type(data) != type(""):
233- if data==None:
233+ if data == None:
234234 return "missing date/time"
235235 try:
236236 data = str(data)
@@ -328,7 +328,7 @@
328328 CSV file name The name of a comma-separated-values file to check."""
329329 vers_msg = "%prog " + "%s %s" % (_version, _vdate)
330330 desc_msg = "Checks the content and format of a CSV file."
331- parser = OptionParser(usage=usage_msg, version=vers_msg, description=desc_msg)
331+ parser = OptionParser(usage = usage_msg, version=vers_msg, description = desc_msg)
332332 parser.add_option("-s", "--showspecs", action="store_true", dest="showspecs",
333333 default=False,
334334 help="Show the format specifications allowed in the configuration file, and exit.")
Show on old repository browser