當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。