import optparse
import os
+import sys
from naja.attrdict import AttrDict
from naja.constants import DEFAULTS
dest='music', action='store_false', default=True,
help='Disable music (but not sound)')
+ parser.add_option("--save-location", default=_get_default_save_location(),
+ dest="save_location", help="Saved game location")
+
+ if options.debug:
+ parser.add_option('--initial-bits', type=int,
+ help='Initial player bits')
+ parser.add_option('--cheat-enabled', default=False,
+ action='store_true',
+ help='For those too lazy to type the KONAMI code')
+
opts, _ = parser.parse_args(args)
for k in DEFAULTS:
if getattr(opts, k, None) is not None:
options[k] = getattr(opts, k)
+
+
+def _get_default_save_location():
+ """Return a default save game location."""
+ app = "naja"
+ if sys.platform.startswith("win"):
+ if "APPDATA" in os.environ:
+ return os.path.join(os.environ["APPDATA"], app)
+ return os.path.join(os.path.expanduser("~"), "." + app)
+ elif 'XDG_DATA_HOME' in os.environ:
+ return os.path.join(os.environ["XDG_DATA_HOME"], app)
+ return os.path.join(os.path.expanduser("~"), ".local", "share", app)