Explorar el Código

Add comment-line remover

Accessed by _load_config_file()
tags/v0.5.1
smittytone hace 5 años
padre
commit
5ca6f87720
Se han modificado 1 ficheros con 19 adiciones y 0 borrados
  1. +19
    -0
      gitup/config.py

+ 19
- 0
gitup/config.py Ver fichero

@@ -37,8 +37,27 @@ def _load_config_file(config_path=None):
except IOError:
return []
paths = [path.decode("utf8").strip() for path in paths]
paths = _strip_comment_lines(paths)
return [path for path in paths if path]

def _strip_comment_lines(paths):
"""Remove any lines starting with #."""
i = 0
while i < len(paths):
path = paths[i]
removed_comment = False
for j in range(0, len(path)):
path_char = path[j]
if path_char == " ":
continue
if path_char == "#":
removed_comment = True
paths.pop(i)
break
if removed_comment is False:
i = i + 1
return paths

def _save_config_file(bookmarks, config_path=None):
"""Save the bookmarks list to the given config file."""
run_migrations()


Cargando…
Cancelar
Guardar