Пример #1
0
def convert_isv_date(date_string, language_code = 'en_US'):
    try:
        date = ParseDateTimeUTC(date_string)
    except ValueError:
        date = ParseDateTimeUTC(date_string[0:4])
    if len(language_code) == 5:
        language_code = language_code[0:2] + '_' + language_code[3:5]
    #print language_code, locale.normalize(language_code)
    locale.setlocale(locale.LC_ALL, (language_code,'utf-8'))
    if len(date_string) >= 9:
        return date.strftime("%e %B %Y").strip() 
    if len(date_string) >= 6:
        return date.strftime("%B %Y") 
    return date.strftime("%Y")
Пример #2
0
def get_printings(original_story, first_publication_date):
    printings = Story.objects.filter(story_version__base_story =\
                original_story).filter(issue__publication_date__gt = "")\
                .order_by('issue__publication_date')
    if len(first_publication_date) <= 4 or 'Q' in first_publication_date:
        first_printings = printings.filter(issue__publication_date__icontains\
            = first_publication_date[0:4])
    else:
        end_date = ParseDateTimeUTC(first_publication_date[0:7])
        end_date += DateTimeDelta(120)
        end_date = end_date.strftime("%Y-%m")
        first_printings = printings.filter(issue__publication_date__gte \
            = first_publication_date[0:7]).filter(issue__publication_date__lte \
            = end_date)
        if not first_printings:
            first_printings = \
                printings.filter(issue__publication_date__icontains \
                = first_publication_date[0:4])
    return printings, first_printings
Пример #3
0
def get_printings(original_story, first_publication_date):
    printings = Story.objects.filter(story_version__base_story =\
                original_story).filter(issue__publication_date__gt = "")\
                .order_by('issue__publication_date')
    if len(first_publication_date) <= 4 or 'Q' in first_publication_date:
        first_printings = printings.filter(issue__publication_date__icontains\
            = first_publication_date[0:4])
    else:
        end_date = ParseDateTimeUTC(first_publication_date[0:7])
        end_date += DateTimeDelta(120)
        end_date = end_date.strftime("%Y-%m")
        first_printings = printings.filter(issue__publication_date__gte \
            = first_publication_date[0:7]).filter(issue__publication_date__lte \
            = end_date)
        if not first_printings:
            first_printings = \
                printings.filter(issue__publication_date__icontains \
                = first_publication_date[0:4])
    return printings,first_printings
Пример #4
0
def convert_isv_date(date_string, language_code='en_US'):
    try:
        date = ParseDateTimeUTC(date_string)
    except ValueError:
        date = ParseDateTimeUTC(date_string[0:4])
    if len(language_code) == 5:
        language_code = language_code[0:2] + '_' + language_code[3:5]
    #print language_code, locale.normalize(language_code)
    locale.setlocale(locale.LC_ALL, (language_code, 'utf-8'))
    if len(date_string) >= 9:
        return date.strftime("%e %B %Y").strip()
    if len(date_string) >= 6:
        return date.strftime("%B %Y")
    return date.strftime("%Y")
Пример #5
0
    def GenerateChangelog(self):
        self.Clone()
        sourcename = self.GetSourceName()

        stylepath = os.path.join(os.path.dirname(build.__file__),
                                 "mercurial_xml_style")

        # Request the changelog from mercurial
        c = subprocess.Popen(["hg", "log", "--follow", "--style", stylepath],
                             cwd=self.tmpdir + "/hg",
                             stdout=subprocess.PIPE)
        xmllog = c.communicate()[0]

        # work around a bug in mercurial 1.0.1, which ignores the footer declaration from the style
        if xmllog.find("</log>") == -1:
            xmllog += "</log>"

        etlog = ET.fromstring(xmllog)

        tagend = None
        taghead = None
        anychanges = False
        currentversion = None

        versions = defaultdict(ChangelogVersion)

        for logentry in etlog:
            if logentry.find("tag") != None:

                version = logentry.find("tag").text

                if version != 'tip':
                    version_s = version.split('.', 2)
                    if len(version_s) == 2:
                        version += '.0'

                currentversion = versions[version]
                currentversion.sourcename = sourcename
                currentversion.description = version

                if self.targetdistribution[0] not in ['tip', 'stable']:
                    currentversion.description += '+' + self.targetdistribution[
                        0]

                if not currentversion.author:
                    currentversion.author = "%s <%s>" % (
                        logentry.find("author").text,
                        logentry.find("author").attrib["email"])
                if not currentversion.date:
                    currentversion.date = ParseDateTimeUTC(
                        logentry.find("date").text)

            msg = logentry.find("msg").text
            tag = _regex_tagging_message.match(msg)
            if tag:
                # This is a "Added tag <version> for changeset <hash>" message.
                # Use the author and date for the specified version
                taggedversion = versions[tag.group("version")]
                taggedversion.author = "%s <%s>" % (logentry.find(
                    "author").text, logentry.find("author").attrib["email"])
                taggedversion.date = ParseDateTimeUTC(
                    logentry.find("date").text)
            else:
                # this is a regular changelog item. Add it to the message
                currentversion.messages.append(msg)

        if not self.buildtag in versions:
            versions[
                self.
                buildtag].author = "OpenPanel packager <*****@*****.**>"
            versions[self.buildtag].description = self.buildtag
            versions[self.buildtag].date = mx.DateTime.now()
            versions[self.buildtag].messages += ["Rebuilt from hg tip"]
            versions[self.buildtag].sourcename = sourcename

        return versions