Skip to content

Commit

Permalink
Merge pull request #7043 from PennyDreadfulMTG/rot
Browse files Browse the repository at this point in the history
Further improve rotation script
  • Loading branch information
vorpal-buildbot committed Feb 10, 2020
2 parents 35a6daa + 1314ed3 commit c9eaa4e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,7 @@ services:
- mysql
env:
global:
- mysql_user=root
- mysql_user=root slow_query=999.0
matrix:
- CMD="python dev.py tests"
- CMD="python dev.py mypy"
Expand Down
24 changes: 24 additions & 0 deletions rotation_script/rotation_script.py
@@ -1,6 +1,8 @@
import datetime
import fileinput
import os
import shutil
import subprocess
from collections import Counter
from typing import Dict, List, Set

Expand Down Expand Up @@ -129,3 +131,25 @@ def make_final_list() -> None:
h = open(os.path.join(configuration.get_str('legality_dir'), f'{setcode}_legal_cards.txt'), mode='w', encoding='utf-8')
h.write(''.join(final))
h.close()

do_push()

def do_push() -> None:
gh_repo = os.path.join(configuration.get_str('legality_dir'), 'gh_pages')
if not os.path.exists(gh_repo):
subprocess.run(['git', 'clone', 'https://github.com/PennyDreadfulMTG/pennydreadfulmtg.github.io.git', gh_repo], check=True)
if is_supplemental():
setcode = rotation.last_rotation_ex()['mtgo_code']
rottype = 'supplemental'
else:
setcode = rotation.next_rotation_ex()['mtgo_code']
rottype = 'rotation'
files = ['legal_cards.txt', f'{setcode}_legal_cards.txt']
for fn in files:
source = os.path.join(configuration.get_str('legality_dir'), fn)
dest = os.path.join(gh_repo, fn)
shutil.copy(source, dest)
os.chdir(gh_repo)
subprocess.run(['git', 'add'] + files, check=True)
subprocess.run(['git', 'commit', '-m', f'{setcode} {rottype}'], check=True)
subprocess.run(['git', 'push'] + files, check=True)
20 changes: 20 additions & 0 deletions setup.py
@@ -0,0 +1,20 @@
import setuptools

with open('README.md', 'r') as fh:
DESC = fh.read()

setuptools.setup(
name='Penny Dreadful Tools',
version='0.0.1',
author='The Penny Dreadful Team',
description='',
long_description=DESC,
long_description_content_type='text/markdown',
url='https://github.com/PennyDreadfulMTG/Penny-Dreadful-Tools',
packages=setuptools.find_packages(),
classifiers=[
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
],
python_requires='>=3.6',
)
5 changes: 5 additions & 0 deletions shared/configuration.py
Expand Up @@ -133,6 +133,11 @@ def get_float(key: str) -> Optional[float]:
return val
if isinstance(val, int):
return write(key, float(val))
if isinstance(val, str):
# required so that we can pass int-values in environment variables
CONFIG[key] = float(val)
return CONFIG[key]

raise fail(key, val, float)

def get_list(key: str) -> List[str]:
Expand Down

0 comments on commit c9eaa4e

Please sign in to comment.