Ver código fonte

Add comment-line remover

Accessed by _load_config_file()
tags/v0.5.1
smittytone 5 anos atrás
pai
commit
5ca6f87720
1 arquivos alterados com 19 adições e 0 exclusões
  1. +19
    -0
      gitup/config.py

+ 19
- 0
gitup/config.py Ver arquivo

@@ -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()


Carregando…
Cancelar
Salvar