def _files_glob(path, globs, trim_prefix='', realpath=False): if not path: path = '.' if realpath: path = p_realpath(path) if trim_prefix: trim_prefix = p_realpath(trim_prefix) elif trim_prefix: trim_prefix = p_normpath(trim_prefix) for globlet in globs: globresults = glob.glob(p_normpath(p_join(path, globlet))) for globresult in globresults: if trim_prefix and len(trim_prefix + _dirsep) < len(globresult) and globresult[:len(trim_prefix + _dirsep)] == trim_prefix + _dirsep: result = globresult[len(trim_prefix + _dirsep):] else: result = globresult yield unicode(result)
def _files_glob(path, globs, trim_prefix='', realpath=False): if not path: path = '.' if realpath: path = p_realpath(path) if trim_prefix: trim_prefix = p_realpath(trim_prefix) elif trim_prefix: trim_prefix = p_normpath(trim_prefix) for globlet in globs: globresults = glob.glob(p_normpath(p_join(path, globlet))) for globresult in globresults: if trim_prefix and len(trim_prefix + _dirsep) < len( globresult ) and globresult[:len(trim_prefix + _dirsep)] == trim_prefix + _dirsep: result = globresult[len(trim_prefix + _dirsep):] else: result = globresult yield unicode(result)
if __name__ != '__main__': raise RuntimeError('This script should only be run directly. It is not a library.') import os, sys, shutil, tempfile, glob, sysconfig, re, fcntl, subprocess, importlib from os.path import join as p_join, dirname as p_dirname, realpath as p_realpath, basename as p_basename, \ isdir as p_isdir, isfile as p_isfile, pardir as p_pardir, getmtime as p_getmtime, \ normpath as p_normpath, splitdrive as p_splitdrive from distutils.dir_util import mkpath as d_mkpath from distutils.command.install_data import install_data as d_install_data from distutils.command.install_scripts import install_scripts as d_install_scripts from distutils.core import setup from distutils.dist import DistributionMetadata ## GLOBAL VARS SETUP ## _newdirsep = p_realpath('.') _dirsep = '' while _newdirsep != _dirsep: # iterate to find '/' or the system equivalent _dirsep = _newdirsep _newdirsep = p_dirname(_dirsep) _dirsep = p_splitdrive(_dirsep)[1] del _newdirsep _projectpath = p_realpath('.') _configvars = sysconfig.get_config_vars() _configpaths = sysconfig.get_paths() if p_basename(_configpaths['data']) == 'usr': #GOTCHA: '[path]/usr', not only '/usr', to allow for virtualenvs... _configprefix = p_normpath(p_join(_configpaths['data'], p_pardir, 'etc')) # "[path]/usr" => "[path]/etc" ("[path]/usr/etc", FHS-friendly) else: _configprefix = p_join(_configpaths['data'], 'etc') # "[path]/[something_else]" => "[path]/[something_else]/etc" _dirsep, _projectpath, _configprefix = unicode(_dirsep), unicode(_projectpath), unicode(_configprefix)
raise RuntimeError( 'This script should only be run directly. It is not a library.') import os, sys, shutil, tempfile, glob, sysconfig, re, fcntl, subprocess, importlib from os.path import join as p_join, dirname as p_dirname, realpath as p_realpath, basename as p_basename, \ isdir as p_isdir, isfile as p_isfile, pardir as p_pardir, getmtime as p_getmtime, \ normpath as p_normpath, splitdrive as p_splitdrive from distutils.dir_util import mkpath as d_mkpath from distutils.command.install_data import install_data as d_install_data from distutils.command.install_scripts import install_scripts as d_install_scripts from distutils.core import setup from distutils.dist import DistributionMetadata ## GLOBAL VARS SETUP ## _newdirsep = p_realpath('.') _dirsep = '' while _newdirsep != _dirsep: # iterate to find '/' or the system equivalent _dirsep = _newdirsep _newdirsep = p_dirname(_dirsep) _dirsep = p_splitdrive(_dirsep)[1] del _newdirsep _projectpath = p_realpath('.') _configvars = sysconfig.get_config_vars() _configpaths = sysconfig.get_paths() if p_basename( _configpaths['data'] ) == 'usr': #GOTCHA: '[path]/usr', not only '/usr', to allow for virtualenvs... _configprefix = p_normpath( p_join(_configpaths['data'], p_pardir, 'etc') ) # "[path]/usr" => "[path]/etc" ("[path]/usr/etc", FHS-friendly)