當前位置: 首頁>>代碼示例>>Python>>正文


Python typing.Dict方法代碼示例

本文整理匯總了Python中typing.Dict方法的典型用法代碼示例。如果您正苦於以下問題:Python typing.Dict方法的具體用法?Python typing.Dict怎麽用?Python typing.Dict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在typing的用法示例。


在下文中一共展示了typing.Dict方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_listeners

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def get_listeners(
        self, event_name=None
    ):  # type: (str) -> Union[List[Callable], Dict[str, Callable]]
        if event_name is not None:
            if event_name not in self._listeners:
                return []

            if event_name not in self._sorted:
                self._sort_listeners(event_name)

            return self._sorted[event_name]

        for event_name, event_listeners in self._listeners.items():
            if event_name not in self._sorted:
                self._sort_listeners(event_name)

        return self._sorted 
開發者ID:sdispater,項目名稱:clikit,代碼行數:19,代碼來源:event_dispatcher.py

示例2: write_cov_file

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def write_cov_file(line_data: Dict[str, List[int]], fname: str) -> None:
    """Write a coverage file supporting both Coverage v4 and v5.

    Args:
        line_data: Dictionary of line data for the coverage file.
        fname: string filename for output location (absolute path)

    Returns:
        None
    """
    if coverage.version_info[0] == 4:
        covdata = coverage.CoverageData()
        covdata.add_lines(line_data)
        covdata.write_file(fname)

    else:
        # assume coverage v 5
        covdata = coverage.CoverageData(basename=fname)
        covdata.add_lines(line_data)
        covdata.write()


####################################################################################################
# CLI: MOCK ARGS
#################################################################################################### 
開發者ID:EvanKepner,項目名稱:mutatest,代碼行數:27,代碼來源:conftest.py

示例3: apply_filter

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def apply_filter(object_id: str, search_props: Dict[str, Any],
                 triples: Graph, session: scoped_session) -> bool:
    """Check whether objects has properties with query values or not.
    :param object_id: Id of the instance.
    :param search_props: Dictionary of query parameters with property id and values.
    :param triples: All triples.
    :param session: sqlalchemy scoped session.
    :return: True if the instance has properties with given values, False otherwise.
    """
    for prop in search_props:
        # For nested properties
        if isinstance(search_props[prop], dict):
            data = session.query(triples).filter(
                triples.GraphIII.subject == object_id, triples.GraphIII.predicate == prop).one()
            if apply_filter(data.object_, search_props[prop], triples, session) is False:
                return False
        else:
            data = session.query(triples).filter(
                triples.GraphIIT.subject == object_id, triples.GraphIIT.predicate == prop).one()
            terminal = session.query(Terminal).filter(
                Terminal.id == data.object_).one()
            if terminal.value != search_props[prop]:
                return False
    return True 
開發者ID:HTTP-APIs,項目名稱:hydrus,代碼行數:26,代碼來源:crud_helpers.py

示例4: insert_single

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def insert_single(object_: Dict[str, Any], session: scoped_session) -> Any:
    """Insert instance of classes with single objects.
    :param object_: object to be inserted
    :param session: sqlalchemy scoped session
    :return:

    Raises:
        ClassNotFound: If `type_` does not represt a valid/defined RDFClass.
        Instance: If an Instance of type `type_` already exists.

    """
    try:
        rdf_class = session.query(RDFClass).filter(
            RDFClass.name == object_["@type"]).one()
    except NoResultFound:
        raise ClassNotFound(type_=object_["@type"])

    try:
        session.query(Instance).filter(
            Instance.type_ == rdf_class.id).all()[-1]
    except (NoResultFound, IndexError, ValueError):
        return insert(object_, session=session)

    raise InstanceExists(type_=rdf_class.name) 
開發者ID:HTTP-APIs,項目名稱:hydrus,代碼行數:26,代碼來源:crud.py

示例5: add_iri_template

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def add_iri_template(path: str, API_NAME: str) -> Dict[str, Any]:
    """
    Creates an IriTemplate.
    :param path: Path of the collection or the non-collection class.
    :param API_NAME: Name of API.
    :return: Hydra IriTemplate .
    """
    template_mappings = list()
    template = "/{}/{}(".format(API_NAME, path)
    first = True
    template, template_mappings = generate_iri_mappings(path, template,
                                                        template_mapping=template_mappings,)

    template, template_mappings = add_pagination_iri_mappings(template=template,
                                                              template_mapping=template_mappings)
    return HydraIriTemplate(template=template, iri_mapping=template_mappings).generate() 
開發者ID:HTTP-APIs,項目名稱:hydrus,代碼行數:18,代碼來源:helpers.py

示例6: get_link_props_for_multiple_objects

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def get_link_props_for_multiple_objects(path: str,
                                        object_list: List[Dict[str, Any]]
                                        ) -> Tuple[List[Dict[str, Any]], bool]:
    """
    Get link_props of multiple objects.
    :param path: Path of the collection or non-collection class.
    :param object_list: List of objects being inserted.
    :return: List of link properties processed with the help of get_link_props.
    """
    link_prop_list = list()
    for object_ in object_list:
        link_props, type_check = get_link_props(path, object_)
        if type_check is True:
            link_prop_list.append(link_props)
        else:
            return [], False
    return link_prop_list, True 
