Example #1
0
def FormatChangelog(text,
                    name=APP_name,
                    version=VERSION_string,
                    dist=OS_codename,
                    urgency=u'low',
                    packager=AUTHOR_name,
                    email=AUTHOR_email,
                    preserve_indent=False):
    if TextIsEmpty(text):
        return None

    # Remove leading & trailing whitespace & empty lines & split into
    # list of lines.
    lines = text.strip(u' \t\n\r').split(u'\n')

    if not lines:
        return None

    lines = RemoveEmptyLines(lines)
    lines = _format_lines(lines, preserve_indent)

    text = u'\n'.join(lines)
    header = u'{} ({}) {}; urgency={}\n'.format(name, version, dist, urgency)
    footer = u'\n -- {} <{}>  {}'.format(packager, email, _get_cl_timestamp())

    return u'\n'.join((header, text, footer))
Example #2
0
	def __init__(self, commands=None, requireAll=False):
		self.Commands = commands
		self.RequireAll = requireAll

		if commands:
			if IsString(self.Commands) and u' ' in self.Commands:
				self.Commands = self.Commands.split(u' ')
				self.Commands = RemoveEmptyLines(self.Commands)

		# Check for the commands when the object is constructed
		self.Check()
Example #3
0
def GetCachedDistNames(unstable=True, obsolete=False, generic=False):
    global FILE_distnames

    if not os.path.isfile(FILE_distnames):
        if not UpdateDistNamesCache(unstable, obsolete, generic):
            return None

    text_temp = ReadFile(FILE_distnames)

    dist_names = {}

    if text_temp:
        try:
            dist_names[u'debian'] = RemoveEmptyLines(
                text_temp.split(u'[DEBIAN]')[1].split(u'[UBUNTU]')[0].split(
                    u'\n'))

        except IndexError:
            pass

        try:
            dist_names[u'ubuntu'] = RemoveEmptyLines(
                text_temp.split(u'[UBUNTU]')[1].split(u'[LINUX MINT]')
                [0].split(u'\n'))

        except IndexError:
            pass

        try:
            dist_names[u'mint'] = RemoveEmptyLines(
                text_temp.split(u'[LINUX MINT]')[1].split(u'\n'))

        except IndexError:
            pass

    return (dist_names)
Example #4
0
def GetOSDistNames():
    global FILE_distnames

    dist_names = []

    if os.path.isfile(FILE_distnames):
        cached_names = GetCachedDistNames()

        if cached_names:
            for OS in (
                    u'debian',
                    u'ubuntu',
                    u'mint',
            ):
                for NAME in cached_names[OS]:
                    dist_names.append(NAME)

    # Only check system for dist names if could not be loaded from cache file
    if not dist_names:
        # Ubuntu & Linux Mint distributions
        global OS_codename, OS_upstream_codename

        for CN in (
                OS_codename,
                OS_upstream_codename,
        ):
            if CN and CN not in dist_names:
                dist_names.append(CN)

        # Debian distributions
        FILE_debian = u'/etc/debian_version'
        if os.path.isfile(FILE_debian):
            debian_names = RemoveEmptyLines(ReadFile(FILE_debian,
                                                     split=True))[:1]

            # Usable names should all be on first line
            if u'/' in debian_names[0]:
                debian_names = sorted(debian_names[0].split(u'/'))

            for NAME in reversed(debian_names):
                if NAME not in dist_names:
                    # Put Debian names first
                    dist_names.insert(0, NAME)

    return tuple(dist_names)
Example #5
0
    def OnSetLintOverrides(self, event=None):
        Logger.Debug(__name__, GT(u'Setting Lintian overrides...'))

        lintian_tags_file = u'{}/data/lintian/tags'.format(PATH_app)

        if not os.path.isfile(lintian_tags_file):
            Logger.Error(
                __name__,
                u'Lintian tags file is missing: {}'.format(lintian_tags_file))

            return False

        lint_tags = RemoveEmptyLines(ReadFile(lintian_tags_file, split=True))

        if lint_tags:
            Logger.Debug(__name__, u'Lintian tags set')

            # DEBUG: Start
            if DebugEnabled() and len(lint_tags) > 50:
                print(u'  Reducing tag count to 200 ...')

                lint_tags = lint_tags[:50]

            Logger.Debug(__name__,
                         u'Processing {} tags'.format(len(lint_tags)))
            # DEBUG: End

            tag_count = len(lint_tags)

            def GetProgressMessage(message, count=tag_count):
                return u'{} ({} {})'.format(message, count, GT(u'tags'))

            progress = TimedProgressDialog(
                GetMainWindow(), GT(u'Building Tag List'),
                GetProgressMessage(GT(u'Scanning default tags')))
            progress.Start()

            wx.Yield()

            # Create the dialog
            overrides_dialog = CheckListDialog(GetMainWindow(),
                                               title=GT(u'Lintian Overrides'),
                                               allow_custom=True)
            # FIXME: Needs progress dialog
            overrides_dialog.InitCheckList(tuple(lint_tags))

            progress.SetMessage(
                GetProgressMessage(GT(u'Setting selected overrides')))

            for T in lint_tags:
                if T in self.lint_overrides:
                    overrides_dialog.SetItemCheckedByLabel(T)
                    self.lint_overrides.remove(T)

            progress.SetMessage(
                GetProgressMessage(GT(u'Adding custom tags'),
                                   len(self.lint_overrides)))

            # Remaining tags should be custom entries
            # FIXME:
            if self.lint_overrides:
                for T in self.lint_overrides:
                    overrides_dialog.AddItem(T, True)

            progress.Stop()

            if overrides_dialog.ShowModal() == wx.ID_OK:
                # Remove old overrides
                self.lint_overrides = []
                for L in overrides_dialog.GetCheckedLabels():
                    Logger.Debug(__name__,
                                 GT(u'Adding Lintian override: {}').format(L))

                    self.lint_overrides.append(L)

            return True

        else:
            Logger.Debug(__name__, u'Setting lintian tags failed')

            return False