load an icon from the data directory
167456
def mp_icon(filename):
        ''''''
        # we have to jump through a lot of hoops to get an OpenCV image
        # when we may be in a package zip file
        try:
                import pkg_resources
                name = __name__
                if name == "__main__":
                        name = "MAVProxy.modules.mavproxy_map.mp_tile"
                raw = pkg_resources.resource_stream(name, "data/%s" % filename).read()
        except Exception:
                raw = open(os.path.join(__file__, 'data', filename)).read()
        imagefiledata = cv.CreateMatHeader(1, len(raw), cv.CV_8UC1)
        cv.SetData(imagefiledata, raw, len(raw))
        img = cv.DecodeImage(imagefiledata, cv.CV_LOAD_IMAGE_COLOR)
        return img
862796
def _load_image(cls, rkey):
        """"""

        v = cls._stock[rkey]
        img = None
        itype = v['type']
        if itype in ('stock', 'data'):
            img = tk.PhotoImage(format=v['format'], data=v['data'])
        elif itype == 'created':
            img = v['image']
        else:
            img = tk.PhotoImage(file=v['filename'])
        cls._cached[rkey] = img
        logger.info('Loaded resource %s.' % rkey)
        return img
1135109
def load(self, name, location='local'):
        """"""
        path = self._get_path(name, location, file_ext='.json')
        if op.exists(path):
            return _load_json(path)
        path = self._get_path(name, location, file_ext='.pkl')
        if op.exists(path):
            return _load_pickle(path)
        logger.debug("The file `%s` doesn't exist.", path)
        return {}
66122
def load_data(data_file, key_name = None, local_file = False, format = 'json'):
    
    if local_file:
        if data_file.startswith('/'):
            src_file = data_file
        else:
            src_dir = os.getcwd()
            src_file = os.path.join(src_dir, data_file)
    else:
        src_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data')
        if not os.path.isdir(src_dir):
            src_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../data')
        src_file = os.path.join(src_dir, data_file)
    with open(src_file) as f:
        if format == 'json':
            data = json.load(f)
        elif format == 'yaml':
            data = yaml.load(f)
        elif format not in ['json', 'yaml'] and not key_name:
            data = f.read()
        else:
            printError('Error, argument \'key_name\' may not be used with data in %s format.' % format)
            return None
    if key_name:
        data = data[key_name]
    return data
1197042
function loadDirectory(dir) {

  // exported accessory objects loaded from this dir
  var accessories = [];

  fs.readdirSync(dir).forEach(function(file) {

    // "Accessories" are modules that export a single accessory.
    if (file.split('_').pop() === 'accessory.js') {
      debug('Parsing accessory: %s', file);
      var loadedAccessory = require(path.join(dir, file)).accessory;
      accessories.push(loadedAccessory);
    }
    // "Accessory Factories" are modules that export an array of accessories.
    else if (file.split('_').pop() === 'accfactory.js') {
      debug('Parsing accessory factory: %s', file);

      // should return an array of objects { accessory: accessory-json }
      var loadedAccessories = require(path.join(dir, file));
      accessories = accessories.concat(loadedAccessories);
    }
  });

  // now we need to coerce all accessory objects into instances of Accessory (some or all of them may
  // be object-literal JSON-style accessories)
  return accessories.map(function(accessory) {
    if(accessory === null || accessory === undefined) { //check if accessory is not empty
      console.log("Invalid accessory!");
      return false;
    } else {
      return (accessory instanceof Accessory) ? accessory : parseAccessoryJSON(accessory);
    }
  }).filter(function(accessory) { return accessory ? true : false; });
}
1017232
def load():
    """"""
    # Get the data file relative to this file's location...
    datadir = os.path.dirname(__file__)
    filename = os.path.join(datadir, 'angelier_data.txt')

    data = []
    with open(filename, 'r') as infile:
        for line in infile:
            # Skip comments
            if line.startswith('#'):
                continue

            # First column: strike, second: dip, third: rake.
            strike, dip, rake = line.strip().split()

            if rake[-1].isalpha():
                # If there's a directional letter on the rake column, parse it
                # normally.
                strike, dip, rake = mplstereonet.parse_rake(strike, dip, rake)
            else:
                # Otherwise, it's actually an azimuthal measurement of the
                # slickenslide directions, so we need to convert it to a rake.
                strike, dip = mplstereonet.parse_strike_dip(strike, dip)
                azimuth = float(rake)
                rake = mplstereonet.azimuth2rake(strike, dip, azimuth)

            data.append([strike, dip, rake])

    # Separate the columns back out
    strike, dip, rake = zip(*data)
    return strike, dip, rake
