Skip to content

Commit

Permalink
add support for a single file
Browse files Browse the repository at this point in the history
- fix wrong use of find_all_ipynb_files function
  • Loading branch information
ichisadashioko committed Nov 7, 2020
1 parent 63da3b7 commit c855dd2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
33 changes: 20 additions & 13 deletions ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,26 @@ def main():
args = parser.parse_args()
print(args)

file_list = os.listdir(args.infile)

for file_name in file_list:
if file_name == '.git':
args.git = True
break

if args.git:
filepaths = list_git_files(args.infile)
filepaths = filter(lambda filepath: os.path.splitext(filepath)[1].lower() == '.ipynb', filepaths)
filepaths = list(filepaths)
else:
filepaths = find_all_ipynb_files(args.infile)
filepaths = []

if not os.path.exists(args.infile):
raise Exception(args.infile + ' does not exist!')
elif os.path.isfile(args.infile):
filepaths.append(args.infile)
elif os.path.isdir(args.infile):
file_list = os.listdir(args.infile)

for file_name in file_list:
if file_name == '.git':
args.git = True
break

if args.git:
filepaths = list_git_files(args.infile)
filepaths = filter(lambda filepath: os.path.splitext(filepath)[1].lower() == '.ipynb', filepaths)
filepaths = list(filepaths)
else:
find_all_ipynb_files(args.infile, out_list=filepaths)

for filepath in filepaths:
print('>', filepath, end=' ')
Expand Down
29 changes: 18 additions & 11 deletions lf-utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,24 @@ def main():
args = parser.parse_args()
print(args)

file_list = os.listdir(args.infile)

for file_name in file_list:
if file_name == '.git':
args.git = True
break

if args.git:
filepaths = list_git_files(args.infile)
else:
filepaths = find_all_files(args.infile)
filepaths = []

if not os.path.exists(args.infile):
raise Exception(args.infile + ' does not exist!')
elif os.path.isfile(args.infile):
filepaths.append(args.infile)
elif os.path.isdir(args.infile):
file_list = os.listdir(args.infile)

for file_name in file_list:
if file_name == '.git':
args.git = True
break

if args.git:
filepaths = list_git_files(args.infile)
else:
filepaths = find_all_files(args.infile)

MAX_FILESIZE = 1024 * 1024 * 10 # 10 MBs
for filepath in filepaths:
Expand Down

0 comments on commit c855dd2

Please sign in to comment.