original_docstring: Create a new LeetCode solution from template.
docstring: Create a new LeetCode solution from template.
docstring_tokens: Create a new LeetCode solution from template .
code: def create_file(args):
      """Create a new LeetCode solution from template."""
      filename = args.filename + ".md"
      target_path = "{}/Problems/{}/{}".format(
          BASE_DIR, args.category,
          filename) if args.category != "Summary" else "{}/Summary/{}".format(
              BASE_DIR, filename)
      # open the template and read lines
      lines = open(TEMPLATE_PATH, 'r').readlines()
      # update title && category && datetime in solution file
      title = " ".join([s.capitalize() for s in filename[:-3].split("-")])
      now = datetime.now()
      dt_string = now.strftime("%Y-%m-%d %H:%M:%S")
      # create a new file and write lines
      os.makedirs(os.path.dirname(target_path), exist_ok=True)
      if TEMPLATE_PATH != DEFAULT_TEMPLATE_PATH:
          with open(target_path, 'w') as fp:
              for line in lines:
                  fp.write(line)
      else:
          with open(target_path, 'w') as fp:
              fp.write(lines[0])
              for line in lines[1:]:
                  if "title:" in line:
                      fp.write("title: Easy Medium Hard | {}\n".format(title))
                  elif "Graph" in line:
                      fp.write("  - {}\n".format(args.category))
                  elif "date:" in line:
                      fp.write("date: {}\n".format(dt_string))
                  elif "TITLE" in line:
                      fp.write("# {}\n".format(title))
                  else:
                      fp.write(line)
      subprocess.call(["open", target_path])
code_tokens: def create_file ( args ) : filename = args . filename + ".md" target_path = "{}/Problems/{}/{}" . format ( BASE_DIR , args . category , filename ) if args . category != "Summary" else "{}/Summary/{}" . format ( BASE_DIR , filename ) lines = open ( TEMPLATE_PATH , 'r' ) . readlines ( ) title = " " . join ( [ s . capitalize ( ) for s in filename [ : - 3 ] . split ( "-" ) ] ) now = datetime . now ( ) dt_string = now . strftime ( "%Y-%m-%d %H:%M:%S" ) os . makedirs ( os . path . dirname ( target_path ) , exist_ok = True ) if TEMPLATE_PATH != DEFAULT_TEMPLATE_PATH : with open ( target_path , 'w' ) as fp : for line in lines : fp . write ( line ) else : with open ( target_path , 'w' ) as fp : fp . write ( lines [ 0 ] ) for line in lines [ 1 : ] : if "title:" in line : fp . write ( "title: Easy Medium Hard | {}\n" . format ( title ) ) elif "Graph" in line : fp . write ( "  - {}\n" . format ( args . category ) ) elif "date:" in line : fp . write ( "date: {}\n" . format ( dt_string ) ) elif "TITLE" in line : fp . write ( "# {}\n" . format ( title ) ) else : fp . write ( line ) subprocess . call ( [ "open" , target_path ] )
short_docstring: Create a new LeetCode solution from template.
short_docstring_tokens: Create a new LeetCode solution from template .
comment: """Create a new LeetCode solution from template."""$SEP$# open the template and read lines$SEP$# update title && category && datetime in solution file$SEP$# create a new file and write lines