@winguru/

R-Studio Apple RAID-5 XML Definition Generator

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9849424930721293","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"cGFyaXR5X2RlbGF5ID0gMgoKZGVmIHNlcSh4LCB5KToKICAgIHJldHVybiBwYXJpdHlfZGVsYXkgKiB4ICogMiArIHkKCm1hdHJpeCA9IFtbTm9uZSBmb3IgXyBpbiByYW5nZSg0KV0gZm9yIF8gaW4gcmFuZ2UoMyAqIHBhcml0eV9kZWxheSldCgpmb3IgaSBpbiByYW5nZShwYXJpdHlfZGVsYXkpOgogICAgYSA9IGkqMiArIDEKICAgIGIgPSBhICsgMQogICAgbWF0cml4W3Bhcml0eV9kZWxheSAqIDAgKyBpXSA9IFswLCBzZXEoMCwgYSksIHNlcSgwLCBiKSwgMF0KICAgIG1hdHJpeFtwYXJpdHlfZGVsYXkgKiAxICsgaV0gPSBbc2VxKDEsIGEpLCBzZXEoMSwgYiksIDAsIHNlcSgyLCBhKV0KICAgIG1hdHJpeFtwYXJpdHlfZGVsYXkgKiAyICsgaV0gPSBbc2VxKDIsIGIpLCAwLCBzZXEoMywgYSksIHNlcSgzLCBiKV0KCnByaW50KCd7fTxUYWJsZT4nLmZvcm1hdCgnICcqOCkpCmZvciBpIGluIHJhbmdlKDAsIDEyICogcGFyaXR5X2RlbGF5KToKICAgIHJvdyA9IGludChpIC8gNCkKICAgIGNvbHVtbiA9IGkgJSA0CiAgICBjZWxsID0gIkFCQ0QiW2NvbHVtbl0gKyBzdHIocm93KzEpCiAgICBvZmZzZXQgPSByb3cgLy8gcGFyaXR5X2RlbGF5ICsgY29sdW1uCiAgICBzZXF1ZW5jZSA9IHJvdyArIChvZmZzZXQgLy8gMykgKiBwYXJpdHlfZGVsYXkgKyAxCgogICAgaWYgKG9mZnNldCAlIDMpID09IDA6CiAgICAgICAgcHJpbnQoJ3t9PEJsb2NrIGlkPS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T4nLmZvcm1hdCgnICcgKiAxMiwgZCwgYywgYywgYyldCnJzdHVkaW9fb3V0cHV0WzNdICs9IFsne308L1NlcXVlbmNlcz4nLmZvcm1hdCgnICcgKiA4KV0KCmZvciBsaW5lX2dyb3VwIGluIHJzdHVkaW9fb3V0cHV0OgogICAgZm9yIGxpbmUgaW4gbGluZV9ncm91cDoKICAgICAgICBwcmludChsaW5lKQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
parity_delay = 2

def seq(x, y):
    return parity_delay * x * 2 + y

matrix = [[None for _ in range(4)] for _ in range(3 * parity_delay)]

for i in range(parity_delay):
    a = i*2 + 1
    b = a + 1
    matrix[parity_delay * 0 + i] = [0, seq(0, a), seq(0, b), 0]
    matrix[parity_delay * 1 + i] = [seq(1, a), seq(1, b), 0, seq(2, a)]
    matrix[parity_delay * 2 + i] = [seq(2, b), 0, seq(3, a), seq(3, b)]

print('{}<Table>'.format(' '*8))
for i in range(0, 12 * parity_delay):
    row = int(i / 4)
    column = i % 4
    cell = "ABCD"[column] + str(row+1)
    offset = row // parity_delay + column
    sequence = row + (offset // 3) * parity_delay + 1

    if (offset % 3) == 0:
        print('{}<Block id="{}" sequence="{}">XorOfData</Block>'.format(' '*12, cell, sequence))
    else:
        print('{}<Block id="{}">{}</Block>'.format(' '*12, cell, matrix[row][column]))
print('{}</Table>'.format(' '*8))

rstudio_output = [[] for _ in range(4)]
rstudio_output[0] += ['{}<Sequences>'.format(' ' * 8)]
for i in range(parity_delay):
    a = i + 1
    b = parity_delay + i + 1
    c = parity_delay * 2 + i + 1
    d = parity_delay * 3 + i + 1
    rstudio_output[0] += ['{}<Sequence id="{}">A{} B{} C{}</Sequence>'.format(' ' * 12, a, a, a, a)]
    rstudio_output[1] += ['{}<Sequence id="{}">D{} A{} B{}</Sequence>'.format(' ' * 12, b, a, b, b)]
    rstudio_output[2] += ['{}<Sequence id="{}">C{} D{} A{}</Sequence>'.format(' ' * 12, c, b, b, c)]
    rstudio_output[3] += ['{}<Sequence id="{}">B{} C{} D{}</Sequence>'.format(' ' * 12, d, c, c, c)]
rstudio_output[3] += ['{}</Sequences>'.format(' ' * 8)]

for line_group in rstudio_output:
    for line in line_group:
        print(line)