about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-02-09 14:18:34 -0600
committerStarfall <us@starfall.systems>2023-12-05 10:01:09 -0600
commita43a3e0c273e50d30561328f090d2fad249c7dd6 (patch)
tree64d13d6a287f764fa333315d80e51e48bea68c64
parentf02c4f4c72e9a99da91cdd0a87e5e838e9b8744f (diff)
strike: reindent with tabs
-rw-r--r--CONTRIBUTING2
-rw-r--r--[-rwxr-xr-x]strike.py94
2 files changed, 48 insertions, 48 deletions
diff --git a/CONTRIBUTING b/CONTRIBUTING
index 783cecd..2f2508f 100644
--- a/CONTRIBUTING
+++ b/CONTRIBUTING
@@ -4,7 +4,7 @@ If anyone actually contributes, feel free to suggest a license change with the f
 
 PATCH CHECKLIST
 ---------------
-* Code style matches everything else (PEP8 compliance is suggested but not required, feel free to reindent everything with tabs or go to 90-110 character lines as appropriate)
+* Code style matches everything else (PEP8 compliance is suggested but not required as I've already decided to indent with tabs, feel free to go to 90-110 character lines as appropriate)
 * Documentation updated to describe new behavior
 * Example case(s) written in sample/blog
 * `./strike.py sample` run and output in sample/html looks as expected (you can use `git diff` to verify nothing except last-modified lines are changed)
diff --git a/strike.py b/strike.py
index 1afd0bf..03d991e 100755..100644
--- a/strike.py
+++ b/strike.py
@@ -6,65 +6,65 @@ from configparser import ConfigParser
 from pathlib import Path
 
 def handle_args():
-    parser = ArgumentParser()
-    parser.add_argument('config', help='location of strike.ini file (or a directory containing it)')
-    return parser.parse_args()
+	parser = ArgumentParser()
+	parser.add_argument('config', help='location of strike.ini file (or a directory containing it)')
+	return parser.parse_args()
 
 def read_config(location):
-    location = Path(location)
-    config = ConfigParser()
-    if location.is_dir():
-        location = location/'strike.ini'
-    if not location.exists():
-        raise FileNotFoundError(f'Config file not found at {location}.')
-    config.read(location)
-    return location.resolve().parent, config
+	location = Path(location)
+	config = ConfigParser()
+	if location.is_dir():
+		location = location/'strike.ini'
+	if not location.exists():
+		raise FileNotFoundError(f'Config file not found at {location}.')
+	config.read(location)
+	return location.resolve().parent, config
 
 def handle_file(file):
-    meta = dict(
-        title = file.stem,
-        date = strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime(file.stat().st_mtime))
-    )
-    contents = file.read_text()
-    delim = '---\n'
-    if contents.startswith(delim):
-        parts = contents.split(delim, maxsplit=2)
-        meta.update(dict((key.strip(), value.strip())
-            for key, value in (line.split('=') for line in parts[1].splitlines())
-        ))
-        contents = parts[2]
-    return contents, meta
+	meta = dict(
+		title = file.stem,
+		date = strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime(file.stat().st_mtime))
+	)
+	contents = file.read_text()
+	delim = '---\n'
+	if contents.startswith(delim):
+		parts = contents.split(delim, maxsplit=2)
+		meta.update(dict((key.strip(), value.strip())
+			for key, value in (line.split('=') for line in parts[1].splitlines())
+		))
+		contents = parts[2]
+	return contents, meta
 
 def apply_template(content, meta, template="{content}"):
-    return template.format(
-        content = content,
-        meta = meta
-    )
+	return template.format(
+		content = content,
+		meta = meta
+	)
 
 def main():
-    args = handle_args()
-    basedir, config = read_config(args.config)
+	args = handle_args()
+	basedir, config = read_config(args.config)
 
-    input_dir = basedir/config['Input']['directory']
+	input_dir = basedir/config['Input']['directory']
 
-    try: exclusions = config['Input']['excludes'].splitlines()
-    except KeyError: exclusions = {}
+	try: exclusions = config['Input']['excludes'].splitlines()
+	except KeyError: exclusions = {}
 
-    default_template = basedir/config['Templates']['default']
-    template = default_template.read_text()
+	default_template = basedir/config['Templates']['default']
+	template = default_template.read_text()
 
-    output_dir = basedir/config['Output']['directory']
+	output_dir = basedir/config['Output']['directory']
 
-    for path, _, files in os.walk(input_dir):
-        loc = os.path.relpath(path, input_dir)
-        (output_dir/loc).mkdir(parents=True, exist_ok=True)
-        for file in files:
-            if file in exclusions:
-                continue 
-            contents, meta = handle_file(input_dir/loc/file)
-            output = apply_template(contents, meta, template)
-            (output_dir/loc/file).write_text(output)
+	for path, _, files in os.walk(input_dir):
+		loc = os.path.relpath(path, input_dir)
+		(output_dir/loc).mkdir(parents=True, exist_ok=True)
+		for file in files:
+			if file in exclusions:
+				continue
+			contents, meta = handle_file(input_dir/loc/file)
+			output = apply_template(contents, meta, template)
+			(output_dir/loc/file).write_text(output)
 
 if __name__ == '__main__':
-    import sys
-    sys.exit(main())
+	import sys
+	sys.exit(main())