Last active
August 29, 2015 14:02
-
-
Save devnoname120/ce37f8bb8e24941e5a7f to your computer and use it in GitHub Desktop.
NoPicAds: remove new line character from files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NoPicAds: remove new line character from files | |
# https://github.com/legnaleurc/nopicads/ | |
import glob | |
for fileName in glob.glob("src/sites/*/*.js"): | |
with open(fileName, "r", encoding='utf-8') as file: | |
lines = file.readlines() | |
# If last line is empty | |
if lines[-1].endswith("\n"): | |
# Delete it | |
lines[-1] = lines[-1][:-1] | |
# Open it in order to overwrite it | |
file = open(fileName, "w", encoding='utf-8') | |
# Write back to the file | |
file.writelines(lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment