Skip to content

Commit

Permalink
updated setup and prepare for v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiufeng54321 committed Jun 15, 2020
1 parent 0ff3923 commit ea16ff8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
15 changes: 13 additions & 2 deletions muser/game_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


import util
import os, io, sys, time
import os, io, sys, time, subprocess

def sprint(text):
return input(text)
Expand Down Expand Up @@ -64,5 +64,16 @@ def sprint(text):
print("Game config written.")

# TODO: Install default sheets
command = ['git', 'describe', '--abbrev=0']
latest_tag = util.cmd(command)[0][:-1]
tag_desc = util.cmd(["git", "cat-file", "-p", latest_tag])[0]
tmp = io.open('.tmpdesc', 'w')
tmp.write(tag_desc)
tmp.close()
message = util.cmd(['tail', '-n', '+6', '.tmpdesc'])[0]
os.remove('.tmpdesc')

print("Setup wizard complete. You may now try the game by running main.py!")
links = util.find_links(message)
print("Links found:", links)

print("Setup wizard complete. You may now try the game by running main.py!")
21 changes: 21 additions & 0 deletions muser/util.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import re
import time
import functools
import subprocess
import sys


version = "1.5"

# GEEZ A LOT OF COPYING LOL

# https://stackoverflow.com/a/50255019/11225486
def pip_install(package: list):
args = [sys.executable, "-m", "pip", "install", *package]
print(" ".join(args))
subprocess.check_call(args)

# Copied and modified from https://stackoverflow.com/a/8217646/11225486
def cmd(args: list):
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=None)
text = p.stdout.read()
retcode = p.wait()
return (str(text.decode('utf-8')), retcode)

# https://geeksforgeeks.org/python-check-url-string/
def find_links(string):
# findall() has been used
# with valid conditions for urls in string
regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))"
url = re.findall(regex, string)
return [x[0] for x in url]

def grid(sw, sh, gw, gh, x, y):
gridw = sw / gw
gridh = sh / gh
Expand Down

0 comments on commit ea16ff8

Please sign in to comment.