-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunctions.py
More file actions
31 lines (24 loc) · 800 Bytes
/
functions.py
File metadata and controls
31 lines (24 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import sys
#Eventually I plan to allow the user to input a file name(perhaps even a path to the JSONMakefile in another directory?
def openIgnoreCase(file_name):
"""
Opens a file, ignoring case for the file name.
Arguments:
file_name: The name of the file to be opened.
"""
files = os.listdir(os.curdir)
#iterate through every file in the directory
for file in files:
if file.lower() == file_name.lower():
return open(file)
#If the loop is exited, then this file is not in the directory.
raise IOError
def isFileInDir(file_name):
"""
Checks to see whether a file is in the current directory
Arguments:
file_name: The name of the file.
"""
files = os.listdir(os.curdir)
return file_name in files