This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 9c7d674c61eb4983280df89689d1230723917c28
Author: Greg Stein <[email protected]>
AuthorDate: Fri Mar 6 06:16:19 2026 -0600

    Some simplifications and tweaks for more modern code.
---
 whatif.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/whatif.py b/whatif.py
index 4c11676..d1ffb3d 100755
--- a/whatif.py
+++ b/whatif.py
@@ -27,19 +27,28 @@
 #   whatif.py ../Meetings/20110712/raw_board_votes.txt -LawrenceRosen
 #   whatif.py ../Meetings/20110712/raw_board_votes.txt 1 kulp noirin geir chris
 
-import os.path
 import sys
+if __name__ != '__main__':
+    raise Exception('ERROR: not intended to be used as a library.')
+
+import os.path
 import re
+import pathlib
 
-sys.path.append(os.path.join(os.path.dirname(__file__), 'monitoring'))
+THIS_DIR = pathlib.Path(__file__).resolve().parent
+
+# We're a top-level script. Adjust the import path.
+sys.path.append(str(THIS_DIR / 'monitoring'))
 import stv_tool
 
+
 def usage():
-  print('Usage: %s [-v] RAW_VOTES_FILE [seats] [-]name...' % scriptname)
+  print(f'Usage: {SCRIPTNAME} [-v] RAW_VOTES_FILE [seats] [-]name...')
   sys.exit(1)
 
-if __name__ == '__main__':
-  scriptname = sys.argv.pop(0)
+
+if True:  ### temporary. avoid indentation changes for now.
+  SCRIPTNAME = sys.argv.pop(0)
 
   if sys.argv and sys.argv[0] == '-v':
     stv_tool.VERBOSE = True

Reply via email to