Verify that a source file name is valid.
766358
private static void checkFilePattern(String s) throws ProblemException {
        // File names like foo/bar/gamma/Bar.java are allowed,
        // as well as /bar/jndi.properties as well as,
        // */bar/Foo.java
        Pattern p = null;
        if (File.separatorChar == '\\') {
            p = Pattern.compile("\\*?(.+\\\\)*.+");
        }
        else if (File.separatorChar == '/') {
            p = Pattern.compile("\\*?(.+/)*.+");
        } else {
            throw new ProblemException("This platform uses the unsupported "+File.separatorChar+
                                      " as file separator character. Please add support for it!");
        }
        Matcher m = p.matcher(s);
        if (!m.matches()) {
            throw new ProblemException("The string \""+s+"\" is not a proper file name.");
        }
    }
501052
def verify_uploaded_file(
            self,
            destination_folder_id,
            source_path,
            verbose = True,
    ):
        '''
        
        '''
        source_file_size = os.stat(source_path).st_size

        total_part_size = 0
        file_position = 0
        uploaded_box_file_ids = self.find_file( destination_folder_id, os.path.basename( source_path ) )
        total_sha1 = hashlib.sha1()
        for i, file_id in enumerate(uploaded_box_file_ids):
            file_info = self.client.file( file_id = file_id ).get()
            uploaded_sha1 = file_info.response_object['sha1']
            uploaded_size = file_info.response_object['size']

            part_sha1 = read_sha1( source_path, start_byte = file_position, read_size = uploaded_size, extra_hashers = [total_sha1] )
            if part_sha1.hexdigest() != uploaded_sha1:
                print( '\n' )
                print( 'Part sha1: ' + part_sha1.hexdigest() )
                print( 'Uploaded sha1: ' + uploaded_sha1 )
                print('Sha1 hash of uploaded file {0} ({1}) does not match'.format(file_info.response_object['name'], file_id) )
                return False

            file_position += uploaded_size
            total_part_size += uploaded_size
            if len(uploaded_box_file_ids) > 1:
                print( 'Finished verifying part {0} of {1} of {2}'.format( i+1, len(uploaded_box_file_ids), file_id ) )

        assert( source_file_size == total_part_size )

        if verbose:
            print( 'Verified uploaded file {0} ({1}) with sha1: {2}'.format(source_path, file_id, total_sha1.hexdigest()) )

        return True
345923
def verify(path):
        """"""
        valid = False
        try:
            h5 = h5py.File(path, mode="r")
        except (OSError, IsADirectoryError):
            pass
        else:
            if ("file_format" in h5.attrs and
                h5.attrs["file_format"].lower() == "hyperspy" and
                    "Experiments" in h5):
                valid = True
        return valid
389428
def check_existance(f):
    """"""
    if not opath.isfile(f):
        logging.error("Nanoget: File provided doesn't exist or the path is incorrect: {}".format(f))
        sys.exit("File provided doesn't exist or the path is incorrect: {}".format(f))
748617
def assure_directory_exists(path, is_file=False):
    """"""
    if is_file:
        path = osp.dirname(path)
    # END handle file
    if not osp.isdir(path):
        os.makedirs(path)
        return True
    return False
1344704
public void validateFileDoesNotExist(UIInput<String> directory, UIInput<String> fileName, UIValidationContext validator) {
        String resourcePath = CamelXmlHelper.createFileName(directory, fileName);
        if (files.contains(resourcePath)) {
            validator.addValidationError(fileName, "A file with that name already exists!");
        }
    }
228982
def verify(self, tool):
        
        if os.path.isfile(tool['file']):
            print('Toolbox: program exists = TOK  :: ' + tool['file'])
            return True
        else:
            print('Toolbox: program exists = FAIL :: ' + tool['file'])
            return False
989204
def verify_exif(filename):
    '''
    
    '''
    # required tags in IFD name convention
    required_exif = required_fields()
    exif = ExifRead(filename)
    required_exif_exist = exif.fields_exist(required_exif)
    return required_exif_exist
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)
499815
def validate_files(pelican):
    
    for dirpath, _, filenames in os.walk(pelican.settings['OUTPUT_PATH']):
        for name in filenames:
            if should_validate(name):
                filepath = os.path.join(dirpath, name)
                validate(filepath)
730729
private void verifiedCopyFile(File sourceFile, File destFile) throws IOException {
        if(!destFile.exists()) {
            destFile.createNewFile();
        }

        FileInputStream source = null;
        FileOutputStream destination = null;
        LogVerificationInputStream verifyStream = null;
        try {
            source = new FileInputStream(sourceFile);
            destination = new FileOutputStream(destFile);
            verifyStream = new LogVerificationInputStream(env, source, sourceFile.getName());

            final byte[] buf = new byte[LOGVERIFY_BUFSIZE];

            while(true) {
                final int len = verifyStream.read(buf);
                if(len < 0) {
                    break;
                }
                destination.write(buf, 0, len);
            }

        } finally {
            if(verifyStream != null) {
                verifyStream.close();
            }
            if(destination != null) {
                destination.close();
            }
        }
    }
191963
def verify(ctx):
    """"""
    oks = run_configurations(
        skipper(verify_environments),
        read_sections,
    )
    ctx.exit(0
             if False not in oks
             else 1)
424899
def validate(self, path):
        """"""
        # Exclude hidden files and folders with '.' prefix
        if os.path.basename(path).startswith('.'):
            return False

        # Check that current path level is more than min path and less than max path
        if not self.check_level(path):
            return False

        if self.filters:
            if not self._level_filters(path):
                return False

        # Force include and exclude iterations to be strings in case of integer filters
        # Handle exclusions
        if self.to_exclude:
            if any(str(ex).lower() in path.lower() for ex in self.to_exclude):
                return False

        # Handle inclusions
        if self.to_include:
            if not any(str(inc).lower() in path.lower() for inc in self.to_include):
                return False

        return True
867476
def fileExists(fName, dire=pDir()):
    
    if os.path.isfile(os.path.join(dire, fName)):
        return True
    return False
177792
def ExistingFileOrNone(fname):
    """"""
    if os.path.isfile(fname):
        return fname
    elif fname.lower() == 'none':
        return None
    else:
        raise ValueError("%s must specify a valid file name or 'None'" % fname)
1164157
def is_valid_folder(parser, arg):
    """"""
    arg = os.path.abspath(arg)
    if not os.path.isdir(arg):
        parser.error("The folder %s does not exist!" % arg)
    else:
        return arg
637808
def verify(sigfilename, filefilename=None):
    """"""

    if gnupg is None:
        return False

    gpg = gnupg.GPG()

    with open(sigfilename, "rb") as sigfile:
        verified = gpg.verify_file(sigfile, filefilename)

        pyspread_keyid = fingerprint2keyid(config["gpg_key_fingerprint"])

        if verified.valid and verified.key_id == pyspread_keyid:
            return True

    return False