muellerzr HF staff commited on
Commit
f95086b
1 Parent(s): 6edddeb

Fix filename issue

Browse files
Files changed (2) hide show
  1. src/markup.py +3 -1
  2. src/template.py +2 -2
src/markup.py CHANGED
@@ -12,6 +12,8 @@
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
 
 
 
15
  _remove_color = "rgb(103,6,12)"
16
  _addition_color = "rgb(6,103,12)"
17
 
@@ -41,7 +43,7 @@ def highlight(option:str):
41
  A menu option chosen from the interface.
42
  """
43
  filename = option.lower().replace(' ', '_')
44
- with open(f"../code_samples/{filename}") as f:
45
  output = f.read()
46
  lines = output.split("\n")
47
  for i,line in enumerate(lines):
 
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
 
15
+ from template import get_filename
16
+
17
  _remove_color = "rgb(103,6,12)"
18
  _addition_color = "rgb(6,103,12)"
19
 
 
43
  A menu option chosen from the interface.
44
  """
45
  filename = option.lower().replace(' ', '_')
46
+ with open(get_filename(filename)) as f:
47
  output = f.read()
48
  lines = output.split("\n")
49
  for i,line in enumerate(lines):
src/template.py CHANGED
@@ -15,7 +15,7 @@ import os
15
 
16
  TEMPLATES = ["initial", "initial_with_metrics", "accelerate"]
17
 
18
- def _get_filename(template: str) -> str:
19
  """
20
  Takes an template and returns the respective filename relative to the cwd.
21
  """
@@ -26,6 +26,6 @@ def get_templates() -> dict:
26
  Returns a dictionary of template type to code content
27
  """
28
  return {
29
- template: open(_get_filename(template)).read()
30
  for template in TEMPLATES
31
  }
 
15
 
16
  TEMPLATES = ["initial", "initial_with_metrics", "accelerate"]
17
 
18
+ def get_filename(template: str) -> str:
19
  """
20
  Takes an template and returns the respective filename relative to the cwd.
21
  """
 
26
  Returns a dictionary of template type to code content
27
  """
28
  return {
29
+ template: open(get_filename(template)).read()
30
  for template in TEMPLATES
31
  }