예제 #1
0
파일: util.py 프로젝트: MFRIbrahim/AML_HTR
def is_file(path):
    return p_exists(path) and p_isfile(path)
예제 #2
0
def _find_dirs(topdir='lib'):
    if p_isdir(topdir):
        for _dir in os.walk(topdir):
            if p_isfile(p_join(_dir[0], '__init__.py')):
                yield _dir[0]
예제 #3
0
def _find_dirs(topdir='lib'):
    if p_isdir(topdir):
        for _dir in os.walk(topdir):
            if p_isfile(p_join(_dir[0], '__init__.py')):
                yield _dir[0]
예제 #4
0
        project['version'] = sys.argv[2]
    else:
        #NB: default to bumping the version up by one patch level, e.g.: 0.1.2 -> 0.1.3
        #    to bump a minor or major level, specify the version string manually as second arg instead
        if project['repotype'] == 'git':
            if not p_isdir('.git'):
                sys.stderr.write("You tried to update version information but the repo files appear not to be in this directory.\n".format(project['repotype']))
                sys.exit(1)
            _projectversionstr = subprocess.Popen(['git describe --abbrev=0'], stdout=subprocess.PIPE, shell=True).communicate()[0].rstrip('\r?\n').split('.')
        else:
            sys.stderr.write("Repo type {} not implemented yet.\n".format(project['repotype']))
            sys.exit(1)
        project['version'] = '.'.join(_projectversionstr[:-1] + [unicode(int(_projectversionstr[-1]) + 1)])
    for file_to_expand in project['files_to_expand']:
        file_to_expand = p_join('.', file_to_expand)
        if p_isfile(file_to_expand + '.in'):
            if p_isfile(file_to_expand) and p_getmtime(file_to_expand) > p_getmtime(file_to_expand + '.in'):
                sys.stderr.write('WARNING: File to generate "{}" is already newer than input file "{}". "touch" the input file to override. Skipping.\n'.format(file_to_expand, file_to_expand + '.in'))
            else:
                with open(file_to_expand + '.in', 'r') as fh_in:
                    file_content = fh_in.read().decode('utf-8')
                for macro_to_replace in project['macros_to_replace']:
                    file_content = re.sub(r'@' + macro_to_replace + r'@', project[macro_to_replace], file_content)
                with open(file_to_expand, 'w') as fh_out:
                    fcntl.lockf(fh_out, fcntl.LOCK_EX)
                    fh_out.write(file_content.encode('utf-8'))
        else:
            sys.stderr.write('WARNING: Specified file to expand "{}" does not have an input file "{}". Skipping.\n'.format(file_to_expand, file_to_expand + '.in'))
else:
    METADATA = {
        'cmdclass': {"install_data": MyInstallData, "install_scripts": MyInstallScripts},
예제 #5
0
                 .format(project['repotype']))
             sys.exit(1)
         _projectversionstr = subprocess.Popen(
             ['git describe --abbrev=0'],
             stdout=subprocess.PIPE,
             shell=True).communicate()[0].rstrip('\r?\n').split('.')
     else:
         sys.stderr.write("Repo type {} not implemented yet.\n".format(
             project['repotype']))
         sys.exit(1)
     project['version'] = '.'.join(
         _projectversionstr[:-1] +
         [unicode(int(_projectversionstr[-1]) + 1)])
 for file_to_expand in project['files_to_expand']:
     file_to_expand = p_join('.', file_to_expand)
     if p_isfile(file_to_expand + '.in'):
         if p_isfile(file_to_expand) and p_getmtime(
                 file_to_expand) > p_getmtime(file_to_expand + '.in'):
             sys.stderr.write(
                 'WARNING: File to generate "{}" is already newer than input file "{}". "touch" the input file to override. Skipping.\n'
                 .format(file_to_expand, file_to_expand + '.in'))
         else:
             with open(file_to_expand + '.in', 'r') as fh_in:
                 file_content = fh_in.read().decode('utf-8')
             for macro_to_replace in project['macros_to_replace']:
                 file_content = re.sub(r'@' + macro_to_replace + r'@',
                                       project[macro_to_replace],
                                       file_content)
             with open(file_to_expand, 'w') as fh_out:
                 fcntl.lockf(fh_out, fcntl.LOCK_EX)
                 fh_out.write(file_content.encode('utf-8'))