Decides how to display fetched gadgets according to options.
 @param [Array<OneGadget::Gadget::Gadget>] gadgets
 @param [String] libc_file
 @return [Boolean]
550819
def handle_gadgets(gadgets, libc_file)
      return false if gadgets.empty? # error occurs when fetching gadgets
      return handle_script(gadgets, @options[:script]) if @options[:script]
      return handle_near(libc_file, gadgets, @options[:near]) if @options[:near]

      display_gadgets(gadgets, @options[:raw])
    end
1324698
def platform_flags_fixup(libs)
      libs[:all].each do |lib|
        ps = tc.platform_settings_for(lib)
        unless ps.empty?
          @settings['ADD_CFLAGS'] += " #{ps[:CFLAGS]}" if ps[:CFLAGS]
          @settings['ADD_CXXFLAGS'] += " #{ps[:CXXFLAGS]}" if ps[:CXXFLAGS]

          # remove all -lXX settings from ps[:LDFLAGS] and use rest for @settings['ADD_LDFLAGS'],
          # -lXX is set in Toolchain#linker_line_for
          @settings['ADD_LDFLAGS'] += ps[:LDFLAGS].gsub(/(\s|^)+-l\S+/, '') if ps[:LDFLAGS]
        end
      end
    end
495934
def load_config(file)
      unless File.exist?(file)
        raise FalkorLib::Error, "Unable to find the YAML file '#{file}'"
      end
      loaded = YAML.load_file(file)
      unless loaded.is_a?(Hash)
        raise FalkorLib::Error, "Corrupted or invalid YAML file '#{file}'"
      end
      loaded
    end
226934
def add_to_search_list
      list = FFI::MemoryPointer.new(:pointer)
      status = Sec.SecKeychainCopySearchList(list)
      Sec.check_osstatus(status)
      ruby_list = CF::Base.typecast(list.read_pointer).release_on_gc.to_ruby
      ruby_list << self unless ruby_list.include?(self)
      status = Sec.SecKeychainSetSearchList(CF::Array.immutable(ruby_list))
      Sec.check_osstatus(status)
      self
    end
1269622
def file_list( files )
    case files
    when String
      [files]
    when Array
      files
    when Proc
      files.call # result should respond to #each
    else
      []
    end
  end
72517
def fetch_result_from_cache(cache_key, cache_options = {}, &block)
      expanded_cache_key = ActiveSupport::Cache.expand_cache_key(cache_key, :rabl)
      Rabl.configuration.cache_engine.fetch(expanded_cache_key, cache_options, &block)
    end
847692
def command_list(self, sources, _opt=False):
        ''''''
        def abspath(x):
            x = Path(x).abspath()
            if not x.exists():
                raise ValueError('file not found! ' + x)
            return x

        self.f_cpu = int(self.f_cpu)

        self.mcu = str(self.mcu)
#        if not self.mcu  in self.targets:
#            raise ValueError('invalid mcu:' + self.mcu)

        if not _opt:
            sources = [abspath(x) for x in sources]
        includes = [abspath(x) for x in self.includes]

        if not self.output:
            self.output = tempfile.NamedTemporaryFile(
                prefix='pyavrutils_', suffix='.elf', delete=0).name

        defines = self.defines + ['F_CPU=' + str(self.f_cpu)]

        cmd = [self.cc]
        if not self.use_only_extra_options:
            if not _opt:
                cmd += sources
            cmd += ['-D' + x for x in defines]
            cmd += ['-I' + x for x in includes]
            if not _opt:
                cmd += ['-o', self.output]
            cmd += ['-mmcu=' + self.mcu]
            cmd += ['--std=' + self.std]
            if self.relax:
                cmd += ['-Wl,--relax']
            if self.gc_sections:
                cmd += ['-Wl,--gc-sections']
            if self.ffunction_sections:
                cmd += ['-ffunction-sections']
            if self.fdata_sections:
                cmd += ['-fdata-sections']
            if self.fno_inline_small_functions:
                cmd += ['-fno-inline-small-functions']
            if self.optimization != 0:
                cmd += ['-O' + str(self.optimization)]

        cmd += self.options_extra
        return cmd
88853
def load_files(file_finder)
      if file_finder.options.fetch(:files).empty?
        file_finder.list(*options[:extensions])
      else
        file_finder.options.fetch(:files) { [] }
      end
    end
185895
def adapter(adapter, options = {}, &block)
      case adapter
      when Symbol
        use(Adapters.const_get(adapter), options, &block)
      when Class
        use(adapter, options, &block)
      else
        raise ArgumentError, 'Adapter must be a Moneta store' unless adapter.respond_to?(:load) && adapter.respond_to?(:store)
        raise ArgumentError, 'No options allowed' unless options.empty?
        @proxies.unshift adapter
        nil
      end
    end
