Skip to content

Commit

Permalink
I should actually commit more changes. Jesus.
Browse files Browse the repository at this point in the history
  • Loading branch information
Villawhatever committed Jan 26, 2020
1 parent 312ba9a commit 458b102
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 13,378 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,4 @@ typings/
#temp static files
/static/res/*.html
/static/add_to_slack.html
twittertest.py
28 changes: 26 additions & 2 deletions difftool/diff_rules.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import json
import sys

Expand Down Expand Up @@ -26,15 +27,38 @@
'old_setcode': orig_cr_set_code,
'new_full': sys.argv[4],
'new_setcode': dest_cr_set_code}}]

changes = []
deletions = []
out_path = 'public/assets/cr-diffs/'
output_rules_file = '%s%s-%s.json' % (out_path,
orig_cr_set_code,
dest_cr_set_code)

with open(output_rules_file, 'w', encoding='utf-8') as out_json:
# output_rules_file = 'test.json'

output_numbering_changes = '/home/vill/Southfall/changes.json'

with open(output_rules_file, 'w', encoding='utf-8') as out_json, \
open(output_numbering_changes, 'w', encoding='utf-8') as out_changes:
for i, (old, new) in enumerate(zip(old_rules, new_rules)):
output_comparison = diff_utils.diff_rules(old, new)
if output_comparison:
rules.append(output_comparison)
if output_comparison['old'] and output_comparison['new']:
if (output_comparison['old']['ruleNum'] !=
output_comparison['new']['ruleNum']):
changes.append({'old':
output_comparison['old']['ruleNum'],
'new':
output_comparison['new']['ruleNum']})

if output_comparison['old'] and not output_comparison['new']:
deletions.append({'removed':
output_comparison['old']['ruleNum']})

out_json.write(json.dumps(rules, indent=4))
finished_changes = {'lastUpdate':
datetime.datetime.today().strftime('%Y-%d-%m'),
'changes': changes,
'deletions': deletions}
out_changes.write(json.dumps(finished_changes, indent=4))
4 changes: 2 additions & 2 deletions difftool/diff_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def diff_rules(old_rule, new_rule):
modded_new.extend(new_rule_text[n:n + i])
new_offset = n + i

if ('old_start' not in ' '.join(modded_old)
and 'new_start' not in ' '.join(modded_new)):
if ('old_start' not in ' '.join(modded_old) and
'new_start' not in ' '.join(modded_new)):
# the only changes were to rule numbers, so we can get out
return None

Expand Down
Binary file removed difftool/newipg
Binary file not shown.
Binary file removed difftool/oldipg
Binary file not shown.
7 changes: 4 additions & 3 deletions difftool/rules_manip.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def extract_rules(input_file):
extracted_rules = re.findall('^\d{3}[^a-zA-Z\n]{2}.*[“"”.) :]$',
entire_doc, re.MULTILINE)
rules_list = []

for rule in extracted_rules[1:]:
rules_list.append(rule.split())
for rule in extracted_rules:
rule_normalized = rule.split()
rule_normalized[0] = rule_normalized[0].rstrip('.')
rules_list.append(rule_normalized)

return rules_list

Expand Down
2 changes: 1 addition & 1 deletion newcr.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ else
new_set_name=$(grep -oP "\"$new_set_abbr\": \"\K[^\"]+" $sets_file)

# Diff 'em away boys
python3 difftool/diff_rules.py "$rules_path$old_rules_file" "$old_set_name" "$rules_path$new_rules_file" "$new_set_name"
python3 difftool/diff_rules.py "$rules_path$old_rules_file" "$old_set_name" "$new_rules_file" "$rules_path$new_set_name"
python3 /home/vill/Southfall/grab_rules.py "$new_rules_file"
fi
9 changes: 4 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ app.get('/:diff([\\w]{3}\\-[\\w]{3})', function(req, res) {
+ '.json', 'utf8',
(err, data) => {
if (err) {
res.status(500).render('pages/error_template', {status: res.statusCode + ': The CR route you tried doesn\'t exist. At all. And never will.'})
console.log(err)
res.status(500).render('pages/error_template', {status: res.statusCode + ': The CR route you tried doesn\'t exist. At all. And never will.'});
} else {
rules = assist.getRules(data);
if (rules.length === 2) {
res.render('pages/gief')
if (rules.length < 2) {
res.render('pages/gief')
} else {
res.render('pages/rules', {rules: rules})
}
Expand All @@ -53,7 +52,7 @@ app.get('/:diff([\\w]{3}\\-[\\w]{3})', function(req, res) {
})

app.get('/:rule(\\d{1,3}[\\.]\\w{1,4})', function (req, res) {
let ruleNum = req.params.rule;
let ruleNum = req.params.rule.toLowerCase();
console.log(date.toLocaleDateString(), ": Requested STANDALONE RULE: ", ruleNum);
const urls = ['https://slack.vensersjournal.com/rule/'+ruleNum, 'https://slack.vensersjournal.com/example/'+ruleNum]
const promises = urls.map(url => request(url));
Expand Down
4 changes: 3 additions & 1 deletion static/res/sets.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,7 @@ var setDict = {
"MH1": "Modern Horizons",
"M20": "Core Set 2020",
"C19": "Commander 2019",
"ELD": "Throne of Eldraine"
"ELD": "Throne of Eldraine",
"THB": "Theros Beyond Death",
"IKO": "Ikoria"
}
Loading

0 comments on commit 458b102

Please sign in to comment.