Browse Source

Add comment-line remover

Accessed by _load_config_file()
tags/v0.5.1
smittytone 5 years ago
parent
commit
5ca6f87720
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      gitup/config.py

+ 19
- 0
gitup/config.py View File

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


Loading…
Cancel
Save