Was a zone file hash issued by a name?  Return {'result': True/False}
335951
def rpc_is_name_zonefile_hash(self, name, zonefile_hash, **con_info):
        
        if not check_name(name) and not check_subdomain(name):
            return {'error': 'invalid name', 'http_status': 400}

        if not check_string(zonefile_hash, min_length=LENGTHS['value_hash']*2, max_length=LENGTHS['value_hash']*2, pattern=OP_HEX_PATTERN):
            return {'error': 'invalid zone file hash', 'http_status': 400}
        
        was_set = None
        if check_name(name):
            # on-chain name 
            db = get_db_state(self.working_dir)
            was_set = db.is_name_zonefile_hash(name, zonefile_hash)
            db.close()
        else:
            # off-chain name 
            was_set = is_subdomain_zonefile_hash(name, zonefile_hash)

        return self.success_response({'result': was_set})
555656
def _check_if_zipped(self, path):
        

        filename = get_file(path).split('.')

        if filename[-1] in ['bz', 'bz2', 'gz']:
            return True

        return False
210377
def is_cached(file_name):
	

	gml_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name)

	return isfile(gml_file_path)
6294
def namedb_is_name_zonefile_hash(cur, name, zonefile_hash):
    
    select_query = 'SELECT COUNT(value_hash) FROM history WHERE history_id = ? AND value_hash = ?'
    select_args = (name,zonefile_hash)

    rows = namedb_query_execute(cur, select_query, select_args)
    count = None

    for r in rows:
        count = r['COUNT(value_hash)']
        break

    return count > 0
839484
def detached(name):
    '''
    

    '''
    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}

    zones = __salt__['zoneadm.list'](installed=True, configured=True)
    if name in zones:
        if zones[name]['state'] != 'configured':
            if __opts__['test']:
                res_detach = {'status': True}
            else:
                res_detach = __salt__['zoneadm.detach'](name)
            ret['result'] = res_detach['status']
            if ret['result']:
                ret['changes'][name] = 'detached'
                ret['comment'] = 'The zone {0} was detached.'.format(name)
            else:
                ret['comment'] = []
                ret['comment'].append('Failed to detach zone {0}!'.format(name))
                if 'message' in res_detach:
                    ret['comment'].append(res_detach['message'])
                ret['comment'] = "\n".join(ret['comment'])
        else:
            ret['result'] = True
            ret['comment'] = 'zone {0} already detached.'.format(name)
    else:
        ## note: a non existing zone is not attached, we do not consider this a failure
        ret['result'] = True
        ret['comment'] = 'zone {0} is not configured!'.format(name)

    return ret
127051
def remove filename
      return false unless source_hash.key?(filename)
      source_hash.delete filename
      true
    end
1346297
def _get_cached_file_name(bucket_name, saltenv, path):
    '''
    
    '''

    file_path = os.path.join(_get_cache_dir(), saltenv, bucket_name, path)

    # make sure bucket and saltenv directories exist
    if not os.path.exists(os.path.dirname(file_path)):
        os.makedirs(os.path.dirname(file_path))

    return file_path
935036
def __isValidFilename(self, filename):
        """"""
        if filename and isinstance(filename, string_types):
            if re.match(r'^[\w\d\_\-\.]+$', filename, re.I):
                if self.__isValidTGZ(filename) or self.__isValidZIP(filename):
                    return True
        return False
859692
def verify_zonefile( zonefile_str, value_hash ):
    
    zonefile_hash = get_zonefile_data_hash( zonefile_str )
    if zonefile_hash != value_hash:
        log.debug("Zonefile hash mismatch: expected %s, got %s" % (value_hash, zonefile_hash))
        return False 

    return True
206753
def get_hash(fName, readSize, dire=pDir()):
    
    if not fileExists(fName, dire):
        return -1
    readSize = readSize * 1024 # bytes to be read
    fName = os.path.join(dire, fName) # name coupled with path
    with open(fName, 'rb') as f:
        size = os.path.getsize(fName)
        if size < readSize * 2:
            return -1
        data = f.read(readSize)
        f.seek(-readSize, os.SEEK_END)
        data += f.read(readSize)
    return md5(data).hexdigest()
640876
def store_atlas_zonefile_data(zonefile_data, zonefile_dir, fsync=True):
    
    if not os.path.exists(zonefile_dir):
        os.makedirs(zonefile_dir, 0700 )

    zonefile_hash = get_zonefile_data_hash( zonefile_data )
    
    # only store to the latest supported directory
    zonefile_path = atlas_zonefile_path( zonefile_dir, zonefile_hash )
    zonefile_dir_path = os.path.dirname(zonefile_path)

    if os.path.exists(zonefile_path):
        # already exists 
        return True

    if not os.path.exists(zonefile_dir_path):
        os.makedirs(zonefile_dir_path)

    try:
        with open( zonefile_path, "wb" ) as f:
            f.write(zonefile_data)
            f.flush()
            if fsync:
                os.fsync(f.fileno())

    except Exception, e:
        log.exception(e)
        return False
        
    return True
994783
def _HasFile(self, file_name):
    """"""
    if self._zip:
      return file_name in self._zip.namelist()
    else:
      file_path = os.path.join(self._path, file_name)
      return os.path.exists(file_path) and os.path.isfile(file_path)
371946
def check_hash(self, checker, filename, tfp):
        
        checker.report(
            self.debug,
            "Validating %%s checksum for %s" % filename)
        if not checker.is_valid():
            tfp.close()
            os.unlink(filename)
            raise DistutilsError(
                "%s validation failed for %s; "
                "possible download problem?"
                % (checker.hash.name, os.path.basename(filename))
            )
1029640
def _create_cache_key(source_file):
        
        path, name = os.path.split(source_file)
        return name + str(hash(path))
247124
def filename(name)
      # Replace space with underscore and downcase extension
      pre, dot, ext = name.rpartition('.')
      name = "#{pre.gsub(' ', '_')}.#{ext.downcase}"

      # Remove illegal characters
      # http://stackoverflow.com/questions/13517100/whats-the-difference-between-palpha-i-and-pl-i-in-ruby
      name = name.gsub(%r{[^\p{L}\-\_\.0-9]}, '')

      name
    end
98647
def is_name_zonefile_hash(name, zonefile_hash, hostport=None, proxy=None):
    
    assert hostport or proxy, 'Need hostport or proxy'
    if proxy is None:
        proxy = connect_hostport(hostport)

    zonefile_check_schema = {
        'type': 'object',
        'properties': {
            'result': {
                'type': 'boolean'
            }
        },
        'required': [ 'result' ]
    }

    schema = json_response_schema(zonefile_check_schema)
    resp = {}
    try:
        resp = proxy.is_name_zonefile_hash(name, zonefile_hash)
        resp = json_validate(schema, resp)
        if json_is_error(resp):
            return resp

    except ValidationError as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
        return resp

    return {'result': resp['result']}
282114
def check_if_committed(self, filename: str) -> bool:
        
        if os.path.isfile(filename + '.json.xz'):
            filename += '.json.xz'
        elif os.path.isfile(filename + '.json'):
            filename += '.json'
        else:
            return False
        try:
            load_structure_from_file(self.context, filename)
            return True
        except (FileNotFoundError, lzma.LZMAError, json.decoder.JSONDecodeError):
            return False