Skip to content

Commit

Permalink
Move file content checks from with block
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Dec 26, 2015
1 parent 53c613c commit aff2a77
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bin/dots
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,18 @@ class ConfigFile(object):
with open(path, 'r') as file:
contents = file.readlines()

# Replace front and back empty lines with None
contents = self.trim_file_whitespace(contents)
# Replace front and back empty lines with None
contents = self.trim_file_whitespace(contents)

# Ensure a trailing newline
if contents and not contents[-1].endswith('\n'):
contents[-1] += '\n'
# Ensure a trailing newline
if contents and not contents[-1].endswith('\n'):
contents[-1] += '\n'

# Ensure the file only has one explicit default append point
if [p.strip() for p in contents].count(AP_IDENTIFIER) > 1:
raise Exception("More than one explicit append point in {0}".format(path))
# Ensure the file only has one explicit default append point
if [p.strip() for p in contents].count(AP_IDENTIFIER) > 1:
raise Exception("More than one explicit append point in {0}".format(path))

compiling_files.append(contents)
compiling_files.append(contents)

# Nothing left to do if there were no files
if not compiling_files:
Expand Down

0 comments on commit aff2a77

Please sign in to comment.