Example #1
0
def main():
    p = argparse.ArgumentParser(usage=(__doc__ or '').strip())
    p.add_argument('--use-timestamp',
                   action='store_true',
                   default=False,
                   help="don't rewrite npz file if it is newer than sources")
    p.add_argument('dirname')  # for Meson: 'boost' or 'gsl'
    p.add_argument("-o",
                   "--outdir",
                   type=str,
                   help="Relative path to the output directory")
    args = p.parse_args()

    if not args.outdir:
        # We're dealing with a distutils build here, write in-place:
        inp = os.path.normpath(args.dirname)
        outp = inp + ".npz"
    else:
        inp = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..',
                           'tests', 'data', args.dirname)
        outdir_abs = os.path.join(os.getcwd(), args.outdir)
        outp = os.path.join(outdir_abs, args.dirname + ".npz")

    # Skip rebuilding if no sources
    if os.path.isfile(outp) and not os.path.isdir(inp):
        return

    # Find source files
    files = []
    for dirpath, dirnames, filenames in os.walk(inp):
        for fn in filenames:
            if fn.endswith('.txt'):
                key = dirpath[len(inp) + 1:] + '-' + fn[:-4]
                key = key.strip('-')
                files.append((key, os.path.join(dirpath, fn)))

    # Check if changes required
    if args.use_timestamp and os.path.isfile(outp):
        try:
            old_data = np.load(outp)
            try:
                changed = set(old_data.keys()) != set(key for key, _ in files)
            finally:
                old_data.close()
        except OSError:
            # corrupted file
            changed = True

        changed = changed or any(newer(fn, outp) for key, fn in files)
        changed = changed or newer(__file__, outp)
        if not changed:
            return

    data = {}
    for key, fn in files:
        data[key] = np.loadtxt(fn)

    np.savez_compressed(outp, **data)
Example #2
0
def main():
    p = argparse.ArgumentParser(usage=(__doc__ or '').strip())
    p.add_argument('--use-timestamp',
                   action='store_true',
                   default=False,
                   help="don't rewrite npz file if it is newer than sources")
    p.add_argument('dirname')
    args = p.parse_args()

    inp = os.path.normpath(args.dirname)
    outp = inp + ".npz"

    # Skip rebuilding if no sources
    if os.path.isfile(outp) and not os.path.isdir(inp):
        print("[makenpz] {} not rebuilt".format(outp))
        return

    # Find source files
    files = []
    for dirpath, dirnames, filenames in os.walk(inp):
        for fn in filenames:
            if fn.endswith('.txt'):
                key = dirpath[len(inp) + 1:] + '-' + fn[:-4]
                key = key.strip('-')
                files.append((key, os.path.join(dirpath, fn)))

    # Check if changes required
    if args.use_timestamp and os.path.isfile(outp):
        try:
            old_data = np.load(outp)
            try:
                changed = set(old_data.keys()) != set(key for key, _ in files)
            finally:
                old_data.close()
        except OSError:
            # corrupted file
            changed = True

        changed = changed or any(newer(fn, outp) for key, fn in files)
        changed = changed or newer(__file__, outp)
        if not changed:
            print("[makenpz] {} is already up to date".format(outp))
            return

    data = {}
    for key, fn in files:
        data[key] = np.loadtxt(fn)

    print("[makenpz] generating {}".format(outp))
    np.savez_compressed(outp, **data)
