Encrypt File
        Args:
            filename: Pass the filename to encrypt.
        Returns:
            No return.
771070
def encrpyt_file(self, filename):
        '''
        
        '''
        if not os.path.exists(filename):
            print "Invalid filename %s. Does not exist" % filename
            return

        if self.vault_password is None:
            print "ENV Variable PYANSI_VAULT_PASSWORD not set"
            return

        if self.is_file_encrypted(filename):
            # No need to do anything.
            return

        cipher = 'AES256'
        vaulteditor = VaultEditor(cipher, self.vault_password, filename)
        vaulteditor.encrypt_file()
37420
def get_file_extension(filename):
    
    filename_x = filename.split('.')
    if len(filename_x) > 1:
        if filename_x[-1].strip() is not '':
            return filename_x[-1]
    return None
946774
def file(self, filename):
        
        try:  # attempt python3 approach first
            if isinstance(filename, bytes):
                bi = filename
            else:
                bi = bytes(filename, 'utf-8')
            return str(_file(self._magic_t, bi), 'utf-8')
        except:
            return _file(self._magic_t, filename.encode('utf-8'))
1223705
def load(self, filename):
        
        self.filename = filename
        with open(filename) as CFG:
            self.data = yaml.load(CFG.read())

        return self
1012539
def readme(filename, encoding='utf8'):
    

    with io.open(filename, encoding=encoding) as source:
        return source.read()
1281802
def hash(filename, algorithm='sha256'):
    
    if incompatible:
        raise Incompatible

    if algorithm not in ['sha256', 'sha384', 'sha512']:
        raise InvalidArguments('Algorithm {} not supported'.format(algorithm))

    result = call('hash', '--algorithm', algorithm, filename)

    # result is of the form:
    # <filename>:\n--hash=<algorithm>:<hash>\n
    return result.strip().split(':')[-1]
220073
def hash_file(filename):
    
    sha256 = hashlib.sha256()
    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(8192), b''):
            sha256.update(chunk)
    return 'sha256:' + sha256.hexdigest()
657558
def _read_file(self, filename):
        

        if self.__compression:
            f = gzip.GzipFile(filename, "rb")
        else:
            f = open(filename, "rb")
        res = pickle.load(f)
        f.close()
        return res
964044
def injected(self, filename):
        
        full_path = os.path.expanduser(filename)
        if not os.path.exists(full_path):
            return False
        with codecs.open(full_path, 'r+', encoding="utf-8") as fh:
            contents = fh.read()
        return self.wrapper_match.search(contents) is not None
75155
def canProcessFilename(cls, filename):
        
        supported_patterns = cls._extpattern_to_mime.keys()
        for pattern in supported_patterns:
            if fnmatch.fnmatch(filename, pattern):
                return True
        return False
1124466
def readfile(filename, binary=False):
    

    if not os.path.isfile(filename):
        return None

    try:
        flags = 'r' if not binary else 'rb'
        with open(filename, flags) as _file:
            return _file.read()

    except (OSError, IOError):
        return None
892259
def verify_file_private(filename):
    
    if platform.system().upper() != 'WINDOWS':
        filename = os.path.expanduser(filename)
        if os.path.exists(filename):
            file_stat = os.stat(filename)
            if mode_allows_group_or_other(file_stat.st_mode):
                raise ValueError(CONFIG_FILE_PERMISSIONS_ERROR)
600660
def encrypt_files(self, file_list, force_nocompress=False, force_compress=False, armored=False, checksum=False):
        """"""
        for the_file in file_list:
            self.encrypt_file(the_file, force_nocompress, force_compress, armored, checksum)
440700
def open(self, filename):
        
        filename = self.real_filename(filename)

        if not os.path.exists(filename):
            raise self.FileNotFound(filename)

        with codecs.open(filename, encoding='utf-8') as f:
            yield f
401061
private String encodeFileName(String fileName) {

		String result = Normalizer.normalize(fileName, Normalizer.Form.NFD).replaceAll("\\s+", "-")
				.replaceAll("[^A-Za-z0-9_\\-\\.]", "");
		if (result.isEmpty()) {
			result = "report";
		}
		return result;
	}
897729
def filename_to_str(self, filename):
        '''
        
        '''
        if filename.__class__ != str:
            if not IS_PY3K:
                filename = filename.encode(file_system_encoding)
            else:
                raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (filename, filename.__class__))
        return filename
1266230
def to_file(self, filename):
		
		with open(filename, 'wb') as f:
			f.write(self.to_bytes())