ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Tool_Box/ValidateAndFormatTools.py
Revision: 630
Committed: Mon Mar 13 15:46:37 2017 UTC (9 years ago) by nino.borges
Content type: text/x-python
File size: 1569 byte(s)
Log Message:
A new set of tools to do simple validating and formating.

File Contents

# User Rev Content
1 nino.borges 630 """
2     ValidateAndFormatTools
3    
4     Created by
5     Emanuel Borges
6     01.20.17
7    
8     A collection of methods to validate, by cleaning up data, or format, by doing things like adding the commas for large numbers, etc
9    
10     """
11    
12     import os
13    
14     class ValidateNumbers:
15     """This class will validate and strip out things to verify proper numbers, like removing commas"""
16     def RemoveCommas(self, data):
17     """Removes the comma and returns an string without commas. not trying to make it a int or a float"""
18     data = data.replace(",","")
19     return data
20    
21     class FormatNumbers:
22     """This class will format numbers by doing things like making sure commas are in the right place"""
23     def AddCommasToNumbers(self, number):
24     """This method will format an int or float and add the commas in the right places. Return a string"""
25     newData = "{:,}".format(number)
26     return newData
27    
28    
29     class ValidateFileNames:
30     """This class will validate and strip out things to verify proper file names, like removing backslashes and appostrophes"""
31     def RemoveIllegalWinChars(self,data):
32     """Removes things that are illegal in win file names"""
33     data = data.replace("'","")
34     data = data.replace("\\","")
35     data = data.replace("/","")
36     data = data.replace(":","")
37     data = data.replace("?","")
38     data = data.replace("*","")
39     data = data.replace('"',"")
40     data = data.replace("<","")
41     data = data.replace(">","")
42     data = data.replace("|","")
43     return data