Example #3
0
def main():
    p = argparse.ArgumentParser(usage=__doc__.strip())
    p.add_argument('--use-timestamp', action='store_true', default=False,
                   help="don't rewrite npz file if it is newer than sources")
    p.add_argument('dirname')
    args = p.parse_args()

    inp = os.path.normpath(args.dirname)
    outp = inp + ".npz"

    # Skip rebuilding if no sources
    if os.path.isfile(outp) and not os.path.isdir(inp):
        print("[makenpz] {} not rebuilt".format(outp))
        return

    # Find source files
    files = []
    for dirpath, dirnames, filenames in os.walk(inp):
        for fn in filenames:
            if fn.endswith('.txt'):
                key = dirpath[len(inp)+1:] + '-' + fn[:-4]
                key = key.strip('-')
                files.append((key, os.path.join(dirpath, fn)))

    # Check if changes required
    if args.use_timestamp and os.path.isfile(outp):
        try:
            old_data = np.load(outp)
            try:
                changed = set(old_data.keys()) != set(key for key, _ in files)
            finally:
                old_data.close()
        except (IOError, OSError):
            # corrupted file
            changed = True

        changed = changed or any(newer(fn, outp) for key, fn in files)
        changed = changed or newer(__file__, outp)
        if not changed:
            print("[makenpz] {} is already up to date".format(outp))
            return

    data = {}
    for key, fn in files:
        data[key] = np.loadtxt(fn)

    print("[makenpz] generating {}".format(outp))
    np.savez_compressed(outp, **data)
    def build_template(self, template, template_file, package):
        """
        Compile the cheetah template in src into a python file in build
        """

        comp = Compiler(file=template_file, moduleName=template)

        # load configuration if it exists
        conf_fn = DEFAULT_CONFIG
        if exists(conf_fn):
            with open(conf_fn, "rt") as config:
                comp.updateSettingsFromConfigFileObj(config)

        # and just why can't I configure these?
        comp.setShBang("")
        comp.addModuleHeader("pylint: disable=C,W,R,F")

        outfd = join(self.build_lib, *package.split("."))
        outfn = join(outfd, template+".py")

        if not exists(outfd):
            makedirs(outfd)

        if newer(template_file, outfn):
            self.announce("compiling %s -> %s" % (template_file, outfd), 2)
            with open(outfn, "w") as output:
                output.write(str(comp))
Example #5
0
def build_trans(build_cmd):
    '''
    Translate the language files into gramps.mo
    '''
    data_files = build_cmd.distribution.data_files
    for lang in ALL_LINGUAS:
        po_file = os.path.join('po', lang + '.po')
        mo_file = os.path.join(build_cmd.build_base, 'mo', lang, 'LC_MESSAGES',
                               'gramps.mo')
        mo_file_unix = (build_cmd.build_base + '/mo/' + lang +
                        '/LC_MESSAGES/gramps.mo')
        mo_dir = os.path.dirname(mo_file)
        if not (os.path.isdir(mo_dir) or os.path.islink(mo_dir)):
            os.makedirs(mo_dir)

        if newer(po_file, mo_file):
            cmd = 'msgfmt %s -o %s' % (po_file, mo_file)
            if os.system(cmd) != 0:
                os.remove(mo_file)
                msg = 'ERROR: Building language translation files failed.'
                ask = msg + '\n Continue building y/n [n] '
                reply = input(ask)
                if reply in ['n', 'N']:
                    raise SystemExit(msg)
            log.info('Compiling %s >> %s', po_file, mo_file)

        #linux specific piece:
        target = 'share/locale/' + lang + '/LC_MESSAGES'
        data_files.append((target, [mo_file_unix]))
Example #6
0
def build_trans(build_cmd):
    """
    Translate the language files into gramps.mo
    """
    data_files = build_cmd.distribution.data_files
    for lang in ALL_LINGUAS:
        po_file = os.path.join("po", lang + ".po")
        mo_file = os.path.join(build_cmd.build_base, "mo", lang, "LC_MESSAGES", "gramps.mo")
        mo_file_unix = build_cmd.build_base + "/mo/" + lang + "/LC_MESSAGES/gramps.mo"
        mo_dir = os.path.dirname(mo_file)
        if not (os.path.isdir(mo_dir) or os.path.islink(mo_dir)):
            os.makedirs(mo_dir)

        if newer(po_file, mo_file):
            cmd = "msgfmt %s -o %s" % (po_file, mo_file)
            if os.system(cmd) != 0:
                os.remove(mo_file)
                msg = "ERROR: Building language translation files failed."
                ask = msg + "\n Continue building y/n [n] "
                reply = input(ask)
                if reply in ["n", "N"]:
                    raise SystemExit(msg)
            log.info("Compiling %s >> %s", po_file, mo_file)

        # linux specific piece:
        target = "share/locale/" + lang + "/LC_MESSAGES"
        data_files.append((target, [mo_file_unix]))
