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


Python typing.MutableSequence方法代码示例

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


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

示例1: start

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def start(self, text):
        """Start browsing to the history.

        Called when the user presses the up/down key and wasn't browsing the
        history already.

        Args:
            text: The preset text.
        """
        log.misc.debug("Preset text: '{}'".format(text))
        if text:
            items = [
                e for e in self.history
                if e.startswith(text)]  # type: typing.MutableSequence[str]
        else:
            items = self.history
        if not items:
            raise HistoryEmptyError
        self._tmphist = usertypes.NeighborList(items)
        return self._tmphist.lastitem() 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:22,代码来源:cmdhistory.py

示例2: address_from_digest

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def address_from_digest(digest):
    # type: (Digest) -> Address
    """
    Generates an address from a private key digest.
    """
    address_trits = [0] * (Address.LEN * TRITS_PER_TRYTE) # type: MutableSequence[int]

    sponge = Kerl()
    sponge.absorb(digest.as_trits())
    sponge.squeeze(address_trits)

    return Address.from_trits(
      trits = address_trits,

      key_index       = digest.key_index,
      security_level  = digest.security_level,
    ) 
开发者ID:llSourcell,项目名称:IOTA_demo,代码行数:19,代码来源:addresses.py

示例3: utilization_table_by_grouping_from_mesos_state

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def utilization_table_by_grouping_from_mesos_state(
    groupings: Sequence[str],
    threshold: float,
    mesos_state: MesosState,
    service_instance_stats: Optional[ServiceInstanceStats] = None,
) -> Tuple[Sequence[MutableSequence[str]], bool]:
    grouping_function = metastatus_lib.key_func_for_attribute_multi(groupings)
    resource_info_dict_grouped = metastatus_lib.get_resource_utilization_by_grouping(
        grouping_function, mesos_state
    )

    return utilization_table_by_grouping(
        groupings,
        grouping_function,
        resource_info_dict_grouped,
        threshold,
        service_instance_stats,
    ) 
开发者ID:Yelp,项目名称:paasta,代码行数:20,代码来源:paasta_metastatus.py

示例4: utilization_table_by_grouping_from_kube

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def utilization_table_by_grouping_from_kube(
    groupings: Sequence[str],
    threshold: float,
    kube_client: KubeClient,
    service_instance_stats: Optional[ServiceInstanceStats] = None,
) -> Tuple[Sequence[MutableSequence[str]], bool]:
    grouping_function = metastatus_lib.key_func_for_attribute_multi_kube(groupings)
    resource_info_dict_grouped = metastatus_lib.get_resource_utilization_by_grouping_kube(
        grouping_function, kube_client
    )

    return utilization_table_by_grouping(
        groupings,
        grouping_function,
        resource_info_dict_grouped,
        threshold,
        service_instance_stats,
    ) 
开发者ID:Yelp,项目名称:paasta,代码行数:20,代码来源:paasta_metastatus.py

示例5: fill_table_rows_with_service_instance_stats

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def fill_table_rows_with_service_instance_stats(
    service_instance_stats: ServiceInstanceStats,
    resource_utilizations: Sequence[ResourceUtilization],
    table_rows: MutableSequence[MutableSequence[str]],
) -> None:
    # Calculate the max number of runnable service instances given the current resources (e.g. cpus, mem, disk)
    resource_free_dict = {rsrc.metric: rsrc.free for rsrc in resource_utilizations}
    num_service_instances_allowed = float("inf")
    limiting_factor = "Unknown"
    # service_instance_stats.keys() should be a subset of resource_free_dict
    for rsrc_name, rsrc_amt_wanted in service_instance_stats.items():
        if rsrc_amt_wanted > 0:  # type: ignore
            # default=0 to indicate there is none of that resource
            rsrc_free = resource_free_dict.get(rsrc_name, 0)
            if (
                rsrc_free // rsrc_amt_wanted  # type: ignore
                < num_service_instances_allowed  # type: ignore
            ):
                limiting_factor = rsrc_name
                num_service_instances_allowed = (
                    rsrc_free // rsrc_amt_wanted  # type: ignore
                )
    table_rows[-1].append(
        "{:6} ; {}".format(int(num_service_instances_allowed), limiting_factor)
    ) 
