示例#1
0
def get_svn_revision():
    with traceguard:
        import package
        return package.getversion()

    import re
    import path
    digsby_root = str(path.path(__file__).parent.parent.parent)
    revision = 0
    urlre = re.compile('url="([^"]+)"')
    revre = re.compile('committed-rev="(\d+)"')

    for base,dirs,_files in os.walk(digsby_root):
        if '.svn' not in dirs:
            dirs[:] = []
            continue    # no sense walking uncontrolled subdirs
        dirs.remove('.svn')
        f = open(os.path.join(base,'.svn','entries'))
        data = f.read()
        f.close()

        if data.startswith('<?xml'):
            dirurl = urlre.search(data).group(1)    # get repository URL
            localrev = max([int(m.group(1)) for m in revre.finditer(data)]+[0])
        else:
            try: _svnver = int(data.splitlines()[0])
            except Exception: _svnver=-1
            if data<8:
#                    log.warn("unrecognized .svn/entries format; skipping %s", base)
                dirs[:] = []
                continue

            data = map(str.splitlines,data.split('\n\x0c\n'))
            del data[0][0]  # get rid of the '8' or '9'
            dirurl = data[0][3]
            localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0])
        if base==str(digsby_root):
            base_url = dirurl+'/'   # save the root url
        elif not dirurl.startswith(base_url):
            dirs[:] = []
            continue    # not part of the same svn tree, skip it
        revision = max(revision, localrev)
    return str(revision)
示例#2
0
    def build(self, bld, ap=None):
        res = {}
        if self._isbuilt: return self
        else: self._isbuilt = True

        basepath = bld.srcnode.find_node('wscript').abspath()
        if self.source == self.target:
            Logs.error("Font source may not be the same as the target: '%s'" %
                       self.target)
        # convert from legacy
        if hasattr(self, 'legacy'):
            self.legacy.build(bld, getattr(self, 'ap', None))

        # build font
        targetnode = bld.path.find_or_declare(self.target)
        tarname = None
        if self.source.endswith(".ttf"):
            bgen = bld(rule="${COPY} '${SRC}' '${TGT}'",
                       source=[self.source],
                       target=targetnode,
                       shell=True)
        else:
            srcnode = bld.path.find_or_declare(self.source)
            if getattr(self, "sfd_master",
                       None) and self.sfd_master != self.source:
                tarname = self.source + "_"
                bld(rule="${COPY} '${SRC}' '${TGT}'",
                    source=srcnode,
                    target=tarname,
                    shell=True)
                modify("${SFDMELD} ${SRC} ${DEP} ${TGT}",
                       tarname, [self.sfd_master],
                       path=basepath,
                       before=self.target + "_sfd")
            bgen = bld(
                rule=
                "${FONTFORGE} -nosplash -quiet -lang=py -c 'import sys; f=open(sys.argv[1]); f.encoding=\"Original\"; f.generate(sys.argv[2])' ${SRC} ${TGT}",
                source=tarname or srcnode,
                target=self.target,
                name=self.target + "_sfd")  # for old fontforges
            # bgen = bld(rule = "${FONTFORGE} -quiet -lang=ff -c 'Open($1); Generate($2)' ${SRC} ${TGT}", source = tarname or srcnode, target = self.target, name = self.target + "_sfd")

        if hasattr(self, 'version'):
            if isinstance(self.version, (list, tuple)):
                ttfsetverparms = "-d '" + self.version[
                    1] + "' " + self.version[0]
            else:
                gotver = package.getversion()
                if gotver != '':
                    ttfsetverparms = "-d 'dev {1}' {0}".format(
                        str(self.version), gotver)
                else:
                    ttfsetverparms = str(self.version)
            modify("${TTFSETVER} " + ttfsetverparms + " ${DEP} ${TGT}",
                   self.target,
                   path=basepath,
                   late=1)
        if hasattr(self, 'copyright'):
            modify("${TTFNAME} -t 0 -n '%s' ${DEP} ${TGT}" % (self.copyright),
                   self.target,
                   path=basepath,
                   late=1)
        if hasattr(self, 'license'):
            if hasattr(self.license, 'reserve'):
                self.package.add_reservedofls(*self.license.reserve)
            self.license.build(bld, self)

        # add smarts
        if hasattr(self, 'ap'):
            if not hasattr(self, 'legacy') or hasattr(self.legacy, 'noap'):
                apnode = bld.path.find_or_declare(self.ap)
                if self.source.endswith(".sfd") and not os.path.exists(
                        apnode.get_src().abspath()):
                    apopts = getattr(self, 'ap_params', "")
                    bld(rule="${SFD2AP} " + apopts + " '${SRC}' '${TGT}'",
                        source=tarname or self.source,
                        target=apnode)
                elif not hasattr(self.ap, 'isGenerated') and (
                        hasattr(self, 'classes')
                        or ismodified(self.ap, path=basepath)):
                    origap = self.ap
                    self.ap = self.ap + ".smith"
                    bld(rule="${COPY} '${SRC}' '${TGT}'",
                        source=origap,
                        target=self.ap,
                        shell=True)
            # if hasattr(self, 'classes') :
            #     modify("${ADD_CLASSES} -c ${SRC} ${DEP} > ${TGT}", self.ap, [self.classes], shell = 1, path = basepath)

        # add smarts
        for x in (getattr(self, y, None)
                  for y in ('opentype', 'graphite', 'pdf', 'woff', 'fret')):
            if x:
                x.build(bld, self.target, bgen, self)

        if hasattr(self, 'typetuner'):
            modify("${TYPETUNER} -o ${TGT} add ${SRC} ${DEP}", self.target,
                   [self.typetuner])

        return self
