diff --git a/src/utils.py b/src/utils.py index aa35d70..d97111d 100644 --- a/src/utils.py +++ b/src/utils.py @@ -16,11 +16,11 @@ def titleescape(s): Makes an article title filename-safe. """ s = s.strip() - s = re.sub(r"\s+", '_', s) # Replace whitespace with _ - s = parse.quote(s) # Encode all other characters - s = re.sub(r"%", "", s) # Strip encoding %s - if len(s) > 64: # If the result is unreasonably long, - s = hex(abs(hash(s)))[2:] # Replace it with a hex hash + s = re.sub(r"\s+", '_', s) # Replace whitespace with _ + s = parse.quote(s) # Encode all other characters + s = re.sub(r"%", "", s) # Strip encoding %s + if len(s) > 64: # If the result is unreasonably long, + s = hex(abs(hash(s)))[2:] # Replace it with a hex hash return s def titlestrip(s): @@ -72,4 +72,4 @@ def load_config(name): if config_value not in config: # TODO Not this either raise SystemExit("Error: {} not set in lexipython.cfg".format(config_value)) - return config \ No newline at end of file + return config