116082
def load_dir(src_dir)
      merged_content = ""

      Pathname.glob("#{src_dir}/*.yml").sort.each do |yaml_path|
        content = yaml_path.read.gsub(/^---$/, "")
        merged_content << content
      end

      YAML.load(merged_content)
    end
1015338
def __get_datadir(self, app=False):
        
        # if 'datadir' in self.oseg.cache.data.keys():
        # if :
        #     directory = self.oseg.input_datapath_start
        if self.cache is not None:
            cache_loaddir = self.cache.get_or_none('loaddir')
            self.loaddir = str(cache_loaddir)
            # self.loaddir = str(self.cache.get_or_none('loaddir'))

        if self.loaddir is None:
            self.loaddir = ''

        directory = self.loaddir

        from PyQt4.QtGui import QFileDialog
        if not app:
            app_inner = QApplication(sys.argv)
        if self._skip_get_path_dialog_for_tests:
            dcmdir = self.datapath
        else:
            dcmdir = QFileDialog.getExistingDirectory(
                caption='Select DICOM Folder',
                options=QFileDialog.ShowDirsOnly,
                directory=directory
            )
            # pp.exec_()
        if not app:
            app_inner.exit(0)

        dcmdir = get_str(dcmdir)

        if len(dcmdir) > 0:


            # dcmdir = "%s" % (dcmdir)
            # dcmdir = dcmdir.encode("utf8")
            pass
        else:
            dcmdir = None

        if self.cache is not None:
            self.cache.update('loaddir', dcmdir)
        return str(dcmdir)
972435
function copyIcon() {
		var dest = path.join(process.env.PWD, 'res');

		// Make sure the destination exists
		mkdir(dest);

		return pify(fs.copy.bind(fs), Promise)(src, path.join(dest, 'icon.' + mime.extension(mimetype)));
	}
437702
def getIcon( data ):
    """"""
    import cStringIO
    stream = cStringIO.StringIO(data)
    image = wx.ImageFromStream(stream)
    icon = wx.EmptyIcon()
    icon.CopyFromBitmap(wx.BitmapFromImage(image))
    return icon
820519
def __load(self, path):
        """"""
        try:
            path = os.path.abspath(path)
            with open(path, 'rb') as df:
                # loaded_dataset = pickle.load(df)
                self.__data, self.__classes, self.__labels, \
                self.__dtype, self.__description, \
                self.__num_features, self.__feature_names = pickle.load(df)

            # ensure the loaded dataset is valid
            self.__validate(self.__data, self.__classes, self.__labels)

        except IOError as ioe:
            raise IOError('Unable to read the dataset from file: {}', format(ioe))
        except:
            raise
749345
function loadFile(dir, filename) {
  if (filename == null) return {}
  filename = path.join(dir, filename)
  try {
    return require(filename)
  } catch(e) {
    return {}
  }
}
1210400
def icon(self):
        
        path = self._icon
        if not path:
            return ''

        path = os.path.expandvars(os.path.expanduser(path))
        if path.startswith('.'):
            base_path = os.path.dirname(self.filepath())
            path = os.path.abspath(os.path.join(base_path, path))

        return path
241804
def load(self, filename=None):
        """"""
        DataFile.load(self, filename)
        self.spectrum.filename = filename
884362
def load(data_path):
        
        with open(data_path, "r") as data_file:
            raw_data = data_file.read()

        data_file.close()
        return raw_data
69890
def get_icon(self, icon_id: str, size: "Gtk.IconSize") -> "Gtk.Image":
        """"""
        return Gtk.Image.new_from_gicon(self.get_gicon(icon_id), size)
1302500
function icons (opts, ctx, done) {
    return vfs.src(opts.input)
        .pipe(easysvg.stream({js: false}))
        .on('error', done)
        .pipe(vfs.dest(opts.output))
}