openpeeps / nyml Goto Github PK
View Code? Open in Web Editor NEWA stupid simple YAML Parser. From YAML to stringified JSON, JsonNode or Nim objects. Written in Nim language ๐
Home Page: https://openpeeps.github.io/nyml
License: MIT License
A stupid simple YAML Parser. From YAML to stringified JSON, JsonNode or Nim objects. Written in Nim language ๐
Home Page: https://openpeeps.github.io/nyml
License: MIT License
Hi!
The nimble file contains the following:
bin = @["nyml"]
binDir = "bin"
which makes it so that we cannot use nyml
as a library (cannot import nyml
).
nimble install
installs a binary nyml
which is a program that simply tries to open sample.yaml
which is not very helpful.
If this is intended to be a library, remove bin
and binDir
from the nimble file! If it is indeed intended to be both a binary AND a library, try creating a hybrid structure instead: https://github.com/nim-lang/nimble#hybrids
You can try to do nimble develop --verbose
in the root of the project and you will get the following:
Error: Cannot develop packages that are binaries only.
Hi, I really liked your rule/validation syntax.
Would be useful, include an array example to readme.
Seems tasks/dev
not fetched by nimble.
โฏ nimble install nyml
Downloading https://github.com/openpeep/nyml using git
Verifying dependencies for [email protected]
Installing [email protected]
Building nyml/nyml using c backend
/tmp/nimble_157926/githubcom_openpeepnyml/src/nyml/parser_json.nim(11, 9) Warning: imported and not used: 'sequtils' [UnusedImport]
/tmp/nimble_157926/githubcom_openpeepnyml/src/nyml.nim(10, 12) Warning: imported and not used: 'utils' [UnusedImport]
Success: nyml installed successfully.
Tip: 6 messages have been suppressed, use --verbose to show them.
Error: Could not read package info file in /home/unikum/.nimble/pkgs/nyml-0.1.0/nyml.nimble;
... Reading as ini file failed with:
... Invalid section: .
... Evaluating as NimScript file failed with:
... /home/unikum/.nimble/pkgs/nyml-0.1.0/nyml.nimble(15, 16) Error: cannot open file: ./tasks/dev
... printPkgInfo() failed.
โฏ ls -1 /home/unikum/.nimble/pkgs/nyml-0.1.0/
nimblemeta.json
nyml*
nyml.nimble
Same with git repo.
https://stackoverflow.com/questions/50788277/why-3-dashes-hyphen-in-yaml-file
If someone's reading YAML files, it's because something else is choosing to emit YAML, and when that something else is Perl it adds a header by default:
% perl -MYAML=Dump -le 'print Dump({some => "content"})'
---
some: content
sample.yaml:
---
name: test
on:
push:
paths-ignore:
- LICENSE
- README.*
pull_request:
paths-ignore:
- LICENSE
- README.*
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
nim-version:
- 'stable'
steps:
- uses: actions/checkout@v2
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ matrix.nim-version }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: nimble install -Y
- run: nim --threads:on c -r src/tim.nim
- run: nimble test
program.nim:
import nyml
echo readFile("sample.yaml").yaml.toJson
Output with sample.yaml:
/Users/jfondren/nim/bug/nymlbug/src/nymlbug.nim(3) nymlbug
/Users/jfondren/.nimble/pkgs/nyml-0.1.3/nyml.nim(38) toJson
/Users/jfondren/nim/nim-1.6.12/lib/pure/json.nim(1035) parseJson
/Users/jfondren/nim/nim-1.6.12/lib/pure/json.nim(952) parseJson
/Users/jfondren/nim/nim-1.6.12/lib/pure/parsejson.nim(519) eat
/Users/jfondren/nim/nim-1.6.12/lib/pure/parsejson.nim(515) raiseParseErr
Error: unhandled exception: input(1, 3) Error: EOF expected [JsonParsingError]
Output with the same file absent the --- line:
(contents: {"name":"test","on":{"push":{"paths-ignore":["LICENSE","README.*"]},"pull_request":{"paths-ignore":["LICENSE","README.*"]}},"jobs":{"test":{"runs-on":"ubuntu-latest","strategy":{"matrix":{"nim-version":["stable"]}},"steps":[{"uses":"actions/checkout@v2"},{"uses":"jiro4989/setup-nim-action@v1","with":{"nim-version":"${{ matrix.nim-version }}","repo-token":"${{ secrets.GITHUB_TOKEN }}"}},{"run":"nimble install -Y"},{"run":"nim --threadson c -r src/tim.nim"},{"run":"nimble test"}]}}}, rules: @[], hasErrors: false, errors: @[])
Since I have files that I know have the --- header and are otherwise extremely simple, I have this workaround:
import nyml, std/[strutils, sugar]
echo readFile("sample.yaml").dup(removePrefix("---\n")).yaml.toJson
Or without sugar:
import nyml, std/strutils
var contents = readFile("sample.yaml")
contents.removePrefix("---\n")
echo contents.yaml.toJson
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.