python类engine()的实例源码

base.py 文件源码 项目:julz_legacy 作者: djsegal 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def pluralize(self, word):
    if inflect.engine().singular_noun(word): return word
    return inflect.engine().plural(word)
base.py 文件源码 项目:julz_legacy 作者: djsegal 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def singularize(self, word):
    singularWord = inflect.engine().singular_noun(word)
    if singularWord: return singularWord
    return word
tcex.py 文件源码 项目:tcex 作者: ThreatConnect-Inc 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self):
        """Initialize class data.

        Setup default values and logging method.
        """
        # init inflect engine
        self.inflect = inflect.engine()

        self._exit_code = 0
        # TODO: replace group_type with dynamic values from API (bcs)
        self.group_types = [
            'Adversary',
            'Campaign',
            'Document',
            'Email',
            'Incident',
            'Signature',
            'Threat'
        ]
        self._indicator_associations_types_data = {}
        self._indicator_types = []
        self._indicator_types_data = {}
        self._max_message_length = 255
        # NOTE: odd issue where args is not updating properly
        self._tc_token = None
        self._tc_token_expires = None

        # Parser
        self._parsed = False
        self.parser = ArgParser()
        self.default_args, unknown = self.parser.parse_known_args()

        # NOTE: odd issue where args is not updating properly
        if self.default_args.tc_token is not None:
            self._tc_token = self.default_args.tc_token
        if self.default_args.tc_token_expires is not None:
            self._tc_token_expires = self.default_args.tc_token_expires

        # logger (must parse args first)
        self.log = self._logger(self.default_args.tc_log_file)

        # Log versions
        self._log_platform()
        self._log_app_version()
        self._log_python_version()
        self._log_tcex_version()
        self._log_tc_proxy()

        # include jobs module
        self._jobs()

        # include playbook module
        self._playbook()

        # include resources module
        self._resources()

        # include utils module
        self._utils()
ttbp.py 文件源码 项目:ttbp 作者: modgethanc 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def check_init():
    '''
    user handler

    * checks for presence of ttbprc
    * checks for last run version
    '''

    global SETTINGS

    print("\n\n")
    if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")):
        print(chatter.say("greet")+", "+config.USER+".\n")

        '''
        ## ttbprc validation
        while not os.path.isfile(config.TTBPRC):
            setup_repair()
        try:
            SETTINGS = json.load(open(config.TTBPRC))
        except ValueError:
            setup_repair()
        '''

        ## ttbp env validation
        if not valid_setup():
            setup_repair()

        ## version checker
        mismatch = build_mismatch()
        if mismatch is not False:
            switch_build(mismatch)
        if not updated():
            update_version()

        ## when ready, enter main program and load core engine
        raw_input("press <enter> to explore your feels.\n\n")
        core.load(SETTINGS)

        return ""
    else:
        return init()
ttbp.py 文件源码 项目:ttbp 作者: modgethanc 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def init():
    '''
    new user creation

    * introduces user
    * calls setup functinos
    '''

    try:
        raw_input("""
i don't recognize you, stranger. let's make friends.

press <enter> to begin, or <ctrl-c> to get out of here.
        """)
    except KeyboardInterrupt:
        print("\n\nthanks for checking in! i'll always be here.\n\n")
        quit()

    ## record user in source list
    users = open(config.USERFILE, 'a')
    users.write(config.USER+"\n")
    users.close()

    #subprocess.call(['chmod', 'a+w', config.USERFILE])

    ## make .ttbp directory structure
    subprocess.call(["mkdir", config.PATH])
    subprocess.call(["mkdir", config.USER_CONFIG])
    subprocess.call(["mkdir", config.USER_DATA])

    versionFile = os.path.join(config.PATH, "version")
    open(versionFile, "w").write(__version__)

    ## create header file
    header = gen_header()
    headerfile = open(os.path.join(config.USER_CONFIG, "header.txt"), 'w')
    for line in header:
        headerfile.write(line)
    headerfile.close()

    ## copy footer and default stylesheet
    with open(os.path.join(config.USER_CONFIG, 'footer.txt'), 'w') as f:
        f.write(config.DEFAULT_FOOTER)
    with open(os.path.join(config.USER_CONFIG, 'style.css'), 'w') as f:
        f.write(config.DEFAULT_STYLE)

    ## run user-interactive setup and load core engine
    setup()
    core.load(SETTINGS)

    #raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n")
    return ""
_ttbp.py 文件源码 项目:ttbp 作者: modgethanc 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def check_init():
    '''
    user handler

    * checks for presence of ttbprc
    * checks for last run version
    '''

    global SETTINGS

    print("\n\n")
    if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")):
        print(chatter.say("greet")+", "+USER+".\n")

        '''
        ## ttbprc validation
        while not os.path.isfile(TTBPRC):
            setup_repair()
        try:
            SETTINGS = json.load(open(TTBPRC))
        except ValueError:
            setup_repair()
        '''

        ## ttbp env validation
        if not valid_setup():
            setup_repair()

        ## version checker
        mismatch = build_mismatch()
        if mismatch is not False:
            switch_build(mismatch)
        if not updated():
            update_version()

        ## when ready, enter main program and load core engine
        raw_input("press <enter> to explore your feels.\n\n")
        core.load(SETTINGS)

        return ""
    else:
        return init()
tcex.py 文件源码 项目:threatconnect-developer-docs 作者: ThreatConnect-Inc 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self):
        """Initialize class data.

        Setup default values and logging method.
        """
        # init inflect engine
        self.inflect = inflect.engine()

        self._exit_code = 0
        # TODO: replace group_type with dynamic values from API (bcs)
        self.group_types = [
            'Adversary',
            'Campaign',
            'Document',
            'Email',
            'Incident',
            'Signature',
            'Threat'
        ]
        self._indicator_associations_types_data = {}
        self._indicator_types = []
        self._indicator_types_data = {}
        self._max_message_length = 255
        # NOTE: odd issue where args is not updating properly
        self._tc_token = None
        self._tc_token_expires = None

        # Parser
        self._parsed = False
        self.parser = ArgParser()
        self.default_args, unknown = self.parser.parse_known_args()

        # NOTE: odd issue where args is not updating properly
        if self.default_args.tc_token is not None:
            self._tc_token = self.default_args.tc_token
        if self.default_args.tc_token_expires is not None:
            self._tc_token_expires = self.default_args.tc_token_expires

        # logger (must parse args first)
        self.log = self._logger(self.default_args.tc_log_file)

        # Log versions
        self._log_platform()
        self._log_app_version()
        self._log_python_version()
        self._log_tcex_version()
        self._log_tc_proxy()

        # include jobs module
        self._jobs()

        # include playbook module
        self._playbook()

        # include resources module
        self._resources()

        # include utils module
        self._utils()


问题


面经


文章

微信
公众号

扫码关注公众号