EzDevInfo.com

yaml

YAML (Yet Another Multicolumn Layout) is a modular CSS framework for truly flexible, accessible and responsive websites. It is based on Sass and has a very slim framework core that weights only ~6kB. YAML CSS Framework — for truly flexible, accessible and responsive websites yet another multicolumn layout (yaml) is a modular css framework for truly flexible, accessible and responsive websites.

How do I install the yaml package for Python?

I have a Python program that uses YAML. I attempted to install it on a new server using pip install yaml and it returns the following:

$ sudo pip install yaml
Downloading/unpacking yaml
  Could not find any downloads that satisfy the requirement yaml
No distributions at all found for yaml
Storing complete log in /home/pa/.pip/pip.log

How do I install the yaml package for Python? I'm running Python 2.7.


Source: (StackOverflow)

Rails load YAML to hash and reference by symbol

I am loading a YAML file in Rails 3.0.9 like this:

APP_CONFIG = YAML.load(File.read(File.expand_path('../app.yml', __FILE__)))

It loads the all of the contents like hierarchical hashes, no problem. The part I don't like is the fact that the hashes can only be accessed with single or double quotes but not a symbol.

APP_CONFIG['mailer']['username']  # works fine
APP_CONFIG[:mailer][:username]    # doesn't

Any thoughts?


Source: (StackOverflow)

Advertisements

How do you do block comment in yaml?

Does anyone know how to comment a block of lines in yaml?


Source: (StackOverflow)

List of Language Codes in YAML or JSON? [closed]

Is there a list of language codes in YAML or JSON somewhere out there?

Another format is fine, I can convert it if necessary.


Source: (StackOverflow)

print an array as code

I want to convert a big yaml file to PHP array source code. I can read in the yaml code and get back a PHP array, but with var_dump($array) I get pseudo code as output. I would like to print the array as valid php code, so I can copy paste it in my project and ditch the yaml.


Source: (StackOverflow)

What is the difference between YAML and JSON? When to prefer one over the other

When should we prefer to use YAML over JSON and vice versa, considering the following things?

  • Performance (encode/decode time)
  • Memory consumption
  • Expression clarity
  • Library availability, ease of use (I prefer C)

I was planning to use one of these two in our embedded system to store configure files.

Related:

Should I use YAML or JSON to store my Perl data?


Source: (StackOverflow)

YAML parsing and Python?

What is the best way to parse a YAML file into a Python object?

For example, this YAML:

Person:
  name: XYZ

To this Python class:

class Person(yaml.YAMLObject):
  yaml_tag = 'Person'

  def __init__(self, name):
    self.name = name

I am using PyYAML by the way.


Source: (StackOverflow)

How do I create an empty array in YAML?

array_with_three_elements:
- 1
- 2
- 3

empty_array:

Is there any way to specify that empty_array: is an array with no elements, such as with []? When I load it into a ruby hash I'd like it to know that it's an array.

Thanks


Source: (StackOverflow)

How can I parse a YAML file [closed]

How can I parse a YAML file in Python?


Source: (StackOverflow)

In YAML, how do I break a string over multiple lines?

In YAML, I have a string that's very long. I want to keep this within the 80-column (or so) view of my editor, so I'd like to break the string. What's the syntax for this?

In other words, I have this:

Key: 'this is my very very very very very very long string'

and I'd like to have this (or something to this effect):

Key: 'this is my very very very ' +
     'long string'

I'd like to use quotes as above, so I don't need to escape anything within the string.


Source: (StackOverflow)

How to make a list of associative array in yaml

I'm trying to store some configuration variables in yaml. Here is how I did:

content_prices:                                                                                                                                                                                                                               
  - {country: AU, price: 6990000}                                                                                                                                                                                                             
  - {country: AT, price: 4990000}                                                                                                                                                                                                             
  - {country: BE, price: 4990000}  

This produce an exception when I try to parse it from my ROR init files:

undefined method `symbolize_keys!' for nil:NilClass

Here is how I init it:

Config = YAML.load_file("#{Rails.root}/config/prices.yml")[Rails.env].symbolize_keys!

I guess my yaml syntax is wrong, then how to write it properly ?


Source: (StackOverflow)

YAML current date in rmarkdown

I'm wondering if there's a trick to put the current date in the YAML front-matter of a .rmd document to be processed by knitr and the rmarkdown package. I used to have the following line at the top of my wiki pages,

   _baptiste, `r format(Sys.time(), "%d %B, %Y")`_

and it would get converted to baptiste, 03 May, 2014 in the html output. Now, I would like to take advantage of the advanced pandoc wrapper provided by rmarkdown, but having r code in the YAML header doesn't seem to work:

---
title: "Sample Document"
output:
  html_document:
    toc: true
    theme: united
date: `r format(Sys.time(), "%d %B, %Y")`
author: baptiste
---

Error in yaml::yaml.load(front_matter) : 
  Scanner error: while scanning for the next token at line 6, column 7
 found character that cannot start any token at line 6, column 7
Calls: <Anonymous> ... output_format_from_yaml_front_matter -> 
       parse_yaml_front_matter -> <Anonymous> -> .Call

Any workaround?


Source: (StackOverflow)

How do you structure i18n yaml files in Rails?

I started populating an en yaml file in Rails and I can already tell it will get messy and out of hand before too long. Is there a convention to keeping this file organized?

So far I have this structure:

language:
  resource:
    pages: # index, show, new, edit
      page html elements: # h1, title
  activerecord:
    attributes:
      model:
        property:

Now I have the following things that I want to fit into this structure but I'm unsure how to:

  1. Navigation
  2. Button text (save changes, create account, etc)
  3. Error messages from controller flash
  4. How to add multi-word keys. Do I use a space or an underscore? For exmaple, t(".update button")) or t(".update_button")

Is there a convention to locale file structure?


Source: (StackOverflow)

Should I use YAML or JSON to store my Perl data? [closed]

I've been using the YAML format with reasonable success in the last 6 months or so.

However, the pure Perl implementation of the YAML parser is fairly fidgety to hand-write a readable file for and has (in my opinion) annoying quirks such as requiring a newline at end of the file. It's also gigantically slow compared to the rest of my program.

I'm pondering the next evolution of my project, and I'm considering using JSON instead (a mostly strict subset of YAML, as it turns out). But which format has the most community traction and effort in Perl?

Which appears today to be the better long-term format for simple data description in Perl, YAML or JSON, and why?


Source: (StackOverflow)

YAML mime type?

What is the most appropriate MIME type to use when sending data structured with YAML over HTTP?

An explanation of why a given choice is most appropriate would be much appreciated.

There is no registered application type or text type that I can see.

Example:

> GET /example.yaml

< Content-Type: ????
<
< --- # Favorite movies
< - Casablanca
< - North by Northwest
< - Notorious

Possible options:

text/yaml
text/x-yaml
application/yaml
application/x-yaml

Source: (StackOverflow)