Example #7
0
def build_trans(build_cmd):
    '''
    Translate the language files into gramps.mo
    '''
    data_files = build_cmd.distribution.data_files
    for lang in ALL_LINGUAS:
        po_file = os.path.join('po', lang + '.po')
        mo_file = os.path.join(build_cmd.build_base, 'mo', lang, 'LC_MESSAGES',
                               'gramps.mo')
        mo_file_unix = (build_cmd.build_base + '/mo/' + lang +
                        '/LC_MESSAGES/gramps.mo')
        mo_dir = os.path.dirname(mo_file)
        if not(os.path.isdir(mo_dir) or os.path.islink(mo_dir)):
            os.makedirs(mo_dir)

        if newer(po_file, mo_file):
            cmd = 'msgfmt %s -o %s' % (po_file, mo_file)
            if os.system(cmd) != 0:
                os.remove(mo_file)
                msg = 'ERROR: Building language translation files failed.'
                ask = msg + '\n Continue building y/n [n] '
                reply = input(ask)
                if reply in ['n', 'N']:
                    raise SystemExit(msg)
            log.info('Compiling %s >> %s', po_file, mo_file)

        #linux specific piece:
        target = 'share/locale/' + lang + '/LC_MESSAGES'
        data_files.append((target, [mo_file_unix]))
Example #8
0
 def run(self):
     # Before importing markdown, tweak sys.path to import from the 
     # build directory (2to3 might have run on the library).
     bld_cmd = self.get_finalized_command("build")
     sys.path.insert(0, bld_cmd.build_lib)
     try:
         import markdown
     except ImportError:
         print ('skipping build_docs: Markdown "import" failed!')
     else:
         template = codecs.open('docs/_template.html', encoding='utf-8').read()
         md = markdown.Markdown(extensions=['extra', 'toc'])
         menu = md.convert(self.sitemap)
         md.reset()
         for infile, title in self.docs:
             outfile, ext = os.path.splitext(infile)
             if ext == '.txt':
                 outfile += '.html'
                 outfile = change_root(self.build_base, outfile)
                 self.mkpath(os.path.split(outfile)[0])
                 if self.force or newer(infile, outfile):
                     if self.verbose:
                         print ('Converting %s -> %s' % (infile, outfile))
                     if not self.dry_run:
                         src = codecs.open(infile, encoding='utf-8').read()
                         out = template % {
                             'title': title, 
                             'body' : md.convert(src),
                             'toc'  : md.toc,
                         }
                         md.reset()
                         doc = open(outfile, 'wb')
                         doc.write(out.encode('utf-8'))
                         doc.close()
Example #9
0
    def build_template(self, template, template_file, package):
        """
        Compile the cheetah template in src into a python file in build
        """

        try:
            from Cheetah.Compiler import Compiler
        except ImportError:
            self.announce("unable to import Cheetah.Compiler, build failed")
            raise
        else:
            comp = Compiler(file=template_file, moduleName=template)

        # load configuration if it exists
        conf_fn = DEFAULT_CONFIG
        if exists(conf_fn):
            with open(conf_fn, "rt") as config:
                comp.updateSettingsFromConfigFileObj(config)

        # and just why can't I configure these?
        comp.setShBang("")
        comp.addModuleHeader("pylint: disable=C,W,R,F")

        outfd = join(self.build_lib, *package.split("."))
        outfn = join(outfd, template + ".py")

        if not exists(outfd):
            makedirs(outfd)

        if newer(template_file, outfn):
            self.announce("compiling %s -> %s" % (template_file, outfd), 2)
            with open(outfn, "w") as output:
                output.write(str(comp))
