Rename internal:limits element to .mudpy.limit
authorJeremy Stanley <fungi@yuggoth.org>
Sun, 17 Jul 2016 02:45:00 +0000 (02:45 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Sun, 17 Jul 2016 02:45:00 +0000 (02:45 +0000)
Convert the old style internal:limits element to a new style
.mudpy.limit element and rename the default_admins,
default_backup_count and max_avatars facets to admins, backups and
avatars respectively.

etc/mudpy.yaml
lib/mudpy/data.py
lib/mudpy/misc.py
share/menu.yaml

index e6fd405..0d61479 100644 (file)
@@ -13,11 +13,10 @@ __control__:
 .mudpy.linguistic.default_punctuation: .
 .mudpy.linguistic.typos: { "i": "I", "i'd": "I'd", "i'll": "I'll", "i'm": "I'm", "teh": "the", "theyre": "they're", "youre": "you're" }
 
-internal:limits:
-    #default_admins: [ "admin" ]
-    #default_backup_count: 10
-    max_avatars: 7
-    password_tries: 3
+#.mudpy.limit.admins: [ admin ]
+.mudpy.limit.avatars: 7
+#.mudpy.limit.backups: 10
+.mudpy.limit.password_tries: 3
 
 internal:logging:
     #file: mudpy.log
index 9c167f5..02a9139 100644 (file)
@@ -132,11 +132,8 @@ class DataFile:
                     "__control__"]:
                 max_count = self.data["__control__"]["backup_count"]
             else:
-                max_count = self.universe.categories[
-                    "internal"
-                ][
-                    "limits"
-                ].get("default_backup_count")
+                max_count = self.universe.contents["mudpy.limit"].get(
+                    "backups")
             if os.path.exists(self.filename) and max_count:
                 backups = []
                 for candidate in os.listdir(os.path.dirname(self.filename)):
index 1dc6b3d..2dc75c0 100644 (file)
@@ -685,13 +685,8 @@ class User:
         if self.state is not "authenticated":
             log("User " + self.account.get("name") + " logged in.", 2)
             self.authenticated = True
-            if self.account.subkey in universe.categories[
-               "internal"
-               ][
-                "limits"
-            ].get(
-                "default_admins"
-            ):
+            if self.account.subkey in universe.contents["mudpy.limit"].get(
+                    "admins"):
                 self.account.set("administrator", "True")
 
     def show_menu(self):
@@ -1760,13 +1755,8 @@ def handler_checking_password(user):
             user.state = "main_utility"
 
     # if at first your hashes don't match, try, try again
-    elif user.password_tries < universe.categories[
-        "internal"
-    ][
-        "limits"
-    ].get(
-        "password_tries"
-    ) - 1:
+    elif user.password_tries < universe.contents["mudpy.limit"].get(
+            "password_tries") - 1:
         user.password_tries += 1
         user.error = "incorrect"
 
@@ -1799,13 +1789,8 @@ def handler_entering_new_password(user):
         user.state = "verifying_new_password"
 
     # the password was weak, try again if you haven't tried too many times
-    elif user.password_tries < universe.categories[
-        "internal"
-    ][
-        "limits"
-    ].get(
-        "password_tries"
-    ) - 1:
+    elif user.password_tries < universe.contents["mudpy.limit"].get(
+            "password_tries") - 1:
         user.password_tries += 1
         user.error = "weak"
 
@@ -1834,13 +1819,8 @@ def handler_verifying_new_password(user):
 
     # go back to entering the new password as long as you haven't tried
     # too many times
-    elif user.password_tries < universe.categories[
-        "internal"
-    ][
-        "limits"
-    ].get(
-        "password_tries"
-    ) - 1:
+    elif user.password_tries < universe.contents["mudpy.limit"].get(
+            "password_tries") - 1:
         user.password_tries += 1
         user.error = "differs"
         user.state = "entering_new_password"
index 94865c1..9735aec 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2004-2015 Jeremy Stanley <fungi@yuggoth.org>. Permission
+# Copyright (c) 2004-2016 Jeremy Stanley <fungi@yuggoth.org>. Permission
 # to use, copy, modify, and distribute this software is granted under
 # terms provided in the LICENSE file distributed with this software.
 
@@ -112,7 +112,7 @@ menu:main_utility:
     choice_l: leave for now
     choice_p: permanently remove your account
     demand_a: user.account.get("avatars")
-    demand_c: len(user.account.get("avatars")) < universe.categories["internal"]["limits"].get("max_avatars")
+    demand_c: len(user.account.get("avatars")) < universe.contents["mudpy.limit"].get("avatars")
     demand_d: user.account.get("avatars")
     description: $(red)$(inc:banner.txt)$(nrm)$(eol)$(eol)From here you can awaken, create and delete avatars. An avatar is your persona in the World. You can also leave or permanently delete your account.
     prompt: What would you like to do?