Advertisement
Guest User

IOU Recruits Manager 1.1.2

a guest
Mar 9th, 2016
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 19.91 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # ------------------------------------------------------------------------------
  5. #  
  6. #  IOU Recruits Manager 1.1.2 (C) 2015-2016 turidrum
  7. #  
  8. #  
  9. #  This program is free software; you can redistribute it and/or modify
  10. #  it under the terms of the GNU General Public License as published by
  11. #  the Free Software Foundation; either version 2 of the License, or
  12. #  (at your option) any later version.
  13. #  
  14. #  This program is distributed in the hope that it will be useful,
  15. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. #  GNU General Public License for more details.
  18. #  
  19. #  You should have received a copy of the GNU General Public License
  20. #  along with this program; if not, write to the Free Software
  21. #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22. #  MA 02110-1301, USA.
  23. #
  24. # ------------------------------------------------------------------------------
  25.  
  26.  
  27.  
  28.  
  29.  
  30. import sys
  31. import json
  32.  
  33.  
  34. program = {
  35.     "name": "IOU Recruits Manager",
  36.     "version": "1.1.2",
  37.     "url": "https://iourpg.com/forum/showthread.php?tid=1350"
  38. }
  39.  
  40. json_file = "config.json"
  41. title_template = "title.txt"
  42. iou_template = "iou.template"
  43. kong_template = "kong.template"
  44.  
  45. # read guild data from configuration file
  46. json_data = open(json_file)
  47. config = json.load(json_data)
  48. json_data.close()
  49.  
  50.  
  51. cliArgs = [
  52.     "-i", "--iou",
  53.     "-k", "--kong",
  54.     "-t", "--title",
  55.     "-r", "--recruiting_string",
  56.     "-v", "--version",
  57.     "-h", "--help"
  58. ]
  59.  
  60.  
  61. def help():
  62.     """
  63.     Prints a little help
  64.     """
  65.     print("-" * 80)
  66.     print("%s %s" % (program["name"], program["version"]))
  67.     print("-" * 80)
  68.     print("")
  69.     print("Description: Helper tool for managing Idle Online Universe's recruiting threads")
  70.     print("")
  71.     print("Usage: %s [ -i | -k | -t | -r | -v | -h ]" % __file__)
  72.     print("{:<30s} {:<60s}".format("-i --iou", "Output format for IOU forum, default."))
  73.     print("{:<30s} {:<60s}".format("-k --kong", "Output format for Kongragate forum(html)"))
  74.     print("{:<30s} {:<60s}".format("-t --title", "Prints the thread's title."))
  75.     print("{:<30s} {:<60s}".format("-r --recruiting_string", "Prints an oneliner, plain text, recruiting string."))
  76.     print("{:<30s} {:<60s}".format("-v --version", "Prints program version."))
  77.     print("{:<30s} {:<60s}".format("-h --help", "Show this help."))
  78.     print("")
  79.     print("Without arguments generates the full post.")
  80.     print("More info: https://iourpg.com/forum/showthread.php?tid=1350")
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. class Building:
  88.    
  89.     # ##########################################################################
  90.     # NOTE:
  91.     # update this from http://iourpg.wikia.com/wiki/Guild_Buildings
  92.     # ##########################################################################
  93.     buildLevels = { # stones needed for each build level
  94.         0: 0,
  95.         1: 5000,
  96.         2: 10000,
  97.         3: 20000,
  98.         4: 40000,
  99.         5: 80000,
  100.         6: 160000,
  101.         7: 290000,
  102.         8: 450000,
  103.         9: 650000,
  104.         10: 900000,
  105.         11: 1000000,
  106.         12: 2000000,
  107.         13: 3000000,
  108.         14: 4000000,
  109.         15: 5000000,
  110.         16: 6000000,
  111.         17: 7000000,
  112.         18: 8000000,
  113.         19: 9000000,
  114.         20: 10000000,
  115.         21: 12000000,
  116.         22: 14000000,
  117.         23: 16000000,
  118.         24: 18000000,
  119.         25: 20000000,
  120.         26: 30000000,
  121.         27: 35000000,
  122.         28: 40000000,
  123.         29: 45000000,
  124.         30: 50000000,
  125.         31: 120000000,
  126.     }
  127.    
  128.     bars = { # links to images corresponding to percentage
  129.         0: "https://upload.wikimedia.org/wikipedia/commons/c/cf/Gasr0percent.png",
  130.         5: "https://upload.wikimedia.org/wikipedia/commons/9/90/Gasr5percent.png",
  131.         10: "https://upload.wikimedia.org/wikipedia/commons/5/5b/Gasr10percent.png",
  132.         15: "https://upload.wikimedia.org/wikipedia/commons/c/c8/Gasr15percent.png",
  133.         20: "https://upload.wikimedia.org/wikipedia/commons/6/62/Gasr20percent.png",
  134.         25: "https://upload.wikimedia.org/wikipedia/commons/0/08/Gasr25percent.png",
  135.         30: "https://upload.wikimedia.org/wikipedia/commons/6/61/Gasr30percent.png",
  136.         35: "https://upload.wikimedia.org/wikipedia/commons/4/47/Gasr35percent.png",
  137.         40: "https://upload.wikimedia.org/wikipedia/commons/3/3e/Gasr40percent.png",
  138.         45: "https://upload.wikimedia.org/wikipedia/commons/0/0e/Gasr45percent.png",
  139.         50: "https://upload.wikimedia.org/wikipedia/commons/a/a8/Gasr50percent.png",
  140.         55: "https://upload.wikimedia.org/wikipedia/commons/2/27/Gasr55percent.png",
  141.         60: "https://upload.wikimedia.org/wikipedia/commons/e/e7/Gasr60percent.png",
  142.         65: "https://upload.wikimedia.org/wikipedia/commons/9/96/Gasr65percent.png",
  143.         70: "https://upload.wikimedia.org/wikipedia/commons/7/70/Gasr70percent.png",
  144.         75: "https://upload.wikimedia.org/wikipedia/commons/7/77/Gasr75percent.png",
  145.         80: "https://upload.wikimedia.org/wikipedia/commons/4/4d/Gasr80percent.png",
  146.         85: "https://upload.wikimedia.org/wikipedia/commons/9/9a/Gasr85percent.png",
  147.         90: "https://upload.wikimedia.org/wikipedia/commons/b/bd/Gasr90percent.png",
  148.         95: "https://upload.wikimedia.org/wikipedia/commons/7/78/Gasr95percent.png",
  149.         100: "https://upload.wikimedia.org/wikipedia/commons/f/f3/Gasr100percent.png"
  150.     }
  151.    
  152.    
  153.     def __init__(self, buildName, buildLevel, stonesNeeded):
  154.         """
  155.         constructor
  156.         """
  157.        
  158.         self.upgradeStatusPercent = 0 # current percentage of building update
  159.         self.percBarURL = "" # URL of the image that match the building upgrade status
  160.         self.buildName = buildName # name of the building
  161.         self.buildLevel = buildLevel # current build level
  162.        
  163.         if self.buildName == "Bank":
  164.             # sets the max cumulable stones for the bank as the sum of stones needed until the max know level building
  165.             self.stonesReserve = stonesNeeded
  166.             stonesNeeded = sum([self.buildLevels[x] for x in self.buildLevels]) - self.stonesReserve
  167.         else:
  168.             if self.buildLevel > len(self.buildLevels)-1 or self.buildLevel < 0:
  169.                 while self.buildLevel > len(self.buildLevels)-1 or self.buildLevel < 0:
  170.                     print("Insert a build level between 0 and %d" % (len(self.buildLevels)-1,))
  171.                     self.buildLevel = int(raw_input("%s level: " % self.buildName))
  172.            
  173.             if stonesNeeded > self.buildLevels[self.buildLevel+1] or stonesNeeded < 0:
  174.                 while stonesNeeded > self.buildLevels[self.buildLevel+1] or stonesNeeded < 0:
  175.                     print("Insert the stones needed between 0 and %d" % (self.buildLevels[self.buildLevel+1],))
  176.                     stonesNeeded = int(raw_input("%s stones needed to next level: " % self.buildName))
  177.        
  178.         self.setUpgradePercent(stonesNeeded)
  179.         self.setPercentURL()
  180.    
  181.    
  182.     def round_to_5(self, n):
  183.         """
  184.         Rounds a number to nearest 5
  185.        
  186.         @param integer              the number to round
  187.         @return integer             the rounded number
  188.         """
  189.        
  190.         return int(round(n*2,-1)/2)
  191.    
  192.    
  193.     def setUpgradePercent(self, stonesNeeded):
  194.         """
  195.         Sets the percentage upgraded status of a building
  196.        
  197.         @param integer              the building's current level
  198.         @param integer              the stones needed to the next building level
  199.         """
  200.        
  201.         nextBuildLevel = self.buildLevels[self.buildLevel+1]
  202.         if self.buildName == "Bank":
  203.             # sets the max cumulable stones for the bank as the sum of stones needed until the max know level building
  204.             #self.stonesReserve = stonesNeeded
  205.             nextBuildLevel = sum([self.buildLevels[x] for x in self.buildLevels])
  206.            
  207.         if nextBuildLevel-stonesNeeded < 0:
  208.             percent = 100
  209.         else:
  210.             percent = (((nextBuildLevel-stonesNeeded)*100)/nextBuildLevel)
  211.         self.upgradeStatusPercent = percent
  212.    
  213.    
  214.     def setPercentURL(self):
  215.         """
  216.         Sets the image URL of building's percentage upgraded status
  217.         """
  218.        
  219.         url = self.bars[self.round_to_5(self.upgradeStatusPercent)]
  220.         self.percBarURL = url
  221.    
  222.    
  223.     def getBuildingProperties(self):
  224.         if self.buildName == "Guild Hall":
  225.             return "Max Members: %d" % (self.buildLevel + 10)
  226.         if self.buildName == "Bank":
  227.             return "Reserves: %d" % (self.stonesReserve)
  228.         if self.buildName == "Fortress":
  229.             return "Ascension Points: %d" % (self.buildLevel)
  230.         if self.buildName == "Altar":
  231.             return "Gold: %1.1f%%, Exp: %1.1f%%" % (self.buildLevel * 0.5, self.buildLevel * 0.5)
  232.         if self.buildName == "Stable":
  233.             return "Pet Dmg: %d%%, Pet Train: %d" % (self.buildLevel * 2, self.buildLevel / 5)
  234.         if self.buildName == "Warehouse":
  235.             return "Yelds: %d%%" % (self.buildLevel * 3)
  236.         if self.buildName == "Sacrificial Tower":
  237.             return "SO Experience Boost: %1.1f%%" % (self.buildLevel * 0.5)
  238.        
  239.    
  240.     def printBuilding(self):
  241.         """
  242.         Prints a row for the guild's thread that contains building info
  243.         """
  244.        
  245.         print("{:<40s} {:<40s} {:<110s}".format("[*][font=Courier New]%s" % self.buildName, ("Lv: %d (%s)") % (self.buildLevel, self.getBuildingProperties()),"Upgrade status: [[img=119x8]%s[/img]][/font]" % (self.percBarURL)))
  246.    
  247.    
  248.    
  249.     def buildingFF(self, forum, method="image"):
  250.         """
  251.         Prints a row for the guild's thread that contains building info
  252.         """
  253.        
  254.         if forum == "kong":
  255.             if method == "text":
  256.                 return "{:<35s} {:<35s} {:<100s}".format("<pre>%s" % self.buildName, ("Lv: %d (%s)") % (self.buildLevel, self.getBuildingProperties()),"Upgrade status: %1.0f%%</pre>\n" % (self.upgradeStatusPercent,))
  257.             elif method == "image":
  258.                 return "{:<35s} {:<35s} {:<100s}".format("<pre>%s" % self.buildName, ("Lv: %d (%s)") % (self.buildLevel, self.getBuildingProperties()),"Upgrade status: %1.0f%%</pre><img width=\"100%%\" height=\"8px\" src=\"%s\" />\n" % (self.upgradeStatusPercent, self.percBarURL))
  259.         if method == "text":
  260.             return "{:<40s} {:<40s} {:<110s}".format("[*][font=Courier New]%s" % self.buildName, ("Lv: %d (%s)") % (self.buildLevel, self.getBuildingProperties()),"Upgrade status: %1.0f%%[/font]" % (self.upgradeStatusPercent))
  261.         elif method == "image":
  262.             return "{:<40s} {:<40s} {:<110s}".format("[*][font=Courier New]%s" % self.buildName, ("Lv: %d (%s)") % (self.buildLevel, self.getBuildingProperties()),"Upgrade status: [[img=119x8]%s[/img]][/font]" % (self.percBarURL))
  263.  
  264.  
  265.  
  266.  
  267. class Guild:
  268.    
  269.     def __init__(self, guildName, guildInitials, guildRank, entryLevel, buildings):
  270.         """
  271.         constructor
  272.         """
  273.         self.members = []
  274.         self.guildName = guildName
  275.         self.guildInitials = guildInitials
  276.         self.guildRank = guildRank
  277.         self.entryLevel = entryLevel
  278.         self.buildings = buildings
  279.         self.setMaxMembers(buildings[0].buildLevel + 10)
  280.         self.forum = "iou"
  281.    
  282.     def setMaxMembers(self, maxMembers):
  283.         """
  284.         Sets the max members number for the guild
  285.         """
  286.        
  287.         self.maxMembers = maxMembers
  288.    
  289.     def addMember(self, name, status, level, IOUScore):
  290.         """
  291.         Adds a member to the guild
  292.         """
  293.        
  294.         self.members.append([name, status, level, IOUScore])
  295.    
  296.     def getAverageLevel(self):
  297.         """
  298.         Calc the average level of guild's members
  299.        
  300.         @return float               the average level of guild's members
  301.         """
  302.        
  303.         sumlevels = 0.0
  304.         for m in self.members:
  305.             sumlevels += m[2]
  306.         return float(sumlevels/len(self.members))
  307.    
  308.     def getGuildIOUScore(self):
  309.         """
  310.         Calc the guild's IOU score
  311.        
  312.         @return integer             the guild's IOU score
  313.         """
  314.        
  315.         sumIOU = 0
  316.         for m in self.members:
  317.             sumIOU += m[3]
  318.         return sumIOU
  319.    
  320.     def getAverageIOUScore(self):
  321.         """
  322.         Calc the average IOU score of guild's members
  323.        
  324.         @return float               the average IOU score of guild's members
  325.         """
  326.        
  327.         return float((0.0+self.getGuildIOUScore())/len(self.members))
  328.    
  329.     def guildIOUScoreFF(self):
  330.         """
  331.         @return string              the guild's IOU Score
  332.         """
  333.        
  334.         if self.forum == "kong":
  335.             return "<strong>%s</strong> IOU: <strong>%d</strong>\n" % (self.guildName, self.getGuildIOUScore())
  336.         return "[b]%s[/b] IOU: [b]%d[/b]\n" % (self.guildName, self.getGuildIOUScore())
  337.    
  338.     def averageLevelFF(self):
  339.         """
  340.         @return string              the average level of guild's members
  341.         """
  342.        
  343.         if self.forum == "kong":
  344.             return "<strong>%s</strong> average level: <strong>%.2f</strong>\n" % (self.guildName, float(self.getAverageLevel()))
  345.         return "[b]%s[/b] average level: [b]%.2f[/b]\n" % (self.guildName, float(self.getAverageLevel()))
  346.    
  347.     def averageIOUScoreFF(self):
  348.         """
  349.         @return string              the average IOU Score of guild's members
  350.         """
  351.        
  352.         if self.forum == "kong":
  353.             return "<strong>%s</strong> average IOU: <strong>%.2f</strong>\n" % (self.guildName, float(self.getAverageIOUScore()))
  354.         return "[b]%s[/b] average IOU: [b]%.2f[/b]\n" % (self.guildName, float(self.getAverageIOUScore()))
  355.    
  356.     def membersListFF(self):
  357.         """
  358.         @return string              the members list
  359.         """
  360.        
  361.         if self.forum == "kong":
  362.             membersCountString = "<span style=\"color: #33ff33\">%d</span>/%d" % (len(self.members), self.maxMembers) if len(self.members) < self.maxMembers else "<span style=\"color: #ff3333\">%d</span>/%d" % (len(self.members), self.maxMembers)
  363.            
  364.             result = "<strong>%s (%s)</strong>:\n" % (self.guildName, membersCountString)
  365.             result += "<pre>\n"
  366.             for m in self.members:
  367.                 result += u'{:<40s} {:<8s} {:<9s} {:<8s}'.format("%s" % m[0], "[%s" % m[1], "| Lv %d" % m[2], "| IOU %d]\n" % m[3])
  368.             result += "</pre>\n\n"
  369.            
  370.             return result
  371.        
  372.         membersCountString = "[color=#33ff33]%d[/color]/%d" % (len(self.members), self.maxMembers) if len(self.members) < self.maxMembers else "[color=#ff3333]%d[/color]/%d" % (len(self.members), self.maxMembers)
  373.        
  374.         result = "[b]%s (%s)[/b]:\n" % (self.guildName, membersCountString)
  375.         result += "[list]\n"
  376.         for m in self.members:
  377.             result += u'{:<40s} {:<8s} {:<9s} {:<8s}'.format("[*][font=Courier New]%s" % m[0], "[%s" % m[1], "| Lv %d" % m[2], "| IOU %d][/font]\n" % m[3])
  378.         result += "[/list]\n\n"
  379.        
  380.         return result
  381.    
  382.     def buildingsListFF(self, method):
  383.         """
  384.         @return string              the buildigs list
  385.         """
  386.        
  387.         # buildigs data forum formatted
  388.         if self.forum == "kong":
  389.             result = "<strong>%s Buildings</strong>:\n" % self.guildName
  390.             #result += "<pre>\n"
  391.             for b in self.buildings:
  392.                 result += b.buildingFF(self.forum, method)
  393.             #result += "</pre>\n\n"
  394.            
  395.             return result
  396.        
  397.         result = "[b]%s Buildings[/b]:\n" % self.guildName
  398.         result += "[list]\n"
  399.         for b in self.buildings:
  400.             result += b.buildingFF(self.forum, method)
  401.         result += "[/list]\n\n"
  402.        
  403.         return result
  404.        
  405.        
  406.  
  407.  
  408.  
  409. class Family:
  410.     def __init__(self, name, initials, guilds):
  411.         self.name = name
  412.         self.initials = initials
  413.         self.guilds = guilds
  414.  
  415.  
  416. class TemplateParser:
  417.    
  418.     def __init__(self, family, forum):
  419.         """
  420.         Constructor
  421.        
  422.         @param list                 a list that contains instances of Guild class
  423.         @param string               the desired forum output (iou|kong)
  424.         """
  425.        
  426.         self.words = {}
  427.         totalEmptySpots = 0
  428.        
  429.         for guild in family.guilds:
  430.            
  431.             guild.forum = forum
  432.            
  433.             levels = []
  434.             for b in guild.buildings:
  435.                 levels.append(str(b.buildLevel))
  436.            
  437.             if (guild.maxMembers-len(guild.members)) > 0:
  438.                 dynamicSlots = str(guild.maxMembers-len(guild.members)) + " players"
  439.                 if (guild.maxMembers-len(guild.members)) == 1:
  440.                     dynamicSlots = str(guild.maxMembers-len(guild.members)) + " player"
  441.             else:
  442.                 dynamicSlots = "Full"
  443.            
  444.             guildPosition = ""
  445.             if guild.guildRank == 1:
  446.                 guildPosition = "1st"
  447.             elif guild.guildRank == 2:
  448.                 guildPosition = "2nd"
  449.             elif guild.guildRank == 3:
  450.                 guildPosition = "3rd"
  451.             else:
  452.                 guildPosition = "%dth" % guild.guildRank
  453.            
  454.            
  455.            
  456.             words = {
  457.                 "{%s-INITIALS}" % (guild.guildInitials):                        guild.guildInitials,
  458.                 "{%s-GUILD}" % (guild.guildInitials):                           guild.guildName,
  459.                 "{%s-RANK}" % (guild.guildInitials):                            str(guild.guildRank),
  460.                 "{%s-POSITION}" % (guild.guildInitials):                        guildPosition,
  461.                 "{%s-ENTRYLEVEL}" % (guild.guildInitials):                      guild.entryLevel,
  462.                 "{%s-BUILDINGS}" % (guild.guildInitials):                       "/".join(levels),
  463.                 "{%s-MEMBERS}" % (guild.guildInitials):                         str(len(guild.members)),
  464.                 "{%s-MAXMEMBERS}" % (guild.guildInitials):                      str(guild.maxMembers),
  465.                 "{%s-EMPTYSLOTS}" % (guild.guildInitials):                      str(guild.maxMembers-len(guild.members)),
  466.                 "{%s-DYNAMICSLOTS}" % (guild.guildInitials):                    dynamicSlots,
  467.                 "{%s-IOUSCORE}" % (guild.guildInitials):                        guild.guildIOUScoreFF(),
  468.                 "{%s-AVERAGELEVEL}" % (guild.guildInitials):                    guild.averageLevelFF(),
  469.                 "{%s-AVERAGEIOUSCORE}" % (guild.guildInitials):                 guild.averageIOUScoreFF(),
  470.                 "{%s-MEMBERSLIST}" % (guild.guildInitials):                     guild.membersListFF(),
  471.                 "{%s-BUILDINGSLIST}" % (guild.guildInitials):                   guild.buildingsListFF("image"),
  472.                 "{%s-BUILDINGSLIST-TEXT}" % (guild.guildInitials):              guild.buildingsListFF("text")
  473.             }
  474.            
  475.             for w in words.keys():
  476.                 self.words[w] = words[w]
  477.             totalEmptySpots += guild.maxMembers-len(guild.members)
  478.         self.words["{TOTALEMPTYSPOTS}"] = str(totalEmptySpots)
  479.         self.words["{%s-INITIALS}" % (family.initials)] = family.initials
  480.    
  481.     def parseText(self, text):
  482.         """
  483.         Translate special words to datas
  484.        
  485.         @param string               the template text
  486.         @return string              the translated text
  487.         """
  488.        
  489.         for word in self.words:
  490.             text = text.replace(word, self.words[word])
  491.        
  492.         return text
  493.  
  494.  
  495. def generateThread(family, template_file, forum):
  496.     """
  497.     Output guild's recruit thread
  498.    
  499.     @param list                     contains instances of Guild class
  500.     @param string                   path to template file
  501.     @param string                   target forum (iou|kong)
  502.     """
  503.     # prints header text
  504.     try:
  505.         f = open(template_file, "r")
  506.     except:
  507.         print("Cannot read header file '%s'" % template_file)
  508.     else:
  509.         parser = TemplateParser(family, forum)
  510.         for l in f.readlines():
  511.             print(parser.parseText(l.rstrip()))
  512.    
  513.     if forum == "kong":
  514.         print("<br /><br /><div><hr /><h6>Generated by <a href=\"%s\">%s %s</a><h6></div>" % (program["url"], program["name"], program["version"]))
  515.     else:
  516.         print("\n\n[hr][align=center][size=xx-small]Generated by [url=%s]%s %s[/url][/size][/align]" % (program["url"], program["name"], program["version"]))
  517.    
  518.    
  519.  
  520.  
  521. def generateTitle(family, template_file, forum):
  522.     """
  523.     Output guild's recruit thread title
  524.    
  525.     @param list                     contains instances of Guild class
  526.     @param string                   path to template file
  527.     @param string                   target forum (iou|kong)
  528.     """
  529.     # read title template
  530.     titleTemplate = ""
  531.     try:
  532.         f = open(template_file, "r")
  533.     except:
  534.         print("Cannot read title file '%s'" % template_file)
  535.     else:
  536.         parser = TemplateParser(family, forum)
  537.         print(parser.parseText(f.readline().rstrip()))
  538.  
  539.  
  540. def generateRecruitingString(family, template_file, forum):
  541.     """
  542.     Output the guild's recruiting string
  543.    
  544.     @param list                     contains instances of Guild class
  545.     @param string                   path to template file
  546.     @param string                   target forum (iou|kong)
  547.     """
  548.     # read title template
  549.     titleTemplate = ""
  550.     try:
  551.         f = open(template_file, "r")
  552.     except:
  553.         print("Cannot read title file '%s'" % template_file).encode("utf-8")
  554.     else:
  555.         parser = TemplateParser(family, forum)
  556.         recruitingString = parser.parseText(f.readline().rstrip())
  557.         recruitingString += " IOU: %s KONG: %s" % (config["recruiting_threads"]["iou"], config["recruiting_threads"]["kong"])
  558.         print(recruitingString)
  559.  
  560.  
  561.  
  562.  
  563.  
  564. guilds = []
  565. for g in config["guilds"]:
  566.    
  567.     # sets buildings data
  568.     buildings = []
  569.     for b in g[0]["buildings"]:
  570.         buildings.append(Building(b[0], b[1], b[2]))
  571.    
  572.     # sets members data
  573.     guild = Guild(g[0]["guild_name"], g[0]["guild_initials"], g[0]["guild_rank"], g[0]["entry_level"], buildings)
  574.    
  575.     for m in g[0]["members"]:
  576.         guild.addMember(m[0], m[1], m[2], m[3])
  577.    
  578.     guilds.append(guild)
  579.     del guild
  580.  
  581.  
  582.  
  583. family = Family(config["family_name"], config["family_initials"], guilds)
  584.  
  585.  
  586.  
  587. if len(sys.argv) > 1:
  588.     if "--title" in sys.argv or "-t" in sys.argv:
  589.         forum = "iou"
  590.         generateTitle(family, title_template, forum)
  591.     elif "--recruiting_string" in sys.argv or "-r" in sys.argv:
  592.         forum = "iou"
  593.         generateRecruitingString(family, title_template, forum)
  594.     elif sys.argv[1] == "--version" or sys.argv[1] == "-v":
  595.         print("%s %s" % (program["name"], program["version"]))
  596.     elif sys.argv[1] == "--help" or sys.argv[1] == "-h":
  597.         help()
  598.     elif "--kong" in sys.argv or "-k" in sys.argv:
  599.         forum = "kong"
  600.         generateThread(family, kong_template, forum)
  601.     elif "--iou" in sys.argv or "-i" in sys.argv:
  602.         forum = "iou"
  603.         generateThread(family, iou_template, forum)
  604.     else:
  605.         for argv in sys.argv[1:]:
  606.             if argv not in cliArgs:
  607.                 print(">>> Unrecognized argument '%s'." % argv)
  608.         print("\n")
  609.         help()
  610.    
  611. else:
  612.     forum = "iou"
  613.     generateThread(family, iou_template, forum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement