plugin Config wont load correctly - yaml

I'm running a two plugins on spigot 1.8.9 called minigameslib and openskywars. To set up the randomizing of chests its required to setup a config
# Just copy paste if you want more chests. The percentages must add up to 100!
config:
enabled: true
chests:
chest1:
items: 5*64;5*64;5*64;5*64;262*64;278*1;5*64%30
percentage: 5
chest2:
items: 5*64;262*64;267*1
percentage: 20
chest3:
items: 5*64;262*64
percentage: 25
chest4:
items: 5*64
percentage: 50
Thats the default config file. It's named chests.yml
I'm atttempting to change the file to contain the following:
# Just copy paste if you want more chests. The percentages must add up to 100!
config:
enabled: true
chests:
chest1:
items:298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
percentage: 4
chest2:
items:298*1;315*1;300*1;317*1;367*1;3*64;1*64;322*4;364*12
percentage: 4
chest3:
items:298*1;299*1;312*1;305*1;272*1;1*64;79*1;261:3#ARROW_DAMAGE*1
percentage: 4
chest4:
items:298*1;307*1;308*1;309*1;272*1;3*64;261*1;364*12
percentage: 4
chest5:
items:298*1;311*1;316*1;313*1;283*1;1*64;326*1;262*16
percentage: 4
chest6:
items:302*1;315*1;312*1;301*1;272*1;33:5#KNOCKBACK*1
percentage: 4
chest7:
items:302*1;299*1;304*1;309*1;272*1;3*64;79*1;364*12
percentage: 4
chest8:
items:302*1;303*1;316*1;313*1;283*1;1*64;261:5#ARROW_DAMAGE*1;364*12
percentage: 4
chest9:
items:302*1;311*1;308*1;305*1;367*1;3*64;79*1;368*5;33:
percentage: 4
chest10:
items:302*1;307*1;300*1;317*1;276*1;1*64;326*1;262*16;364*12
percentage: 4
chest11:
items:306*1;299*1;316*1;309*1;283*1;3*64;322*4
percentage: 4
chest12:
items:306*1;307*1;308*1;301*1;272*1;3*64;262*16;261:1#ARROW_DAMAGE*1;364*12
percentage: 4
chest13:
items:306*1;303*1;312*1;313*1;276*1;1*64;326*1
percentage: 4
chest14:
items:306*1;315*1;304*1;305*1;367*1;3*64;368*1
percentage: 4
chest15:
items:306*1;311*1;300*1;317*1;272*1;322*4
percentage: 4
chest16:
items:310*1;307*1;316*1;301*1;276*1;261*1
percentage: 4
chest17:
items:310*1;311*1;304*1;309*1;272*1;3*64;261:1#ARROW_DAMAGE*1
percentage: 4
chest18:
items:310*1;315*1;312*1;305*1;283*1;262*16;322*4;364*12
percentage: 4
chest19:
items:310*1;303*1;308*1;317*1;367*1;3*64;79*1
percentage: 4
chest20:
items:310*1;299*1;300*1;313*1;272*1;1*64;364*12
percentage: 4
chest21:
items:314*1;303*1;312*1;317*1;367*1;3*64;368*2;33:5#KNOCKBACK*1;364*12
percentage: 4
chest22:
items:314*1;307*1;316*1;305*1;283*1;326*1;364*12
percentage: 4
chest23:
items:314*1;311*1;300*1;301*1;276*1;1*64;261:1#ARROW_DAMAGE*1
percentage: 4
chest24:
items:314*1;299*1;304*1;313*1;272*1;3*64;262*16;364*12
percentage: 4
chest25:
items:314*1;315*1;308*1;309*1;272*1;79*1;261*1;322*4
percentage: 4
Im not sure if my syntax for yml files is wrong or the item ids are wrong. The enchanting ids are Here, and the plugin page is here. The program resets back to the original config every time its run, making small changes and its fine. I would like to get this long list working if I can.
I hope you have more like than I do. Thanks in advance.

A yaml file needs a space after the colon.
Also indentation is dictative for what object belongs to what.
You made chests a top level opbject
You have
# Just copy paste if you want more chests. The percentages must add up to 100!
config:
enabled: true
chests:
chest1:
items:298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
percentage: 4
it should be
# Just copy paste if you want more chests. The percentages must add up to 100!
# top level. no spaces
config:
# secondary, two spaces. Could also be one space.
# All following secondary level elements need to have the equal amount of spaces
enabled: true
# secondary two spaces
chests:
# Tertiary: 4 spaces. All following tertiary elements under this secondary
# element need to have 4 spaces.
chest1:
# Quaternary element. 6 spaces. All following quaternary elements under this
# tertiary element needs to have 6 spaces
# Also note the space after the colon: Yaml needs this to discern where the
# variable starts
items: 298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
percentage: 4
Without clarifying comments
# Just copy paste if you want more chests. The percentages must add up to 100!
config:
enabled: true
chests:
chest1:
items: 298*1;303*1;304*1;301*1;276*1;3*64;1*64;368*2;262*16;322*4;
percentage: 4

Related

YTT overlays: modify arrays using data from that arrays

