当前位置: 首页>>代码示例>>Python>>正文


Python inflect.engine方法代码示例

本文整理汇总了Python中inflect.engine方法的典型用法代码示例。如果您正苦于以下问题:Python inflect.engine方法的具体用法?Python inflect.engine怎么用?Python inflect.engine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inflect的用法示例。


在下文中一共展示了inflect.engine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_resource_url

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def get_resource_url(cls, resource, base_url):
        """
        Construct the URL for talking to this resource.

        i.e.:

        http://myapi.com/api/resource

        Note that this is NOT the method for calling individual instances i.e.

        http://myapi.com/api/resource/1

        Args:
            resource: The resource class instance
            base_url: The Base URL of this API service.
        returns:
            resource_url: The URL for this resource
        """
        if resource.Meta.resource_name:
            url = '{}/{}'.format(base_url, resource.Meta.resource_name)
        else:
            p = inflect.engine()
            plural_name = p.plural(resource.Meta.name.lower())
            url = '{}/{}'.format(base_url, plural_name)
        return cls._parse_url_and_validate(url) 
开发者ID:phalt,项目名称:beckett,代码行数:27,代码来源:resources.py

示例2: get_related_wikihow_actions_basic_search

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def get_related_wikihow_actions_basic_search(seed_word):
    page = basic_search_wikihow(seed_word)
    # Try again but with plural if nothing is found
    if not page:
        page = basic_search_wikihow(inflect.engine().plural(seed_word))

    soup = BeautifulSoup(page.content, "html.parser")
    actions_elements = soup.find_all("a", class_="result_link")
    action_titles = list(
        chain.from_iterable(
            [a.find_all("div", "result_title") for a in actions_elements]
        )
    )
    actions = [
        clean_wikihow_action(remove_how_to(x.get_text()))
        for x in action_titles
        if x is not None and not x.get_text().startswith("Category")
    ]
    return actions 
开发者ID:korymath,项目名称:talk-generator,代码行数:21,代码来源:wikihow.py

示例3: blacklisted_titles

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def blacklisted_titles(self):

        """
        Pluralize the blacklisted titles.

        Returns: list
        """

        p = inflect.engine()

        singulars = self.config.get('blacklisted_titles', [])

        return map(
            tokenize_field,
            singulars + [p.plural(s) for s in singulars],
        ) 
开发者ID:davidmcclure,项目名称:open-syllabus-project,代码行数:18,代码来源:validate_config.py

示例4: syntactic_analysis

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def syntactic_analysis(self, src):
        i = inflect.engine()
        relations = {}
        foreign_keys = {}
        for table in src:
            for k, v in table.items():
                if k == 'table_name':
                    foreign_keys[(i.singular_noun(v) if i.singular_noun(v) else v) + '_id'] = v
        for table in src:
            for k, v in table.items():
                if k == 'table_name':
                    table_name = v
            for e in table:
                if 'column_name' in e:
                    if e['column_name'] in foreign_keys.keys():
                        relations[table_name + ':' + e['column_name']] = foreign_keys[e['column_name']] + ':id'
        result = {}
        result['src'] = src
        result['relations'] = relations
        return result 
开发者ID:hideshi,项目名称:pyagram,代码行数:22,代码来源:entity_relationship_diagram.py

示例5: dump

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def dump(self):
		"""
		Dump Domino account hashes.
		"""
		# Check if the user can access names.nsf
		if self.check_access(self.username, self.password)['names.nsf']:

			if self.auth_type == 'basic':
				self.session.auth = (self.username, self.password)

			# Enumerate account URLs
			account_urls = self.get_accounts()
			if account_urls:
				self.logger.info("Found {0} account {1}".format(len(account_urls), inflect.engine().plural('hash', len(account_urls))))
				self.get_hashes(account_urls)
			else:
				self.logger.warn('No account hashes found')
		else:
			self.logger.error("Unable to access {0}/names.nsf, bad username or password".format(self.url)) 
