def __proceed_files( self, dir_path, manifest ):
     for file_path in files_iterator( dir_path, is_recursive=False ):
         file_name = os.path.split( file_path )[1]
         if file_name in to_be_deleted_files:
             continue
         if file_name in [ 'www_configuration.py', 'MANIFEST.readme' ]:
             continue
         file_ext = os.path.splitext( file_name )[1]
         if file_ext in to_be_deleted_file_exts:
             continue
         if file_ext.endswith( '~' ):
             continue
         manifest.write( file_path[ len( self.root ) + 1 : ] + os.linesep )
    , '*.def'
    , '*.exp'
    , '*.lib'
    , '*.scons'
    , '*.bak'
    , '*.pdb'
    , '*.htm'
    , '*.idb'
    , '*.pdb'
    , '*.dat'
    , '*.ncb'
    , '*.out'
    , '*.dblite'
]

to_be_deleted_files = [ '.sconsign' ]

if __name__ == '__main__':
    sources_dir = os.path.join( os.path.abspath( os.curdir ), '..' )

    for file in files_iterator( sources_dir, to_be_deleted_file_exts ):
        if 'gccxml_bin' in file:
            continue
        print 'removing : ', file
        os.remove( file )

    for file in files_iterator( sources_dir ):
        if os.path.split( file )[1] in to_be_deleted_files:
            print 'removing : ', file
            os.remove( file )
Пример #3
0
                f = codecs.open( fpath, 'rb', encoding )
                fcontent = f.read()
                f.close()
                return fcontent
            except UnicodeDecodeError, err:
                last_error = err
        else:
            raise last_error

    def write_content( fpath, content ):
        fcontent_new = content #unicode( content, 'UTF8' )
        fcontent_new = fcontent_new.lstrip( unicode( codecs.BOM_UTF8, "utf8" ) )
        f = codecs.open( fpath, 'w+b', 'UTF8' )
        f.write( fcontent_new )
        f.close()

    write_content( fpath, read_content( fpath ) )


if __name__ == '__main__':
    sources_dir = os.path.join( os.path.abspath( os.curdir ), '..' )
    dirs_to_go = [ os.path.join( sources_dir, 'pydsc_dev' )
                   , os.path.join( sources_dir, 'pygccxml_dev' )
                   , os.path.join( sources_dir, 'pyplusplus_dev' ) ]

    for fpath in files_iterator( dirs_to_go, to_be_validated_file_exts ):

        print 'converting %s' % fpath
        ensure_utf8( fpath )
        print 'converting %s - done' % fpath