Skip to content

Commit b35979e

Browse files
authored
Merge pull request #679 from srinivasreddy/refactor
refactor the files.py
2 parents be3dab6 + 4676c42 commit b35979e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

plotly/files.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@
2222
'sharing': 'public',
2323
'auto_open': True}}
2424

25-
try:
26-
os.mkdir(TEST_DIR)
27-
os.rmdir(TEST_DIR)
28-
if not os.path.exists(PLOTLY_DIR):
29-
os.mkdir(PLOTLY_DIR)
30-
f = open(TEST_FILE, 'w')
31-
f.write('testing\n')
32-
f.close()
33-
os.remove(TEST_FILE)
34-
_file_permissions = True
35-
except:
36-
_file_permissions = False
25+
26+
def _permissions():
27+
try:
28+
os.mkdir(TEST_DIR)
29+
os.rmdir(TEST_DIR)
30+
if not os.path.exists(PLOTLY_DIR):
31+
os.mkdir(PLOTLY_DIR)
32+
with open(TEST_FILE, 'w') as f:
33+
f.write('testing\n')
34+
os.remove(TEST_FILE)
35+
return True
36+
except:
37+
return False
38+
39+
40+
_file_permissions = _permissions()
3741

3842

3943
def check_file_permissions():

0 commit comments

Comments
 (0)