<commit_before>module Fog
  module Image
    class OpenStack
      class Real

        def create_image(attributes)
          data = {
            'Content-Type'=>'application/octet-stream',
            'x-image-meta-name' => attributes[:name],
            'x-image-meta-disk-format' => attributes[:disk_format],
            'x-image-meta-container-format' => attributes[:container_format],
            'x-image-meta-size' => attributes[:size],
            'x-image-meta-is-public' => attributes[:is_public],
            'x-image-meta-min-ram'  => attributes[:min_ram],
            'x-image-meta-min-disk' => attributes[:min_disk],
            'x-image-meta-checksum' => attributes[:checksum],
            'x-image-meta-owner' => attributes[:owner],
            'x-glance-api-copy-from' => attributes[:copy_from]
          }.reject { |k,v| v.nil? }

          body = String.new
          if attributes[:location]
            body = File.open(attributes[:location], "rb")
            # Make sure the image file size is always present
            data['x-image-meta-size'] = File.size(body)
          end

          unless attributes[:properties].nil?
            attributes[:properties].each do |key,value|
              data['x-image-meta-property-#{key}'] = value
            end
          end

          request(
            :headers  => data,
            :body     => body,
            :expects  => 201,
            :method   => 'POST',
            :path     => "images"
          )
        ensure
          body.close if body.respond_to?(:close)
        end<commit_msg>[openstack] string interpolation problem image create fixes #1493<commit_after>module Fog
  module Image
    class OpenStack
      class Real

        def create_image(attributes)
          data = {
            'Content-Type'=>'application/octet-stream',
            'x-image-meta-name' => attributes[:name],
            'x-image-meta-disk-format' => attributes[:disk_format],
            'x-image-meta-container-format' => attributes[:container_format],
            'x-image-meta-size' => attributes[:size],
            'x-image-meta-is-public' => attributes[:is_public],
            'x-image-meta-min-ram'  => attributes[:min_ram],
            'x-image-meta-min-disk' => attributes[:min_disk],
            'x-image-meta-checksum' => attributes[:checksum],
            'x-image-meta-owner' => attributes[:owner],
            'x-glance-api-copy-from' => attributes[:copy_from]
          }.reject { |k,v| v.nil? }

          body = String.new
          if attributes[:location]
            body = File.open(attributes[:location], "rb")
            # Make sure the image file size is always present
            data['x-image-meta-size'] = File.size(body)
          end

          unless attributes[:properties].nil?
            attributes[:properties].each do |key,value|
              data["x-image-meta-property-#{key}"] = value
            end
          end

          request(
            :headers  => data,
            :body     => body,
            :expects  => 201,
            :method   => 'POST',
            :path     => "images"
          )
        ensure
          body.close if body.respond_to?(:close)
        end
{'fraction_non_alphanumeric': 0.14040025015634772, 'fraction_numerical': 0.0031269543464665416, 'mean_word_length': 1.7530120481927711, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4816359', 'n_tokens_mistral': 903, 'n_tokens_neox': 885, 'n_words': 164}