Skip to content

Commit

Permalink
Merge pull request #114 from pnahratow/minimal_ci
Browse files Browse the repository at this point in the history
Add a minimal CI workflow
  • Loading branch information
MissLavender-LQ committed Mar 9, 2024
2 parents ed595d4 + df9a393 commit bbe8e5a
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 94 deletions.
3 changes: 3 additions & 0 deletions .flake8
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 120
exclude = venv,docs/.etherpad-backups
19 changes: 19 additions & 0 deletions .github/workflows/linting.yml
@@ -0,0 +1,19 @@
name: flake8

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Analysing the code with flake8
run: flake8
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,6 +6,7 @@ autosave/
lq1/screenshots/
working/
releases/
venv/

# ignored files
docs/lqlogos/logomockup-wip2.ora
Expand Down
102 changes: 53 additions & 49 deletions bin/py/asset_analyze.py
Expand Up @@ -8,61 +8,65 @@
import sys

console = 1
#Green text
# Green text
if console == 1:
col = '\033[92m'
end = '\033[0m'
col = '\033[92m'
end = '\033[0m'
else:
col = "**"
end = "**"
col = "**"
end = "**"


def bold(str_in):
return col + str(str_in) + end
return col + str(str_in) + end


def bprint(s):
sys.stdout.write(s)
sys.stdout.write(s)


def main():
print(bold("LibreQuake Asset report:\n"))

count_total = 0
count_complete = 0

#Go through the file, listing incomplete items
print(bold("Items that still need to be accounted for:"))
file1 = open("assets.txt","r")
#Go through each line
for line in file1:
#Only read lines that contain a file
if line[:3] == "pak" or line[:3] == "mus":
#Track the total number of items
count_total += 1
items = line.split(" - ")
#Ensure there is a name on the list
if len(items) == 1:
bprint(items[0])
elif len(items) >= 2:
if items[1] == "\n":
bprint(items[0])
file1.close()

#Go through the file again, listing complete items
print(bold("\nItems that are complete or in progress:"))

file1 = open("assets.txt","r")
for line in file1:
if line[:3] == "pak" or line[:3] == "mus":
items = line.split(" - ")
#Ensure there is not a name on the list
if len(items) >= 2:
if items[1] != "\n":
#Track the total number of COMPLETED items
count_complete += 1
bprint(bold(items[0]) + " is being accounted for by " + bold(items[1]))
file1.close()
print("\nItems accounted for: " + bold(str(count_complete) + "/" + str(count_total)))
percent = (1.0*count_complete/count_total)*100
percent_truncate = int(percent * 1000) / 1000.0
print("We're " + bold(str(percent_truncate) + "%") + " of the way there!")

print(bold("LibreQuake Asset report:\n"))

count_total = 0
count_complete = 0

# Go through the file, listing incomplete items
print(bold("Items that still need to be accounted for:"))
file1 = open("assets.txt", "r")
# Go through each line
for line in file1:
# Only read lines that contain a file
if line[:3] == "pak" or line[:3] == "mus":
# Track the total number of items
count_total += 1
items = line.split(" - ")
# Ensure there is a name on the list
if len(items) == 1:
bprint(items[0])
elif len(items) >= 2:
if items[1] == "\n":
bprint(items[0])
file1.close()

# Go through the file again, listing complete items
print(bold("\nItems that are complete or in progress:"))

file1 = open("assets.txt", "r")
for line in file1:
if line[:3] == "pak" or line[:3] == "mus":
items = line.split(" - ")
# Ensure there is not a name on the list
if len(items) >= 2:
if items[1] != "\n":
# Track the total number of COMPLETED items
count_complete += 1
bprint(bold(items[0]) + " is being accounted for by " + bold(items[1]))
file1.close()
print("\nItems accounted for: " + bold(str(count_complete) + "/" + str(count_total)))
percent = (1.0*count_complete/count_total)*100
percent_truncate = int(percent * 1000) / 1000.0
print("We're " + bold(str(percent_truncate) + "%") + " of the way there!")


main()
56 changes: 27 additions & 29 deletions bin/py/quake16x.py
@@ -1,42 +1,40 @@

import os, sys
import os
from PIL import Image
import pdb

base_folder = os.path.abspath(os.path.dirname(__file__)).replace("\\","/")
base_folder = os.path.abspath(os.path.dirname(__file__)).replace("\\", "/")
converted_folder = base_folder+"/converted/"
if not os.path.exists(converted_folder):
os.makedirs(converted_folder)
os.makedirs(converted_folder)

files = os.listdir(base_folder)

converted = 0
for name in files:
try:
img = Image.open(name)
except (PermissionError, OSError):
## skip anything that can't be opened or isn't an image
continue

