def test_spacify(self):
     f = open("file.txt", 'r')
     content = f.read()
     f.close()
     self.f.write(string_utils.tabs_to_spaces(content, 4))
     self.f.close()
     self.assertEqual(content.replace('\t', " " * 4),
         string_utils.tabs_to_spaces(content, 4))
 def test_spacify(self):
     f = open("file.txt", 'r')
     content = f.read()
     f.close()
     self.f.write(string_utils.tabs_to_spaces(content, 4))
     self.f.close()
     self.assertEqual(content.replace('\t', " " * 4),
                      string_utils.tabs_to_spaces(content, 4))
def tab_to_spaces(file_name):
    file = open(file_name, "r")
    content = file.read()
    file.close()
    file = open(file_name, "w")
    temp = string_utils.tabs_to_spaces(content)
    file.write(temp)
Exemple #4
0
def spacify(filename):
	f = open(filename, "r+")
	content = f.read()
	f.seek(0)

	f.write(tabs_to_spaces(content))
	f.close()
Exemple #5
0
def spacify(filename):
    infile = open(filename, 'r')
    content = infile.read()
    infile.close()
    content = tabs_to_spaces(content, 4)
    outfile = open(filename, 'w')
    outfile.write(content)
    outfile.close()
Exemple #6
0
def spacify(filename):
    file = open(filename, "r")
    content = file.read()
    new_content = tabs_to_spaces(content, 4)
    file.close()

    file = open(filename, "w")
    file.write(new_content)
    file.close()
Exemple #7
0
def main():
    filename = sys.argv[1]
    file = open(filename, 'r')
    content = file.read()
    file.close()

    file = open(filename, 'w')
    new_content = string_utils.tabs_to_spaces(content, 4)
    file.write(new_content)
    file.close()
def spacify(filename):
    new_file = open(filename, 'r')
    contents = new_file.read()
    contents = tabs_to_spaces(contents, 2)
    new_file.close()
    file = open(filename, 'w')
    file.write(contents)
    file.close()
    file = open(filename, 'r')
    contents = file.read()
    file.close()
    return contents
def spacify(filename):
    new_file = open(filename, 'r')
    contents = new_file.read()
    contents = tabs_to_spaces(contents, 2)
    new_file.close()
    file = open(filename, 'w')
    file.write(contents)
    file.close()
    file = open(filename, 'r')
    contents = file.read()
    file.close()
    return contents
def main():
    if len(sys.argv) > 1:
        filename = sys.argv[1]
        if not os.path.isfile(filename):
            print("File does not exist")
            return
        f = open(filename, "r+")
        contents = f.read()
        f.seek(0)
        contents_with_spaces = string_utils.tabs_to_spaces(contents)
        f.write(contents_with_spaces)
        f.close()
    else:
        print("No filename given.")
 def test_tabs_to_spaces(self):
     self.assertEqual("Takes a    Tab", string_utils.tabs_to_spaces("Takes a\tTab", 4))
     self.assertEqual("Takes a  Tab", string_utils.tabs_to_spaces("Takes a\tTab", 2))
Exemple #12
0
 def test_tabs_to_spaces(self):
     self.assertEqual("Takes a    Tab",
                      string_utils.tabs_to_spaces("Takes a\tTab", 4))
     self.assertEqual("Takes a  Tab",
                      string_utils.tabs_to_spaces("Takes a\tTab", 2))
 def test_tabs_to_spaces(self):
     self.assertEqual('it    works',
         string_utils.tabs_to_spaces('it\tworks'))
     self.assertEqual('this    works    too',
         string_utils.tabs_to_spaces('this\tworks\ttoo'))
	def test_tabs_to_spaces(self):
		self.assertEqual("blq    lqlq    fefe    ty", string_utils.tabs_to_spaces('blq	lqlq	fefe	ty'))
Exemple #15
0
 def test_tabs_to_spaces(self):
     self.assertEqual("blq    lqlq    fefe    ty",
                      string_utils.tabs_to_spaces('blq	lqlq	fefe	ty'))
 def test_tabs_to_spaces(self):
     string = "this\tis\tstring example....wow!!!\t\tthis\tis really string"
     expected = "this is string example....wow!!!  this is really string"
     self.assertEqual(expected, string_utils.tabs_to_spaces(string, 1))
     self.assertEqual("", string_utils.tabs_to_spaces(""))
 def test_tabs_to_spaces2(self):
     self.assertEqual('    a\na', string_utils.tabs_to_spaces('\ta\na', 4))
Exemple #18
0
	def test_tabs_to_spaces(self):
		self.assertEqual("my    test for the    example",
			string_utils.tabs_to_spaces("my\ttest for the\texample"))
		self.assertEqual("my  other test for the  example",
			string_utils.tabs_to_spaces("my\tother test for the\texample", 2))