Return IPFS data as if file was pinned to an actual node.
326148
def dummy_ipfs_pin(path: Path) -> Dict[str, str]:
    
    ipfs_return = {
        "Hash": generate_file_hash(path.read_bytes()),
        "Name": path.name,
        "Size": str(path.stat().st_size),
    }
    return ipfs_return
184997
def load_child_node(self, key):
        """"""
        index = self.get_child_index(key)
        if key is None:
            return EmptyNode(None)
        else:
            path = os.path.join(self.get_value(), key)
            if index < self.dir_count:
                return DirectoryNode(path, self.display, parent=self)
            else:
                path = os.path.join(self.get_value(), key)
                return FileNode(path, self.display, parent=self)
946189
def _buildFileUrl(self, xml_req):
		""""""
		return '%(protocol)s://%(host)s:%(port)s%(xml_req)s'%{
			'protocol': self._protocol,
			'host': self._host,
			'port': self._port,
			'xml_req': xml_req,
		}
1343513
def get_raw_data(self, ptr, unbuffered=False):
        """"""
        if unbuffered:
            self._data_pos = None
        # round down ptr to a 'block boundary'
        idx = ptr - (ptr % 0x20)
        ptr -= idx
        count = self.reading_len[self.ws_type]
        if self._data_pos == idx:
            # cache contains useful data
            result = self._data_block[ptr:ptr + count]
            if len(result) >= count:
                return result
        else:
            result = list()
        if ptr + count > 0x20:
            # need part of next block, which may be in cache
            if self._data_pos != idx + 0x20:
                self._data_pos = idx + 0x20
                self._data_block = self._read_block(self._data_pos)
            result += self._data_block[0:ptr + count - 0x20]
            if len(result) >= count:
                return result
        # read current block
        self._data_pos = idx
        self._data_block = self._read_block(self._data_pos)
        result = self._data_block[ptr:ptr + count] + result
        return result
494094
def pin_assets(self, file_or_dir_path: Path) -> List[Dict[str, str]]:
        
        if file_or_dir_path.is_dir():
            asset_data = [dummy_ipfs_pin(path) for path in file_or_dir_path.glob("*")]
        elif file_or_dir_path.is_file():
            asset_data = [dummy_ipfs_pin(file_or_dir_path)]
        else:
            raise FileNotFoundError(
                f"{file_or_dir_path} is not a valid file or directory path."
            )
        return asset_data
908047
public FileStatus getFileStatus(final Path f, final boolean useStandby)
    throws IOException {
    return new StandbyCaller<FileStatus>() {
      @Override
      FileStatus call(DistributedFileSystem fs) throws IOException {
        return fs.getFileStatus(f);
      }
    }.callFS(useStandby);
  }
1078022
def data_from_file(self, file, apple_fix=False):
        
        with open(file, mode='rb') as f:
            content = f.read()

        if not content:
            raise IOError("File %f is not readable or is empty!" % file)

        return self.decode(content, apple_fix=apple_fix)
837970
def get_file_client(opts, pillar=False):
    '''
    
    '''
    client = opts.get('file_client', 'remote')
    if pillar and client == 'local':
        client = 'pillar'
    return {
        'remote': RemoteClient,
        'local': FSClient,
        'pillar': PillarClient,
    }.get(client, RemoteClient)(opts)
1258097
def get_file_contents(filename):
    
    data = None
    try:
        with open(filename) as pf:
            data = pf.read()
    except IOError:
        # File not found, return None
        pass
    return data
1199744
async function viaTreesApi(identifier, dir, token) {
	const files = [];
	const {repo, ref} = parseIdentifier(identifier);
	const contents = await api(`${repo}/git/trees/${ref}?recursive=1`, token);
	for (const item of contents.tree) {
		if (item.type === 'blob' && item.path.startsWith(dir)) {
			files.push(item.path);
		}
	}
	files.truncated = contents.truncated;
	return files;
}
227284
def _ifconfig_getnode():
    """"""

    # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.
    for args in ('', '-a', '-av'):
        mac = _find_mac('ifconfig', args, ['hwaddr', 'ether'], lambda i: i+1)
        if mac:
            return mac

    import socket
    ip_addr = socket.gethostbyname(socket.gethostname())

    # Try getting the MAC addr from arp based on our IP address (Solaris).
    mac = _find_mac('arp', '-an', [ip_addr], lambda i: -1)
    if mac:
        return mac

    # This might work on HP-UX.
    mac = _find_mac('lanscan', '-ai', ['lan0'], lambda i: 0)
    if mac:
        return mac

    return None
135318
def _get_file_content(self, path):
        """"""
        with open(path, 'r') as file_:
            content = file_.read()
        return content
277547
public static FileBlockInfo fromProto(alluxio.grpc.FileBlockInfo fileBlockPInfo) {
    return new FileBlockInfo().setBlockInfo(fromProto(fileBlockPInfo.getBlockInfo()))
        .setOffset(fileBlockPInfo.getOffset()).setUfsLocations(
            fileBlockPInfo.getUfsLocationsCount() > 0 ? fileBlockPInfo.getUfsStringLocationsList()
                : map(addr -> HostAndPort.fromParts(addr.getHost(), addr.getDataPort()).toString(),
                    fileBlockPInfo.getUfsLocationsList()));
  }
1233049
def _Load(self,cached=True):
		""""""

		if not self.data or not cached:
			self.data = clc.v2.API.Call('GET','servers/%s/%s/publicIPAddresses/%s' % (self.parent.server.alias,self.parent.server.id,self.id),
										session=self.session)

			# build ports
			self.data['_ports'] = self.data['ports']
			self.data['ports'] = []
			for port in self.data['_ports']:
				if 'portTo' in port:  self.ports.append(Port(self,port['protocol'],port['port'],port['portTo']))
				else:  self.ports.append(Port(self,port['protocol'],port['port']))

			# build source restriction
			self.data['_source_restrictions'] = self.data['sourceRestrictions']
			self.data['source_restrictions'] = []
			for source_restriction in self.data['_source_restrictions']:
				self.source_restrictions.append(SourceRestriction(self,source_restriction['cidr']))

		return(self.data)
1077785
def _get_post_data(cls, args):
        ''''''
        if args.post_data:
            return args.post_data
        elif args.post_file:
            return args.post_file.read()
1246408
def get_overlay_data_start_offset(self):
        """"""

        highest_PointerToRawData = 0
        highest_SizeOfRawData = 0
        for section in self.sections:
            
            # If a section seems to fall outside the boundaries of the file we assume it's either
            # because of intentionally misleading values or because the file is truncated
            # In either case we skip it
            if section.PointerToRawData + section.SizeOfRawData > len(self.__data__):
                continue
                
            if section.PointerToRawData + section.SizeOfRawData > highest_PointerToRawData + highest_SizeOfRawData:
                highest_PointerToRawData = section.PointerToRawData
                highest_SizeOfRawData = section.SizeOfRawData
                
        if len(self.__data__) > highest_PointerToRawData + highest_SizeOfRawData:
            return highest_PointerToRawData + highest_SizeOfRawData
            
        return None
663046
def from_node(cls, work):
        """"""
        new = super().from_node(work)

        # Will put all files found in outdir in GridFs
        # Warning: assuming binary files.
        d = {os.path.basename(f): f for f in work.outdir.list_filepaths()}
        new.register_gridfs_files(**d)

        return new