Пример #1
0
    def _title_is_ok(self, title):
        if TextIsEmpty(title):
            return False

        return not Contains(title, (
            u' ',
            u'\t',
        ))
Пример #2
0
def _get_containing_sizer(parent, sizer):
    if isinstance(parent, wx.Window):
        parent = parent.GetSizer()

    if not parent or parent == sizer:
        return None

    if Contains(parent, sizer):
        return parent

    for S in parent.GetChildren():
        S = S.GetSizer()

        if S:
            S = _get_containing_sizer(S, sizer)

            if S:
                return S
Пример #3
0
def _get_ubuntu_distnames(unstable=True, obsolete=False):
    ref_site = u'https://wiki.ubuntu.com/Releases'
    page_html = GetRemotePageText(ref_site).split(u'\n')

    dist_names = []
    current = []

    if unstable:
        future = []

    if obsolete:
        eol = []

    if page_html:
        for INDEX in range(len(page_html)):
            LINE = page_html[INDEX].lower()

            if u'id="current"' in LINE and len(current) < 2:
                current.append(INDEX + 8)

                continue

            if u'id="future"' in LINE:
                if len(current) < 2:
                    current.append(INDEX)

                if unstable and len(future) < 2:
                    future.append(INDEX + 8)

                continue

            if u'id="end_of_life"' in LINE:
                if unstable and len(future) < 2:
                    future.append(INDEX)

                if obsolete and len(eol) < 2:
                    eol.append(INDEX + 8)
                    eol.append(len(page_html) - 1)

                    break

        # Lines containing these strings will be ignored
        skip_lines = (
            u'releasenotes',
            u'class="http',
        )

        # Add names in order of newest first

        if unstable and len(future) > 1:
            future = page_html[future[0]:future[1]]

            for LINE in future:
                LINE = LINE.lower()

                if u'class="line891"' in LINE and not Contains(
                        LINE, skip_lines):
                    name = LINE.split(u'</a>')[0].split(
                        u'>')[-1].strip().split(u' ')[0]

                    if name and name not in dist_names:
                        dist_names.append(name)

        if len(current) > 1:
            current = page_html[current[0]:current[1]]

            for LINE in current:
                LINE = LINE.lower()

                if u'class="line891"' in LINE and not Contains(
                        LINE, skip_lines):
                    name = LINE.split(u'</a>')[0].split(
                        u'>')[-1].strip().split(u' ')[0]
                    if name and name not in dist_names:
                        dist_names.append(name)

        if obsolete and len(eol) > 1:
            eol = page_html[eol[0]:eol[1]]

            # Maximum number of obsolete dists that will be added
            eol_max = 6
            eol_added = 0

            for LINE in eol:
                LINE = LINE.lower()

                if u'class="line891"' in LINE and not Contains(
                        LINE, skip_lines):
                    name = LINE.split(u'</a>')[0].split(
                        u'>')[-1].strip().split(u' ')[0]

                    if name and name not in dist_names:
                        dist_names.append(name)

                        eol_added += 1
                        if eol_added >= eol_max:
                            break

    return dist_names