Example #10
0
 def run(self):
     # Before importing markdown, tweak sys.path to import from the
     # build directory (2to3 might have run on the library).
     bld_cmd = self.get_finalized_command("build")
     sys.path.insert(0, bld_cmd.build_lib)
     try:
         import markdown
     except ImportError:
         print('skipping build_docs: Markdown "import" failed!')
     else:
         md = markdown.Markdown()
         menu = md.convert(self.sitemap)
         md.reset()
         for infile, title in self.docs:
             outfile, ext = os.path.splitext(infile)
             if ext == '.txt':
                 outfile += '.html'
                 outfile = change_root(self.build_base, outfile)
                 self.mkpath(os.path.split(outfile)[0])
                 if self.force or newer(infile, outfile):
                     if self.verbose:
                         print('Converting %s -> %s' % (infile, outfile))
                     if not self.dry_run:
                         doc = open(outfile, 'wb')
                         header = doc_header % {
                             'title': title,
                             'menu': menu
                         }
                         doc.write(header.encode('utf-8'))
                         md.convertFile(infile, doc)
                         md.reset()
                         doc.write(doc_footer.encode('utf-8'))
                         doc.close()
Example #11
0
def build_man(build_cmd):
    '''
    Compress Gajim manual files
    '''
    data_files = build_cmd.distribution.data_files
    for man in ['gajim.1', 'gajim-history-manager.1', 'gajim-remote.1']:
        filename = os.path.join('data', man)
        newdir = os.path.join(build_dir, 'man')
        if not (os.path.isdir(newdir) or os.path.islink(newdir)):
            os.makedirs(newdir)

        import gzip
        man_file_gz = os.path.join(newdir, man + '.gz')
        if os.path.exists(man_file_gz):
            if newer(filename, man_file_gz):
                os.remove(man_file_gz)
            else:
                filename = False

        if filename:
            # Binary io, so open is OK
            with open(filename, 'rb') as f_in,\
                    gzip.open(man_file_gz, 'wb') as f_out:
                f_out.writelines(f_in)
                log.info('Compiling %s >> %s', filename, man_file_gz)

        target = 'share/man/man1'
        data_files.append((target, [man_file_gz]))
 def run(self):
     # Before importing markdown, tweak sys.path to import from the
     # build directory (2to3 might have run on the library).
     bld_cmd = self.get_finalized_command("build")
     sys.path.insert(0, bld_cmd.build_lib)
     try:
         import markdown
     except ImportError:
         print('skipping build_docs: Markdown "import" failed!')
     else:
         with codecs.open('docs/_template.html', encoding='utf-8') as f:
             template = f.read()
         self.md = markdown.Markdown(
             extensions=[
                 'extra',
                 'toc(permalink=true)',
                 'meta',
                 'admonition',
                 'smarty'
             ]
         )
         for infile in self.docs:
             outfile, ext = os.path.splitext(infile)
             if ext == '.txt':
                 # Copy src to .txt file
                 srcfile = outfile + '.txt'
                 srcfile = change_root(self.build_base, srcfile)
                 self.mkpath(os.path.split(srcfile)[0])
                 self.copy_file(infile, srcfile)
                 # Render html file
                 outfile += '.html'
                 outfile = change_root(self.build_base, outfile)
                 self.mkpath(os.path.split(outfile)[0])
                 if self.force or newer(infile, outfile):
                     if self.verbose:
                         print('Converting %s -> %s' % (infile, outfile))
                     if not self.dry_run:
                         with codecs.open(infile, encoding='utf-8') as f:
                             src = f.read()
                         out = template % self._get_context(src, outfile)
                         doc = open(outfile, 'wb')
                         doc.write(out.encode('utf-8'))
                         doc.close()
             else:
                 outfile = change_root(self.build_base, infile)
                 self.mkpath(os.path.split(outfile)[0])
                 self.copy_file(infile, outfile)
