build.py 文件源码

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

项目:OSPTF 作者: xSploited 项目源码 文件源码
def MakePublicAttributeName(className, is_global = False):
    # Given a class attribute that needs to be public, convert it to a
    # reasonable name.
    # Also need to be careful that the munging doesnt
    # create duplicates - eg, just removing a leading "_" is likely to cause
    # a clash.
    # if is_global is True, then the name is a global variable that may
    # overwrite a builtin - eg, "None"
    if className[:2]=='__':
        return demunge_leading_underscores(className)
    elif className == 'None':
        # assign to None is evil (and SyntaxError in 2.4, even though
        # iskeyword says False there) - note that if it was a global
        # it would get picked up below
        className = 'NONE'
    elif iskeyword(className):
        # most keywords are lower case (except True, False etc in py3k)
        ret = className.capitalize()
        # but those which aren't get forced upper.
        if ret == className:
            ret = ret.upper()
        return ret
    elif is_global and hasattr(__builtins__, className):
        # builtins may be mixed case.  If capitalizing it doesn't change it,
        # force to all uppercase (eg, "None", "True" become "NONE", "TRUE"
        ret = className.capitalize()
        if ret==className: # didn't change - force all uppercase.
            ret = ret.upper()
        return ret
    # Strip non printable chars
    return ''.join([char for char in className if char in valid_identifier_chars])

# Given a default value passed by a type library, return a string with
# an appropriate repr() for the type.
# Takes a raw ELEMDESC and returns a repr string, or None
# (NOTE: The string itself may be '"None"', which is valid, and different to None.
# XXX - To do: Dates are probably screwed, but can they come in?
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号