开发者ID:coldfusion39,项目名称:domi-owned,代码行数:21,代码来源:hashdump.py

示例6: bruteforce

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def bruteforce(self, userlist):
		"""
		Perform a reverse brute force attack with multiple usernames and one password.
		"""
		if self.auth_type == 'open':
			self.logger.info("{0}/names.nsf does not require authentication".format(self.url))
		else:
			usernames = self.build_userlist(userlist)
			valid_accounts = self.brute_accounts(usernames)

			print('\n')
			if valid_accounts:
				self.logger.info("Found {0} valid {1}".format(len(valid_accounts), inflect.engine().plural('account', len(valid_accounts))))
				print(tabulate.tabulate(valid_accounts, headers=['Username', 'Password', 'Account Type'], tablefmt='simple'))
			else:
				self.logger.warn('No valid accounts found') 
开发者ID:coldfusion39,项目名称:domi-owned,代码行数:18,代码来源:bruteforce.py

示例7: main

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def main():
    '''
    main engine head

    * called on program start
    * calls config check
    * proceeds to main menu
    * handles ^c and ^d ejects
    '''

    redraw()
    print("""
if you don't want to be here at any point, press <ctrl-d> and it'll all go away.
just keep in mind that you might lose anything you've started here.\
""")

    try:
        print(check_init())
    except EOFError:
        print(stop())
        return

    redraw()

    while 1:
        try:
            print(main_menu())
        except EOFError:
            print(stop())
            break
        except KeyboardInterrupt:
            redraw(EJECT)
        else:
            break 
开发者ID:modgethanc,项目名称:ttbp,代码行数:36,代码来源:ttbp.py

示例8: og_description

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def og_description(self) -> str:
        p = inflect.engine()
        fmt = titlecase.titlecase(p.a(self.format_name))
        description = '{fmt} match.'.format(fmt=fmt)
        return description 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:7,代码来源:match_view.py

示例9: day2ordinal

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def day2ordinal(m: Match) -> str:
    p = inflect.engine()
    return p.ordinal(int(m.group(1))) 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:5,代码来源:dtutil.py

示例10: prizes_by_finish

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def prizes_by_finish(multiplier: int = 1) -> List[Dict[str, Any]]:
    prizes, finish, p = [], 1, inflect.engine()
    while True:
        pz = prize_by_finish(finish)
        if not pz:
            break
        prizes.append({'finish': p.ordinal(finish), 'prize': pz * multiplier})
        finish += 1
    return prizes 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:11,代码来源:tournaments.py

示例11: og_description

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def og_description(self) -> str:
        if self.public() and self.archetype_name:
            p = inflect.engine()
            archetype_s = titlecase.titlecase(p.a(self.archetype_name))
        else:
            archetype_s = 'A'
        description = '{archetype_s} deck by {author}'.format(archetype_s=archetype_s, author=self.person)
        return description 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:10,代码来源:deck.py

示例12: num_tournaments

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def num_tournaments(self) -> str:
        return inflect.engine().number_to_words(len(tournaments.all_series_info())) 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:4,代码来源:view.py

示例13: inflect

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def inflect(self):
        """Return instance of inflect."""
        if self._inflect is None:
            import inflect

            self._inflect = inflect.engine()
        return self._inflect 
开发者ID:ThreatConnect-Inc,项目名称:tcex,代码行数:9,代码来源:utils.py

示例14: contributions_ordinal

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def contributions_ordinal(self):
        p = inflect.engine()
        return p.ordinal(self.num_contributions) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:5,代码来源:user.py

示例15: create_inflect_engine

# 需要导入模块: import inflect [as 别名]
# 或者: from inflect import engine [as 别名]
def create_inflect_engine(self):
        if self.noinflect:
            return _DummyInflectEngine()
        else:
            import inflect

            return inflect.engine() 
开发者ID:thomaxxl,项目名称:safrs,代码行数:9,代码来源:codegen.py


注:本文中的inflect.engine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。