0009-misc-fix-consider-using-with-pylint-error-55505.patch
chrono/manager/management/commands/export_site.py | ||
---|---|---|
32 | 32 | |
33 | 33 |
def handle(self, *args, **options): |
34 | 34 |
if options['output']: |
35 |
output = open(options['output'], 'w') |
|
35 |
with open(options['output'], 'w') as output: |
|
36 |
json.dump(export_site(), output, indent=4) |
|
36 | 37 |
else: |
37 | 38 |
output = sys.stdout |
38 |
json.dump(export_site(), output, indent=4) |
|
39 |
json.dump(export_site(), output, indent=4) |
chrono/manager/management/commands/import_site.py | ||
---|---|---|
35 | 35 |
parser.add_argument('--overwrite', action='store_true', default=False, help='Overwrite existing data') |
36 | 36 | |
37 | 37 |
def handle(self, filename, **options): |
38 |
def do_import(fd): |
|
39 |
try: |
|
40 |
import_site( |
|
41 |
json.load(fd), |
|
42 |
if_empty=options['if_empty'], |
|
43 |
clean=options['clean'], |
|
44 |
overwrite=options['overwrite'], |
|
45 |
) |
|
46 |
except AgendaImportError as exc: |
|
47 |
raise CommandError(u'%s' % exc) |
|
48 | ||
38 | 49 |
if filename == '-': |
39 | 50 |
fd = sys.stdin |
51 |
do_import(fd) |
|
40 | 52 |
else: |
41 |
fd = open(filename) |
|
42 |
try: |
|
43 |
import_site( |
|
44 |
json.load(fd), |
|
45 |
if_empty=options['if_empty'], |
|
46 |
clean=options['clean'], |
|
47 |
overwrite=options['overwrite'], |
|
48 |
) |
|
49 |
except AgendaImportError as exc: |
|
50 |
raise CommandError(u'%s' % exc) |
|
53 |
with open(filename) as fd: |
|
54 |
do_import(fd) |
chrono/settings.py | ||
---|---|---|
196 | 196 |
'CHRONO_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py') |
197 | 197 |
) |
198 | 198 |
if os.path.exists(local_settings_file): |
199 |
exec(open(local_settings_file).read()) |
|
199 |
with open(local_settings_file) as fd: |
|
200 |
exec(fd.read()) |
|
200 |
- |