示例#3
0
文件: font.py 项目: silnrsi/smith
    def build(self, bld, ap=None) :
        res = {}
        if self._isbuilt : return self
        else : self._isbuilt = True

        basepath = bld.srcnode.find_node('wscript').abspath()
        if self.source == self.target :
            Logs.error("Font source may not be the same as the target: '%s'" % self.target)
        # convert from legacy
        if hasattr(self, 'legacy') :
            self.legacy.build(bld, getattr(self, 'ap', None))

        # build font
        targetnode = bld.path.find_or_declare(self.target)
        tarname = None
        if self.source.endswith(".ttf") :
            bgen = bld(rule = "${COPY} '${SRC}' '${TGT}'", source = [self.source], target = targetnode, shell=True)
        else :
            srcnode = bld.path.find_or_declare(self.source)
            if getattr(self, "sfd_master", None) and self.sfd_master != self.source:
                tarname = self.source + "_"
                bld(rule = "${COPY} '${SRC}' '${TGT}'", source = srcnode, target = tarname, shell=True)
                modify("${SFDMELD} ${SRC} ${DEP} ${TGT}", tarname, [self.sfd_master], path = basepath, before = self.target + "_sfd")
            bgen = bld(rule = "${FONTFORGE} -nosplash -quiet -lang=py -c 'import sys; f=open(sys.argv[1]); f.encoding=\"Original\"; f.generate(sys.argv[2])' ${SRC} ${TGT}", source = tarname or srcnode, target = self.target, name = self.target + "_sfd") # for old fontforges
            # bgen = bld(rule = "${FONTFORGE} -quiet -lang=ff -c 'Open($1); Generate($2)' ${SRC} ${TGT}", source = tarname or srcnode, target = self.target, name = self.target + "_sfd")

        if hasattr(self, 'version') :
            if isinstance(self.version, (list, tuple)) :
                ttfsetverparms = "-d '" + self.version[1] + "' " + self.version[0]
            else :
                gotver = package.getversion()
                if gotver != '' :
                    ttfsetverparms = "-d 'dev {1}' {0}".format(str(self.version), gotver)
                else :
                    ttfsetverparms = str(self.version)
            modify("${TTFSETVER} " + ttfsetverparms + " ${DEP} ${TGT}", self.target, path = basepath, late = 1)
        if hasattr(self, 'copyright') :
            modify("${TTFNAME} -t 0 -n '%s' ${DEP} ${TGT}" % (self.copyright), self.target, path = basepath, late = 1)
        if hasattr(self, 'license') :
            if hasattr(self.license, 'reserve') :
                self.package.add_reservedofls(*self.license.reserve)
            self.license.build(bld, self)

        # add smarts
        if hasattr(self, 'ap') :
            if not hasattr(self, 'legacy') or hasattr(self.legacy, 'noap') :
                apnode = bld.path.find_or_declare(self.ap)
                if self.source.endswith(".sfd") and not os.path.exists(apnode.get_src().abspath()) :
                    apopts = getattr(self, 'ap_params', "")
                    bld(rule = "${SFD2AP} " + apopts + " '${SRC}' '${TGT}'", source = tarname or self.source, target = apnode)
                elif not hasattr(self.ap, 'isGenerated') and (hasattr(self, 'classes') or ismodified(self.ap, path = basepath)) :
                    origap = self.ap
                    self.ap = self.ap + ".smith"
                    bld(rule="${COPY} '${SRC}' '${TGT}'", source = origap, target = self.ap, shell=True)
            # if hasattr(self, 'classes') :
            #     modify("${ADD_CLASSES} -c ${SRC} ${DEP} > ${TGT}", self.ap, [self.classes], shell = 1, path = basepath)
        
        # add smarts
        for x in (getattr(self, y, None) for y in ('opentype', 'graphite', 'pdf', 'woff', 'fret')) :
            if x :
                x.build(bld, self.target, bgen, self)

        if hasattr(self, 'typetuner') :
            modify("${TYPETUNER} -o ${TGT} add ${SRC} ${DEP}", self.target, [self.typetuner])

        return self