scripts: Change use of typing.Text to str.

This commit is contained in:
Aditya Bansal
2018-05-10 22:24:59 +05:30
committed by Tim Abbott
parent 64ddfc6ac0
commit e14974ff2c
3 changed files with 17 additions and 17 deletions

View File

@@ -4,7 +4,7 @@
import sys
import os
if False:
from typing import Dict, List, Optional, Text
from typing import Dict, List, Optional
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(BASE_DIR)
@@ -36,7 +36,7 @@ AUTOGENERATED_SETTINGS = [
# TODO: We can eliminate this function if we refactor the install
# script to run generate_secrets before zulip-puppet-apply.
def generate_camo_config_file(camo_key):
# type: (Text) -> None
# type: (str) -> None
camo_config = """ENABLED=yes
PORT=9292
CAMO_KEY=%s
@@ -46,13 +46,13 @@ CAMO_KEY=%s
print("Generated Camo config file %s" % (CAMO_CONFIG_FILENAME,))
def generate_django_secretkey():
# type: () -> Text
# type: () -> str
"""Secret key generation taken from Django's startproject.py"""
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
return get_random_string(50, chars)
def get_old_conf(output_filename):
# type: (str) -> Dict[str, Text]
# type: (str) -> Dict[str, str]
if not os.path.exists(output_filename) or os.path.getsize(output_filename) == 0:
return {}
@@ -69,7 +69,7 @@ def generate_secrets(development=False):
OUTPUT_SETTINGS_FILENAME = "/etc/zulip/zulip-secrets.conf"
current_conf = get_old_conf(OUTPUT_SETTINGS_FILENAME)
lines = [] # type: List[Text]
lines = [] # type: List[str]
if len(current_conf) == 0:
lines = ['[secrets]\n']
@@ -78,7 +78,7 @@ def generate_secrets(development=False):
return name not in current_conf
def add_secret(name, value):
# type: (str, Text) -> None
# type: (str, str) -> None
lines.append("%s = %s\n" % (name, value))
current_conf[name] = value