Skip to content

Commit

Permalink
Merge pull request #8 from jtrain/patch-1
Browse files Browse the repository at this point in the history
Avoid use of __future__ import
  • Loading branch information
valdergallo authored Jan 9, 2020
2 parents cfaf74d + 22dcaf6 commit b92e5cb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions reset_migrations/management/commands/reset_migrations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

from django.core.management import BaseCommand
from django.core.management import call_command
from django.db import connection
Expand All @@ -8,13 +6,13 @@
import re
import tempfile

def delete_line(filename, pattern):
def delete_line(filename, pattern, stdout):
pattern_compiled = re.compile(pattern)
with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file:
with open(filename) as src_file:
for line in src_file:
if pattern_compiled.findall(line):
print('Deleting line in %s' % filename)
stdout.write('Deleting line in %s' % filename)
continue
tmp_file.write(line)

Expand Down Expand Up @@ -64,7 +62,7 @@ def delete_dependence_app(self, app):
continue
if '.py' in file_name:
regex = r'\(\'%s\'' % app
delete_line(file_name, regex)
delete_line(file_name, regex, self.stdout)

def handle(self, *args, **options):
apps = options['apps']
Expand Down

0 comments on commit b92e5cb

Please sign in to comment.