This question is about YTT.
Is it possible to modify YAML list of items using the data from that items via overlays?
For example we have a template:
---
vlans:
- vlan-id: 10
- vlan-id: 20
- vlan-id: 30
some_other_configuration: #! some other config here
And using overlays we need to transform the template above into this:
---
vlans:
- vlan-id: 10
vlan-name: vlan10
- vlan-id: 20
vlan-name: vlan20
- vlan-id: 30
vlan-name: vlan30
some_other_configuration: #! some other config here
Yes. One can use an overlay within an overlay. 🤯
## load("#ytt:overlay", "overlay")
## def with_name(vlan):
##overlay/match missing_ok=True
vlan-name: ## "vlan{}".format(vlan["vlan-id"])
## end
##overlay/match by=overlay.all
---
vlans:
##overlay/match by=lambda idx, left, right: "vlan-id" in left, expects="1+"
##overlay/replace via=lambda left, right: overlay.apply(left, with_name(left))
-
which can be read:
for all documents,
in the vlans: map item...
for every array item it contains that has a map that includes the key "vland-id"...
replace the map with one that's been overlay'ed with the vlan name
https://carvel.dev/ytt/#gist:https://gist.github.com/pivotaljohn/33cbc52e808422e68c5ec1dc2ca38354
See also:
the #overlay/replace action: https://carvel.dev/ytt/docs/v0.40.0/lang-ref-ytt-overlay/#overlayreplace
Overlays, programmatically: https://carvel.dev/ytt/docs/v0.40.0/lang-ref-ytt-overlay/#programmatic-access.

Edit yaml objects in array with yq. Speed up Terminalizer's terminal cast (record)

The goal: Speed up Terminalizer's terminal cast (record)
I have a record of terminal created with Terminalizer. cast.yaml:
# The configurations that used for the recording, feel free to edit them
config:
# do not touch it
# Records, feel free to edit them
records:
- delay: 841
content: "\e]1337;RemoteHost=kyb#kyb-nuc\a\e]1337;CurrentDir=/home/kyb/devel/git-rev-label\a\e]1337;ShellIntegrationVersion=7;shell=fish\a"
- delay: 19
content: "\e]1337;RemoteHost=kyb#kyb-nuc\a\e]1337;CurrentDir=/home/kyb/devel/git-rev-label\a\e]0;fish /home/kyb/devel/git-rev-label\a\e[30m\e(B\e[m"
- delay: 6
content: "\e[?2004h"
- delay: 28
content: "\e]0;fish /home/kyb/devel/git-rev-label\a\e[30m\e(B\e[m\e[2m⏎\e(B\e[m \r⏎ \r\e[K\e]133;D;0\a\e]133;A\a\e[44m\e[30m ~/d/git-rev-label \e[42m\e[34m \e[42m\e[30m demo \e[30m\e(B\e[m\e[32m \e[30m\e(B\e[m\e]133;B\a\e[K"
- delay: 1202
content: "#\b\e[38;2;231;197;71m#\e[30m\e(B\e[m"
- delay: 134
content: "\e[38;2;231;197;71m#\e[30m\e(B\e[m"
- delay: 489
content: "\e[38;2;231;197;71m \e[30m\e(B\e[m"
- delay: 318
I want to speed up payback without passing --speed-factor to terminalizer play. To do so delays should be decreased.
So, I need to create yq-expression to make delays lower
.records.delay=.records.delay/3
but this expression won't work. Please help to write proper one.
.records is an array, so you could use this filter:
.records |= map(.delay /= 3)
Or you might prefer:
.records[].delay |= (. /= 3)

Transpose a list based on specific text in ruby

