Merge pull request #2405 from CHOMPStationBot/upstream-merge-10869

[MIRROR] Upgrade rust_g to version 0.4.0
This commit is contained in:
Nadyr
2021-07-14 22:49:49 -04:00
committed by GitHub
6 changed files with 17 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ env:
jobs:
autochangelog:
name: Autochangelog
runs-on: ubuntu-16.04
runs-on: ubuntu-20.04
if: github.event.pull_request.merged == true
steps:
- uses: /actions/checkout@v2

View File

@@ -10,7 +10,7 @@ env:
jobs:
file_tests:
name: Run Linters
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Ensure +x on CI directory
@@ -26,7 +26,7 @@ jobs:
# dreamchecker:
# name: DreamChecker
# runs-on: ubuntu-18.04
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v2
#
@@ -54,7 +54,7 @@ jobs:
unit_tests:
name: Integration Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Ensure +x on CI directory
@@ -69,7 +69,7 @@ jobs:
run: |
sudo dpkg --add-architecture i386
sudo apt update || true
sudo apt install libc6:i386 libgcc1:i386 libstdc++6:i386 libssl1.0.0:i386 zlib1g:i386
sudo apt install zlib1g-dev:i386 libssl-dev:i386 pkg-config:i386
ldd librust_g.so
- name: Unit Tests
run: |

View File

@@ -14,7 +14,7 @@ on:
jobs:
generate_maps:
name: 'Generate NanoMaps'
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Clone
uses: actions/checkout@v2

Binary file not shown.

Binary file not shown.

View File

@@ -20,14 +20,15 @@ THE SOFTWARE.
import argparse, re, sys
from collections import defaultdict
from os import path, walk
from codecs import open
opt = argparse.ArgumentParser()
opt.add_argument('dir', help='The directory to scan for *.dm files with non-matching spans')
args = opt.parse_args()
if(not path.isdir(args.dir)):
print('Not a directory')
sys.exit(1)
print('Not a directory')
sys.exit(1)
# These tuples are expected to be ordered as:
# A unique human readable name (henceforth referred to as tuple name), a regex pattern matching an opening tag, a regex pattern matching a closing tag
@@ -54,13 +55,13 @@ def get_tag_matches(line):
# Support def that simply checks if a given dictionary in the format tag/list of unmatched lines has mismatch entries.
def has_mismatch(match_list):
for tag, list_of_mismatched_lines in match_list.iteritems():
for tag, list_of_mismatched_lines in match_list.items():
if(len(list_of_mismatched_lines) > 0):
return 1
return 0
def arrange_mismatches(mismatches_by_tag, mismatch_line, mismatch_counts):
for tag, mismatch_count in mismatch_counts.iteritems():
for tag, mismatch_count in mismatch_counts.items():
stack_of_existing_mismatches = mismatches_by_tag[tag]
for i in range(0, abs(mismatch_count)):
if len(stack_of_existing_mismatches) == 0:
@@ -83,10 +84,10 @@ def arrange_mismatches(mismatches_by_tag, mismatch_line, mismatch_counts):
# This section parses all *.dm files in the given directory, recursively.
for root, subdirs, files in walk(args.dir):
for filename in files:
if filename.endswith('.dm'):
file_path = path.join(root, filename)
with open(file_path, 'r') as file:
for filename in files:
if filename.endswith('.dm'):
file_path = path.join(root, filename)
with open(file_path, 'r', encoding='utf-8', errors='ignore') as file:
mismatches_by_file[file_path] = defaultdict(list)
for line_number, line in enumerate(file, 1):
# Then for each line in the file, conduct the tuple open/close matching.
@@ -97,10 +98,10 @@ for root, subdirs, files in walk(args.dir):
# Loops over all matches and checks if there is a mismatch of tags.
# If so, then and only then is the corresponding file path printed along with the number of unmatched open/close tags.
total_mismatches = 0
for file, mismatches_by_tag in mismatches_by_file.iteritems():
for file, mismatches_by_tag in mismatches_by_file.items():
if has_mismatch(mismatches_by_tag):
print(file)
for tag, mismatch_list in mismatches_by_tag.iteritems():
for tag, mismatch_list in mismatches_by_tag.items():
# A positive number means an excess of opening tag, a negative number means an excess of closing tags.
total_mismatches += len(mismatch_list)
if len(mismatch_list) > 0: