Пример #1
0
    def test_10_doc_string_is_kept(self):
        def t():
            """Always returns True."""
            return True

        t2 = TT.memoize(t)
        self.assertEquals(getdoc(t), getdoc(t2))
Пример #2
0
    def test_10_doc_string_is_kept(self):
        def t():
            """Always returns True."""
            return True

        t2 = TT.memoize(t)
        self.assertEquals(getdoc(t), getdoc(t2))
Пример #3
0
    def test_00_simple_case(self):
        x = 0
        f = lambda _x: x

        f = TT.memoize(f)
        x = 1

        self.assertEquals(f(0), f(1))
Пример #4
0
    def test_00_simple_case(self):
        x = 0
        f = lambda _x: x

        f = TT.memoize(f)
        x = 1

        self.assertEquals(f(0), f(1))
Пример #5
0
    g = NX.DiGraph()

    if rreqs is None:
        rreqs = RU.make_requires_dict(root, reversed)

    for k, vs in rreqs.iteritems():
        g.add_node(k, names=[k])
        g.add_edges_from([(k, v, edge_attrs) for v in vs])

    # Remove edges of self cyclic nodes:
    g.remove_edges_from(g.selfloop_edges())

    return g


make_dependency_graph = RM.memoize(_make_dependency_graph)

_DGNODE_CTR = count()


def _degenerate_node(nodes, reason, cntr=_DGNODE_CTR):
    """
    :param nodes: List of nodes to degenerate :: [str]
    :param reason: Reason to degenerate nodes

    :return: Degenerated node, (name :: str, attr :: dict)
    """
    assert nodes, "Empty node list was given!"

    label = "%s %d" % (reason, cntr.next())
    nodes_s = "[%s...]" % ", ".join(n for n in nodes[:5])
Пример #6
0
    return None


def _is_noarch(srpm):
    """
    Detect if given srpm is for noarch (arch-independent) package.
    """
    h = rpm_header_from_rpmfile(srpm)
    if h is None:
        return False  # TODO: What should be returned?

    return h["arch"] == "noarch"


is_noarch = RM.memoize(_is_noarch)


def normalize_arch(arch):
    """
    Normalize given package's arch.

    NOTE: $arch maybe '(none)', 'gpg-pubkey' for example.

    >>> normalize_arch("(none)")
    'noarch'
    >>> normalize_arch("x86_64")
    'x86_64'
    """
    return "noarch" if arch == "(none)" else arch
Пример #7
0
    g = NX.DiGraph()

    if rreqs is None:
        rreqs = RU.make_requires_dict(root, reversed)

    for k, vs in rreqs.iteritems():
        g.add_node(k, names=[k])
        g.add_edges_from([(k, v, edge_attrs) for v in vs])

    # Remove edges of self cyclic nodes:
    g.remove_edges_from(g.selfloop_edges())

    return g


make_dependency_graph = RM.memoize(_make_dependency_graph)

_DGNODE_CTR = count()


def _degenerate_node(nodes, reason, cntr=_DGNODE_CTR):
    """
    :param nodes: List of nodes to degenerate :: [str]
    :param reason: Reason to degenerate nodes

    :return: Degenerated node, (name :: str, attr :: dict)
    """
    assert nodes, "Empty node list was given!"

    label = "%s %d" % (reason, cntr.next())
    nodes_s = "[%s...]" % ', '.join(n for n in nodes[:5])
Пример #8
0
    return None


def _is_noarch(srpm):
    """
    Detect if given srpm is for noarch (arch-independent) package.
    """
    h = rpm_header_from_rpmfile(srpm)
    if h is None:
        return False  # TODO: What should be returned?

    return h["arch"] == "noarch"


is_noarch = RM.memoize(_is_noarch)


def normalize_arch(arch):
    """
    Normalize given package's arch.

    NOTE: $arch maybe '(none)', 'gpg-pubkey' for example.

    >>> normalize_arch("(none)")
    'noarch'
    >>> normalize_arch("x86_64")
    'x86_64'
    """
    return "noarch" if arch == "(none)" else arch