@@ -23,9 +23,14 @@ SKIP_FILENAMES = [
2323]
2424
2525
26−def get_extra_options(source):
27− with open(path.join(source, "bat_options"), "r") as f:
28− return list(map(lambda x: x.rstrip(), f.readlines()))
26+def get_options(source):
27+ source_dirpath = path.dirname(source)
28+ options = BAT_OPTIONS.copy()
29+ if path.exists(path.join(source_dirpath, "bat_options")):
30+ with open(path.join(source, "bat_options"), "r") as f:
31+ options += list(map(lambda x: x.rstrip(), f.readlines()))
32+ return options
33+
2934
3035
3136def create_highlighted_versions(output_basepath):
@@ -42,20 +47,14 @@ def create_highlighted_versions(output_basepath):
4247 env.pop("BAT_TABS", None)
4348 env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
4449
45− source_dirpath = path.dirname(source)
46− source_dirname = path.basename(source_dirpath)
50+ source_dirname = path.basename(path.dirname(source))
4751 source_filename = path.basename(source)
4852
4953 if source_filename in SKIP_FILENAMES:
5054 continue
5155
52− options = BAT_OPTIONS.copy()
53− # If a directory is empty, `files` could possibly be 0-length
54− if path.exists(path.join(source_dirpath, "bat_options")):
55− options += get_extra_options(source_dirpath)
56−
5756 bat_output = subprocess.check_output(
58− ["bat"] + options + [source],
57+ ["bat"] + get_options(source) + [source],
5958 stderr=subprocess.PIPE, env=env,
6059 )
6160