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