google.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:dsub 作者: googlegenomics 项目源码 文件源码
def convert_to_label_chars(s):
    """Turn the specified name and value into a valid Google label."""

    # We want the results to be user-friendly, not just functional.
    # So we can't base-64 encode it.
    #   * If upper-case: lower-case it
    #   * If the char is not a standard letter or digit. make it a dash
    accepted_characters = string.ascii_lowercase + string.digits + '-'

    def label_char_transform(char):
      if char in accepted_characters:
        return char
      if char in string.ascii_uppercase:
        return char.lower()
      return '-'

    return ''.join(label_char_transform(c) for c in s)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号