Commit deaf512c authored by Adrian DC's avatar Adrian DC
Browse files

chore: types: refactor 'Dicts.find' without regex dependency

parent 6f43910c
Loading
Loading
Loading
Loading
Loading
+5 −5
Changes for gitlabci_local/types/dicts.py: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
#!/usr/bin/env python3

# Standard libraries
from regex import match
from re import findall, match

# Dicts class
class Dicts:
@@ -18,10 +18,10 @@ class Dicts:
        for query in queries:

            # Parse query to key and index
            parse = match(r'([^\[]*)(\[(\d)\])*', query)
            if parse.group(1) and parse.captures(3):
                key = parse.group(1)
                indexes = [int(value) for value in parse.captures(3)]
            matches = match(r'([^\[]*)(\[.*\])*', query).groups()
            if matches[0] and matches[1]:
                key = matches[0]
                indexes = [int(value) for value in findall(r'\[(\d+)\]*', matches[1])]
            else:
                key = query
                indexes = []
+1 −1
Changes for tests/configurations/.gitlab-ci.yml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ variables:
      help: Configure the 10th variable
      type: json
      path: ./data.json
      key: 'lists[1][2]'
      key: 'lists[1][12]'
    VARIABLE_11:
      help: Configure the 11th variable
      type: json
+10 −0
Changes for tests/configurations/data.json: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,6 +15,16 @@
    [
      ["Eight", "Nine", "Ten"],
      ["Eleven", "Twelve", "Thirteen"],
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      ["Fourteen", "Fifteen", "Sixteen"]
    ]
  ],