Example #13
0
 def run(self):
     # Before importing markdown, tweak sys.path to import from the
     # build directory (2to3 might have run on the library).
     bld_cmd = self.get_finalized_command("build")
     sys.path.insert(0, bld_cmd.build_lib)
     try:
         import markdown
     except ImportError:
         print('skipping build_docs: Markdown "import" failed!')
     else:
         with codecs.open('docs/_template.html', encoding='utf-8') as f:
             template = f.read()
         self.md = markdown.Markdown(
             extensions=[
                 'extra',
                 'toc(permalink=true)',
                 'meta',
                 'admonition',
                 'smarty'
             ]
         )
         for infile in self.docs:
             outfile, ext = os.path.splitext(infile)
             if ext == '.txt':
                 # Copy src to .txt file
                 srcfile = outfile + '.txt'
                 srcfile = change_root(self.build_base, srcfile)
                 self.mkpath(os.path.split(srcfile)[0])
                 self.copy_file(infile, srcfile)
                 # Render html file
                 outfile += '.html'
                 outfile = change_root(self.build_base, outfile)
                 self.mkpath(os.path.split(outfile)[0])
                 if self.force or newer(infile, outfile):
                     if self.verbose:
                         print('Converting %s -> %s' % (infile, outfile))
                     if not self.dry_run:
                         with codecs.open(infile, encoding='utf-8') as f:
                             src = f.read()
                         out = template % self._get_context(src, outfile)
                         doc = open(outfile, 'wb')
                         doc.write(out.encode('utf-8'))
                         doc.close()
             else:
                 outfile = change_root(self.build_base, infile)
                 self.mkpath(os.path.split(outfile)[0])
                 self.copy_file(infile, outfile)
Example #14
0
def build_man(build_cmd):
    '''
    Compresses Gramps manual files
    '''
    data_files = build_cmd.distribution.data_files
    for man_dir, dirs, files in os.walk(os.path.join('data', 'man')):
        if 'gramps.1.in' in files:
            filename = os.path.join(man_dir, 'gramps.1.in')
            newdir = os.path.join(build_cmd.build_base, man_dir)
            if not(os.path.isdir(newdir) or os.path.islink(newdir)):
                os.makedirs(newdir)

            newfile = os.path.join(newdir, 'gramps.1')
            subst_vars = (('@VERSION@', VERSION), )
            substitute_variables(filename, newfile, subst_vars)

            src = 'gramps.1'
            if not args.no_compress_manpages:
                import gzip
                src += '.gz'
                man_file_gz = os.path.join(newdir, src)
                if os.path.exists(man_file_gz):
                    if newer(filename, man_file_gz):
                        os.remove(man_file_gz)
                    else:
                        filename = False
                        os.remove(newfile)

                if filename:
                    #Binary io, so open is OK
                    with open(newfile, 'rb') as f_in,\
                            gzip.open(man_file_gz, 'wb') as f_out:
                        f_out.writelines(f_in)
                        log.info('Compiling %s >> %s', filename, man_file_gz)

                    os.remove(newfile)
                    filename = False

            lang = man_dir[8:]
            src = build_cmd.build_base  + '/data/man' + lang  + '/' + src
            target = 'share/man' + lang + '/man1'
            data_files.append((target, [src]))
Example #15
0
def build_man(build_cmd):
    '''
    Compresses Gramps manual files
    '''
    data_files = build_cmd.distribution.data_files
    for man_dir, dirs, files in os.walk(os.path.join('data', 'man')):
        if 'gramps.1.in' in files:
            filename = os.path.join(man_dir, 'gramps.1.in')
            newdir = os.path.join(build_cmd.build_base, man_dir)
            if not(os.path.isdir(newdir) or os.path.islink(newdir)):
                os.makedirs(newdir)

            newfile = os.path.join(newdir, 'gramps.1')
            subst_vars = (('@VERSION@', VERSION), )
            substitute_variables(filename, newfile, subst_vars)

            src = 'gramps.1'
            if not args.no_compress_manpages:
                import gzip
                src += '.gz'
                man_file_gz = os.path.join(newdir, src)
                if os.path.exists(man_file_gz):
                    if newer(filename, man_file_gz):
                        os.remove(man_file_gz)
                    else:
                        filename = False
                        os.remove(newfile)

                if filename:
                    #Binary io, so open is OK
                    with open(newfile, 'rb') as f_in,\
                            gzip.open(man_file_gz, 'wb') as f_out:
                        f_out.writelines(f_in)
                        log.info('Compiling %s >> %s', filename, man_file_gz)

                    os.remove(newfile)
                    filename = False

            lang = man_dir[8:]
            src = build_cmd.build_base  + '/data/man' + lang  + '/' + src
            target = 'share/man' + lang + '/man1'
            data_files.append((target, [src]))