開發者ID:HTTP-APIs,項目名稱:hydrus,代碼行數:19,代碼來源:helpers.py

示例7: subscribe

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def subscribe(
        self, document: DocumentNode, *args, **kwargs
    ) -> Generator[Dict, None, None]:
        """Execute a GraphQL subscription with a python generator.

        We need an async transport for this functionality.
        """

        async_generator = self.subscribe_async(document, *args, **kwargs)

        loop = asyncio.get_event_loop()

        assert not loop.is_running(), (
            "Cannot run client.subscribe if an asyncio loop is running."
            " Use subscribe_async instead."
        )

        try:
            while True:
                result = loop.run_until_complete(async_generator.__anext__())
                yield result

        except StopAsyncIteration:
            pass 
開發者ID:graphql-python,項目名稱:gql,代碼行數:26,代碼來源:client.py

示例8: get_info_batch

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def get_info_batch(self, item_list: List[Dict[str, str]]) -> dict:
        """批量查詢電子發票

        參考:https://work.weixin.qq.com/api/doc/90000/90135/90287

        報銷方在獲得用戶選擇的電子發票標識參數後,可以通過該接口批量查詢電子發票的結構化信息。

        **權限說明**:
        僅認證的企業微信賬號並且企業激活人數超過200的企業才有接口權限,如果認證的企業
        激活人數不超過200人請聯係企業微信客服谘詢。

        返回結果參數說明請查看官方文檔。

        :param item_list: 發票列表,示例:
            [{'card_id': 'id', 'encrypt_code': 'code'}...]
        :return: 電子發票信息
        """
        if not item_list:
            raise ValueError("the item_list cannot be empty")

        url = "card/invoice/reimburse/getinvoiceinfobatch"
        data = {"item_list": item_list}
        return self._post(url, data=data) 
開發者ID:wechatpy,項目名稱:wechatpy,代碼行數:25,代碼來源:invoice.py

示例9: is_taking

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def is_taking(cotc: Dict) -> bool:
    """檢查當前用戶是否選了這門課"""
    user_is_taking = False

    if session.get(SESSION_CURRENT_USER, None):
        # 檢查當前用戶是否選了這門課
        student = entity_service.get_student(session[SESSION_CURRENT_USER].identifier)
        for semester in sorted(student.semesters, reverse=True):  # 新學期可能性大,學期從新到舊查找
            timetable = entity_service.get_student_timetable(session[SESSION_CURRENT_USER].identifier, semester)
            for card in timetable.cards:
                if card.course_id == cotc["course_id"] and cotc["teacher_id_str"] == teacher_list_to_tid_str(
                        card.teachers):
                    user_is_taking = True
                    break
            if user_is_taking:
                break
    return user_is_taking 
開發者ID:everyclass,項目名稱:everyclass-server,代碼行數:19,代碼來源:views.py

示例10: get_status_summary

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def get_status_summary(trial_results: List[MutantTrialResult]) -> Dict[str, Union[str, int]]:
    """Create a status summary dictionary for later formatting.

    Args:
        trial_results: list of mutant trials

    Returns:
        Dictionary with keys for formatting in the report
    """
    status: Dict[str, Union[str, int]] = dict(Counter([t.status for t in trial_results]))
    status["TOTAL RUNS"] = len(trial_results)
    status["RUN DATETIME"] = str(datetime.now())

    return status 
開發者ID:EvanKepner,項目名稱:mutatest,代碼行數:16,代碼來源:report.py

示例11: valid_categories

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def valid_categories(self) -> Dict[str, str]:
        """All valid categories with descriptive name and 2 letter code.

        Returns:
            The categories defined in transformers.
        """
        return self._valid_categories 
開發者ID:EvanKepner,項目名稱:mutatest,代碼行數:9,代碼來源:filters.py

示例12: styles

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def styles(self):  # type: () -> (Dict[str, Style])
        return self._styles 
開發者ID:sdispater,項目名稱:clikit,代碼行數:4,代碼來源:style_set.py

示例13: get_arguments

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def get_arguments(self, include_base=True):  # type: (bool) -> Dict[str, Argument]
        arguments = self._arguments.copy()

        if include_base and self._base_format:
            arguments.update(self._base_format.get_arguments())

        return arguments 
開發者ID:sdispater,項目名稱:clikit,代碼行數:9,代碼來源:args_format_builder.py

示例14: get_options

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def get_options(self, include_base=True):  # type: (bool) -> Dict[str, Option]
        options = self._options.copy()

        if include_base and self._base_format:
            options.update(self._base_format.get_options())

        return options 
開發者ID:sdispater,項目名稱:clikit,代碼行數:9,代碼來源:args_format_builder.py

示例15: get_arguments

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import Dict [as 別名]
def get_arguments(self, include_base=True):  # type: (bool) -> Dict[str, Argument]
        arguments = self._arguments.copy()

        if include_base and self._base_format:
            base_arguments = self._base_format.get_arguments()
            base_arguments.update(arguments)
            arguments = base_arguments

        return arguments 
開發者ID:sdispater,項目名稱:clikit,代碼行數:11,代碼來源:args_format.py


注:本文中的typing.Dict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。