Mercurial > piecrust2
view piecrust/osutil.py @ 621:8f9c0bdb3724
publish: Polish/refactor the publishing workflows.
* Add a `--preview` option.
* The `--list` option gives a nicer output, and prints warnings/errors for
incorrect configuration.
* Moved most of the `shell` code into a base class that's reusable.
* Simplified the code to log publishing to a file.
* Nicer output overall, with times.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 08 Feb 2016 20:44:26 -0800 |
parents | 6ef89b31ddda |
children | a4ac464a45b3 |
line wrap: on
line source
import os import sys import glob as _system_glob import unicodedata walk = os.walk listdir = os.listdir glob = _system_glob.glob if sys.platform == 'darwin': def _walk(top, **kwargs): for dirpath, dirnames, filenames in os.walk(top, **kwargs): dirpath = _from_osx_fs(dirpath) dirnames[:] = list(map(_from_osx_fs, dirnames)) filenames[:] = list(map(_from_osx_fs, filenames)) yield dirpath, dirnames, filenames def _listdir(path='.'): for name in os.listdir(path): name = _from_osx_fs(name) yield name def _glob(pathname): pathname = _to_osx_fs(pathname) matches = _system_glob.glob(pathname) return list(map(_from_osx_fs, matches)) def _from_osx_fs(s): return unicodedata.normalize('NFC', s) def _to_osx_fs(s): return unicodedata.ucd_3_2_0.normalize('NFD', s) global walk, listdir, glob walk = _walk listdir = _listdir glob = _glob