output_file = converted_folder + name

if not img.width % 16 == 0:
new_width = img.width - (img.width % 16) + 16

else:
new_width = img.width

if not img.height % 16 == 0:
new_height = img.height - (img.height % 16) + 16

else: new_height = img.height


print(f"Converting: ({img.width}x{img.height}) -> ({new_width}x{new_height}) - {output_file}");

resized = img.resize((new_width, new_height), Image.NEAREST)
resized.save(output_file)
converted += 1
try:
img = Image.open(name)
except (PermissionError, OSError):
# skip anything that can't be opened or isn't an image
continue

output_file = converted_folder + name

if not img.width % 16 == 0:
new_width = img.width - (img.width % 16) + 16

else:
new_width = img.width

if not img.height % 16 == 0:
new_height = img.height - (img.height % 16) + 16
else:
new_height = img.height

print(f"Converting: ({img.width}x{img.height}) -> ({new_width}x{new_height}) - {output_file}")

resized = img.resize((new_width, new_height), Image.NEAREST)
resized.save(output_file)
converted += 1

plural = "" if converted == 1 else "s"
print(f"Total: {converted} image{plural} converted.")
25 changes: 18 additions & 7 deletions build.py
Expand Up @@ -19,18 +19,20 @@
import glob
import argparse


# Builds a single file
def build_file(source_path, destination_path, source_if_missing):
print(source_path)
os.makedirs(os.path.dirname(destination_path), exist_ok=True)
try:
shutil.copy(source_path, destination_path)
except:
except Exception:
if len(source_if_missing):
shutil.copy(source_if_missing, destination_path)
else:
warnings.warn(f"Missing file with no substitute: {source_path}")


# Gets a source and dest path from a file entry File. Entries can be a string
# (where source and dest are the same) or a 2-long list (specifying the source
# and dest, respectively)
Expand All @@ -40,6 +42,7 @@ def extract_file(file):
else:
return file, file


# Builds a single component from build_components.json
def build_component(component_data):
# Determine the source if missing
Expand Down Expand Up @@ -73,6 +76,7 @@ def build_component(component_data):
source_if_missing,
)


# Build a single release from build_releases.json
def build_release(name, data):
# Print
Expand All @@ -82,7 +86,7 @@ def build_release(name, data):
clear_working()

# Create release directory
os.makedirs(f'releases', exist_ok=True)
os.makedirs('releases', exist_ok=True)

# Pull out base directory
base_dir = data['base_dir']
Expand All @@ -108,7 +112,6 @@ def build_release(name, data):
os.chdir('../../')
shutil.copy('working/pak0.pak', os.path.join('releases', name, base_dir, 'pak0.pak'))


# Build and copy pak1
pak1_exists = len(os.listdir('working/pak1')) > 0
if pak1_exists:
Expand All @@ -121,35 +124,41 @@ def build_release(name, data):
os.chdir('../../')
shutil.copy('working/pak1.pak', os.path.join('releases', name, base_dir, 'pak1.pak'))


# Clears the working directory and sets up empty directories
def clear_working():
# Remove working folder and its contents
shutil.rmtree('./working', ignore_errors=True)

# Create new empty directories
os.makedirs(f'working', exist_ok=True)
os.makedirs(f'working/pak0', exist_ok=True)
os.makedirs(f'working/pak1', exist_ok=True)
os.makedirs(f'working/unpacked', exist_ok=True)
os.makedirs('working', exist_ok=True)
os.makedirs('working/pak0', exist_ok=True)
os.makedirs('working/pak1', exist_ok=True)
os.makedirs('working/unpacked', exist_ok=True)


def compile_wad():
os.chdir('texture-wads')
runpy.run_path('./compile_wads.py', run_name="__build__")
os.chdir('../')


def compile_bsp():
os.chdir('./lq1/maps')
runpy.run_path('./compile_maps.py', run_name="__build__")
os.chdir('../../')


def compile_progs():
subprocess.call(['fteqcc', 'qcsrc/progs.src', '-D__LIBREQUAKE__', '-O3'])


def compile():
compile_wad()
compile_bsp()
compile_progs()


def build():
# Delete existing releases
shutil.rmtree('./releases', ignore_errors=True)
Expand All @@ -160,6 +169,7 @@ def build():
for key, value in releases.items():
build_release(key, value)


def main():
# Parse command-line arguments
parser = argparse.ArgumentParser(description="Example script to demonstrate argparse usage.")
Expand Down Expand Up @@ -195,5 +205,6 @@ def main():
# Confirmation
print("Build complete!")


if __name__ == "__main__":
main()

0 comments on commit bbe8e5a

Please sign in to comment.