Example #16
0
def build_trans(build_cmd):
    '''
    Translate the language files into gajim.mo
    '''
    for lang in ALL_LINGUAS:
        po_file = os.path.join('po', lang + '.po')
        mo_file = os.path.join(build_dir, 'mo', lang, 'LC_MESSAGES', 'gajim.mo')
        mo_dir = os.path.dirname(mo_file)
        if not (os.path.isdir(mo_dir) or os.path.islink(mo_dir)):
            os.makedirs(mo_dir)

        if newer(po_file, mo_file):
            cmd = 'msgfmt %s -o %s' % (po_file, mo_file)
            if os.system(cmd) != 0:
                os.remove(mo_file)
                msg = 'ERROR: Building language translation files failed.'
                ask = msg + '\n Continue building y/n [n] '
                reply = input(ask)
                if reply in ['n', 'N']:
                    raise SystemExit(msg)
            log.info('Compiling %s >> %s', po_file, mo_file)
Example #17
0
def build_trans(build_cmd):
    '''
    Translate the language files into gajim.mo
    '''
    for lang in ALL_LINGUAS:
        po_file = Path('po') / (lang + '.po')
        mo_file = build_dir / 'mo' / lang / 'LC_MESSAGES' / 'gajim.mo'
        mo_dir = mo_file.parent
        if not (mo_dir.is_dir() or mo_dir.is_symlink()):
            mo_dir.mkdir(parents=True)

        if newer(po_file, mo_file):
            cmd = f'msgfmt {po_file} -o {mo_file}'
            if os.system(cmd) != 0:
                mo_file.unlink()
                msg = 'ERROR: Building language translation files failed.'
                ask = msg + '\n Continue building y/n [n] '
                reply = input(ask)
                if reply in ['n', 'N']:
                    raise SystemExit(msg)
            log.info('Compiling %s >> %s', po_file, mo_file)
Example #18
0
def build_man(build_cmd):
    """
    Compresses Gramps manual files
    """
    data_files = build_cmd.distribution.data_files
    for man_dir, dirs, files in os.walk(os.path.join("data", "man")):
        if "gramps.1.in" in files:
            filename = os.path.join(man_dir, "gramps.1.in")
            newdir = os.path.join(build_cmd.build_base, man_dir)
            if not (os.path.isdir(newdir) or os.path.islink(newdir)):
                os.makedirs(newdir)

            newfile = os.path.join(newdir, "gramps.1")
            subst_vars = (("@VERSION@", VERSION),)
            substitute_variables(filename, newfile, subst_vars)

            import gzip

            man_file_gz = os.path.join(newdir, "gramps.1.gz")
            if os.path.exists(man_file_gz):
                if newer(filename, man_file_gz):
                    os.remove(man_file_gz)
                else:
                    filename = False
                    os.remove(newfile)

            if filename:
                # Binary io, so open is OK
                with open(newfile, "rb") as f_in, gzip.open(man_file_gz, "wb") as f_out:
                    f_out.writelines(f_in)
                    log.info("Compiling %s >> %s", filename, man_file_gz)

                os.remove(newfile)
                filename = False

            lang = man_dir[8:]
            src = build_cmd.build_base + "/data/man" + lang + "/gramps.1.gz"
            target = "share/man" + lang + "/man1"
            data_files.append((target, [src]))