966587
def show_chips(options = {})
      options = {
        group:             nil,
        family:            nil,
        performance:       nil,
        part:              nil,
        chips_to_be_shown: ChipArray.new,
        creating_chip:     false
      }.update(options)
      chips_to_be_shown = options[:chips_to_be_shown]
      filter_hash(_chips, options[:group]).each do |_group, hash|
        filter_hash(hash, options[:family]).each do |_family, hash_|
          filter_hash(hash_, options[:performance]).each do |_performance, hash__|
            filter_hash(hash__, options[:part]).each do |_part, chip|
              chips_to_be_shown << chip
            end
          end
        end
      end
      # If no specs were found must check the possibility another search
      # should be started with mode set to :local or :global
      if chips_to_be_shown.empty?
        # Don't want to re-call this method if the callee is trying to create a spec and just wants to know
        # if there is a spec with the exact same options
        if options[:creating_chip] == false
          # Doesn't make sense to recall the method however if the mode is already set to :global or :local
          options[:chips_to_be_shown] = chips_to_be_shown
          Origen.log.debug "re-calling show_chips with options #{options}"
          return show_chips(options)
        end
        Origen.log.debug "Returning no chips for options #{options}"
        return nil
      elsif chips_to_be_shown.size == 1
        Origen.log.debug "returning one spec #{chips_to_be_shown.first.part_name}"
        return chips_to_be_shown.first
      else
        Origen.log.debug "returning an array of specs during initial search: #{chips_to_be_shown}"
        return chips_to_be_shown
      end
    end
1083568
def libasan?(gcc_binary)
      unless @has_libasan_cache.key?(gcc_binary)
        file = Tempfile.new(["arduino_ci_libasan_check", ".cpp"])
        begin
          file.write "int main(){}"
          file.close
          @has_libasan_cache[gcc_binary] = run_gcc(gcc_binary, "-o", "/dev/null", "-fsanitize=address", file.path)
        ensure
          file.delete
        end
      end
      @has_libasan_cache[gcc_binary]
    end
1227996
def show(config_file=False):
    '''
    
    '''
    ret = {}
    if config_file:
        # If the file doesn't exist, return an empty list
        if not os.path.exists(config_file):
            return []

        try:
            with salt.utils.files.fopen(config_file) as fp_:
                for line in fp_:
                    line = salt.utils.stringutils.to_str(line)
                    if not line.startswith('#') and '=' in line:
                        # search if we have some '=' instead of ' = ' separators
                        SPLIT = ' = '
                        if SPLIT not in line:
                            SPLIT = SPLIT.strip()
                        key, value = line.split(SPLIT, 1)
                        key = key.strip()
                        value = value.lstrip()
                        ret[key] = value
        except (OSError, IOError):
            log.error('Could not open sysctl file')
            return None
    else:
        cmd = 'sysctl -a'
        out = __salt__['cmd.run_stdout'](cmd, output_loglevel='trace')
        for line in out.splitlines():
            if not line or ' = ' not in line:
                continue
            comps = line.split(' = ', 1)
            ret[comps[0]] = comps[1]
    return ret
1170663
def view(media_or_io, options = {})
      @devices.map do |device|
        ok = device.view(media_or_io, options)
        [device, ok]
      end
    end
251254
def run_list():
    
    term = TerminalView()
    term.print_info("These are the available templates:")
    import pkgutil, projy.templates
    pkgpath = os.path.dirname(projy.templates.__file__)
    templates = [name for _, name, _ in pkgutil.iter_modules([pkgpath])]
    for name in templates:
        # the father of all templates, not a real usable one
        if (name != 'ProjyTemplate'):
            term.print_info(term.text_in_color(template_name_from_class_name(name), TERM_PINK))
640112
def libs_for_binary(a_binary, visited=[])
    return [] if visited.include?(a_binary)
    visited << a_binary
    pre = Rake::Task[a_binary].prerequisites
    rv = []
    pre.each do |p|

      next if (File.extname(p) != '.a') && (File.extname(p) != '.so')
      next if p =~ /\-app\.a/

      rv << File.basename(p).gsub(/(\.a|\.so|^lib)/, '')
      rv += libs_for_binary(p, visited)   # Recursive call
    end

    reduce_libs_to_bare_minimum(rv.uniq)
  end
83536
def command_objects(names=self.commands, command_array=Boson.commands)
      command_array.select {|e| names.include?(e.name) && e.lib == self.name }
    end
694083
def set_library(pLibrary)
      return nil if (pLibrary.nil?) ||
                    (!pLibrary.is_a? String) ||
                    (pLibrary.empty?)

      @library = pLibrary
    end