teelinsan commited on
Commit
d8fdbeb
1 Parent(s): a5044c6

Fix filename bug

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -45,9 +45,16 @@ def clear_cached_images(file_name):
45
  if file.startswith(f"errors-{file_name}") and file.endswith(".png"):
46
  os.remove(file)
47
 
 
 
 
 
 
 
 
48
  def upload_file(file, paper_type):
49
  file_name_cmd = file.name.replace(" ", "\ ")
50
- file_name = os.path.basename(file.name).split(".")[0]
51
  clear_cached_images(file_name)
52
  command = f"python3 aclpubcheck-main/aclpubcheck/formatchecker.py --paper_type {paper_type} {file_name_cmd}"
53
  out = subprocess.run(command, shell=True, stdout=subprocess.PIPE, text=True, stderr=subprocess.STDOUT)
 
45
  if file.startswith(f"errors-{file_name}") and file.endswith(".png"):
46
  os.remove(file)
47
 
48
+ def get_filename(file):
49
+ file_name = os.path.basename(file).split(".")[0]
50
+ if "_" in file_name:
51
+ # apparently aclpubcheck doesn't like underscores in filenames
52
+ file_name = file_name.split("_")[0]
53
+ return file_name
54
+
55
  def upload_file(file, paper_type):
56
  file_name_cmd = file.name.replace(" ", "\ ")
57
+ file_name = get_filename(file.name)
58
  clear_cached_images(file_name)
59
  command = f"python3 aclpubcheck-main/aclpubcheck/formatchecker.py --paper_type {paper_type} {file_name_cmd}"
60
  out = subprocess.run(command, shell=True, stdout=subprocess.PIPE, text=True, stderr=subprocess.STDOUT)