Determines if the current project is a chef repo

 @return [Boolean]
   true if the current project is a chef repo, false otherwise
325254
def chef_repo?
        @_chef_repo ||= begin
          chef_folders = %w(.chef certificates config cookbooks data_bags environments roles)
          (root_folders & chef_folders).size > 2
        end
      end
1365155
def valid_grammar?
      return true unless options.key?(:search_grammar)
      return false unless File.exist?(options[:search_grammar])
      search = FoodCritic::Chef::Search.new
      search.create_parser([options[:search_grammar]])
      search.parser?
    end
197657
def _project_is_apache():
    

    global _is_apache_cache
    if _is_apache_cache is not None:
        return _is_apache_cache
    license_files = ["LICENSE"]
    for filename in license_files:
        try:
            with open(filename, "r") as file:
                for line in file:
                    if re.search('Apache License', line):
                        _is_apache_cache = True
                        return True
        except IOError:
            pass
    _is_apache_cache = False
    return False
1019210
def recipe(recipe):
    
    env.host_string = lib.get_env_host_string()
    lib.print_header(
        "Applying recipe '{0}' on node {1}".format(recipe, env.host_string))

    # Create configuration and sync node
    data = lib.get_node(env.host_string)
    data["run_list"] = ["recipe[{0}]".format(recipe)]
    if not __testing__:
        if env.autodeploy_chef and not chef.chef_test():
            deploy_chef(ask="no")
        chef.sync_node(data)
822511
def user_has_fork_of_repo?
      # The API doesn't provide a simple means of checking whether a user has
      # forked a repository.

      # First, if there are no forks for the repository, return false.
      return false if @repo[:forks_count] == 0

      # Then check whether it's worth getting the list of forks
      if @repo[:forks_count] <= 100
        repo_forks = @client.forks @repo[:full_name], :per_page => 100
        repo_forks.each do |f|
          return true if f[:owner][:login] == @user[:login]
        end
      end

      # Then try to directly find a repository with the same name as the
      # repository in which the commit exists.
      potential_fork_nwo = "#{@user[:login]}/#{@repo[:name]}"
      begin
        potential_fork = @client.repository potential_fork_nwo
        if potential_fork[:fork]
          return true if potential_fork[:parent][:full_name] == @repo[:full_name]
        end
      rescue Octokit::NotFound
        # Keep going...
      end

      # Otherwise, get the user's forks and check the `parent` field of each
      # fork to see whether it matches @repo.
      @client.auto_paginate = true
      @user_repos = @client.repos
      @user_forks = @user_repos.select { |r| r[:fork] }
      @user_forks.each do |f|
        r = @client.repository f[:full_name]
        if r[:parent][:full_name] == @repo[:full_name]
          @client.auto_paginate = false
          return true
        end
      end
      @client.auto_paginate = false
      false
    end
143751
def is_canonical(version, loosedev=False):  # type: (str, bool) -> bool
    
    if loosedev:
        return loose440re.match(version) is not None
    return pep440re.match(version) is not None
240920
def checkout_cookbook_repos(&callback)
      @dev_cookbooks.each_pair do |repo_sha, dev_repo|
        repo = dev_repo.to_scraper_hash

        # get the root dir this repo should be, or was, checked out to
        repo_dir = @scraper.repo_dir(repo)

        if File.directory?(repo_dir)
          # repo was already checked out on this machine; leave it alone
          # synthesize a scraper callback so our progress listener knows what's up
          if callback
            callback.call(:commit, :initialize, "Skipping checkout -- repository already exists in #{repo_dir}", nil)
          end
          @registered_checkouts[repo_sha] = repo_dir
        else
          # repo wasn't checked out successfully yet; check it out now
          success = false
          begin
            success = @scraper.scrape(repo, &callback)
          ensure
            if success
              @registered_checkouts[repo_sha] = repo_dir
            else
              # nuke the repo dir if checkout fails, so we try again next time
              FileUtils.rm_rf(repo_dir) unless success

              # scraper logger is an odd duck, so just transfer any errors to
              # the normal logger.
              @scraper.errors.each { |e| ::RightScale::Log.error(e) }
              ::RightScale::Log.error("Failed to checkout from #{repo[:url].inspect}")
            end
          end
        end
      end
      true
    end
752789
def matches_content?
      return true if @expected_content.empty?

      @actual_content = ChefSpec::Renderer.new(@runner, resource).content

      return false if @actual_content.nil?

      # Knock out matches that pass. When we're done, we pass if the list is
      # empty. Otherwise, @expected_content is the list of matchers that
      # failed
      @expected_content.delete_if do |expected|
        if expected.is_a?(Regexp)
          @actual_content =~ expected
        elsif RSpec::Matchers.is_a_matcher?(expected)
          expected.matches?(@actual_content)
        elsif expected.is_a?(Proc)
          expected.call(@actual_content)
          # Weird RSpecish, but that block will return false for a negated check,
          # so we always return true. The block will raise an exception if the
          # assertion fails.
          true
        else
          @actual_content.include?(expected)
        end
      end
      @expected_content.empty?
    end
1325293
def is_remote_package(resource):
    
    remote_regexp = re.compile(r"^https?://(.+).rpm$", re.I)
    result = remote_regexp.match(resource)

    if result is not None:
        juicer.utils.Log.log_debug("%s matches remote package regexp" % resource)
        return True
    else:
        juicer.utils.Log.log_debug("%s doesn't match remote package regexp" % resource)
        return False
525015
def converge_block(&block)
      converge do
        recipe = Chef::Recipe.new(cookbook_name, '_test', run_context)
        recipe.instance_exec(&block)
      end
    end
503713
def is_git_repo(repo_dir):
    """"""
    command = ['git', 'rev-parse']
    try:
        execute_git_command(command, repo_dir=repo_dir)
    except exceptions.SimplGitCommandError:
        return False
    else:
        return True
646468
def role_admin?(run_list = nil)
      return false unless run_list.is_a?(Array)
      # => This will Authorize Anyone if the RunList is Empty or the Chef Node does not exist!!!
      run_list.empty? || auth['roles'].any? { |role| run_list.any? { |r| r =~ /role\[#{role}\]/i } }
    end
165694
def _is_local_repository(cls, repo):
        # type: (str) -> bool
        
        drive, tail = os.path.splitdrive(repo)
        return repo.startswith(os.path.sep) or bool(drive)
573391
def update_node(node_updates, merge = false)
      config[:disable_editing] = true

      begin
        # load then update and save the node
        node = Chef::Node.load(node_updates['name'])

        env = node_updates['chef_environment']
        check_chef_env(env) unless env == node['chef_environment']
        do_node_updates(node, node_updates, merge)

      rescue Net::HTTPServerException => e
        raise unless e.to_s =~ /^404/
        # Node has not been created
      end

      node
    end
1095598
def method_missing(m, *args, &block)
      if block = ChefSpec.matchers[resource_name(m.to_sym)]
        instance_exec(args.first, &block)
      else
        super
      end
    end
1037012
def setup!
      env = ::Librarian::Chef::Environment.new(project_path: Dir.pwd)
      @originalpath, env.config_db.local['path'] = env.config_db.local['path'], @tmpdir
      ::Librarian::Action::Resolve.new(env).run
      ::Librarian::Action::Install.new(env).run

      ::RSpec.configure { |config| config.cookbook_path = @tmpdir }
    end
802179
def has_in_repos(self, repo):
        
        assert isinstance(repo, github.Repository.Repository), repo
        status, headers, data = self._requester.requestJson(
            "GET",
            self.url + "/repos/" + repo._identity
        )
        return status == 204