Example #19
0
 def run(self):
     # Before importing markdown, tweak sys.path to import from the
     # build directory (2to3 might have run on the library).
     bld_cmd = self.get_finalized_command("build")
     sys.path.insert(0, bld_cmd.build_lib)
     try:
         import markdown
     except ImportError:
         print('skipping build_docs: Markdown "import" failed!')
     else:
         with codecs.open("docs/_template.html", encoding="utf-8") as f:
             template = f.read()
         self.md = markdown.Markdown(extensions=["extra", "toc", "meta"])
         for infile in self.docs:
             outfile, ext = os.path.splitext(infile)
             if ext == ".txt":
                 # Copy src to .txt file
                 srcfile = outfile + ".txt"
                 srcfile = change_root(self.build_base, srcfile)
                 self.mkpath(os.path.split(srcfile)[0])
                 self.copy_file(infile, srcfile)
                 # Render html file
                 outfile += ".html"
                 outfile = change_root(self.build_base, outfile)
                 self.mkpath(os.path.split(outfile)[0])
                 if self.force or newer(infile, outfile):
                     if self.verbose:
                         print("Converting %s -> %s" % (infile, outfile))
                     if not self.dry_run:
                         with codecs.open(infile, encoding="utf-8") as f:
                             src = f.read()
                         out = template % self._get_context(src, outfile)
                         doc = open(outfile, "wb")
                         doc.write(out.encode("utf-8"))
                         doc.close()
             else:
                 outfile = change_root(self.build_base, infile)
                 self.mkpath(os.path.split(outfile)[0])
                 self.copy_file(infile, outfile)
Example #20
0
def build_man(build_cmd):
    '''
    Compress Gajim manual files
    '''
    newdir = build_dir / 'man'
    if not (newdir.is_dir() or newdir.is_symlink()):
        newdir.mkdir()

    for man in MAN_FILES:
        filename = Path('data') / man
        man_file_gz = newdir / (man + '.gz')
        if man_file_gz.exists():
            if newer(filename, man_file_gz):
                man_file_gz.unlink()
            else:
                continue

        import gzip
        # Binary io, so open is OK
        with open(filename, 'rb') as f_in,\
                gzip.open(man_file_gz, 'wb') as f_out:
            f_out.writelines(f_in)
            log.info('Compiling %s >> %s', filename, man_file_gz)
Example #21
0
def build_man(build_cmd):
    '''
    Compress Gajim manual files
    '''
    newdir = os.path.join(build_dir, 'man')
    if not (os.path.isdir(newdir) or os.path.islink(newdir)):
        os.makedirs(newdir)

    for man in MAN_FILES:
        filename = os.path.join('data', man)
        man_file_gz = os.path.join(newdir, man + '.gz')
        if os.path.exists(man_file_gz):
            if newer(filename, man_file_gz):
                os.remove(man_file_gz)
            else:
                filename = False

        if filename:
            import gzip
            # Binary io, so open is OK
            with open(filename, 'rb') as f_in,\
                    gzip.open(man_file_gz, 'wb') as f_out:
                f_out.writelines(f_in)
                log.info('Compiling %s >> %s', filename, man_file_gz)
Example #22
0
 def run(self):
     # Before importing markdown, tweak sys.path to import from the 
     # build directory (2to3 might have run on the library).
     bld_cmd = self.get_finalized_command("build")
     sys.path.insert(0, bld_cmd.build_lib)
     try:
         import markdown
     except ImportError:
         print ('skipping build_docs: Markdown "import" failed!')
     else:
         template = codecs.open('docs/_template.html', encoding='utf-8').read()
         md = markdown.Markdown(extensions=['extra', 'toc'])
         for infile, title in self.docs:
             outfile, ext = os.path.splitext(infile)
             if ext == '.md':
                 outfile += '.html'
                 outfile = change_root(self.build_base, outfile)
                 self.mkpath(os.path.split(outfile)[0])
                 if self.force or newer(infile, outfile):
                     if self.verbose:
                         print ('Converting %s -> %s' % (infile, outfile))
                     if not self.dry_run:
                         src = codecs.open(infile, encoding='utf-8').read()
                         out = template % {
                             'title': title, 
                             'body' : md.convert(src),
                             'toc'  : md.toc,
                         }
                         md.reset()
                         doc = open(outfile, 'wb')
                         doc.write(out.encode('utf-8'))
                         doc.close()
             else:
                 outfile = change_root(self.build_base, infile)
                 self.mkpath(os.path.split(outfile)[0])
                 self.copy_file(infile, outfile)