开发者ID:Yelp,项目名称:paasta,代码行数:27,代码来源:paasta_metastatus.py

示例6: __init__

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def __init__(
        self,
        write: typing.Callable[[str], None],
        do_log: bool,
        do_capture: bool,
        max_capture: int,
    ):
        self.write = write
        self.do_log = do_log
        self.do_capture = do_capture
        self.finished = Lock()
        if max_capture < 0:
            capture = []  # type: typing.MutableSequence[str]
        else:
            capture = deque(maxlen=max_capture)
        self.capture = capture  # type: typing.MutableSequence[str]
        self.finished.acquire() 
开发者ID:telepresenceio,项目名称:telepresence,代码行数:19,代码来源:launch.py

示例7: run

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def run(
            self,
            binary_mask_collection: BinaryMaskCollection,
            *args, **kwargs) -> BinaryMaskCollection:
        matching_mask_data: MutableSequence[MaskData] = list()
        for ix in range(len(binary_mask_collection)):
            props = binary_mask_collection.mask_regionprops(ix)
            if self._min_area is not None and props.area < self._min_area:
                continue
            if self._max_area is not None and props.area > self._max_area:
                continue

            matching_mask_data.append(binary_mask_collection._masks[ix])

        return BinaryMaskCollection(
            binary_mask_collection._pixel_ticks,
            binary_mask_collection._physical_ticks,
            matching_mask_data,
            binary_mask_collection._log,
        ) 
开发者ID:spacetx,项目名称:starfish,代码行数:22,代码来源:areafilter.py

示例8: filter_tilekeys

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def filter_tilekeys(self, tilekeys: Collection[TileKey]) -> Collection[TileKey]:
        """
        Filters tilekeys for those that should be included in the resulting ImageStack.
        """
        results: MutableSequence[TileKey] = list()
        for tilekey in tilekeys:
            if self._permitted_rounds is not None and tilekey.round not in self._permitted_rounds:
                continue
            if self._permitted_chs is not None and tilekey.ch not in self._permitted_chs:
                continue
            if self._permitted_zplanes is not None and tilekey.z not in self._permitted_zplanes:
                continue

            results.append(tilekey)

        return results 
开发者ID:spacetx,项目名称:starfish,代码行数:18,代码来源:crop.py

示例9: _setup_filtering

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def _setup_filtering(argv):
  # type: (MutableSequence[Text]) -> None
  """Implements the bazel test filtering protocol.

  The following environment variable is used in this method:

    TESTBRIDGE_TEST_ONLY: string, if set, is forwarded to the unittest
      framework to use as a test filter. Its value is split with shlex
      before being passed as positional arguments on argv.

  Args:
    argv: the argv to mutate in-place.
  """
  test_filter = os.environ.get('TESTBRIDGE_TEST_ONLY')
  if argv is None or not test_filter:
    return

  argv[1:1] = shlex.split(test_filter) 
开发者ID:abseil,项目名称:abseil-py,代码行数:20,代码来源:absltest.py

示例10: run_tests

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def run_tests(argv, args, kwargs):  # pylint: disable=line-too-long
  # type: (MutableSequence[Text], Sequence[Any], MutableMapping[Text, Any]) -> None
  # pylint: enable=line-too-long
  """Executes a set of Python unit tests.

  Most users should call absltest.main() instead of run_tests.

  Please note that run_tests should be called from app.run.
  Calling absltest.main() would ensure that.

  Please note that run_tests is allowed to make changes to kwargs.

  Args:
    argv: sys.argv with the command-line flags removed from the front, i.e. the
      argv with which app.run() has called __main__.main.
    args: Positional arguments passed through to unittest.TestProgram.__init__.
    kwargs: Keyword arguments passed through to unittest.TestProgram.__init__.
  """
  result = _run_and_get_tests_result(
      argv, args, kwargs, xml_reporter.TextAndXMLTestRunner)
  sys.exit(not result.wasSuccessful()) 
开发者ID:abseil,项目名称:abseil-py,代码行数:23,代码来源:absltest.py

