• R/O
  • SSH

chkcsv: Commit

Default repository for chkcsv.py.


Commit MetaInfo

Revisionbcebd5ad90bfb33d57d5bc0e507ce14427ef8c8f (tree)
Zeit2019-01-04 22:35:23
AutorDreas Nielsen <dreas.nielsen@gmai...>
CommiterDreas Nielsen

Log Message

Merged heads.

Ändern Zusammenfassung

Diff

diff -r 1e00f4280f2f -r bcebd5ad90bf chkcsv/chkcsv.py
--- a/chkcsv/chkcsv.py Fri Jan 04 05:33:56 2019 -0800
+++ b/chkcsv/chkcsv.py Fri Jan 04 05:35:23 2019 -0800
@@ -81,7 +81,7 @@
8181
8282 class CsvChecker():
8383 """Create an object to check a specific column of a defined type.
84-
84+
8585 :param fmt_spec: A ConfigParser object.
8686 :param colname: The name of the data column.
8787 :param column_required_default: A Boolean indicating whether the column is required by default.
@@ -194,16 +194,16 @@
194194 # Basic format checking functions. These return None if the data are acceptable,
195195 # a textual description of the problem otherwise.
196196 def chk_req(self, data):
197- return "missing data" if len(data)==0 else None
197+ return "missing data" if len(data) == 0 else None
198198 def chk_min(self, data):
199- return None if (not self.data_required and len(data)==0) or \
199+ return None if (not self.data_required and len(data) == 0) or \
200200 len(data) >= self.minlen else "data too short"
201201 def chk_max(self, data):
202202 return None if len(data) <= self.maxlen else "data too long"
203203 def chk_pat(self, data):
204- return None if len(data)==0 or self.rx.match(data) else "pattern mismatch"
204+ return None if len(data) == 0 or self.rx.match(data) else "pattern mismatch"
205205 def chk_int(self, data):
206- if len(data)==0:
206+ if len(data) == 0:
207207 return None
208208 try:
209209 x = int(data)
@@ -211,7 +211,7 @@
211211 except ValueError:
212212 return "not an integer"
213213 def chk_float(self, data):
214- if len(data)==0:
214+ if len(data) == 0:
215215 return None
216216 try:
217217 x = float(data)
@@ -219,20 +219,20 @@
219219 except ValueError:
220220 return "not a floating-point number"
221221 def chk_bool(self, data):
222- if len(data)==0:
222+ if len(data) == 0:
223223 return None
224224 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',
225225 u'False', u'false', u'FALSE', u'F', u'f',
226226 u'No', u'no', u'NO', u'N', u'n', True, False) else u"unrecognized boolean"
227227 def chk_datetime(self, data):
228- if len(data)==0:
228+ if len(data) == 0:
229229 return None
230230 if type(data) == type(datetime.datetime.now()):
231231 return None
232232 if type(data) == type(datetime.date.today()):
233233 return None
234234 if type(data) != type(""):
235- if data==None:
235+ if data == None:
236236 return "missing date/time"
237237 try:
238238 data = str(data)
@@ -330,7 +330,7 @@
330330 CSV file name The name of a comma-separated-values file to check."""
331331 vers_msg = "%prog " + "%s %s" % (_version, _vdate)
332332 desc_msg = "Checks the content and format of a CSV file."
333- parser = OptionParser(usage=usage_msg, version=vers_msg, description=desc_msg)
333+ parser = OptionParser(usage = usage_msg, version=vers_msg, description = desc_msg)
334334 parser.add_option("-s", "--showspecs", action="store_true", dest="showspecs",
335335 default=False,
336336 help="Show the format specifications allowed in the configuration file, and exit.")
Show on old repository browser