I have one file which is one long list of different patient samples. Each sample always starts with "SLX" as below:
I would like to transpose each sample into a CSV with the output shown below. I know that the CSV library might be able to do this but I don't know how to approach it as I would have to transpose only when the line starting with SLX is matched.
Input:
SLX.1767356.fdfsIH.fq.gz
Sequences: 160220
With index: 139019
Sufficient length: 139018
Min index: 0
Max index: 83
Unique: 48932
# reads processed: 48932
# reads with at least one reported alignment: 21172 (43.27%)
# reads that failed to align: 27022 (55.22%)
# reads with alignments suppressed due to -m: 738 (1.51%)
Reported 21172 alignments to 1 output stream(s)
SLX.94373.GHDUA_.fq.gz
Sequences: 28232
With index: 24875
Sufficient length: 24875
Min index: 3
Max index: 41
Unique: 14405
# reads processed: 14405
# reads with at least one reported alignment: 8307 (57.67%)
# reads that failed to align: 5776 (40.10%)
# reads with alignments suppressed due to -m: 322 (2.24%)
Reported 8307 alignments to 1 output stream(s)
SLX.73837.BLABLA_Control.fq.gz
Sequences: 248466
With index: 230037
Sufficient length: 230036
Min index: 0
Max index: 98
Unique: 64883
# reads processed: 64883
# reads with at least one reported alignment: 24307 (37.46%)
# reads that failed to align: 39764 (61.29%)
# reads with alignments suppressed due to -m: 812 (1.25%)
Reported 24307 alignments to 1 output stream(s)
Output
SLX.10456.FastSeqI_Control_OC_AH_094.fq.gz Sequences: 160220 With index: 139019 Sufficient length: 139018 Min index: 0 Max index: 83 Unique: 48932 # reads processed: 48932 # reads with at least one reported alignment: 21172 (43.27%) # reads that failed to align: 27022 (55.22%) # reads with alignments suppressed due to -m: 738 (1.51%) Reported 21172 alignments to 1 output stream(s) mv: /Volumes/SeagateBackupPlusDriv1/SequencingRawFiles/TumourOesophagealOCCAMS/MetaOCCAMSTumoursRawFiles/LCMDysplasiaAndCancer_LCM_PS14_1105_1F/SLX.10456.FastSeqI_Control_OC_AH_094.fq.gz and /Volumes/SeagateBackupPlusDriv1/SequencingRawFiles/TumourOesophagealOCCAMS/MetaOCCAMSTumoursRawFiles/LCMDysplasiaAndCancer_LCM_PS14_1105_1F/SLX.10456.FastSeqI_Control_OC_AH_094.fq.gz are identical
SLX.10456.FastSeqI_Control_OC_ED_008_F1_.fq.gz Sequences: 28232 With index: 24875 Sufficient length: 24875 Min index: 3 Max index: 41 Unique: 14405 # reads processed: 14405 # reads with at least one reported alignment: 8307 (57.67%) # reads that failed to align: 5776 (40.10%) # reads with alignments suppressed due to -m: 322 (2.24%) Reported 8307 alignments to 1 output stream(s)
SLX.10456.FastSeqJ_OC_AH_086_F1_Control.fq.gz Sequences: 248466 With index: 230037 Sufficient length: 230036 Min index: 0 Max index: 98 Unique: 64883 # reads processed: 64883 # reads with at least one reported alignment: 24307 (37.46%) # reads that failed to align: 39764 (61.29%) # reads with alignments suppressed due to -m: 812 (1.25%) Reported 24307 alignments to 1 output stream(s)
OK, it’s so easy that I will post an answer.
input.scan(/^SLX.*?(?=^SLX|\z)/m)
.map { |p| p.split($/).map { |e| %Q|"#{e}"| }.join (', ') }
.join($/)

Repeat node value in YAML

pagination:
limit:
default: 10
min: 0
max: 50
current: default
The current node should have the same value as the default node? (in this case, 10). Is it possible to do that with YAML?
You can use an anchor for that, which is a token starting with & inserted before the scalar/mapping/sequence you want to "re-use". You "paste" it with an alias which is the same token preceded by a *.
pagination:
limit:
default: &def 10
min: 0
max: 50
current: *def
(you can use default instead of def but you don't have to use the same string as the key whose value you put an anchor on)

Matching all lines between two lines recursively in ruby

I would like to match all lines (including the first line) between two lines that start with 'SLX-', convert them to a comma separated line and then append them to a text file.
A truncated version of the original text file looks like:
SLX-9397._TC038IV_L_FLD0214.Read1.fq.gz
Sequences: 1406295
With index: 1300537
Sufficient length: 1300501
Min index: 0
Max index: 115
0 1299240
1 71
2 1
4 1
Unique: 86490
# reads processed: 86490
# reads with at least one reported alignment: 27433 (31.72%)
# reads that failed to align: 58544 (67.69%)
# reads with alignments suppressed due to -m: 513 (0.59%)
Reported 27433 alignments to 1 output stream(s)
SLX-9397._TC044II_D_FLD0197.Read1.fq.gz
Sequences: 308905
With index: 284599
Sufficient length: 284589
Min index: 0
Max index: 114
0 284290
1 16
Unique: 32715
# reads processed: 32715
# reads with at least one reported alignment: 13114 (40.09%)
# reads that failed to align: 19327 (59.08%)
# reads with alignments suppressed due to -m: 274 (0.84%)
Reported 13114 alignments to 1 output stream(s)
SLX-9397._TC047II_D_FLD0220.Read1.fq.gz
I imagine the ruby would look like
Convert all /n between two lines with SLX- to commas
Save the original text file as a new text file (or even better a CSV file.
I think I specifically have a problem with how to find and replace between two specific lines.
I guess I could do this without using ruby, but seeing as I'm trying to get into Ruby...
Assuming, that you have your string in str:
require 'csv'
CSV.open("/tmp/file.csv", "wb") do |csv|
str.scan(/^(SLX-.*?)(?=\R+SLX-)/m).map do |s| # break by SLX-
s.first.split($/).map do |el| # split by CR
"'#{el}'" # quote values
end
end.each do |line| # iterate
csv << line # fulfil csv
end
end
I don't know much about Ruby but this should work. You should read the entire file into a Sting. Use this regex - (\RSLX-) - to match all SLX- (all but the first one) and replace it with ,SLX-. For the explanation of the regex, go to https://regex101.com/r/pP3pP3/1
This question - Ruby replace string with captured regex pattern - might help you to understand how to replace in ruby

Resources