示例11: test_collections_as_base

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def test_collections_as_base(self):

        class M(collections.Mapping): ...
        self.assertIsSubclass(M, typing.Mapping)
        self.assertIsSubclass(M, typing.Iterable)

        class S(collections.MutableSequence): ...
        self.assertIsSubclass(S, typing.MutableSequence)
        self.assertIsSubclass(S, typing.Iterable)

        class I(collections.Iterable): ...
        self.assertIsSubclass(I, typing.Iterable)

        class A(collections.Mapping, metaclass=abc.ABCMeta): ...
        class B: ...
        A.register(B)
        self.assertIsSubclass(B, typing.Mapping) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:19,代码来源:test_typing.py

示例12: __init__

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def __init__(
        self,
        string: Union[str, MutableSequence[str]],
        pattern: str,
        _match: Match = None,
        _type_to_spans: Dict[str, List[List[int]]] = None,
        _span: List[int] = None,
        _type: str = None,
    ) -> None:
        super().__init__(string, _type_to_spans, _span, _type)
        self.pattern = pattern
        if _match:
            self._match_cache = _match, self.string
        else:
            self._match_cache = fullmatch(
                LIST_PATTERN_FORMAT.replace(
                    b'{pattern}', pattern.encode(), 1),
                self._shadow,
                MULTILINE,
            ), self.string 
开发者ID:5j9,项目名称:wikitextparser,代码行数:22,代码来源:_wikilist.py

示例13: __init__

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def __init__(
        self,
        string: Union[str, MutableSequence[str]],
        header: bool = False,
        _type_to_spans: Dict[str, List[List[int]]] = None,
        _span: int = None,
        _type: int = None,
        _match: Match = None,
        _attrs_match: Match = None,
    ) -> None:
        """Initialize the object."""
        super().__init__(string, _type_to_spans, _span, _type)
        self._header = header
        if _match:
            string = self.string
            self._match_cache = _match, string
            if _attrs_match:
                self._attrs_match_cache = _attrs_match, string
            else:
                self._attrs_match_cache = \
                    ATTRS_MATCH(_match['attrs']), string
        else:
            self._attrs_match_cache = self._match_cache = None, None 
开发者ID:5j9,项目名称:wikitextparser,代码行数:25,代码来源:_cell.py

示例14: find_defaults

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def find_defaults(item, operation):
    """
    Find instances of a default field and apply the given operation.

    Adapted from:
    https://github.com/curoverse/arvados/blob/2b0b06579199967eca3d44d955ad64195d2db3c3/sdk/cwl/arvados_cwl/runner.py#L56
    """
    if isinstance(item, MutableSequence):
        for entry in item:
            find_defaults(entry, operation)
    elif isinstance(item, MutableMapping):
        if "default" in item:
            operation(item)
        else:
            for entry in itervalues(item):
                find_defaults(entry, operation) 
开发者ID:ohsu-comp-bio,项目名称:cwl-tes,代码行数:18,代码来源:main.py

示例15: set_secondary

# 需要导入模块: import typing [as 别名]
# 或者: from typing import MutableSequence [as 别名]
def set_secondary(typedef, fileobj, discovered):
    """
    Pull over missing secondaryFiles to the job object entry.

    Adapted from:
    https://github.com/curoverse/arvados/blob/2b0b06579199967eca3d44d955ad64195d2db3c3/sdk/cwl/arvados_cwl/runner.py#L67
    """
    if isinstance(fileobj, MutableMapping) and fileobj.get("class") == "File":
        if "secondaryFiles" not in fileobj:
            fileobj["secondaryFiles"] = cmap(
                [{"location": substitute(fileobj["location"], sf["pattern"]),
                  "class": "File"} for sf in typedef["secondaryFiles"]])
            if discovered is not None:
                discovered[fileobj["location"]] = fileobj["secondaryFiles"]
    elif isinstance(fileobj, MutableSequence):
        for entry in fileobj:
            set_secondary(typedef, entry, discovered) 
开发者ID:ohsu-comp-bio,项目名称:cwl-tes,代码行数:19,代码来源:main.py


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