Skip to content

Commit

Permalink
Remove special utf8 handling
Browse files Browse the repository at this point in the history
This basically reverts two commits:

 - d252369
 - f0d4aaa

Unfortunatlye I did a poor job documenting the reason for these commits.
But they both seem to have "broken" things, and now I'm unsure exactly
what they *fixed*.
  • Loading branch information
evanpurkhiser committed Dec 26, 2015
1 parent 1b0ef96 commit 53c613c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions bin/dots
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ from __future__ import print_function

import sys
import os
import io
import shutil
import subprocess
import glob
Expand Down Expand Up @@ -220,7 +219,7 @@ class Configuration(object):
exist in the source tree (meaning it's considered an 'invalid group'"""
if not os.path.exists(self.group_file): return

with io.open(self.group_file, 'r') as f:
with open(self.group_file, 'r') as f:
self.groups = f.read().splitlines()

if not self.groups:
Expand All @@ -235,7 +234,7 @@ class Configuration(object):
if not os.path.exists(directory):
os.makedirs(directory)

with io.open(self.group_file, 'w+') as f:
with open(self.group_file, 'w+') as f:
f.write('\n'.join(self.groups))

def files(self, path_filters=None):
Expand Down Expand Up @@ -376,7 +375,7 @@ class ConfigFile(object):
append_points = set()

for path in self.real_paths():
with io.open(path, 'r') as file:
with open(path, 'r') as file:
for line in file:
line = line.strip()
if line.startswith(AP_IDENTIFIER):
Expand Down Expand Up @@ -422,7 +421,7 @@ class ConfigFile(object):
# Read all file paths into arrays
# This may be memory inefficient and may have to be changed later
for path in self.real_paths():
with io.open(path, 'r') as file:
with open(path, 'r') as file:
contents = file.readlines()

# Replace front and back empty lines with None
Expand Down Expand Up @@ -519,18 +518,18 @@ class ConfigFile(object):

# Test that the file hasn't changed
if os.path.exists(path):
compiled = ''.join(self.compiled).encode('utf-8')
compiled = ''.join(self.compiled)
compiled = hashlib.md5(compiled).digest()

with io.open(path, 'r', encoding='utf-8') as installed_file:
installed = installed_file.read().encode('utf-8')
with open(path, 'r') as installed_file:
installed = installed_file.read()
installed = hashlib.md5(installed).digest()

if installed == compiled and os.stat(path).st_mode == self.mode():
return

# Write the file
with io.open(path, 'w') as file:
with open(path, 'w') as file:
file.writelines(self.compiled)

# Set the file's mode
Expand Down

0 comments on commit 53c613c

Please sign in to comment.