def substitute(): options.order('substitutions', add_rest=True) substitutions = options.patterns if hasattr(options.substitute, 'install_conf'): substitutions['@CONFDIR@'] = options.substitute.install_conf if hasattr(options.substitute, 'install_data'): substitutions['@DATADIR@'] = options.substitute.install_data if hasattr(options.substitute, 'install_sbin'): substitutions['@SBINDIR@'] = options.substitute.install_sbin subRE = re.compile('('+'|'.join(options.patterns.keys())+')+') for filename in options.onfiles: infile = paver_path(filename + '.in') if not infile.exists(): raise PavementError('Nonexistent file listed in substitute: %s' % infile) outf = paver_path(filename) contents = [] for line in infile.lines(encoding='utf8'): matches = subRE.search(line) if matches: for pattern in substitutions: line = line.replace(pattern, substitutions[pattern]) contents.append(line) outf.write_lines(contents, encoding='utf8')
def _install_catalogs(args, paths): '''Install message catalogs in their proper location on the filesystem. Note: To use this with non-default commandline arguments, you must use ''' # Rebuild message catalogs if 'skip_build' not in args and 'skip-build' not in args: call_task('make_catalogs') options.order('i18n', add_rest=True) # Setup the install_dir cat_dir = _apply_root(args, paths.localedir) for catalog in paver_path(options.builddir).walkfiles('*.mo'): locale_dir = catalog.dirname() path = paver_path('.') for index, nextpath in enumerate(locale_dir.splitall()): path = path.joinpath(nextpath) if paver_path(options.builddir).samefile(path): install_locale = cat_dir.joinpath(os.path.join( *locale_dir.splitall()[index + 1:])) install_locale.makedirs(mode=0755) install_locale = install_locale.joinpath(catalog.basename()) if install_locale.exists(): install_locale.remove() dry('cp %s %s'% (catalog, install_locale), catalog.copy, install_locale) dry('chmod 0644 %s'% install_locale, install_locale.chmod, 0644)
def _apply_root(args, path): '''Add the root value to the start of the path''' if 'root' in args: if path.startswith('/'): path = path[1:] path = paver_path(os.path.join(args['root'], path)) else: path = paver_path(path) return path
def _apply_root(args, path): """Add the root value to the start of the path""" if "root" in args: if path.startswith("/"): path = path[1:] path = paver_path(os.path.join(args["root"], path)) else: path = paver_path(path) return path
def make_catalogs(): '''Compile all message catalogs for release''' options.order('i18n', add_rest=True) for po_file in glob.glob('po/*.po'): locale, ext = os.path.splitext(os.path.basename(po_file)) build_dir = paver_path(os.path.join(options.builddir, locale, 'LC_MESSAGES')) try: build_dir.makedirs(mode=0755) except OSError, e: # paver < 1.0 raises if directory exists if e.errno == 17: pass else: raise if 'compile_catalog' in options.keys(): defaults = options.compile_catalog else: defaults = Bunch(domain=options.domain, directory=options.builddir) options.compile_catalog = defaults defaults.update({'input-file': po_file, 'locale': locale}) ### FIXME: compile_catalog cannot handle --dry-run on its own dry('paver compile_catalog -D %(domain)s -d %(directory)s' ' -i %(input-file)s --locale %(locale)s' % defaults, paver_sh, 'paver compile_catalog -D %(domain)s' \ ' -d %(directory)s -i %(input-file)s' \ ' --locale %(locale)s' % defaults)
def make_catalogs(): '''Compile all message catalogs for release''' options.order('i18n', add_rest=True) for po_file in glob.glob('translations/*.po'): locale, ext = os.path.splitext(os.path.basename(po_file)) build_dir = paver_path(os.path.join(options.builddir, locale, 'LC_MESSAGES')) try: build_dir.makedirs(mode=0755) except OSError, e: # paver < 1.0 raises if directory exists if e.errno == 17: pass else: raise if 'compile_catalog' in options.keys(): defaults = options.compile_catalog else: defaults = Bunch(domain=options.domain, directory=options.builddir) options.compile_catalog = defaults defaults.update({'input-file': po_file, 'locale': locale}) ### FIXME: compile_catalog cannot handle --dry-run on its own dry('paver compile_catalog -D %(domain)s -d %(directory)s' ' -i %(input-file)s --locale %(locale)s' % defaults, paver_sh, 'paver compile_catalog -D %(domain)s' \ ' -d %(directory)s -i %(input-file)s' \ ' --locale %(locale)s' % defaults)
def make_catalogs(): """Compile all message catalogs for release""" options.order("i18n", add_rest=True) for po_file in glob.glob("translations/*.po"): locale, ext = os.path.splitext(os.path.basename(po_file)) build_dir = paver_path(os.path.join(options.builddir, locale, "LC_MESSAGES")) try: build_dir.makedirs(mode=0755) except OSError, e: # paver < 1.0 raises if directory exists if e.errno == 17: pass else: raise if "compile_catalog" in options.keys(): defaults = options.compile_catalog else: defaults = Bunch(domain=options.domain, directory=options.builddir) options.compile_catalog = defaults defaults.update({"input-file": po_file, "locale": locale}) ### FIXME: compile_catalog cannot handle --dry-run on its own dry( "paver compile_catalog -D %(domain)s -d %(directory)s" " -i %(input-file)s --locale %(locale)s" % defaults, paver_sh, "paver compile_catalog -D %(domain)s" " -d %(directory)s -i %(input-file)s" " --locale %(locale)s" % defaults, )
def _install_catalogs(args): """Install message catalogs in their proper location on the filesystem. Note: To use this with non-default commandline arguments, you must use """ # Rebuild message catalogs if "skip_build" not in args and "skip-build" not in args: call_task("make_catalogs") options.order("i18n", add_rest=True) # Setup the install_dir if "install_catalogs" in args: cat_dir = args["install_catalogs"] elif "install_data" in args: cat_dir = os.path.join(args["install_data"], "locale") else: cat_dir = options.installdir # Setup the install_dir cat_dir = _apply_root(args, cat_dir) for catalog in paver_path(options.builddir).walkfiles("*.mo"): locale_dir = catalog.dirname() path = paver_path(".") for index, nextpath in enumerate(locale_dir.splitall()): path = path.joinpath(nextpath) if paver_path(options.builddir).samefile(path): install_locale = cat_dir.joinpath(os.path.join(*locale_dir.splitall()[index + 1 :])) try: install_locale.makedirs(mode=0755) except OSError, e: # paver < 1.0 raises if directory exists if e.errno == 17: pass else: raise install_locale = install_locale.joinpath(catalog.basename()) if install_locale.exists(): install_locale.remove() dry("cp %s %s" % (catalog, install_locale), catalog.copy, install_locale) dry("chmod 0644 %s" % install_locale, install_locale.chmod, 0644)
def _install_conf(args, paths): '''Install configuration files''' options.order('setup', add_rest=True) if 'skip_build' not in args and 'skip-build' not in args: call_task('substitute') options.order('data', add_rest=True) # Setup the install_dir conf_dir = apply_root(args, paths.sysconfdir) conf_dir.joinpath(options.name) if not conf_dir.exists(): conf_dir.makedirs(mode=0755) for conf_file in options.data.conffiles: conf_file = paver_path(conf_file) installfile = conf_dir.joinpath(conf_file) dry('cp %s %s' % (conf_file, installfile), conf_file.copy, install_file) dry('chmod 0644 %s'% install_locale, install_locale.chmod, 0644) for catalog in paver_path(options.builddir).walkfiles('*.mo'): locale_dir = catalog.dirname() path = paver_path('.') for index, nextpath in enumerate(locale_dir.splitall()): path = path.joinpath(nextpath) if paver_path(options.builddir).samefile(path): install_locale = cat_dir.joinpath(os.path.join( *locale_dir.splitall()[index + 1:])) install_locale.makedirs(mode=0755) install_locale = install_locale.joinpath(catalog.basename()) if install_locale.exists(): install_locale.remove() dry('cp %s %s'% (catalog, install_locale), catalog.copy, install_locale) dry('chmod 0644 %s'% install_locale, install_locale.chmod, 0644) pass