Example #23
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.core import setup, Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os
del os.link

if newer('./src/getdate.y', './src/getdate.c'):
    execute(spawn,
            (['bison', '-y', '-o', './src/getdate.c', './src/getdate.y'], ))

setup(
    name='python-kadmin',
    version='0.1.1',
    description='Python module for kerberos admin (kadm5)',
    url='https://github.com/russjancewicz/python-kadmin',
    download_url=
    'https://github.com/russjancewicz/python-kadmin/tarball/v0.1.1',
    author='Russell Jancewicz',
    author_email='*****@*****.**',
    license='MIT',
    ext_modules=[
        Extension("kadmin",
Example #24
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.core import setup, Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os
del os.link

if newer('getdate.y', 'getdate.c'):
    execute(spawn, (['bison', '-y', '-o', 'getdate.c', 'getdate.y'],))

setup(name='python-kadmin',
      version='0.1',
      description='Python module for kerberos admin (kadm5)',
      url='https://github.com/russjancewicz/python-kadmin',
      author='Russell Jancewicz',
      author_email='*****@*****.**',
      license='MIT',
      ext_modules=[
          Extension(
              "kadmin",
              libraries=["krb5", "kadm5clnt", "kdb5"],
              include_dirs=["/usr/include/", "/usr/include/et/"],
              sources=[
Example #25
0
# -*- coding: utf-8 -*-

from distutils.core import setup, Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os

del os.link

if newer("getdate.y", "getdate.c"):
    execute(spawn, (["bison", "-y", "-o", "getdate.c", "getdate.y"],))

setup(
    name="python-kadmin",
    version="0.1",
    description="Python module for kerberos admin (kadm5)",
    url="https://github.com/russjancewicz/python-kadmin",
    download_url="https://github.com/russjancewicz/python-kadmin/tarball/0.0.1",
    author="Russell Jancewicz",
    author_email="*****@*****.**",
    license="MIT",
    ext_modules=[
        Extension(
            "kadmin",
            libraries=["krb5", "kadm5clnt", "kdb5"],
Example #26
0
from distutils.util import newer, spawn

v = time.strftime("%Y%m%d%H%M")
projectname = "getdate"

#module1 = Extension("libgetdate") #, sources=["getdate.tab.c", "getdate.c"])

extmodules = []
extmodules.append(
    Extension("libgetdate", [
        "pygetdate.c", "getdate-parser.c", "getdate-lexer-original.c",
        "getdate-timezones.c"
    ]))
grammary = "getdate-parser.y"
grammarc = "getdate-parser.c"
if newer(grammary, grammarc):
    spawn(["make", grammarc], verbose=1)

setup(
    name=projectname,
    version=v,
    url="http://projects.zoidtechnologies.com/%s/" % (projectname),
    author="zoid technologies",
    author_email="*****@*****.**" % (projectname),
    py_modules=[
        "getdate",
    ],
    #  headers=["xtime.h"],
    #  ext_modules=[Extension("libgetdate", ["pygetdate.c", "getdate-parser.c", "getdate-lexer-original.c", "getdate-timezones.c"])] # module1,]
    ext_modules=extmodules,
    classifiers=[
Example #27
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.core import setup, Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os
del os.link

if newer('./src/getdate.y', './src/getdate.c'):
    execute(spawn, (['bison', '-y', '-o', './src/getdate.c', './src/getdate.y'],))

setup(name='python-kadmin',
      version='0.1.1',
      description='Python module for kerberos admin (kadm5)',
      url='https://github.com/russjancewicz/python-kadmin',
      download_url='https://github.com/russjancewicz/python-kadmin/tarball/v0.1.1',
      author='Russell Jancewicz',
      author_email='*****@*****.**',
      license='MIT',
      ext_modules=[
          Extension(
              "kadmin",
              libraries=["krb5", "kadm5clnt", "kdb5"],
              include_dirs=["/usr/include/", "/usr/include/et/"],